Search in sources :

Example 1 with VpcVirtualRouterElement

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

the class NetworkServiceImpl method addDefaultVpcVirtualRouterToPhysicalNetwork.

protected PhysicalNetworkServiceProvider addDefaultVpcVirtualRouterToPhysicalNetwork(long physicalNetworkId) {
    PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VPCVirtualRouter.getName(), null, null);
    NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
    if (networkElement == null) {
        throw new CloudRuntimeException("Unable to find the Network Element implementing the VPCVirtualRouter Provider");
    }
    VpcVirtualRouterElement element = (VpcVirtualRouterElement) networkElement;
    element.addElement(nsp.getId(), Type.VPCVirtualRouter);
    return nsp;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VpcVirtualRouterElement(com.cloud.network.element.VpcVirtualRouterElement)

Example 2 with VpcVirtualRouterElement

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

the class NetworkServiceImpl method addDefaultVpcVirtualRouterToPhysicalNetwork.

private PhysicalNetworkServiceProvider addDefaultVpcVirtualRouterToPhysicalNetwork(final long physicalNetworkId) {
    final PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VPCVirtualRouter.getName(), null, null);
    final NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
    if (networkElement == null) {
        throw new CloudRuntimeException("Unable to find the Network Element implementing the VPCVirtualRouter Provider");
    }
    final VpcVirtualRouterElement element = (VpcVirtualRouterElement) networkElement;
    element.addElement(nsp.getId(), Type.VPCVirtualRouter);
    return nsp;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VpcVirtualRouterElement(com.cloud.network.element.VpcVirtualRouterElement)

Example 3 with VpcVirtualRouterElement

use of com.cloud.network.element.VpcVirtualRouterElement 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");
    }
}
Also used : VpcVirtualRouterElement(com.cloud.network.element.VpcVirtualRouterElement) VirtualRouterElement(com.cloud.network.element.VirtualRouterElement) Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) FirewallServiceProvider(com.cloud.network.element.FirewallServiceProvider) ArrayList(java.util.ArrayList) List(java.util.List) VpcVirtualRouterElement(com.cloud.network.element.VpcVirtualRouterElement) FirewallRuleVO(com.cloud.network.rules.FirewallRuleVO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

VpcVirtualRouterElement (com.cloud.network.element.VpcVirtualRouterElement)3 NetworkElement (com.cloud.network.element.NetworkElement)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 Network (com.cloud.network.Network)1 FirewallServiceProvider (com.cloud.network.element.FirewallServiceProvider)1 VirtualRouterElement (com.cloud.network.element.VirtualRouterElement)1 FirewallRuleVO (com.cloud.network.rules.FirewallRuleVO)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1