<?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: Netmiko for Switch macro creation in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798614#M972</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the info.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried both of those methods and i'm still not having any luck. Just get and attributeError 'list' object has no attribute 'rstrip'&lt;/P&gt;&lt;P&gt;on both. I didn't find the documentation particularly helpful to be honest.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Mar 2023 14:53:07 GMT</pubDate>
    <dc:creator>glsparks</dc:creator>
    <dc:date>2023-03-21T14:53:07Z</dc:date>
    <item>
      <title>Netmiko for Switch macro creation</title>
      <link>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798454#M970</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm attempting to write a netmiko script to create a macro on a Cisco switch.&lt;/P&gt;&lt;P&gt;However the script doesn't seem to like the fact that a prompt is being returned.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the relevant portion of the script:&lt;/P&gt;&lt;P&gt;switch1 = {&lt;BR /&gt;'device_type':'cisco_ios',&lt;BR /&gt;'host':hostIP,&lt;BR /&gt;'username':username,&lt;BR /&gt;'password':pwd,&lt;BR /&gt;'global_delay_factor':4,&lt;BR /&gt;'session_log':'netmiko.log'&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#Define the commands to send&lt;/P&gt;&lt;P&gt;SwitchMacro = [&lt;BR /&gt;'macro name PythonTest',&lt;BR /&gt;'switchport host',&lt;BR /&gt;'switchport access vlan 999',&lt;BR /&gt;'shutdown',&lt;BR /&gt;'@'&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;# Apply the commands to the devices&lt;BR /&gt;all_devices = [switch1]&lt;/P&gt;&lt;P&gt;file = open('switchmacro.txt', 'w')&lt;BR /&gt;for devices in all_devices:&lt;/P&gt;&lt;P&gt;net_connect = ConnectHandler(**devices)&lt;/P&gt;&lt;P&gt;output = net_connect.send_config_set(SwitchMacro)&lt;BR /&gt;file.write(output)&lt;BR /&gt;#Print the verification to a file&lt;/P&gt;&lt;P&gt;file.close()&lt;/P&gt;&lt;P&gt;The log file shows:&lt;/P&gt;&lt;P&gt;SW1#configure terminal&lt;BR /&gt;Enter configuration commands, one per line. End with CNTL/Z.&lt;BR /&gt;SW1(config)#&lt;BR /&gt;SW1(config)#macro name PythonTest&lt;BR /&gt;Enter macro commands one per line. End with the character '@'.&lt;/P&gt;&lt;P&gt;Python output displays:&lt;/P&gt;&lt;P&gt;Pattern not detected: '(?:SW1.*$|#.*$)' in output.&lt;/P&gt;&lt;P&gt;Any ideas on how to resolve this?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 11:37:17 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798454#M970</guid>
      <dc:creator>glsparks</dc:creator>
      <dc:date>2023-03-21T11:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Netmiko for Switch macro creation</title>
      <link>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798488#M971</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As soon as you send "macro name PythonTest" the prompt changes, and Netmiko can't handle this (Netmiko is looking for "#" before it sends the next command). You need to work with netmiko_send_command_timing or netmiko_send_command_expect to workaround this (attention in both cases your first command must be "conf t").&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ktbyers.github.io/netmiko/docs/netmiko/index.html#netmiko.BaseConnection.send_command_expect" target="_blank"&gt;https://ktbyers.github.io/netmiko/docs/netmiko/index.html#netmiko.BaseConnection.send_command_expect&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://ktbyers.github.io/netmiko/docs/netmiko/index.html#netmiko.BaseConnection.send_command_timing" target="_blank"&gt;https://ktbyers.github.io/netmiko/docs/netmiko/index.html#netmiko.BaseConnection.send_command_timing&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 11:59:48 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798488#M971</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2023-03-21T11:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Netmiko for Switch macro creation</title>
      <link>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798614#M972</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the info.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried both of those methods and i'm still not having any luck. Just get and attributeError 'list' object has no attribute 'rstrip'&lt;/P&gt;&lt;P&gt;on both. I didn't find the documentation particularly helpful to be honest.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 14:53:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798614#M972</guid>
      <dc:creator>glsparks</dc:creator>
      <dc:date>2023-03-21T14:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Netmiko for Switch macro creation</title>
      <link>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798640#M973</link>
      <description>&lt;P&gt;Okay got this working now, rather by luck than by skill.&lt;/P&gt;&lt;P&gt;Added this and it started working:&lt;/P&gt;&lt;P&gt;output = net_connect.send_config_set(SwitchMacro, &lt;STRONG&gt;cmd_verify=False&lt;/STRONG&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 15:34:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798640#M973</guid>
      <dc:creator>glsparks</dc:creator>
      <dc:date>2023-03-21T15:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Netmiko for Switch macro creation</title>
      <link>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798663#M974</link>
      <description>&lt;P&gt;That‘s even better, didn‘t know that the flag behaves this way.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 06:16:20 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/netmiko-for-switch-macro-creation/m-p/4798663#M974</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2023-03-22T06:16:20Z</dc:date>
    </item>
  </channel>
</rss>

