Skip to content
Snippets Groups Projects

Fixes on OpenConfig and ACLs

Merged Lluis Gifre Renom requested to merge fix/tid-openconfig-acls into develop
@@ -14,20 +14,38 @@
from yattag import Doc, indent
RULE_TYPE_MAPPING = {
'ACLRULETYPE_UNDEFINED': 'ACL_UNDEFINED',
'ACLRULETYPE_IPV4' : 'ACL_IPV4',
'ACLRULETYPE_IPV6' : 'ACL_IPV6',
'ACLRULETYPE_L2' : 'ACL_L2',
'ACLRULETYPE_MPLS' : 'ACL_MPLS',
'ACLRULETYPE_MIXED' : 'ACL_MIXED',
}
FORWARDING_ACTION_MAPPING = {
'ACLFORWARDINGACTION_UNDEFINED': 'UNDEFINED',
'ACLFORWARDINGACTION_DROP' : 'DROP',
'ACLFORWARDINGACTION_ACCEPT' : 'ACCEPT',
'ACLFORWARDINGACTION_REJECT' : 'REJECT',
}
LOG_ACTION_MAPPING = {
'ACLLOGACTION_UNDEFINED': 'UNDEFINED',
'ACLLOGACTION_NOLOG' : 'LOG_NONE',
'ACLLOGACTION_SYSLOG' : 'LOG_SYSLOG',
}
def acl_set_mng(data, DEL):
doc, tag, text = Doc().tagtext()
type = ["ACL_UNDEFINED", "ACL_IPV4","ACL_IPV6","ACL_L2","ACL_MPLS","ACL_MIXED"]
f_action = ["UNDEFINED", "DROP","ACCEPT","REJECT"]
l_action = ["UNDEFINED", "LOG_NONE","LOG_SYSLOG"]
Acl_data = data["rule_set"]
Acl_name = Acl_data['name']
Acl_type = type[Acl_data['type']]
Acl_type = RULE_TYPE_MAPPING[Acl_data['type']]
Acl_desc = Acl_data['description']
Acl_entries = Acl_data['entries']
with tag('acl', xmlns="http://openconfig.net/yang/acl"):
if DEL == True:
if DEL:
with tag('acl-sets' ,'xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"'):
with tag('acl-set'):
with tag('name'):text(Acl_name)
@@ -105,9 +123,9 @@ def acl_set_mng(data, DEL):
with tag('actions'):
for key, value in action.items():
if "forward_action" in key :
with tag('forward-action'):text(l_action[value])
with tag('forward-action'):text(FORWARDING_ACTION_MAPPING[value])
elif "log_action" in key :
with tag('log-action'):text(f_action[value])
with tag('log-action'):text(LOG_ACTION_MAPPING[value])
result = indent(
doc.getvalue(),
indentation = ' '*2,
@@ -118,11 +136,10 @@ def acl_set_mng(data, DEL):
def acl_interface(data,vendor, DEL):
doc, tag, text = Doc().tagtext()
type = ["ACL_UNDEFINED", "ACL_IPV4","ACL_IPV6","ACL_L2","ACL_MPLS","ACL_MIXED"]
ID = data['endpoint_id']['endpoint_uuid']['uuid']
Acl_data = data["rule_set"]
Acl_name = Acl_data['name']
Acl_type = type[Acl_data['type']]
Acl_type = RULE_TYPE_MAPPING[Acl_data['type']]
with tag('acl', xmlns="http://openconfig.net/yang/acl"):
with tag('interfaces'):
@@ -285,4 +302,4 @@ def acl_interface(parameters,vendor):
acl_set = acl_set.replace('<acl>','<acl xmlns="http://openconfig.net/yang/acl">')
acl_set = acl_set.replace('</openconfig-acl>','')
return(acl_set)
'''
\ No newline at end of file
'''
Loading