use of org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException 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.NeutronRestApiException in project cloudstack by apache.
the class OpenDaylightControllerResource method executeRequest.
private Answer executeRequest(ConfigurePortCommand cmd) {
NeutronPortsNorthboundAction configurePort = new NeutronPortsNorthboundAction(controllerUrl, controllerUsername, controllerPassword);
NeutronPort newPort = new NeutronPort();
// Configuration from the command
newPort.setId(cmd.getPortId());
newPort.setTenantId(cmd.getTennantId());
newPort.setAdminStateUp(true);
newPort.setName(cmd.getPortId().toString());
newPort.setNetworkId(cmd.getNetworkId());
newPort.setMacAddress(cmd.getMacAddress());
newPort.setDeviceId(UUID.randomUUID());
// Static valus
newPort.setStatus("ACTIVE");
newPort.setFixedIps(Collections.<String>emptyList());
NeutronPortWrapper portWrapper = new NeutronPortWrapper();
portWrapper.setPort(newPort);
try {
portWrapper = configurePort.createNeutronPort(portWrapper);
} catch (NeutronRestApiException e) {
s_logger.error("createPortCommand failed", e);
return new ConfigurePortAnswer(cmd, e);
}
return new ConfigurePortAnswer(cmd, true, "Port " + portWrapper.getPort().getId().toString() + " created");
}
Aggregations