use of com.cloud.network.PhysicalNetworkServiceProvider in project cloudstack by apache.
the class ApiResponseHelper method createVirtualRouterProviderResponse.
@Override
public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
//generate only response of the VR/VPCVR provider type
if (!(result.getType() == VirtualRouterProvider.Type.VirtualRouter || result.getType() == VirtualRouterProvider.Type.VPCVirtualRouter)) {
return null;
}
VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
response.setId(result.getUuid());
PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
if (nsp != null) {
response.setNspId(nsp.getUuid());
}
response.setEnabled(result.isEnabled());
response.setObjectName("virtualrouterelement");
return response;
}
use of com.cloud.network.PhysicalNetworkServiceProvider in project cloudstack by apache.
the class ApiResponseHelper method createOvsProviderResponse.
@Override
public OvsProviderResponse createOvsProviderResponse(OvsProvider result) {
OvsProviderResponse response = new OvsProviderResponse();
response.setId(result.getUuid());
PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
if (nsp != null) {
response.setNspId(nsp.getUuid());
}
response.setEnabled(result.isEnabled());
response.setObjectName("ovselement");
return response;
}
use of com.cloud.network.PhysicalNetworkServiceProvider in project cloudstack by apache.
the class AddNetworkServiceProviderCmdTest method testCreateProviderToPhysicalNetworkSuccess.
@Test
public void testCreateProviderToPhysicalNetworkSuccess() {
NetworkService networkService = Mockito.mock(NetworkService.class);
addNetworkServiceProviderCmd._networkService = networkService;
PhysicalNetworkServiceProvider physicalNetworkServiceProvider = Mockito.mock(PhysicalNetworkServiceProvider.class);
Mockito.when(networkService.addProviderToPhysicalNetwork(Matchers.anyLong(), Matchers.anyString(), Matchers.anyLong(), Matchers.anyList())).thenReturn(physicalNetworkServiceProvider);
try {
addNetworkServiceProviderCmd.create();
} catch (ResourceAllocationException e) {
e.printStackTrace();
}
}
use of com.cloud.network.PhysicalNetworkServiceProvider in project cloudstack by apache.
the class AddNetworkServiceProviderCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Network ServiceProvider Id: " + getEntityId());
PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
if (result != null) {
ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add service provider to physical network");
}
}
Aggregations