Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
Khen Nursimulu | c9ef7c1 | 2017-01-04 20:40:53 -0500 | [diff] [blame] | 3 | # Copyright 2017 the original author or authors. |
Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 4 | # |
| 5 | # Code adapted from https://github.com/choppsv1/netconf |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # |
| 19 | |
| 20 | from rpc_response import RpcResponse |
Khen Nursimulu | aaac7ee | 2016-12-11 22:03:52 -0500 | [diff] [blame] | 21 | from lxml import etree |
| 22 | import io |
Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 23 | |
Khen Nursimulu | a497274 | 2016-12-23 17:15:20 -0500 | [diff] [blame] | 24 | |
Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 25 | class Rpc(object): |
Khen Nursimulu | 8ffb893 | 2017-01-26 13:40:49 -0500 | [diff] [blame] | 26 | def __init__(self, request_dict, request_xml, grpc_client, session, |
| 27 | capabilities): |
Khen Nursimulu | c9ef7c1 | 2017-01-04 20:40:53 -0500 | [diff] [blame] | 28 | self.request = request_dict |
| 29 | self.request_xml = request_xml |
Khen Nursimulu | 8ffb893 | 2017-01-26 13:40:49 -0500 | [diff] [blame] | 30 | self.rpc_response = RpcResponse(capabilities) |
| 31 | self.grpc_client = grpc_client |
Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 32 | self.session = session |
Khen Nursimulu | 8ffb893 | 2017-01-26 13:40:49 -0500 | [diff] [blame] | 33 | self.capabilities = capabilities |
Khen Nursimulu | 7626ce1 | 2016-12-21 11:51:46 -0500 | [diff] [blame] | 34 | |
Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 35 | def execute(self): |
| 36 | """ run the command - returns a OperationResponse """ |
| 37 | pass |
| 38 | |
| 39 | def set_rpc_response(self): |
| 40 | self.rpc_response = RpcResponse() |
| 41 | |
| 42 | def _validate_parameters(self, rpc_request): |
| 43 | """Sets and validates the node as well""" |
| 44 | pass |
Khen Nursimulu | aaac7ee | 2016-12-11 22:03:52 -0500 | [diff] [blame] | 45 | |
| 46 | def get_root_element(self, xml_msg): |
| 47 | tree = etree.parse(io.BytesIO(xml_msg)) |
| 48 | return tree.getroot() |