use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper in project cloudstack by apache.
the class OpenDaylightControllerResource method executeRequest.
private Answer executeRequest(AddHypervisorCommand cmd) {
NeutronNodesNorthboundAction nodeActions = new NeutronNodesNorthboundAction(controllerUrl, controllerUsername, controllerPassword);
try {
NeutronNodesList<NeutronNodeWrapper> nodes = nodeActions.listAllNodes();
if (nodes.getNodes() != null) {
for (NeutronNodeWrapper nodeWrapper : nodes.getNodes()) {
NeutronNode node = nodeWrapper.getNode();
if (node.getId().equals(cmd.getHostId())) {
return new AddHypervisorAnswer(cmd, true, "Hypervisor already connected");
}
}
}
// Not found in the existing node list, add it
nodeActions.updateNeutronNodeV2("OVS", cmd.getHostId(), cmd.getIpAddress(), 6640);
} catch (NeutronRestApiException e) {
s_logger.error("Call to OpenDaylight failed", e);
return new AddHypervisorAnswer(cmd, e);
}
return new AddHypervisorAnswer(cmd, true, "Hypervisor " + cmd.getHostId() + " added");
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper in project cloudstack by apache.
the class NeutronNodeAdapterTest method gsonNeutronPortUnmarshalingTest.
@Test
public <T> void gsonNeutronPortUnmarshalingTest() throws NeutronRestApiException {
NeutronNodeWrapper returnValue = (NeutronNodeWrapper) gsonNeutronNode.fromJson(jsonString, TypeToken.get(NeutronNodeWrapper.class).getType());
Assert.assertNotNull(returnValue);
Assert.assertEquals("node-test", returnValue.getNode().getId().toString());
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper in project cloudstack by apache.
the class NeutronNodeAdapterTest method gsonNeutronPortUnmarshalingNullTest.
@Test
public <T> void gsonNeutronPortUnmarshalingNullTest() throws NeutronRestApiException {
String json = null;
NeutronNodeWrapper returnValue = (NeutronNodeWrapper) gsonNeutronNode.fromJson(json, TypeToken.get(NeutronNodeWrapper.class).getType());
Assert.assertNull(returnValue);
}
use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper in project cloudstack by apache.
the class NeutronNodeAdapterTest method gsonNeutronPortMarshalingTest.
@Test
public void gsonNeutronPortMarshalingTest() throws NeutronRestApiException {
NeutronNode node = new NeutronNode("node-test", "test");
NeutronNodeWrapper nodeWrapper = new NeutronNodeWrapper(node);
StringRequestEntity entity;
try {
entity = new StringRequestEntity(gsonNeutronNode.toJson(nodeWrapper), "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.NeutronNodeWrapper in project cloudstack by apache.
the class NeutronRestApiIT method neutronListAllNodes.
@Test
public void neutronListAllNodes() throws NeutronRestApiException {
URL url;
try {
url = new URL("http://178.237.34.233:8080");
NeutronNodesNorthboundAction neutron = new NeutronNodesNorthboundAction(url, "admin", "admin");
NeutronNodesList<NeutronNodeWrapper> results = neutron.listAllNodes();
Assert.assertNotNull(results);
} catch (MalformedURLException e) {
Assert.fail("Should not fail here.");
}
}
Aggregations