<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using Netconf NCCLIENT to automate multiple devices at once in Network Devices</title>
    <link>https://community.cisco.com/t5/network-devices/using-netconf-ncclient-to-automate-multiple-devices-at-once/m-p/4862149#M372</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;As a basic example you can simply loop over a list of devices:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from ncclient import manager  

devices = [
        "1.1.1.1",
        "1.1.1.2",
        "hostname.xyz",
        "1.1.1.3"
]

username = "admin"
password = "secret"

cfg = """
&amp;lt;config&amp;gt;
  &amp;lt;native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"&amp;gt;
    &amp;lt;banner&amp;gt;
      &amp;lt;motd&amp;gt;
        &amp;lt;banner&amp;gt;Welcome to this device. Have a nice day!&amp;lt;/banner&amp;gt;
      &amp;lt;/motd&amp;gt;
    &amp;lt;/banner&amp;gt;
  &amp;lt;/native&amp;gt;
&amp;lt;/config&amp;gt;
"""


for dev in devices:
    with manager.connect(
                host=dev,
                port=830,
                username=username,
                password=password,
                hostkey_verify=False,
            ) as m:
                res = m.edit_config(target="running", config=cfg)
                if res.ok:
                    print(f"successfully configured {dev}")&lt;/LI-CODE&gt;
&lt;P&gt;HTH&lt;BR /&gt;Marcel&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2023 06:08:44 GMT</pubDate>
    <dc:creator>Marcel Zehnder</dc:creator>
    <dc:date>2023-06-26T06:08:44Z</dc:date>
    <item>
      <title>Using Netconf NCCLIENT to automate multiple devices at once</title>
      <link>https://community.cisco.com/t5/network-devices/using-netconf-ncclient-to-automate-multiple-devices-at-once/m-p/4862143#M371</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know of a script to use or can help out with a link that simply shows how to loop through multiple devices to program them using ncclient?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Champ&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 05:26:20 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/using-netconf-ncclient-to-automate-multiple-devices-at-once/m-p/4862143#M371</guid>
      <dc:creator>nwekechampion</dc:creator>
      <dc:date>2023-06-26T05:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Netconf NCCLIENT to automate multiple devices at once</title>
      <link>https://community.cisco.com/t5/network-devices/using-netconf-ncclient-to-automate-multiple-devices-at-once/m-p/4862149#M372</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;As a basic example you can simply loop over a list of devices:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from ncclient import manager  

devices = [
        "1.1.1.1",
        "1.1.1.2",
        "hostname.xyz",
        "1.1.1.3"
]

username = "admin"
password = "secret"

cfg = """
&amp;lt;config&amp;gt;
  &amp;lt;native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"&amp;gt;
    &amp;lt;banner&amp;gt;
      &amp;lt;motd&amp;gt;
        &amp;lt;banner&amp;gt;Welcome to this device. Have a nice day!&amp;lt;/banner&amp;gt;
      &amp;lt;/motd&amp;gt;
    &amp;lt;/banner&amp;gt;
  &amp;lt;/native&amp;gt;
&amp;lt;/config&amp;gt;
"""


for dev in devices:
    with manager.connect(
                host=dev,
                port=830,
                username=username,
                password=password,
                hostkey_verify=False,
            ) as m:
                res = m.edit_config(target="running", config=cfg)
                if res.ok:
                    print(f"successfully configured {dev}")&lt;/LI-CODE&gt;
&lt;P&gt;HTH&lt;BR /&gt;Marcel&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 06:08:44 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/using-netconf-ncclient-to-automate-multiple-devices-at-once/m-p/4862149#M372</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2023-06-26T06:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using Netconf NCCLIENT to automate multiple devices at once</title>
      <link>https://community.cisco.com/t5/network-devices/using-netconf-ncclient-to-automate-multiple-devices-at-once/m-p/4862184#M373</link>
      <description>&lt;P&gt;Thanks Marcel,&lt;/P&gt;&lt;P&gt;That worked.&lt;/P&gt;&lt;P&gt;I might use functions to group routers for similar config and see how far I go.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 08:04:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/using-netconf-ncclient-to-automate-multiple-devices-at-once/m-p/4862184#M373</guid>
      <dc:creator>nwekechampion</dc:creator>
      <dc:date>2023-06-26T08:04:28Z</dc:date>
    </item>
  </channel>
</rss>

