Debian Codegraph @

ncclient/devices/alu.py

raw
1 from lxml import etree
2
3 from .default import DefaultDeviceHandler
4 from ncclient.operations.third_party.alu.rpc import GetConfiguration, LoadConfiguration, ShowCLI
5 from ncclient.xml_ import BASE_NS_1_0
6
7
8 def remove_namespaces(xml):
9
10 for elem in xml.getiterator():
11 if elem.tag is etree.Comment:
12 continue
13 i = elem.tag.find('}')
14 if i > 0:
15 elem.tag = elem.tag[i + 1:]
16
17 etree.cleanup_namespaces(xml)
18 return xml
19
20
21 class AluDeviceHandler(DefaultDeviceHandler):
22 """
23 Alcatel-Lucent 7x50 handler for device specific information.
24 """
25
26 def __init__(self, device_params, ignore_errors=None):
27 super(AluDeviceHandler, self).__init__(device_params, ignore_errors)
28
29 def get_capabilities(self):
30 return [
31 "urn:ietf:params:netconf:base:1.0",
32 ]
33
34 def get_xml_base_namespace_dict(self):
35 return {None: BASE_NS_1_0}
36
37 def get_xml_extra_prefix_kwargs(self):
38 d = {}
39 d.update(self.get_xml_base_namespace_dict())
40 return {"nsmap": d}
41
42 def add_additional_operations(self):
43 dict = {}
44 dict["get_configuration"] = GetConfiguration
45 dict["show_cli"] = ShowCLI
46 dict["load_configuration"] = LoadConfiguration
47 return dict
48
49 def transform_reply(self):
50 return remove_namespaces