use of org.apache.cloudstack.network.opendaylight.api.model.NeutronPortWrapper in project cloudstack by apache.
the class NeutronPortAdapterTest method gsonNeutronPortMarshalingTest.
@Test
public void gsonNeutronPortMarshalingTest() throws NeutronRestApiException {
NeutronPort port = new NeutronPort();
port.setId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setName("test_gre");
port.setAdminStateUp(true);
port.setDeviceId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setMacAddress("ca31aa7f-84c7-416d-bc00-1f84927367e0");
port.setNetworkId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setStatus("ACTIVE");
port.setTenantId("wilder");
NeutronPortWrapper portWrapper = new NeutronPortWrapper();
portWrapper.setPort(port);
StringRequestEntity entity;
try {
entity = new StringRequestEntity(gsonNeutronPort.toJson(portWrapper), "application/json", null);
String actual = entity.getContent();
Assert.assertEquals(jsonString, actual);
} catch (UnsupportedEncodingException e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronPortWrapper in project cloudstack by apache.
the class NeutronRestApiIT method neutronListAllPorts.
@Test
public void neutronListAllPorts() throws NeutronRestApiException {
URL url;
try {
url = new URL("http://178.237.34.233:8080");
NeutronPortsNorthboundAction neutron = new NeutronPortsNorthboundAction(url, "admin", "admin");
NeutronPortsList<NeutronPortWrapper> results = neutron.listAllPorts();
Assert.assertNotNull(results);
List<NeutronPortWrapper> networks = results.getPorts();
Assert.assertNotNull(networks);
} catch (MalformedURLException e) {
Assert.fail("Should not fail here.");
}
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronPortWrapper in project cloudstack by apache.
the class NeutronPortsNorthboundAction method createNeutronPort.
@SuppressWarnings("unchecked")
public <T> T createNeutronPort(final NeutronPortWrapper newPortWrapper) throws NeutronRestApiException {
try {
String uri = NeutronNorthboundEnum.PORTS_URI.getUri();
StringRequestEntity entity = new StringRequestEntity(gsonNeutronPort.toJson(newPortWrapper), JSON_CONTENT_TYPE, null);
String bodystring = executePost(uri, entity);
T result = (T) gsonNeutronPort.fromJson(bodystring, TypeToken.get(NeutronPortWrapper.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.NeutronPortWrapper in project cloudstack by apache.
the class NeutronPortsNorthboundAction method findPortById.
@SuppressWarnings("unchecked")
public <T> T findPortById(final String portId) throws NeutronRestApiException {
String uri = NeutronNorthboundEnum.PORTS_PARAM_URI.getUri();
uri = MessageFormat.format(uri, portId);
String bodystring = executeGet(uri, Collections.<String, String>emptyMap());
Type returnType = new TypeToken<NeutronPortWrapper>() {
}.getType();
T returnValue = (T) gsonNeutronPort.fromJson(bodystring, returnType);
return returnValue;
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronPortWrapper in project cloudstack by apache.
the class NeutronPortAdapterTest method gsonNeutronPortUnmarshalingTest.
@Test
public <T> void gsonNeutronPortUnmarshalingTest() throws NeutronRestApiException {
NeutronPort port = new NeutronPort();
port.setId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setName("test_gre");
port.setAdminStateUp(true);
port.setDeviceId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setMacAddress("ca31aa7f-84c7-416d-bc00-1f84927367e0");
port.setNetworkId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setStatus("ACTIVE");
port.setTenantId("wilder");
NeutronPortWrapper portWrapper = new NeutronPortWrapper();
portWrapper.setPort(port);
NeutronPortWrapper returnValue = (NeutronPortWrapper) gsonNeutronPort.fromJson(jsonString, TypeToken.get(portWrapper.getClass()).getType());
Assert.assertNotNull(returnValue);
Assert.assertEquals("ca31aa7f-84c7-416d-bc00-1f84927367e0", returnValue.getPort().getMacAddress());
}
Aggregations