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());
}
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);
}
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;
}
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;
}
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);
}
Aggregations