Skip to content

Commit 654bc8e

Browse files
authored
Merge pull request openstack4j#226 from slankka/issue-152
Fix openstack4j#152 Cinder:create snapshot 'display_description' was unexpected
2 parents 44816b0 + 8f2439c commit 654bc8e

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

core-test/src/main/java/org/openstack4j/api/AbstractTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import okhttp3.mockwebserver.RecordedRequest;
1717
import org.openstack4j.api.OSClient.OSClientV2;
1818
import org.openstack4j.api.OSClient.OSClientV3;
19+
import org.openstack4j.api.exceptions.ConnectorNotFoundException;
1920
import org.openstack4j.core.transport.internal.HttpExecutor;
2021
import org.openstack4j.openstack.OSFactory;
2122
import org.openstack4j.openstack.identity.v2.domain.KeystoneAccess;
@@ -53,7 +54,12 @@ protected void startServer() throws UnknownHostException {
5354

5455
InetAddress inetAddress = InetAddress.getByName("localhost");
5556
LOG.info("localhost inet address: " + inetAddress.toString());
56-
LOG.info("Tests using connector: " + HttpExecutor.create().getExecutorName() + " on " + getHost());
57+
58+
try {
59+
LOG.info("Tests using connector: " + HttpExecutor.create().getExecutorName() + " on " + getHost());
60+
} catch (ConnectorNotFoundException ex) {
61+
LOG.info("Tests without any connector");
62+
}
5763

5864
try {
5965
LOG.info("Starting server on port " + service().port);

core-test/src/main/java/org/openstack4j/api/storage/VolumeSnapshotTests.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
import java.util.List;
55
import java.util.Map;
66

7+
import com.fasterxml.jackson.core.JsonProcessingException;
8+
import com.fasterxml.jackson.databind.JsonNode;
9+
import com.fasterxml.jackson.databind.ObjectMapper;
710
import okhttp3.mockwebserver.RecordedRequest;
811
import org.openstack4j.api.AbstractTest;
12+
import org.openstack4j.core.transport.ObjectMapperSingleton;
913
import org.openstack4j.model.storage.block.VolumeSnapshot;
14+
import org.openstack4j.openstack.storage.block.domain.CinderVolumeSnapshot;
1015
import org.testng.annotations.Test;
1116

12-
import static org.testng.Assert.assertEquals;
13-
import static org.testng.Assert.assertNotNull;
14-
import static org.testng.Assert.assertTrue;
17+
import static org.testng.Assert.*;
1518

1619

1720
@Test(suiteName = "Block Storage Tests")
@@ -47,4 +50,14 @@ public void listVolumeSnaphotsV1() throws Exception {
4750
assertTrue(filteredListRequest.getPath().matches("/v[12]/\\p{XDigit}*/snapshots\\?display_name=" + volName));
4851
}
4952

53+
@Test
54+
public void createVolumeSnapshotV2() throws JsonProcessingException {
55+
ObjectMapper objectMapper = ObjectMapperSingleton.getContext(Object.class);
56+
VolumeSnapshot disc = CinderVolumeSnapshot.builder().description("disc").build();
57+
String value = objectMapper.writeValueAsString(disc);
58+
JsonNode jsonNode = objectMapper.valueToTree(value);
59+
//see https://github.com/openstack4j/openstack4j/issues/152
60+
assertFalse(jsonNode.has("display_description"));
61+
}
62+
5063
}

core/src/main/java/org/openstack4j/core/transport/internal/HttpExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ private HttpExecutorService service() {
3434

3535
Iterator<HttpExecutorService> it = ServiceLoader.load(HttpExecutorService.class, getClass().getClassLoader()).iterator();
3636
if (!it.hasNext()) {
37-
LOG.error("No OpenStack4j connector found in classpath");
38-
throw new ConnectorNotFoundException("No OpenStack4j connector found in classpath");
37+
LOG.error("No OpenStack4j connector found in classpath, see https://github.com/ContainX/openstack4j/issues/832");
38+
throw new ConnectorNotFoundException("No OpenStack4j connector found in classpath, see https://github.com/ContainX/openstack4j/issues/832");
3939
}
4040
return service = it.next();
4141
}

core/src/main/java/org/openstack4j/openstack/storage/block/domain/CinderVolumeSnapshot.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public String getDescription() {
9898
* {@inheritDoc}
9999
*/
100100
@Override
101+
@JsonIgnore
101102
public String getDisplayDescription() {
102103
return displayDescription;
103104
}

0 commit comments

Comments
 (0)