Search in sources :

Example 1 with Type

use of com.cloud.network.VirtualRouterProvider.Type in project cloudstack by apache.

the class InternalLoadBalancerVMManagerImpl method getInternalLbProviderId.

protected long getInternalLbProviderId(final Network guestNetwork) {
    final Type type = Type.InternalLbVm;
    final long physicalNetworkId = _ntwkModel.getPhysicalNetworkId(guestNetwork);
    final PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
    if (provider == null) {
        throw new CloudRuntimeException("Cannot find service provider " + type.toString() + " in physical network " + physicalNetworkId);
    }
    final VirtualRouterProvider internalLbProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), type);
    if (internalLbProvider == null) {
        throw new CloudRuntimeException("Cannot find provider " + type.toString() + " as service provider " + provider.getId());
    }
    return internalLbProvider.getId();
}
Also used : Type(com.cloud.network.VirtualRouterProvider.Type) TrafficType(com.cloud.network.Networks.TrafficType) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 2 with Type

use of com.cloud.network.VirtualRouterProvider.Type in project cloudstack by apache.

the class RouterDeploymentDefinitionTest method testFindVirtualProviderWithNullVrProvider.

@Test(expected = CloudRuntimeException.class)
public void testFindVirtualProviderWithNullVrProvider() {
    // Prepare
    when(mockNetworkModel.getPhysicalNetworkId(deployment.guestNetwork)).thenReturn(PHYSICAL_NW_ID);
    final Type type = Type.VirtualRouter;
    final PhysicalNetworkServiceProviderVO physicalNwSrvProvider = mock(PhysicalNetworkServiceProviderVO.class);
    when(physicalProviderDao.findByServiceProvider(PHYSICAL_NW_ID, type.toString())).thenReturn(physicalNwSrvProvider);
    when(physicalNwSrvProvider.getId()).thenReturn(PROVIDER_ID);
    when(mockVrProviderDao.findByNspIdAndType(PROVIDER_ID, type)).thenReturn(null);
    // Execute
    deployment.findVirtualProvider();
}
Also used : Type(com.cloud.network.VirtualRouterProvider.Type) NetworkType(com.cloud.dc.DataCenter.NetworkType) TrafficType(com.cloud.network.Networks.TrafficType) PhysicalNetworkServiceProviderVO(com.cloud.network.dao.PhysicalNetworkServiceProviderVO) Test(org.junit.Test)

Example 3 with Type

use of com.cloud.network.VirtualRouterProvider.Type in project cloudstack by apache.

the class RouterDeploymentDefinition method findVirtualProvider.

protected void findVirtualProvider() {
    // Check if providers are supported in the physical networks
    final Type type = Type.VirtualRouter;
    final Long physicalNetworkId = networkModel.getPhysicalNetworkId(guestNetwork);
    final PhysicalNetworkServiceProvider provider = physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
    if (provider == null) {
        throw new CloudRuntimeException(String.format("Cannot find service provider %s in physical network %s", type.toString(), physicalNetworkId));
    }
    vrProvider = vrProviderDao.findByNspIdAndType(provider.getId(), type);
    if (vrProvider == null) {
        throw new CloudRuntimeException(String.format("Cannot find virtual router provider %s as service provider %s", type.toString(), provider.getId()));
    }
}
Also used : Type(com.cloud.network.VirtualRouterProvider.Type) TrafficType(com.cloud.network.Networks.TrafficType) NetworkType(com.cloud.dc.DataCenter.NetworkType) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 4 with Type

use of com.cloud.network.VirtualRouterProvider.Type in project cloudstack by apache.

the class RouterDeploymentDefinitionTest method testFindVirtualProviderWithNullPhyNwSrvProvider.

@Test(expected = CloudRuntimeException.class)
public void testFindVirtualProviderWithNullPhyNwSrvProvider() {
    // Prepare
    when(mockNetworkModel.getPhysicalNetworkId(deployment.guestNetwork)).thenReturn(PHYSICAL_NW_ID);
    final Type type = Type.VirtualRouter;
    when(physicalProviderDao.findByServiceProvider(PHYSICAL_NW_ID, type.toString())).thenReturn(null);
    // Execute
    deployment.findVirtualProvider();
}
Also used : Type(com.cloud.network.VirtualRouterProvider.Type) NetworkType(com.cloud.dc.DataCenter.NetworkType) TrafficType(com.cloud.network.Networks.TrafficType) Test(org.junit.Test)

Example 5 with Type

use of com.cloud.network.VirtualRouterProvider.Type in project cloudstack by apache.

the class RouterDeploymentDefinitionTest method testFindVirtualProvider.

@Test
public void testFindVirtualProvider() {
    // Prepare
    when(mockNetworkModel.getPhysicalNetworkId(deployment.guestNetwork)).thenReturn(PHYSICAL_NW_ID);
    final Type type = Type.VirtualRouter;
    final PhysicalNetworkServiceProviderVO physicalNwSrvProvider = mock(PhysicalNetworkServiceProviderVO.class);
    when(physicalProviderDao.findByServiceProvider(PHYSICAL_NW_ID, type.toString())).thenReturn(physicalNwSrvProvider);
    when(physicalNwSrvProvider.getId()).thenReturn(PROVIDER_ID);
    final VirtualRouterProviderVO vrProvider = mock(VirtualRouterProviderVO.class);
    when(mockVrProviderDao.findByNspIdAndType(PROVIDER_ID, type)).thenReturn(vrProvider);
    // Execute
    deployment.findVirtualProvider();
    // Assert
    assertEquals("Didn't find and set the VirtualRouterProvider as expected", vrProvider, deployment.getVirtualProvider());
}
Also used : Type(com.cloud.network.VirtualRouterProvider.Type) NetworkType(com.cloud.dc.DataCenter.NetworkType) TrafficType(com.cloud.network.Networks.TrafficType) PhysicalNetworkServiceProviderVO(com.cloud.network.dao.PhysicalNetworkServiceProviderVO) VirtualRouterProviderVO(com.cloud.network.element.VirtualRouterProviderVO) Test(org.junit.Test)

Aggregations

TrafficType (com.cloud.network.Networks.TrafficType)5 Type (com.cloud.network.VirtualRouterProvider.Type)5 NetworkType (com.cloud.dc.DataCenter.NetworkType)4 Test (org.junit.Test)3 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)2 PhysicalNetworkServiceProviderVO (com.cloud.network.dao.PhysicalNetworkServiceProviderVO)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)1 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)1 VirtualRouterProviderVO (com.cloud.network.element.VirtualRouterProviderVO)1