Revision 3e99e2d1 utils/proxy.py
b/utils/proxy.py | ||
---|---|---|
56 | 56 |
self.username = username |
57 | 57 |
self.password = password |
58 | 58 |
|
59 |
def to_xml(self): |
|
59 |
def to_xml(self, operation=None): |
|
60 |
logger.info("Operation: %s"%operation) |
|
60 | 61 |
if self.route_object: |
61 | 62 |
logger.info("Generating XML config") |
62 | 63 |
route_obj = self.route_object |
... | ... | |
66 | 67 |
flow.routes.append(route) |
67 | 68 |
device.routing_options.append(flow) |
68 | 69 |
route.name = route_obj.name |
70 |
if operation == "delete": |
|
71 |
logger.info("Requesting a delete operation") |
|
72 |
route.operation = operation |
|
73 |
device = device.export(netconf_config=True) |
|
74 |
return ET.tostring(device) |
|
69 | 75 |
if route_obj.source: |
70 | 76 |
route.match['source'].append(route_obj.source) |
71 | 77 |
if route_obj.destination: |
... | ... | |
109 | 115 |
route.then[thenaction.action] = thenaction.action_value |
110 | 116 |
else: |
111 | 117 |
route.then[thenaction.action] = True |
112 |
device = device.export(netconf_config=True) |
|
113 |
return ET.tostring(device) |
|
114 |
else: |
|
115 |
return False |
|
116 |
|
|
117 |
def delete_route(self): |
|
118 |
if self.route_object: |
|
119 |
logger.info("Generating XML config") |
|
120 |
route_obj = self.route_object |
|
121 |
device = np.Device() |
|
122 |
flow = np.Flow() |
|
123 |
route = np.Route() |
|
124 |
flow.routes.append(route) |
|
125 |
device.routing_options.append(flow) |
|
126 |
route.name = route_obj.name |
|
127 |
route.operation = 'delete' |
|
118 |
if operation == "replace": |
|
119 |
logger.info("Requesting a replace operation") |
|
120 |
route.operation = operation |
|
128 | 121 |
device = device.export(netconf_config=True) |
129 | 122 |
return ET.tostring(device) |
130 | 123 |
else: |
... | ... | |
147 | 140 |
else: |
148 | 141 |
return False |
149 | 142 |
|
150 |
def apply(self, configuration = None): |
|
143 |
def apply(self, configuration = None, operation=None):
|
|
151 | 144 |
reason = None |
152 | 145 |
if not configuration: |
153 |
configuration = self.to_xml() |
|
146 |
configuration = self.to_xml(operation=operation)
|
|
154 | 147 |
edit_is_successful = False |
155 | 148 |
commit_confirmed_is_successful = False |
156 | 149 |
commit_is_successful = False |
Also available in: Unified diff