use of com.cloud.network.PhysicalNetworkServiceProvider in project CloudStack-archive by CloudStack-extras.
the class UpdateNetworkServiceProviderCmd method execute.
@Override
public void execute() {
PhysicalNetworkServiceProvider result = _networkService.updateNetworkServiceProvider(getId(), getState(), getEnabledServices());
if (result != null) {
ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service provider");
}
}
use of com.cloud.network.PhysicalNetworkServiceProvider in project CloudStack-archive by CloudStack-extras.
the class ListNetworkServiceProvidersCmd method execute.
@Override
public void execute() {
List<? extends PhysicalNetworkServiceProvider> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId(), getName(), getState(), this.getStartIndex(), this.getPageSizeVal());
ListResponse<ProviderResponse> response = new ListResponse<ProviderResponse>();
List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
for (PhysicalNetworkServiceProvider serviceProvider : serviceProviders) {
ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
serviceProvidersResponses.add(serviceProviderResponse);
}
response.setResponses(serviceProvidersResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.network.PhysicalNetworkServiceProvider in project cloudstack by apache.
the class ApiResponseHelper method createInternalLbElementResponse.
@Override
public InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result) {
if (result.getType() != VirtualRouterProvider.Type.InternalLbVm) {
return null;
}
InternalLoadBalancerElementResponse response = new InternalLoadBalancerElementResponse();
response.setId(result.getUuid());
PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
if (nsp != null) {
response.setNspId(nsp.getUuid());
}
response.setEnabled(result.isEnabled());
response.setObjectName("internalloadbalancerelement");
return response;
}
use of com.cloud.network.PhysicalNetworkServiceProvider in project cloudstack by apache.
the class InternalLoadBalancerElement method addInternalLoadBalancerElement.
@Override
public VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId) {
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(ntwkSvcProviderId, Type.InternalLbVm);
if (element != null) {
s_logger.debug("There is already an " + getName() + " with service provider id " + ntwkSvcProviderId);
return null;
}
PhysicalNetworkServiceProvider provider = _pNtwkSvcProviderDao.findById(ntwkSvcProviderId);
if (provider == null || !provider.getProviderName().equalsIgnoreCase(getName())) {
throw new InvalidParameterValueException("Invalid network service provider is specified");
}
element = new VirtualRouterProviderVO(ntwkSvcProviderId, Type.InternalLbVm);
element = _vrProviderDao.persist(element);
return element;
}
use of com.cloud.network.PhysicalNetworkServiceProvider in project cloudstack by apache.
the class InternalLoadBalancerVMManagerImpl method getInternalLbProviderId.
protected long getInternalLbProviderId(final Network guestNetwork) {
final Type type = Type.InternalLbVm;
final long physicalNetworkId = _ntwkModel.getPhysicalNetworkId(guestNetwork);
final PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
if (provider == null) {
throw new CloudRuntimeException("Cannot find service provider " + type.toString() + " in physical network " + physicalNetworkId);
}
final VirtualRouterProvider internalLbProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), type);
if (internalLbProvider == null) {
throw new CloudRuntimeException("Cannot find provider " + type.toString() + " as service provider " + provider.getId());
}
return internalLbProvider.getId();
}
Aggregations