| 1 |
""" |
| 2 |
Handler for Huawei device specific information. |
| 3 |
|
| 4 |
Note that for proper import, the classname has to be: |
| 5 |
|
| 6 |
"<Devicename>DeviceHandler" |
| 7 |
|
| 8 |
...where <Devicename> is something like "Default", "Huawei", etc. |
| 9 |
|
| 10 |
All device-specific handlers derive from the DefaultDeviceHandler, which implements the |
| 11 |
generic information needed for interaction with a Netconf server. |
| 12 |
|
| 13 |
""" |
| 14 |
from ncclient.operations.third_party.huawei.rpc import * |
| 15 |
|
| 16 |
from ncclient.xml_ import BASE_NS_1_0 |
| 17 |
|
| 18 |
from .default import DefaultDeviceHandler |
| 19 |
|
| 20 |
class HuaweiDeviceHandler(DefaultDeviceHandler): |
| 21 |
""" |
| 22 |
Huawei handler for device specific information. |
| 23 |
|
| 24 |
In the device_params dictionary, which is passed to __init__, you can specify |
| 25 |
the parameter "ssh_subsystem_name". That allows you to configure the preferred |
| 26 |
SSH subsystem name that should be tried on your Huawei switch. If connecting with |
| 27 |
that name fails, or you didn't specify that name, the other known subsystem names |
| 28 |
will be tried. However, if you specify it then this name will be tried first. |
| 29 |
|
| 30 |
""" |
| 31 |
_EXEMPT_ERRORS = [] |
| 32 |
|
| 33 |
def __init__(self, device_params, ignore_errors=None): |
| 34 |
super(HuaweiDeviceHandler, self).__init__(device_params, ignore_errors) |
| 35 |
|
| 36 |
|
| 37 |
def add_additional_operations(self): |
| 38 |
dict = {} |
| 39 |
dict["cli"] = CLI |
| 40 |
dict["action"] = Action |
| 41 |
return dict |
| 42 |
|
| 43 |
def handle_raw_dispatch(self, raw): |
| 44 |
return raw.strip('\0') |
| 45 |
|
| 46 |
def get_capabilities(self): |
| 47 |
# Just need to replace a single value in the default capabilities |
| 48 |
c = super(HuaweiDeviceHandler, self).get_capabilities() |
| 49 |
c.append('http://www.huawei.com/netconf/capability/execute-cli/1.0') |
| 50 |
c.append('http://www.huawei.com/netconf/capability/action/1.0') |
| 51 |
c.append('http://www.huawei.com/netconf/capability/active/1.0') |
| 52 |
c.append('http://www.huawei.com/netconf/capability/discard-commit/1.0') |
| 53 |
c.append('http://www.huawei.com/netconf/capability/exchange/1.0') |
| 54 |
|
| 55 |
return c |
| 56 |
|
| 57 |
def get_xml_base_namespace_dict(self): |
| 58 |
return {None: BASE_NS_1_0} |
| 59 |
|
| 60 |
def get_xml_extra_prefix_kwargs(self): |
| 61 |
d = {} |
| 62 |
d.update(self.get_xml_base_namespace_dict()) |
| 63 |
return {"nsmap": d} |
| 64 |
|
| 65 |
def perform_qualify_check(self): |
| 66 |
return False |