use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworkWrapper in project cloudstack by apache.
the class NeutronNetworksNorthboundAction method findNetworkById.
@SuppressWarnings("unchecked")
public <T> T findNetworkById(final String networkId) throws NeutronRestApiException {
String uri = NeutronNorthboundEnum.NETWORK_PARAM_URI.getUri();
uri = MessageFormat.format(uri, networkId);
String bodystring = executeGet(uri, Collections.<String, String>emptyMap());
Type returnType = new TypeToken<NeutronNetworkWrapper>() {
}.getType();
T returnValue = (T) gsonNeutronNetwork.fromJson(bodystring, returnType);
return returnValue;
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworkWrapper in project cloudstack by apache.
the class NeutronNetworksNorthboundAction method createNeutronNetwork.
@SuppressWarnings("unchecked")
public <T> T createNeutronNetwork(final NeutronNetworkWrapper newNetworkWrapper) throws NeutronRestApiException {
try {
String uri = NeutronNorthboundEnum.NETWORKS_URI.getUri();
StringRequestEntity entity = new StringRequestEntity(gsonNeutronNetwork.toJson(newNetworkWrapper), JSON_CONTENT_TYPE, null);
String bodystring = executePost(uri, entity);
T result = (T) gsonNeutronNetwork.fromJson(bodystring, TypeToken.get(NeutronNetworkWrapper.class).getType());
return result;
} catch (UnsupportedEncodingException e) {
throw new NeutronRestApiException("Failed to encode json request body", e);
}
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworkWrapper in project cloudstack by apache.
the class NeutronNetworkAdapterTest method gsonNeutronNetworkUnmarshalingTest.
@Test
public <T> void gsonNeutronNetworkUnmarshalingTest() throws NeutronRestApiException {
NeutronNetwork network = new NeutronNetwork();
network.setId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
network.setName("test_gre");
network.setNetworkType("test");
network.setSegmentationId(1001);
network.setShared(true);
network.setTenantId("wilder");
NeutronNetworkWrapper networkWrapper = new NeutronNetworkWrapper();
networkWrapper.setNetwork(network);
NeutronNetworkWrapper returnValue = (NeutronNetworkWrapper) gsonNeutronNetwork.fromJson(jsonString, TypeToken.get(networkWrapper.getClass()).getType());
Assert.assertNotNull(returnValue);
Assert.assertEquals("test_gre", returnValue.getNetwork().getName());
}
Aggregations