Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2016 the original author or authors. |
| 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 | |
| 24 | class Rpc(object): |
Khen Nursimulu | e0d53f8 | 2016-12-14 11:05:44 -0800 | [diff] [blame^] | 25 | def __init__(self,rpc_request, rpc_method, voltha_method_ref, |
| 26 | grpc_client, session): |
Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 27 | self.rpc_request = rpc_request |
| 28 | self.rpc_method = rpc_method |
| 29 | self.rpc_response = RpcResponse() |
Khen Nursimulu | aaac7ee | 2016-12-11 22:03:52 -0500 | [diff] [blame] | 30 | self.grpc_client = grpc_client |
Khen Nursimulu | e0d53f8 | 2016-12-14 11:05:44 -0800 | [diff] [blame^] | 31 | self.voltha_method_ref = voltha_method_ref |
Khen Nursimulu | a7b842a | 2016-12-03 23:28:42 -0500 | [diff] [blame] | 32 | self.session = session |
| 33 | |
| 34 | def execute(self): |
| 35 | """ run the command - returns a OperationResponse """ |
| 36 | pass |
| 37 | |
| 38 | def set_rpc_response(self): |
| 39 | self.rpc_response = RpcResponse() |
| 40 | |
| 41 | def _validate_parameters(self, rpc_request): |
| 42 | """Sets and validates the node as well""" |
| 43 | pass |
Khen Nursimulu | aaac7ee | 2016-12-11 22:03:52 -0500 | [diff] [blame] | 44 | |
| 45 | def get_root_element(self, xml_msg): |
| 46 | tree = etree.parse(io.BytesIO(xml_msg)) |
| 47 | return tree.getroot() |
| 48 | |