Search in sources :

Example 26 with PhysicalNetwork

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;
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PhysicalNetwork(com.cloud.network.PhysicalNetwork) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO)

Example 27 with PhysicalNetwork

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;
}
Also used : ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) VirtualRouterProviderResponse(org.apache.cloudstack.api.response.VirtualRouterProviderResponse) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) UsageService(org.apache.cloudstack.usage.UsageService) OvsProvider(com.cloud.network.OvsProvider) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 28 with PhysicalNetwork

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);
    }
}
Also used : ProjectAccount(com.cloud.projects.ProjectAccount) UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) VlanIpRangeResponse(org.apache.cloudstack.api.response.VlanIpRangeResponse) HostPodVO(com.cloud.dc.HostPodVO) DataCenter(com.cloud.dc.DataCenter) PhysicalNetwork(com.cloud.network.PhysicalNetwork) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Domain(com.cloud.domain.Domain)

Example 29 with PhysicalNetwork

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;
}
Also used : ProjectAccount(com.cloud.projects.ProjectAccount) UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) PortableIpResponse(org.apache.cloudstack.api.response.PortableIpResponse) DataCenter(com.cloud.dc.DataCenter) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Vpc(com.cloud.network.vpc.Vpc) Domain(com.cloud.domain.Domain)

Example 30 with PhysicalNetwork

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;
}
Also used : PhysicalNetwork(com.cloud.network.PhysicalNetwork) OpenDaylightControllerResponse(org.apache.cloudstack.network.opendaylight.api.responses.OpenDaylightControllerResponse) HostVO(com.cloud.host.HostVO)

Aggregations

PhysicalNetwork (com.cloud.network.PhysicalNetwork)34 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)9 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 ArrayList (java.util.ArrayList)8 HostVO (com.cloud.host.HostVO)7 Network (com.cloud.network.Network)7 Host (com.cloud.host.Host)6 DB (com.cloud.utils.db.DB)6 DataCenterVO (com.cloud.dc.DataCenterVO)5 TransactionStatus (com.cloud.utils.db.TransactionStatus)5 DataCenter (com.cloud.dc.DataCenter)4 ActionEvent (com.cloud.event.ActionEvent)4 NetworkVO (com.cloud.network.dao.NetworkVO)4 Account (com.cloud.user.Account)4 List (java.util.List)4 ConfigurationException (javax.naming.ConfigurationException)4 ServerApiException (com.cloud.api.ServerApiException)3 PhysicalNetworkResponse (com.cloud.api.response.PhysicalNetworkResponse)3 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)3 NetworkOffering (com.cloud.offering.NetworkOffering)3