Search in sources :

Example 16 with SourceNatRule

use of com.cloud.network.nicira.SourceNatRule in project cloudstack by apache.

the class NiciraNvpResourceTest method testGenerateStaticNatRulePair.

@Test
public void testGenerateStaticNatRulePair() {
    final NatRule[] rules = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
    assertTrue("DestinationNatRule".equals(rules[0].getType()));
    assertTrue("SourceNatRule".equals(rules[1].getType()));
    final DestinationNatRule dnr = (DestinationNatRule) rules[0];
    assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
    assertTrue(dnr.getToDestinationPort() == null);
    assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));
    final SourceNatRule snr = (SourceNatRule) rules[1];
    assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
    assertTrue(snr.getToSourcePort() == null);
    assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
}
Also used : DestinationNatRule(com.cloud.network.nicira.DestinationNatRule) NatRule(com.cloud.network.nicira.NatRule) SourceNatRule(com.cloud.network.nicira.SourceNatRule) DestinationNatRule(com.cloud.network.nicira.DestinationNatRule) SourceNatRule(com.cloud.network.nicira.SourceNatRule) Test(org.junit.Test)

Aggregations

SourceNatRule (com.cloud.network.nicira.SourceNatRule)16 DestinationNatRule (com.cloud.network.nicira.DestinationNatRule)14 NatRule (com.cloud.network.nicira.NatRule)14 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)10 ArgumentMatcher (org.mockito.ArgumentMatcher)8 ConfigurePortForwardingRulesOnLogicalRouterAnswer (com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterAnswer)4 ConfigurePortForwardingRulesOnLogicalRouterCommand (com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterCommand)4 ConfigureStaticNatRulesOnLogicalRouterAnswer (com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterAnswer)4 ConfigureStaticNatRulesOnLogicalRouterCommand (com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterCommand)4 PortForwardingRuleTO (com.cloud.agent.api.to.PortForwardingRuleTO)4 StaticNatRuleTO (com.cloud.agent.api.to.StaticNatRuleTO)4 Match (com.cloud.network.nicira.Match)4 CreateLogicalRouterAnswer (com.cloud.agent.api.CreateLogicalRouterAnswer)2 L3GatewayAttachment (com.cloud.network.nicira.L3GatewayAttachment)2 LogicalRouter (com.cloud.network.nicira.LogicalRouter)2 LogicalRouterPort (com.cloud.network.nicira.LogicalRouterPort)2 LogicalSwitchPort (com.cloud.network.nicira.LogicalSwitchPort)2 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)2 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)2