Skip to content

Commit

Permalink
Merge pull request #1046 from cbirajdar/master
Browse files Browse the repository at this point in the history
Renamed CinderVolume properties to be compatible with block storage API v2, fixed broken VolumeTests
  • Loading branch information
auhlig authored Jun 27, 2017
2 parents 53cde99 + 88fdf16 commit c0a7f2b
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ pom-shade.xml
*.versionsBackup
*/bin/*
*.iml
*.ipr
*.iws
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public void getVolumeV1() throws Exception {
assertTrue(getRequest.getPath().matches("/v[12]/\\p{XDigit}*/volumes/8a9287b7-4f4d-4213-8d75-63470f19f27c"));

assertEquals(volume.getId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
assertEquals(volume.getName(), "vol-test");
assertEquals(volume.getDescription(), "a description");
assertEquals(volume.getDisplayName(), "vol-test");
assertEquals(volume.getDisplayDescription(), "a description");
assertNotNull(volume.getCreated());
assertEquals(volume.getZone(), "nova");
assertEquals(volume.getSize(), 100);
Expand All @@ -91,7 +91,6 @@ public void getVolumeV1() throws Exception {

@SuppressWarnings("unchecked")
@Test
@SkipTest(connector = ".*", issue = 395, description = "Volume attribute not recognized when using cinder v2 api")
public void getVolumeV2() throws Exception {
// Check get volume
respondWith("/storage/v2/volume.json");
Expand All @@ -101,7 +100,7 @@ public void getVolumeV2() throws Exception {
assertTrue(getRequest.getPath().matches("/v[12]/\\p{XDigit}*/volumes/8a9287b7-4f4d-4213-8d75-63470f19f27c"));

assertEquals(volume.getId(), "8a9287b7-4f4d-4213-8d75-63470f19f27c");
assertEquals(volume.getName(), "vol-test");
assertEquals(volume.getName(), "test-volume");
assertEquals(volume.getDescription(), "a description");
assertNotNull(volume.getCreated());
assertEquals(volume.getZone(), "nova");
Expand Down
2 changes: 1 addition & 1 deletion core-test/src/main/resources/storage/v2/volume.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"status": "in-use",
"user_id": "92ac3530a6cb4d47aa406f1c2c90fca4",
"attachments": [{
"host_name": null,
"host_name": "myhost",
"device": "/dev/vdd",
"server_id": "eaa6a54d-35c1-40ce-831d-bb61f991e1a9",
"id": "8a9287b7-4f4d-4213-8d75-63470f19f27c",
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/org/openstack4j/model/storage/block/Volume.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,23 @@ public static MigrationStatus fromValue(String migrationStatus) {
*/
String getName();

/**
* @return the display name of the volume
*/
@Deprecated
String getDisplayName();

/**
* @return the description of the volume
*/
String getDescription();

/**
* @return the display description of the volume
*/
@Deprecated
String getDisplayDescription();

/**
* @return the status of the volume
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,23 @@ public interface VolumeSnapshot extends ModelEntity, Buildable<VolumeSnapshotBui
*/
String getName();

/**
* @return the display name of the snapshot
*/
@Deprecated
String getDisplayName();

/**
* @return the description of the snapshot
*/
String getDescription();

/**
* @return the display description of the snapshot
*/
@Deprecated
String getDisplayDescription();

/**
* The volume identifier of an existing volume
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public class CinderVolume implements Volume {
private static final long serialVersionUID = 1L;

private String id;
@JsonProperty("display_name")
@JsonProperty("name")
private String name;
@JsonProperty("display_description")
@JsonProperty("display_name")
private String displayName;
@JsonProperty("description")
private String description;
@JsonProperty("display_description")
private String displayDescription;
private Status status;
@JsonInclude(Include.NON_DEFAULT)
@JsonProperty("size")
Expand Down Expand Up @@ -96,6 +100,14 @@ public String getName() {
return name;
}

/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return displayName;
}

/**
* {@inheritDoc}
*/
Expand All @@ -104,6 +116,14 @@ public String getDescription() {
return description;
}

/**
* {@inheritDoc}
*/
@Override
public String getDisplayDescription() {
return displayDescription;
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public class CinderVolumeSnapshot implements VolumeSnapshot {
private String id;
@JsonProperty("name")
private String name;
@JsonProperty("display_name")
private String displayName;
@JsonProperty("description")
private String description;
@JsonProperty("display_description")
private String displayDescription;
@JsonProperty("volume_id")
private String volumeId;
private Status status;
Expand Down Expand Up @@ -73,6 +77,14 @@ public String getName() {
return name;
}

/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return displayName;
}

/**
* {@inheritDoc}
*/
Expand All @@ -81,6 +93,14 @@ public String getDescription() {
return description;
}

/**
* {@inheritDoc}
*/
@Override
public String getDisplayDescription() {
return displayDescription;
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit c0a7f2b

Please sign in to comment.