use of com.cloud.network.nicira.DestinationNatRule 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"));
}
use of com.cloud.network.nicira.DestinationNatRule in project cloudstack by apache.
the class NiciraNvpResource method generateStaticNatRulePair.
public NatRule[] generateStaticNatRulePair(final String insideIp, final String outsideIp) {
final NatRule[] rulepair = new NatRule[2];
rulepair[0] = new DestinationNatRule();
rulepair[0].setType("DestinationNatRule");
rulepair[0].setOrder(100);
rulepair[1] = new SourceNatRule();
rulepair[1].setType("SourceNatRule");
rulepair[1].setOrder(100);
Match m = new Match();
m.setDestinationIpAddresses(outsideIp);
rulepair[0].setMatch(m);
((DestinationNatRule) rulepair[0]).setToDestinationIpAddress(insideIp);
// create matching snat rule
m = new Match();
m.setSourceIpAddresses(insideIp);
rulepair[1].setMatch(m);
((SourceNatRule) rulepair[1]).setToSourceIpAddressMin(outsideIp);
((SourceNatRule) rulepair[1]).setToSourceIpAddressMax(outsideIp);
return rulepair;
}
Aggregations