use of com.cloud.network.element.VirtualRouterElement in project cloudstack by apache.
the class NetworkServiceImpl method addDefaultVirtualRouterToPhysicalNetwork.
protected PhysicalNetworkServiceProvider addDefaultVirtualRouterToPhysicalNetwork(long physicalNetworkId) {
PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName(), null, null);
// add instance of the provider
NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
if (networkElement == null) {
throw new CloudRuntimeException("Unable to find the Network Element implementing the VirtualRouter Provider");
}
VirtualRouterElement element = (VirtualRouterElement) networkElement;
element.addElement(nsp.getId(), Type.VirtualRouter);
return nsp;
}
use of com.cloud.network.element.VirtualRouterElement in project cloudstack by apache.
the class FirewallManagerTest method testApplyFWRules.
@Ignore("Requires database to be set up")
@Test
public void testApplyFWRules() {
List<FirewallRuleVO> ruleList = new ArrayList<FirewallRuleVO>();
FirewallRuleVO rule = new FirewallRuleVO("rule1", 1, 80, "TCP", 1, 2, 1, FirewallRule.Purpose.Firewall, null, null, null, null);
ruleList.add(rule);
FirewallManagerImpl firewallMgr = (FirewallManagerImpl) _firewallMgr;
VirtualRouterElement virtualRouter = mock(VirtualRouterElement.class);
VpcVirtualRouterElement vpcVirtualRouter = mock(VpcVirtualRouterElement.class);
List<FirewallServiceProvider> fwElements = new ArrayList<FirewallServiceProvider>();
fwElements.add(ComponentContext.inject(VirtualRouterElement.class));
fwElements.add(ComponentContext.inject(VpcVirtualRouterElement.class));
firewallMgr._firewallElements = fwElements;
try {
when(virtualRouter.applyFWRules(any(Network.class), any(List.class))).thenReturn(false);
when(vpcVirtualRouter.applyFWRules(any(Network.class), any(List.class))).thenReturn(true);
//Network network, Purpose purpose, List<? extends FirewallRule> rules
firewallMgr.applyRules(mock(Network.class), Purpose.Firewall, ruleList);
verify(vpcVirtualRouter).applyFWRules(any(Network.class), any(List.class));
verify(virtualRouter).applyFWRules(any(Network.class), any(List.class));
} catch (ResourceUnavailableException e) {
Assert.fail("Unreachable code");
}
}
Aggregations