use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.
the class NetscalerElement method findGslbProvider.
private ExternalLoadBalancerDeviceVO findGslbProvider(long zoneId, long physicalNetworkId) {
List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, TrafficType.Guest);
if (pNtwks == null || pNtwks.isEmpty()) {
throw new InvalidParameterValueException("Unable to get physical network: " + physicalNetworkId + " in zone id = " + zoneId);
} else {
for (PhysicalNetwork physicalNetwork : pNtwks) {
if (physicalNetwork.getId() == physicalNetworkId) {
PhysicalNetworkVO physNetwork = pNtwks.get(0);
ExternalLoadBalancerDeviceVO nsGslbProvider = _externalLoadBalancerDeviceDao.findGslbServiceProvider(physNetwork.getId(), Provider.Netscaler.getName());
return nsGslbProvider;
}
}
}
return null;
}
use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.
the class ApiResponseHelper method createNetworkServiceProviderResponse.
@Override
public ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result) {
ProviderResponse response = new ProviderResponse();
response.setId(result.getUuid());
response.setName(result.getProviderName());
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
if (pnw != null) {
response.setPhysicalNetworkId(pnw.getUuid());
}
PhysicalNetwork dnw = ApiDBUtils.findPhysicalNetworkById(result.getDestinationPhysicalNetworkId());
if (dnw != null) {
response.setDestinationPhysicalNetworkId(dnw.getUuid());
}
response.setState(result.getState().toString());
// set enabled services
List<String> services = new ArrayList<String>();
for (Service service : result.getEnabledServices()) {
services.add(service.getName());
}
response.setServices(services);
Provider serviceProvider = Provider.getProvider(result.getProviderName());
boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
response.setCanEnableIndividualServices(canEnableIndividualServices);
response.setObjectName("networkserviceprovider");
return response;
}
use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.
the class ApiResponseHelper method createVlanIpRangeResponse.
@Override
public VlanIpRangeResponse createVlanIpRangeResponse(Class<? extends VlanIpRangeResponse> subClass, Vlan vlan) {
try {
Long podId = ApiDBUtils.getPodIdForVlan(vlan.getId());
VlanIpRangeResponse vlanResponse = subClass.newInstance();
vlanResponse.setId(vlan.getUuid());
if (vlan.getVlanType() != null) {
vlanResponse.setForVirtualNetwork(vlan.getVlanType().equals(VlanType.VirtualNetwork));
}
vlanResponse.setVlan(vlan.getVlanTag());
DataCenter zone = ApiDBUtils.findZoneById(vlan.getDataCenterId());
if (zone != null) {
vlanResponse.setZoneId(zone.getUuid());
}
if (podId != null) {
HostPodVO pod = ApiDBUtils.findPodById(podId);
if (pod != null) {
vlanResponse.setPodId(pod.getUuid());
vlanResponse.setPodName(pod.getName());
}
}
vlanResponse.setGateway(vlan.getVlanGateway());
vlanResponse.setNetmask(vlan.getVlanNetmask());
// get start ip and end ip of corresponding vlan
String ipRange = vlan.getIpRange();
if (ipRange != null) {
String[] range = ipRange.split("-");
vlanResponse.setStartIp(range[0]);
vlanResponse.setEndIp(range[1]);
}
vlanResponse.setIp6Gateway(vlan.getIp6Gateway());
vlanResponse.setIp6Cidr(vlan.getIp6Cidr());
String ip6Range = vlan.getIp6Range();
if (ip6Range != null) {
String[] range = ip6Range.split("-");
vlanResponse.setStartIpv6(range[0]);
vlanResponse.setEndIpv6(range[1]);
}
if (vlan.getNetworkId() != null) {
Network nw = ApiDBUtils.findNetworkById(vlan.getNetworkId());
if (nw != null) {
vlanResponse.setNetworkId(nw.getUuid());
}
}
Account owner = ApiDBUtils.getVlanAccount(vlan.getId());
if (owner != null) {
populateAccount(vlanResponse, owner.getId());
populateDomain(vlanResponse, owner.getDomainId());
} else {
Domain domain = ApiDBUtils.getVlanDomain(vlan.getId());
if (domain != null) {
populateDomain(vlanResponse, domain.getId());
} else {
Long networkId = vlan.getNetworkId();
if (networkId != null) {
Network network = _ntwkModel.getNetwork(networkId);
if (network != null) {
Long accountId = network.getAccountId();
populateAccount(vlanResponse, accountId);
populateDomain(vlanResponse, ApiDBUtils.findAccountById(accountId).getDomainId());
}
}
}
}
if (vlan.getPhysicalNetworkId() != null) {
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(vlan.getPhysicalNetworkId());
if (pnw != null) {
vlanResponse.setPhysicalNetworkId(pnw.getUuid());
}
}
vlanResponse.setObjectName("vlan");
return vlanResponse;
} catch (InstantiationException | IllegalAccessException e) {
throw new CloudRuntimeException("Failed to create Vlan IP Range response", e);
}
}
use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.
the class ApiResponseHelper method createPortableIPResponse.
@Override
public PortableIpResponse createPortableIPResponse(PortableIp portableIp) {
PortableIpResponse response = new PortableIpResponse();
response.setAddress(portableIp.getAddress());
Long accountId = portableIp.getAllocatedInDomainId();
if (accountId != null) {
Account account = ApiDBUtils.findAccountById(accountId);
response.setAllocatedToAccountId(account.getAccountName());
Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
response.setAllocatedInDomainId(domain.getUuid());
}
response.setAllocatedTime(portableIp.getAllocatedTime());
if (portableIp.getAssociatedDataCenterId() != null) {
DataCenter zone = ApiDBUtils.findZoneById(portableIp.getAssociatedDataCenterId());
if (zone != null) {
response.setAssociatedDataCenterId(zone.getUuid());
}
}
if (portableIp.getPhysicalNetworkId() != null) {
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(portableIp.getPhysicalNetworkId());
if (pnw != null) {
response.setPhysicalNetworkId(pnw.getUuid());
}
}
if (portableIp.getAssociatedWithNetworkId() != null) {
Network ntwk = ApiDBUtils.findNetworkById(portableIp.getAssociatedWithNetworkId());
if (ntwk != null) {
response.setAssociatedWithNetworkId(ntwk.getUuid());
}
}
if (portableIp.getAssociatedWithVpcId() != null) {
Vpc vpc = ApiDBUtils.findVpcById(portableIp.getAssociatedWithVpcId());
if (vpc != null) {
response.setAssociatedWithVpcId(vpc.getUuid());
}
}
response.setState(portableIp.getState().name());
response.setObjectName("portableip");
return response;
}
use of com.cloud.network.PhysicalNetwork in project cloudstack by apache.
the class OpenDaylightControllerResourceManagerImpl method createResponseFromVO.
@Override
public OpenDaylightControllerResponse createResponseFromVO(OpenDaylightControllerVO controller) {
OpenDaylightControllerResponse response = new OpenDaylightControllerResponse();
HostVO controllerHost = hostDao.findById(controller.getHostId());
hostDao.loadDetails(controllerHost);
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(controller.getPhysicalNetworkId());
if (pnw != null) {
response.setPhysicalNetworkId(pnw.getUuid());
}
response.setObjectName("opendaylightcontroller");
response.setId(controller.getUuid());
response.setUrl(controllerHost.getDetail("url"));
response.setName(controllerHost.getDetail("name"));
response.setUsername(controllerHost.getDetail("username"));
return response;
}
Aggregations