add stubs for automating acl/route actions
@@ -73,19 +73,31 @@ class Parser:
return Parser().yaml_out(config_file, obj_doc)
return False
- def apply_acl():
- pass
+ def add_acl(self, obj_doc, acl_obj):
+ # TODO
+ return obj_doc
- def remove_acl():
- pass
+ def remove_acl(self, obj_doc, acl_name):
+ # TODO
+ return obj_doc
- def apply_route():
- pass
+ def apply_acl(self, obj_doc, acl_name, port, switch):
+ # TODO
+ return obj_doc
- def remove_route():
- pass
+ def detach_acl(self, obj_doc, acl_name, port, switch):
+ # TODO
+ return obj_doc
+
+ def apply_route(self, obj_doc, route_obj, vlan):
+ # TODO
+ return obj_doc
+
+ def detach_route(self, obj_doc, route_obj, vlan):
+ # TODO
+ return obj_doc
- def config(self, config_file, action, port, switch):
+ def config(self, config_file, action, port, switch, acl_name=None, acl_obj=None, route_obj=None):
switch_found = None
config_file = Parser().get_config_file(config_file)
obj_doc = Parser().yaml_in(config_file)
@@ -160,6 +172,18 @@ class Parser:
elif action == 'shutdown':
# TODO
pass
+ elif action == 'add_acl':
+ obj_doc = self.add_acl(obj_doc, acl_obj)
+ elif action == 'remove_acl':
+ obj_doc = self.remove_acl(obj_doc, acl_name)
+ elif action == 'apply_acl':
+ obj_doc = self.apply_acl(obj_doc, acl_name, port, switch)
+ elif action == 'detach_acl':
+ obj_doc = self.detach_acl(obj_doc, acl_name, port, switch)
+ elif action == 'apply_route':
+ obj_doc = self.apply_route(obj_doc, route_obj, vlan)
+ elif action == 'detach_route':
+ obj_doc = self.detach_route(obj_doc, route_obj, vlan)
else:
self.logger.warning('Unknown action: {0}'.format(action))
try:
