Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

import okhttp3.mockwebserver.RecordedRequest;
import org.openstack4j.api.AbstractTest;
import org.openstack4j.api.Builders;
import org.openstack4j.api.SkipTest;
import org.openstack4j.model.storage.block.Volume;
import org.openstack4j.model.storage.block.VolumeAttachment;
import org.openstack4j.model.storage.block.builder.VolumeBuilder;
import org.testng.annotations.Test;


Expand Down Expand Up @@ -141,4 +143,23 @@ public void testVolumesWithBootableAndEncyrpted() throws Exception {


}


@Test
public void CreateVolumeV2WithMultiattach() throws Exception {

respondWith("/storage/v2/createVolume-muitiattach.json");

VolumeBuilder volumeBuilder = Builders.volume();
volumeBuilder.size(10);
volumeBuilder.name("test_openstack4j");
volumeBuilder.description("test");
volumeBuilder.multiattach(true);
Volume volume = osv2().blockStorage().volumes().create(volumeBuilder.build());

server.takeRequest();

assertEquals(volume.getSize(), 10);
assertEquals(volume.multiattach(), Boolean.TRUE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"volume": {
"id" : "ac9ae248-cf21-4301-87b1-568ff20a0a02",
"status" : "creating",
"size" : 10,
"zone" : "nova",
"created" : "Wed Aug 16 13:27:14 KST 2017",
"multiattach" : true,
"metadata" : {},
"bootable" : false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public static MigrationStatus fromValue(String migrationStatus) {
* @return the image reference identifier (if an image was associated) otherwise null
*/
String getImageRef();

/**
* @return To enable this volume to attach
*/
Boolean multiattach();

/**
* @return ID of source volume to clone from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public interface VolumeBuilder extends Builder<VolumeBuilder, Volume> {
*/
VolumeBuilder imageRef(String imageRef);

/**
* To enable this volume to attach to more than one server <b>Optional</b>
*
* @param To enable this volume to attach to more than one server set this value to true
* @return VolumeBuilder
*/
VolumeBuilder multiattach(Boolean multiattach);

/**
* The size of the volume, in GB.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class CinderVolume implements Volume {
private String volumeType;
@JsonProperty("imageRef")
private String imageRef;
@JsonProperty("multiattach")
private Boolean multiattach;
@JsonProperty("source_volid")
private String sourceVolid;
@JsonProperty("snapshot_id")
Expand Down Expand Up @@ -196,6 +198,14 @@ public String getImageRef() {
return imageId;
}

/**
* {@inheritDoc}
*/
@Override
public Boolean multiattach(){
return multiattach;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -259,7 +269,7 @@ public String toString() {
return MoreObjects.toStringHelper(this).omitNullValues()
.add("id", id).add("name", name).add("description", description)
.add("status", status).add("size", size).add("zone", zone).add("created", created)
.add("volumeType", volumeType).add("imageRef", getImageRef())
.add("volumeType", volumeType).add("imageRef", getImageRef()).add("multiattach", multiattach)
.add("sourceVolid", sourceVolid).add("snapshotId", snapshotId).add("metadata", metadata)
.add("bootable", bootable)
.toString();
Expand Down Expand Up @@ -321,6 +331,12 @@ public VolumeBuilder imageRef(String imageRef) {
m.imageRef = imageRef;
return this;
}

@Override
public VolumeBuilder multiattach(Boolean multiattach) {
m.multiattach = multiattach;
return this;
}

@Override
public VolumeBuilder size(int size) {
Expand Down