use of org.apache.cloudstack.network.opendaylight.api.model.NeutronNode 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.NeutronNode 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());
}
}
Aggregations