Search in sources :

Example 1 with VirtualRouterProviderVO

use of com.cloud.network.element.VirtualRouterProviderVO in project cosmic by MissionCriticalCloud.

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.model.enumeration.NetworkType) TrafficType(com.cloud.network.Networks.TrafficType) PhysicalNetworkServiceProviderVO(com.cloud.network.dao.PhysicalNetworkServiceProviderVO) VirtualRouterProviderVO(com.cloud.network.element.VirtualRouterProviderVO) Test(org.junit.Test)

Example 2 with VirtualRouterProviderVO

use of com.cloud.network.element.VirtualRouterProviderVO in project cloudstack by apache.

the class InternalLbElementServiceTest method setUp.

@Before
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    VirtualRouterProviderVO validElement = new VirtualRouterProviderVO(1, Type.InternalLbVm);
    VirtualRouterProviderVO invalidElement = new VirtualRouterProviderVO(1, Type.VirtualRouter);
    Mockito.when(_vrProviderDao.findById(validElId)).thenReturn(validElement);
    Mockito.when(_vrProviderDao.findById(invalidElId)).thenReturn(invalidElement);
    Mockito.when(_vrProviderDao.persist(validElement)).thenReturn(validElement);
    Mockito.when(_vrProviderDao.findByNspIdAndType(validProviderId, Type.InternalLbVm)).thenReturn(validElement);
    PhysicalNetworkServiceProviderVO validProvider = new PhysicalNetworkServiceProviderVO(1, "InternalLoadBalancerElement");
    PhysicalNetworkServiceProviderVO invalidProvider = new PhysicalNetworkServiceProviderVO(1, "Invalid name!");
    Mockito.when(_pNtwkProviderDao.findById(validProviderId)).thenReturn(validProvider);
    Mockito.when(_pNtwkProviderDao.findById(invalidProviderId)).thenReturn(invalidProvider);
    Mockito.when(_vrProviderDao.persist(Matchers.any(VirtualRouterProviderVO.class))).thenReturn(validElement);
}
Also used : PhysicalNetworkServiceProviderVO(com.cloud.network.dao.PhysicalNetworkServiceProviderVO) VirtualRouterProviderVO(com.cloud.network.element.VirtualRouterProviderVO) Before(org.junit.Before)

Example 3 with VirtualRouterProviderVO

use of com.cloud.network.element.VirtualRouterProviderVO in project cloudstack by apache.

the class InternalLoadBalancerElement method shutdownProviderInstances.

@Override
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
    VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), Type.InternalLbVm);
    if (element == null) {
        return true;
    }
    long elementId = element.getId();
    List<DomainRouterVO> internalLbVms = _routerDao.listByElementId(elementId);
    boolean result = true;
    for (DomainRouterVO internalLbVm : internalLbVms) {
        result = result && (_internalLbMgr.destroyInternalLbVm(internalLbVm.getId(), context.getAccount(), context.getCaller().getId()));
    }
    _vrProviderDao.remove(elementId);
    return result;
}
Also used : VirtualRouterProviderVO(com.cloud.network.element.VirtualRouterProviderVO) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 4 with VirtualRouterProviderVO

use of com.cloud.network.element.VirtualRouterProviderVO in project cloudstack by apache.

the class InternalLoadBalancerElement method addInternalLoadBalancerElement.

@Override
public VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId) {
    VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(ntwkSvcProviderId, Type.InternalLbVm);
    if (element != null) {
        s_logger.debug("There is already an " + getName() + " with service provider id " + ntwkSvcProviderId);
        return null;
    }
    PhysicalNetworkServiceProvider provider = _pNtwkSvcProviderDao.findById(ntwkSvcProviderId);
    if (provider == null || !provider.getProviderName().equalsIgnoreCase(getName())) {
        throw new InvalidParameterValueException("Invalid network service provider is specified");
    }
    element = new VirtualRouterProviderVO(ntwkSvcProviderId, Type.InternalLbVm);
    element = _vrProviderDao.persist(element);
    return element;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) VirtualRouterProviderVO(com.cloud.network.element.VirtualRouterProviderVO) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 5 with VirtualRouterProviderVO

use of com.cloud.network.element.VirtualRouterProviderVO in project cloudstack by apache.

the class InternalLbElementTest method setUp.

@Before
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    VirtualRouterProviderVO validElement = new VirtualRouterProviderVO(1, Type.InternalLbVm);
    validElement.setEnabled(true);
    VirtualRouterProviderVO invalidElement = new VirtualRouterProviderVO(1, Type.VirtualRouter);
    VirtualRouterProviderVO notEnabledElement = new VirtualRouterProviderVO(1, Type.InternalLbVm);
    Mockito.when(_vrProviderDao.findByNspIdAndType(validElId, Type.InternalLbVm)).thenReturn(validElement);
    Mockito.when(_vrProviderDao.findByNspIdAndType(invalidElId, Type.InternalLbVm)).thenReturn(invalidElement);
    Mockito.when(_vrProviderDao.findByNspIdAndType(notEnabledElId, Type.InternalLbVm)).thenReturn(notEnabledElement);
    Mockito.when(_vrProviderDao.persist(validElement)).thenReturn(validElement);
    Mockito.when(_vrProviderDao.findByNspIdAndType(validProviderId, Type.InternalLbVm)).thenReturn(validElement);
    PhysicalNetworkServiceProviderVO validProvider = new PhysicalNetworkServiceProviderVO(1, "InternalLoadBalancerElement");
    PhysicalNetworkServiceProviderVO invalidProvider = new PhysicalNetworkServiceProviderVO(1, "Invalid name!");
    Mockito.when(_pNtwkProviderDao.findById(validProviderId)).thenReturn(validProvider);
    Mockito.when(_pNtwkProviderDao.findById(invalidProviderId)).thenReturn(invalidProvider);
    Mockito.when(_vrProviderDao.persist(Matchers.any(VirtualRouterProviderVO.class))).thenReturn(validElement);
    DataCenterVO dc = new DataCenterVO(1L, null, null, null, null, null, null, null, null, null, NetworkType.Advanced, null, null);
    Mockito.when(_entityMgr.findById(Matchers.eq(DataCenter.class), Matchers.anyLong())).thenReturn(dc);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) DataCenter(com.cloud.dc.DataCenter) PhysicalNetworkServiceProviderVO(com.cloud.network.dao.PhysicalNetworkServiceProviderVO) VirtualRouterProviderVO(com.cloud.network.element.VirtualRouterProviderVO) Before(org.junit.Before)

Aggregations

VirtualRouterProviderVO (com.cloud.network.element.VirtualRouterProviderVO)8 PhysicalNetworkServiceProviderVO (com.cloud.network.dao.PhysicalNetworkServiceProviderVO)4 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)3 TrafficType (com.cloud.network.Networks.TrafficType)2 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)2 Type (com.cloud.network.VirtualRouterProvider.Type)2 Before (org.junit.Before)2 Test (org.junit.Test)2 DataCenter (com.cloud.dc.DataCenter)1 NetworkType (com.cloud.dc.DataCenter.NetworkType)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 NetworkType (com.cloud.model.enumeration.NetworkType)1 DomainRouterVO (com.cloud.vm.DomainRouterVO)1