Search in sources :

Example 86 with PhysicalNetworkVO

use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.

the class BrocadeVcsGuestNetworkGuruTest method testDesign.

@Test
public void testDesign() {
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById((Long) any())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VCS" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
    final DeploymentPlan plan = mock(DeploymentPlan.class);
    final Network network = mock(Network.class);
    final Account account = mock(Account.class);
    final Network designednetwork = guru.design(offering, plan, network, account);
    assertTrue(designednetwork != null);
    assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vcs);
}
Also used : Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeploymentPlan(com.cloud.deploy.DeploymentPlan) Test(org.junit.Test)

Example 87 with PhysicalNetworkVO

use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.

the class BrocadeVcsElement method listBrocadeVcsDevices.

@Override
public List<BrocadeVcsDeviceVO> listBrocadeVcsDevices(ListBrocadeVcsDevicesCmd cmd) {
    Long physicalNetworkId = cmd.getPhysicalNetworkId();
    Long brocadeVcsDeviceId = cmd.getBrocadeVcsDeviceId();
    List<BrocadeVcsDeviceVO> responseList = new ArrayList<BrocadeVcsDeviceVO>();
    if (physicalNetworkId == null && brocadeVcsDeviceId == null) {
        throw new InvalidParameterValueException("Either physical network Id or brocade vcs switch Id must be specified");
    }
    if (brocadeVcsDeviceId != null) {
        BrocadeVcsDeviceVO brocadeVcsDevice = _brocadeVcsDao.findById(brocadeVcsDeviceId);
        if (brocadeVcsDevice == null) {
            throw new InvalidParameterValueException("Could not find Brocade VCS Switch with id: " + brocadeVcsDeviceId);
        }
        responseList.add(brocadeVcsDevice);
    } else {
        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
        if (physicalNetwork == null) {
            throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId);
        }
        responseList = _brocadeVcsDao.listByPhysicalNetwork(physicalNetworkId);
    }
    return responseList;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) BrocadeVcsDeviceVO(com.cloud.network.BrocadeVcsDeviceVO)

Example 88 with PhysicalNetworkVO

use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.

the class NiciraNvpGuestNetworkGuru method design.

@Override
public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner) {
    // Check of the isolation type of the related physical network is supported
    final PhysicalNetworkVO physnet = physicalNetworkDao.findById(plan.getPhysicalNetworkId());
    final DataCenter dc = _dcDao.findById(plan.getDataCenterId());
    if (!canHandle(offering, dc.getNetworkType(), physnet)) {
        s_logger.debug("Refusing to design this network");
        return null;
    }
    final List<NiciraNvpDeviceVO> devices = niciraNvpDao.listByPhysicalNetwork(physnet.getId());
    if (devices.isEmpty()) {
        s_logger.error("No NiciraNvp Controller on physical network " + physnet.getName());
        return null;
    }
    s_logger.debug("Nicira Nvp " + devices.get(0).getUuid() + " found on physical network " + physnet.getId());
    s_logger.debug("Physical isolation type is supported, asking GuestNetworkGuru to design this network");
    final NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
    if (networkObject == null) {
        return null;
    }
    networkObject.setBroadcastDomainType(BroadcastDomainType.Lswitch);
    if (offering.getGuestType().equals(GuestType.Shared)) {
        networkObject.setState(State.Allocated);
    }
    return networkObject;
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) DataCenter(com.cloud.dc.DataCenter) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO)

Example 89 with PhysicalNetworkVO

use of com.cloud.network.dao.PhysicalNetworkVO 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 90 with PhysicalNetworkVO

use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.

the class NiciraNvpElement method listNiciraNvpDeviceNetworks.

@Override
public List<? extends Network> listNiciraNvpDeviceNetworks(ListNiciraNvpDeviceNetworksCmd cmd) {
    Long niciraDeviceId = cmd.getNiciraNvpDeviceId();
    NiciraNvpDeviceVO niciraNvpDevice = niciraNvpDao.findById(niciraDeviceId);
    if (niciraNvpDevice == null) {
        throw new InvalidParameterValueException("Could not find a nicira device with id " + niciraDeviceId);
    }
    // Find the physical network we work for
    Long physicalNetworkId = niciraNvpDevice.getPhysicalNetworkId();
    PhysicalNetworkVO physicalNetwork = physicalNetworkDao.findById(physicalNetworkId);
    if (physicalNetwork == null) {
        // No such physical network, so no provisioned networks
        return Collections.emptyList();
    }
    // Find the nicira networks on this physical network
    List<NetworkVO> networkList = networkDao.listByPhysicalNetwork(physicalNetworkId);
    if (networkList == null) {
        return Collections.emptyList();
    }
    // Networks with broadcast type lswitch are ours
    List<NetworkVO> responseList = new ArrayList<NetworkVO>();
    for (NetworkVO network : networkList) {
        if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Lswitch) {
            responseList.add(network);
        }
    }
    return responseList;
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) ArrayList(java.util.ArrayList)

Aggregations

PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)112 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)50 ArrayList (java.util.ArrayList)40 NetworkVO (com.cloud.network.dao.NetworkVO)35 HostVO (com.cloud.host.HostVO)28 Test (org.junit.Test)28 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)26 Account (com.cloud.user.Account)25 DataCenter (com.cloud.dc.DataCenter)22 NetworkOffering (com.cloud.offering.NetworkOffering)22 Network (com.cloud.network.Network)18 PhysicalNetworkServiceProviderVO (com.cloud.network.dao.PhysicalNetworkServiceProviderVO)18 Host (com.cloud.host.Host)15 DB (com.cloud.utils.db.DB)15 ConfigurationException (javax.naming.ConfigurationException)14 HashMap (java.util.HashMap)12 DataCenterVO (com.cloud.dc.DataCenterVO)11 Domain (com.cloud.domain.Domain)11 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)11 TransactionStatus (com.cloud.utils.db.TransactionStatus)10