Search in sources :

Example 31 with PhysicalNetworkVO

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

the class BrocadeVcsGuestNetworkGuru method design.

@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
    // Check of the isolation type of the related physical network is VLAN
    PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
    DataCenter dc = _dcDao.findById(plan.getDataCenterId());
    if (!canHandle(offering, dc.getNetworkType(), physnet)) {
        s_logger.debug("Refusing to design this network");
        return null;
    }
    s_logger.debug("Physical isolation type is VCS, asking GuestNetworkGuru to design this network");
    NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
    if (networkObject == null) {
        return null;
    }
    // Override the broadcast domain type
    networkObject.setBroadcastDomainType(BroadcastDomainType.Vcs);
    networkObject.setState(State.Allocated);
    return networkObject;
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DataCenter(com.cloud.dc.DataCenter) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO)

Example 32 with PhysicalNetworkVO

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

the class CiscoVnmcElement method deleteCiscoVnmcResource.

@Override
public boolean deleteCiscoVnmcResource(DeleteCiscoVnmcResourceCmd cmd) {
    Long vnmcResourceId = cmd.getCiscoVnmcResourceId();
    CiscoVnmcControllerVO vnmcResource = _ciscoVnmcDao.findById(vnmcResourceId);
    if (vnmcResource == null) {
        throw new InvalidParameterValueException("Could not find a Cisco VNMC appliance with id " + vnmcResourceId);
    }
    // Check if there any ASA 1000v appliances
    Long physicalNetworkId = vnmcResource.getPhysicalNetworkId();
    PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
    if (physicalNetwork != null) {
        List<CiscoAsa1000vDeviceVO> responseList = _ciscoAsa1000vDao.listByPhysicalNetwork(physicalNetworkId);
        if (responseList.size() > 0) {
            throw new CloudRuntimeException("Cisco VNMC appliance with id " + vnmcResourceId + " cannot be deleted as there Cisco ASA 1000v appliances using it");
        }
    }
    HostVO vnmcHost = _hostDao.findById(vnmcResource.getHostId());
    Long hostId = vnmcHost.getId();
    vnmcHost.setResourceState(ResourceState.Maintenance);
    _hostDao.update(hostId, vnmcHost);
    _resourceMgr.deleteHost(hostId, false, false);
    _ciscoVnmcDao.remove(vnmcResourceId);
    return true;
}
Also used : CiscoAsa1000vDeviceVO(com.cloud.network.cisco.CiscoAsa1000vDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) CiscoVnmcControllerVO(com.cloud.network.cisco.CiscoVnmcControllerVO) HostVO(com.cloud.host.HostVO)

Example 33 with PhysicalNetworkVO

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

the class CiscoVnmcElement method listCiscoAsa1000vResources.

@Override
public List<CiscoAsa1000vDeviceVO> listCiscoAsa1000vResources(ListCiscoAsa1000vResourcesCmd cmd) {
    Long physicalNetworkId = cmd.getPhysicalNetworkId();
    Long ciscoAsa1000vResourceId = cmd.getCiscoAsa1000vResourceId();
    List<CiscoAsa1000vDeviceVO> responseList = new ArrayList<CiscoAsa1000vDeviceVO>();
    if (physicalNetworkId == null && ciscoAsa1000vResourceId == null) {
        throw new InvalidParameterValueException("Either physical network Id or Asa 1000v device Id must be specified");
    }
    if (ciscoAsa1000vResourceId != null) {
        CiscoAsa1000vDeviceVO ciscoAsa1000vResource = _ciscoAsa1000vDao.findById(ciscoAsa1000vResourceId);
        if (ciscoAsa1000vResource == null) {
            throw new InvalidParameterValueException("Could not find Cisco Asa 1000v device with id: " + ciscoAsa1000vResourceId);
        }
        responseList.add(ciscoAsa1000vResource);
    } else {
        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
        if (physicalNetwork == null) {
            throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId);
        }
        responseList = _ciscoAsa1000vDao.listByPhysicalNetwork(physicalNetworkId);
    }
    return responseList;
}
Also used : CiscoAsa1000vDeviceVO(com.cloud.network.cisco.CiscoAsa1000vDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO)

Example 34 with PhysicalNetworkVO

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

the class BrocadeVcsGuestNetworkGuruTest 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[] { "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(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) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeploymentPlan(com.cloud.deploy.DeploymentPlan) Test(org.junit.Test)

Example 35 with PhysicalNetworkVO

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

the class BrocadeVcsGuestNetworkGuruTest 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[] { "VCS" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
    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);
    // Not supported: GuestType Shared
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Shared);
    assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
    // Not supported: Basic networking
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
    // Not supported: IsolationMethod != VCS
    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)

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