CLOUDSTACK-2475: Failed to create PF rules with Cisco VNMC as the port pool object name is exceeding the max limit

Ip and port pool object names in VNMC were created by appending guest vlan, public ip and id of corresponding rule for better readability. This resulted in the name exceeding max. length allowed.
Shortened the name by removing public ip part from it.
This commit is contained in:
Koushik Das 2013-05-15 09:12:48 +05:30
parent 1518e7ee43
commit f484f4af09
2 changed files with 13 additions and 11 deletions

View File

@ -795,7 +795,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
}
private String getNameForPFPortPool(String tenantName, String identifier) {
return "PFPort-" + tenantName + "-" + identifier;
return "PortPool-" + tenantName + "-" + identifier;
}
private String getDnForPFPortPool(String tenantName, String identifier) {
@ -803,7 +803,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
}
private String getNameForPFIpPool(String tenantName, String identifier) {
return "PFIp-" + tenantName + "-" + identifier;
return "IpPool-" + tenantName + "-" + identifier;
}
private String getDnForPFIpPool(String tenantName, String identifier) {
@ -1010,8 +1010,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
xml = replaceXmlValue(xml, "natruledn", getDnForPFRule(tenantName, identifier, policyIdentifier));
xml = replaceXmlValue(xml, "natrulename", getNameForPFRule(tenantName, identifier));
xml = replaceXmlValue(xml, "descr", "PF rule for Tenant VDC " + tenantName);
xml = replaceXmlValue(xml, "ippoolname", getNameForPFIpPool(tenantName, policyIdentifier + "-" + identifier));
xml = replaceXmlValue(xml, "portpoolname", getNameForPFPortPool(tenantName, policyIdentifier + "-" + identifier));
xml = replaceXmlValue(xml, "ippoolname", getNameForPFIpPool(tenantName, identifier));
xml = replaceXmlValue(xml, "portpoolname", getNameForPFPortPool(tenantName, identifier));
xml = replaceXmlValue(xml, "ip", publicIp);
xml = replaceXmlValue(xml, "startport", startPort);
xml = replaceXmlValue(xml, "endport", endPort);
@ -1088,7 +1088,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
}
private String getNameForDNatIpPool(String tenantName, String identifier) {
return "DNATIp-" + tenantName + "-" + identifier;
return "IpPool-" + tenantName + "-" + identifier;
}
private String getDnForDNatIpPool(String tenantName, String identifier) {
@ -1135,7 +1135,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
xml = replaceXmlValue(xml, "natruledn", getDnForDNatRule(tenantName, identifier, policyIdentifier));
xml = replaceXmlValue(xml, "natrulename", getNameForDNatRule(tenantName, identifier));
xml = replaceXmlValue(xml, "descr", "DNAT rule for Tenant VDC " + tenantName);
xml = replaceXmlValue(xml, "ippoolname", getNameForDNatIpPool(tenantName, policyIdentifier + "-" + identifier));
xml = replaceXmlValue(xml, "ippoolname", getNameForDNatIpPool(tenantName, identifier));
xml = replaceXmlValue(xml, "ip", publicIp);
List<String> rules = listChildren(getDnForDNatPolicy(tenantName, policyIdentifier));

View File

@ -364,7 +364,8 @@ public class CiscoVnmcResource implements ServerResource {
} else {
String[] externalIpRange = getIpRangeFromCidr(rule.getSourceCidrList().get(0));
if (rule.getTrafficType() == TrafficType.Ingress) {
if (!rule.getProtocol().equalsIgnoreCase("icmp")) {
if (!rule.getProtocol().equalsIgnoreCase("icmp")
&& rule.getSrcPortRange() != null) {
if (!_connection.createTenantVDCIngressAclRule(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1],
@ -379,7 +380,8 @@ public class CiscoVnmcResource implements ServerResource {
}
}
} else {
if (rule.getProtocol().equalsIgnoreCase("tcp") || rule.getProtocol().equalsIgnoreCase("udp")) {
if ((rule.getProtocol().equalsIgnoreCase("tcp") || rule.getProtocol().equalsIgnoreCase("udp"))
&& rule.getSrcPortRange() != null) {
if (!_connection.createTenantVDCEgressAclRule(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(),
@ -477,7 +479,7 @@ public class CiscoVnmcResource implements ServerResource {
throw new Exception("Failed to delete ACL ingress rule for DNAT in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCDNatIpPool(tenant, policyIdentifier + "-" + rule.getId(), rule.getDstIp())) {
if (!_connection.createTenantVDCDNatIpPool(tenant, Long.toString(rule.getId()), rule.getDstIp())) {
throw new Exception("Failed to create DNAT ip pool in VNMC for guest network with vlan " + vlanId);
}
@ -572,10 +574,10 @@ public class CiscoVnmcResource implements ServerResource {
throw new Exception("Failed to delete ACL ingress rule for PF in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCPFIpPool(tenant, policyIdentifier + "-" + rule.getId(), rule.getDstIp())) {
if (!_connection.createTenantVDCPFIpPool(tenant, Long.toString(rule.getId()), rule.getDstIp())) {
throw new Exception("Failed to create PF ip pool in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCPFPortPool(tenant, policyIdentifier + "-" + rule.getId(),
if (!_connection.createTenantVDCPFPortPool(tenant, Long.toString(rule.getId()),
Integer.toString(rule.getDstPortRange()[0]), Integer.toString(rule.getDstPortRange()[1]))) {
throw new Exception("Failed to create PF port pool in VNMC for guest network with vlan " + vlanId);
}