<?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: Paramiko doesnt get any data in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478727#M2987</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/215208"&gt;@batchenr&lt;/a&gt;, trying to fix your problem at source, does this example help for DHCP relay with Ansible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  tasks:
    - name: Create DHCP relay on interface
      paloaltonetworks.panos.panos_type_cmd:
        provider: "{{ device }}"
        cmd: "set"
        xpath: "/config/devices/entry[@name='localhost.localdomain']/network/dhcp/interface/entry[@name='{{ interface }}']/relay"
        element: "&amp;lt;ip&amp;gt;&amp;lt;server&amp;gt;&amp;lt;member&amp;gt;{{ relay_ip }}&amp;lt;/member&amp;gt;&amp;lt;/server&amp;gt;&amp;lt;enabled&amp;gt;yes&amp;lt;/enabled&amp;gt;&amp;lt;/ip&amp;gt;"&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 06 Apr 2022 19:23:41 GMT</pubDate>
    <dc:creator>JimmyHolland</dc:creator>
    <dc:date>2022-04-06T19:23:41Z</dc:date>
    <item>
      <title>Paramiko doesnt get any data</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478644#M2986</link>
      <description>&lt;DIV class=""&gt;&lt;P&gt;Im using python3 with Paramiko 2.10.3 on a palo alto version 9.1.10&lt;/P&gt;&lt;P&gt;I created this python script:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;def&lt;/SPAN&gt; &lt;SPAN class=""&gt;connect_SSH&lt;/SPAN&gt;():
    ssh_client = paramiko.SSHClient()
    ip=&lt;SPAN class=""&gt;'10.x.x.x'&lt;/SPAN&gt;
    port=&lt;SPAN class=""&gt;22&lt;/SPAN&gt;
    username=&lt;SPAN class=""&gt;'someuser'&lt;/SPAN&gt;
    password=&lt;SPAN class=""&gt;'somepassword'&lt;/SPAN&gt;
    ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh_client.connect(ip,port,username,password , look_for_keys=&lt;SPAN class=""&gt;False&lt;/SPAN&gt;, allow_agent=&lt;SPAN class=""&gt;False&lt;/SPAN&gt;)
    remote_conn = ssh_client.invoke_shell()
    output = remote_conn.recv(&lt;SPAN class=""&gt;1000&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;print&lt;/SPAN&gt;(output)
    remote_conn.send(&lt;SPAN class=""&gt;"\n"&lt;/SPAN&gt;)
    remote_conn.send(&lt;SPAN class=""&gt;"show system info\n"&lt;/SPAN&gt;)
    time.sleep(&lt;SPAN class=""&gt;5&lt;/SPAN&gt;)
    output = remote_conn.recv(&lt;SPAN class=""&gt;50000&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;print&lt;/SPAN&gt;(output)
connect_SSH()&lt;/PRE&gt;&lt;P&gt;Now I dont get any data from the palo alto, this is what i recive:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;b'Last login: Wed Apr  6 16:43:18 2022 from 10.x.x.x\r\r\n'&lt;/SPAN&gt;
&lt;SPAN class=""&gt;b'\r\nshow system info\r\n'&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;It is just repeating the command i did with no data. i have tried more ways to run it even with&lt;/P&gt;&lt;PRE&gt;stdout = remote_conn.send(&lt;SPAN class=""&gt;"show system info\n"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;and i get:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;b'Last login: Wed Apr  6 16:53:23 2022 from 10.x.x.x\r\r\n'&lt;/SPAN&gt;
&lt;SPAN class=""&gt;17&lt;/SPAN&gt;
&lt;SPAN class=""&gt;b'show system info\r\n\r\nshow system info\r\n'&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;What am i missing?&lt;/P&gt;&lt;P&gt;Im using paramiko as lest resort as i havent found any module of ansible to add dhcp relay to subinterface and also didnt find any docs to do it using python panos.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: also using this gives error:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;stdin, stdout, stderr = ssh_client.exec_command(&lt;SPAN class=""&gt;'show system info'&lt;/SPAN&gt;)
time.sleep(&lt;SPAN class=""&gt;5&lt;/SPAN&gt;)
&lt;SPAN class=""&gt;print&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"OUT"&lt;/SPAN&gt;, stdout.readlines())

&lt;SPAN class=""&gt;b'Last login: Wed Apr  6 17:05:26 2022 from 10.x.x.x\r\r\n'&lt;/SPAN&gt;
OUT []
Traceback (most recent call last):
  File &lt;SPAN class=""&gt;"parmiko.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;76&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; &amp;lt;module&amp;gt;
    connect_SSH()
  File &lt;SPAN class=""&gt;"parmiko.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;52&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; connect_SSH
    remote_conn.send(&lt;SPAN class=""&gt;"\n"&lt;/SPAN&gt;)
  File &lt;SPAN class=""&gt;"/usr/local/lib/python3.6/dist-packages/paramiko/channel.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;801&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; send
    &lt;SPAN class=""&gt;return&lt;/SPAN&gt; self._send(s, m)
  File &lt;SPAN class=""&gt;"/usr/local/lib/python3.6/dist-packages/paramiko/channel.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;1198&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; _send
    &lt;SPAN class=""&gt;raise&lt;/SPAN&gt; socket.error(&lt;SPAN class=""&gt;"Socket is closed"&lt;/SPAN&gt;)
OSError: Socket &lt;SPAN class=""&gt;is&lt;/SPAN&gt; closed&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 06 Apr 2022 14:08:54 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478644#M2986</guid>
      <dc:creator>batchenr</dc:creator>
      <dc:date>2022-04-06T14:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Paramiko doesnt get any data</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478727#M2987</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/215208"&gt;@batchenr&lt;/a&gt;, trying to fix your problem at source, does this example help for DHCP relay with Ansible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  tasks:
    - name: Create DHCP relay on interface
      paloaltonetworks.panos.panos_type_cmd:
        provider: "{{ device }}"
        cmd: "set"
        xpath: "/config/devices/entry[@name='localhost.localdomain']/network/dhcp/interface/entry[@name='{{ interface }}']/relay"
        element: "&amp;lt;ip&amp;gt;&amp;lt;server&amp;gt;&amp;lt;member&amp;gt;{{ relay_ip }}&amp;lt;/member&amp;gt;&amp;lt;/server&amp;gt;&amp;lt;enabled&amp;gt;yes&amp;lt;/enabled&amp;gt;&amp;lt;/ip&amp;gt;"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 06 Apr 2022 19:23:41 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478727#M2987</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2022-04-06T19:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Paramiko doesnt get any data</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478944#M2993</link>
      <description>&lt;P&gt;Thanks!!! used it loke this :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;---&lt;BR /&gt;- name: DHCP&lt;BR /&gt;hosts: localhost&lt;BR /&gt;connection: local&lt;BR /&gt;vars:&lt;BR /&gt;- ansible_python_interpreter: /usr/bin/env python3&lt;BR /&gt;roles:&lt;BR /&gt;- role: PaloAltoNetworks.paloaltonetworks&lt;BR /&gt;gather_facts: False&lt;BR /&gt;tasks:&lt;BR /&gt;- name: Grab the credentials&lt;BR /&gt;include_vars: 'firewall-secrets.yml'&lt;BR /&gt;- name: Create DHCP relay on interface&lt;BR /&gt;panos_type_cmd:&lt;BR /&gt;ip_address: '{{ ip_address }}'&lt;BR /&gt;username: '{{ username }}'&lt;BR /&gt;password: '{{ password }}'&lt;BR /&gt;cmd: "set"&lt;BR /&gt;xpath: "/config/devices/entry[@name='localhost.localdomain']/network/dhcp/interface/entry[@name='{{ interface }}']/relay"&lt;BR /&gt;element: "&amp;lt;ip&amp;gt;&amp;lt;server&amp;gt;&amp;lt;member&amp;gt;10.x.x.x1&amp;lt;/member&amp;gt;&amp;lt;/server&amp;gt;&amp;lt;enabled&amp;gt;yes&amp;lt;/enabled&amp;gt;&amp;lt;/ip&amp;gt;&amp;lt;ip&amp;gt;&amp;lt;server&amp;gt;&amp;lt;member&amp;gt;10.x.x.x2&amp;lt;/member&amp;gt;&amp;lt;/server&amp;gt;&amp;lt;enabled&amp;gt;yes&amp;lt;/enabled&amp;gt;&amp;lt;/ip&amp;gt;"&lt;BR /&gt;register: response&lt;/P&gt;&lt;P&gt;- debug:&lt;BR /&gt;msg: "{{ response.stdout }}"&lt;BR /&gt;msg: "{{ response.stdout_xml }}"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- name: Commit changes&lt;BR /&gt;panos_commit:&lt;BR /&gt;ip_address: '{{ ip_address }}'&lt;BR /&gt;username: '{{ username }}'&lt;BR /&gt;password: '{{ password }}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Couldnt find a way to send a list of dhcp ips so i duplicated the line&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 11:45:03 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478944#M2993</guid>
      <dc:creator>batchenr</dc:creator>
      <dc:date>2022-04-07T11:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Paramiko doesnt get any data</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478994#M2994</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/215208"&gt;@batchenr&lt;/a&gt;, for multiple IP addresses in a single DHCP relay, your element would look like this ideally:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;element: "&amp;lt;ip&amp;gt;&amp;lt;server&amp;gt;&amp;lt;member&amp;gt;{{ relay_ip_1 }}&amp;lt;/member&amp;gt;&amp;lt;member&amp;gt;{{ relay_ip_2 }}&amp;lt;/member&amp;gt;&amp;lt;/server&amp;gt;&amp;lt;enabled&amp;gt;yes&amp;lt;/enabled&amp;gt;&amp;lt;/ip&amp;gt;"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Apr 2022 14:31:22 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/478994#M2994</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2022-04-07T14:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Paramiko doesnt get any data</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/492300#M3034</link>
      <description>&lt;P&gt;Now I have an issue deleting the dhcp relay:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tasks:&lt;BR /&gt;- name: delete DHCP relay on interface&lt;BR /&gt;panos_type_cmd:&lt;BR /&gt;ip_address: '{{ ip_address }}'&lt;BR /&gt;username: '{{ username }}'&lt;BR /&gt;password: '{{ password }}'&lt;BR /&gt;cmd: "delete"&lt;BR /&gt;xpath: "/config/devices/entry[@name='localhost.localdomain']/network/dhcp/interface/entry[@name='a5.22']/relay"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Im trying to delete the interface itself using "panos_l3_subinterface" module but it gives errors that i have to delete the dhcp first&lt;/P&gt;&lt;P&gt;what is the correct way ?&lt;/P&gt;&lt;P&gt;also tried with "element" there but nothing seem to work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 10:07:57 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/492300#M3034</guid>
      <dc:creator>batchenr</dc:creator>
      <dc:date>2022-05-26T10:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Paramiko doesnt get any data</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/514570#M3131</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/215208"&gt;@batchenr&lt;/a&gt;, yes, PAN-OS maintains referential integrity, meaning you can not delete a layer3 network interface if there are things attached to it like a DHCP relay (or other things like DNS servers, GlobalProtect, etc). So please delete the other items before trying to delete the layer 3 network interface.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 12:08:57 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/paramiko-doesnt-get-any-data/m-p/514570#M3131</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2022-09-12T12:08:57Z</dc:date>
    </item>
  </channel>
</rss>

