File: ericsson.py

package info (click to toggle)
python-ncclient 0.6.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,144 kB
  • sloc: python: 9,208; xml: 476; makefile: 83
file content (45 lines) | stat: -rw-r--r-- 1,316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Handler for Ericsson device specific information.

Note that for proper import, the classname has to be:

    "<Devicename>DeviceHandler"

...where <Devicename> is something like "Default", "Ericsson", etc.

All device-specific handlers derive from the DefaultDeviceHandler, which implements the
generic information needed for interaction with a Netconf server.

"""
from ncclient.xml_ import BASE_NS_1_0
from ncclient.operations.errors import OperationError
from .default import DefaultDeviceHandler


class EricssonDeviceHandler(DefaultDeviceHandler):
    """
    Ericsson handler for device specific information.

    """
    _EXEMPT_ERRORS = []

    def __init__(self, device_params):
        super(EricssonDeviceHandler, self).__init__(device_params)

    def get_xml_base_namespace_dict(self):
        return {None: BASE_NS_1_0}

    def get_xml_extra_prefix_kwargs(self):
        d = {}
        if self.check_device_params() is False:
            d.update(self.get_xml_base_namespace_dict())
        return {"nsmap": d}

    def check_device_params(self):
        value = self.device_params.get('with_ns')
        if value in [True, False]:
            return value
        elif value is None:
            return False
        else:
            raise OperationError('Invalid "with_ns" value: %s' % value)