Search in sources :

Example 16 with PhysicalNetworkVO

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

the class NetworkModelImpl method getPhysicalNetworkInfo.

@Override
public List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfo(long dcId, HypervisorType hypervisorType) {
    List<PhysicalNetworkSetupInfo> networkInfoList = new ArrayList<PhysicalNetworkSetupInfo>();
    List<PhysicalNetworkVO> physicalNtwkList = _physicalNetworkDao.listByZone(dcId);
    for (PhysicalNetworkVO pNtwk : physicalNtwkList) {
        String publicName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Public, hypervisorType);
        String privateName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Management, hypervisorType);
        String guestName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Guest, hypervisorType);
        String storageName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Storage, hypervisorType);
        // String controlName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Control, hypervisorType);
        PhysicalNetworkSetupInfo info = new PhysicalNetworkSetupInfo();
        info.setPhysicalNetworkId(pNtwk.getId());
        info.setGuestNetworkName(guestName);
        info.setPrivateNetworkName(privateName);
        info.setPublicNetworkName(publicName);
        info.setStorageNetworkName(storageName);
        PhysicalNetworkTrafficTypeVO mgmtTraffic = _pNTrafficTypeDao.findBy(pNtwk.getId(), TrafficType.Management);
        if (mgmtTraffic != null) {
            String vlan = mgmtTraffic.getVlan();
            info.setMgmtVlan(vlan);
        }
        networkInfoList.add(info);
    }
    return networkInfoList;
}
Also used : ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) PhysicalNetworkTrafficTypeVO(com.cloud.network.dao.PhysicalNetworkTrafficTypeVO)

Example 17 with PhysicalNetworkVO

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

the class F5ExternalLoadBalancerElement method listF5LoadBalancers.

@Override
public List<ExternalLoadBalancerDeviceVO> listF5LoadBalancers(ListF5LoadBalancersCmd cmd) {
    Long physcialNetworkId = cmd.getPhysicalNetworkId();
    Long lbDeviceId = cmd.getLoadBalancerDeviceId();
    PhysicalNetworkVO pNetwork = null;
    List<ExternalLoadBalancerDeviceVO> lbDevices = new ArrayList<ExternalLoadBalancerDeviceVO>();
    if (physcialNetworkId == null && lbDeviceId == null) {
        throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
    }
    if (lbDeviceId != null) {
        ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
        if (lbDeviceVo == null || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
            throw new InvalidParameterValueException("Could not find F5 load balancer device with ID: " + lbDeviceId);
        }
        lbDevices.add(lbDeviceVo);
        return lbDevices;
    }
    if (physcialNetworkId != null) {
        pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
        if (pNetwork == null) {
            throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
        }
        lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.F5BigIp.getName());
        return lbDevices;
    }
    return null;
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) ArrayList(java.util.ArrayList)

Example 18 with PhysicalNetworkVO

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

the class NiciraNvpGuestNetworkGuruTest method testCanHandle.

@Test
public void testCanHandle() {
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT", "VXLAN" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
    assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
    // Supported: IsolationMethod == VXLAN
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VXLAN" }));
    assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
    // Not supported TrafficType != Guest
    when(offering.getTrafficType()).thenReturn(TrafficType.Management);
    assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
    // Supported: GuestType Shared
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Shared);
    assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet));
    // Not supported: Basic networking
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
    // Not supported: IsolationMethod != STT, VXLAN
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
    assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
}
Also used : NetworkOffering(com.cloud.offering.NetworkOffering) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) Test(org.junit.Test)

Example 19 with PhysicalNetworkVO

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

the class NiciraNvpGuestNetworkGuruTest method testDesignNoConnectivityInOffering.

@Test
public void testDesignNoConnectivityInOffering() {
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById((Long) any())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT", "VXLAN" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
    when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
    when(device.getId()).thenReturn(1L);
    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(false);
    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);
}
Also used : Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeploymentPlan(com.cloud.deploy.DeploymentPlan) Test(org.junit.Test)

Example 20 with PhysicalNetworkVO

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

the class NiciraNvpGuestNetworkGuruTest method testDesignNoElementOnPhysicalNetwork.

@Test
public void testDesignNoElementOnPhysicalNetwork() {
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById((Long) any())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT", "VXLAN" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    mock(NiciraNvpDeviceVO.class);
    when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NiciraNvpDeviceVO>emptyList());
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    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);
}
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)

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