| 1 |
from .default import DefaultDeviceHandler |
| 2 |
from ncclient.operations.third_party.sros.rpc import MdCliRawCommand, Commit |
| 3 |
from ncclient.xml_ import BASE_NS_1_0 |
| 4 |
|
| 5 |
|
| 6 |
class ConfigMode: |
| 7 |
PRIVATE = 'private' |
| 8 |
|
| 9 |
def passthrough(xml): |
| 10 |
return xml |
| 11 |
|
| 12 |
class SrosDeviceHandler(DefaultDeviceHandler): |
| 13 |
""" |
| 14 |
Nokia SR OS handler for device specific information. |
| 15 |
""" |
| 16 |
|
| 17 |
def __init__(self, device_params, ignore_errors=None): |
| 18 |
super(SrosDeviceHandler, self).__init__(device_params, ignore_errors) |
| 19 |
|
| 20 |
def get_capabilities(self): |
| 21 |
"""Set SR OS device handler client capabilities |
| 22 |
|
| 23 |
Set additional capabilities beyond the default device handler. |
| 24 |
|
| 25 |
Returns: |
| 26 |
A list of strings representing NETCONF capabilities to be |
| 27 |
sent to the server. |
| 28 |
""" |
| 29 |
base = super(SrosDeviceHandler, self).get_capabilities() |
| 30 |
additional = [ |
| 31 |
'urn:ietf:params:xml:ns:netconf:base:1.0', |
| 32 |
'urn:ietf:params:xml:ns:yang:1', |
| 33 |
'urn:ietf:params:netconf:capability:confirmed-commit:1.1', |
| 34 |
'urn:ietf:params:netconf:capability:validate:1.1', |
| 35 |
] |
| 36 |
if self.device_params.get('config_mode') == ConfigMode.PRIVATE: |
| 37 |
additional.append('urn:nokia.com:nc:pc') |
| 38 |
|
| 39 |
return base + additional |
| 40 |
|
| 41 |
def get_xml_base_namespace_dict(self): |
| 42 |
return {None: BASE_NS_1_0} |
| 43 |
|
| 44 |
def get_xml_extra_prefix_kwargs(self): |
| 45 |
d = {} |
| 46 |
d.update(self.get_xml_base_namespace_dict()) |
| 47 |
return {"nsmap": d} |
| 48 |
|
| 49 |
def add_additional_operations(self): |
| 50 |
operations = { |
| 51 |
'md_cli_raw_command': MdCliRawCommand, |
| 52 |
'commit': Commit, |
| 53 |
} |
| 54 |
return operations |
| 55 |
|
| 56 |
def perform_qualify_check(self): |
| 57 |
return False |
| 58 |
|
| 59 |
def transform_reply(self): |
| 60 |
return passthrough |