Got it

S5720 Netconf NCClient XML help

Created: Sep 9, 2021 09:38:28Latest reply: Sep 16, 2021 14:27:34 407 3 0 0 0
  Rewarded HiCoins: 0 (problem resolved)

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.

Featured Answers

Recommended answer

DDSN
Admin Created Sep 9, 2021 12:12:24

Hi Pawang,
Strictly speaking, your question is beyond our knowledge of network communications and is a question of third-party programming.
View more
  • x
  • convention:

All Answers
DDSN
DDSN Admin Created Sep 9, 2021 09:39:44

Hi Pawang,
Please wait patiently. Our engineers are looking for answers to your questions.
View more
  • x
  • convention:

DDSN
DDSN Admin Created Sep 9, 2021 12:12:24

Hi Pawang,
Strictly speaking, your question is beyond our knowledge of network communications and is a question of third-party programming.
View more
  • x
  • convention:

Note
View more
  • x
  • convention:

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.