Dear Friends,
Huawei Switch Model Number :S5720-12TP-LI-AC
Software Version: (S5720 V200R019C10SPC500)
I am trying to use ncclient edit-config to configure system time zone using python script.below is my code:
================================================================
import sys
import logging
from ncclient import manager
from ncclient import operations
log = logging.getLogger(__name__)
CREATE_INTERFACE = '''<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="39" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<edit-config>
<target>
<running/>
</target>
<config>
<sys:system xmlns:sys="urn:ietf:params:xml:ns:yang:ietf-system">
<sys:clock>
<sys:timezone-utc-offset>480</sys:timezone-utc-offset>
</sys:clock>
</sys:system>
</config>
</edit-config>
</rpc>'''
def huawei_connect(host, port, user, password):
return manager.connect(host=host,
port=port,
username=user,
password=password,
hostkey_verify = False,
device_params={'name': "huawei"},
allow_agent = False,
look_for_keys = False)
def _check_response(rpc_obj, snippet_name):
print("RPCReply for %s is %s" % (snippet_name, rpc_obj.xml))
xml_str = rpc_obj.xml
if "<ok/>" in xml_str:
print("%s successful" % snippet_name)
else:
print("Cannot successfully execute: %s" % snippet_name)
def test_edit_config_running(host, port, user, password):
with huawei_connect(host, port=port, user=user, password=password) as m:
rpc_obj = m.edit_config(target='running', config=CREATE_INTERFACE)
_check_response(rpc_obj, 'CREATE_INTERFACE')
m.commit()
if __name__ == '__main__':
test_edit_config_running(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
=====================================================================
I am getting below error while executing this script:
=====================================================================
Traceback (most recent call last):
File "huawei_connect_edit.py", line 52, in <module>
test_edit_config_running(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
File "huawei_connect_edit.py", line 46, in test_edit_config_running
rpc_obj = m.edit_config(target='running', config=CREATE_INTERFACE)
File "/usr/local/lib/python3.7/dist-packages/ncclient/manager.py", line 251, in execute
huge_tree=self._huge_tree).request(*args, **kwds)
File "/usr/local/lib/python3.7/dist-packages/ncclient/operations/edit.py", line 65, in request
node.append(validated_element(config, ("config", qualify("config"))))
File "/usr/local/lib/python3.7/dist-packages/ncclient/xml_.py", line 155, in validated_element
raise XMLError("Element [%s] does not meet requirement" % ele.tag)
ncclient.xml_.XMLError: Element [{urn:ietf:params:xml:ns:netconf:base:1.0}rpc] does not meet requirement
==================================================================================
Request you to please help us to resolve xml error.