Decided not at this stage to combine VPC and VR code

This commit is contained in:
Ian Southam 2014-11-10 14:39:31 +01:00 committed by wilderrodrigues
parent 0afe0153a7
commit 54f5c53a20
2 changed files with 26 additions and 5 deletions

View File

@ -85,20 +85,20 @@ class CsAcl(CsDataBag):
def process(self, direction, rule_list):
for i in rule_list:
r = self.AclRule(direction, self, i)
r = self.AclRule(direction, self, i, self.config)
r.create()
class AclRule():
def __init__(self, direction, acl, rule):
def __init__(self, direction, acl, rule, config):
self.table = ""
self.device = acl.device
self.fw = acl.fw
self.chain = "ACL_INBOUND_%s" % self.device
self.chain = config.get_ingress_chain(self.device, acl.ip)
self.dest = "-s %s" % rule['cidr']
if direction == "egress":
self.table = "mangle"
self.chain = "ACL_OUTBOUND_%s" % self.device
self.table = config.get_efress_table()
self.chain = config.get_egress_chain(self.device, ip)
self.dest = "-d %s" % rule['cidr']
self.type = ""
self.type = rule['type']

View File

@ -47,5 +47,26 @@ class CsConfig(object):
def get_level(self):
return self.__LOG_LEVEL
def is_vpc(self):
return self.cl.get_type() == "vpcrouter":
def get_format(self):
return self.__LOG_FORMAT
def get_ingress_chain(self, device, ip):
if self.is_vpc:
return "ACL_INBOUND_%s" % device
else:
return "FIREWALL_" % ip
def get_egress_chain(self, device, ip):
if self.is_vpc:
return "ACL_OUTBOUND_%s" % device
else:
return "FW_EGRESS_RULES"
def get_egress_table(self):
if self.is_vpc:
return 'mangle'
else:
return "";