<?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: Cisco ISE, Python and PHP in Network Devices</title>
    <link>https://community.cisco.com/t5/network-devices/cisco-ise-python-and-php/m-p/3828528#M245</link>
    <description>&lt;P&gt;Just reread and it looks like a possible issue with your permissions on the python modules you are calling.&amp;nbsp; If you didn't install them for everyone, it could be causing you issues.&amp;nbsp; Go look at what user is calling python (I suspect www-data or httpd) and make sure they are listed as being able to read the libraries.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2019 21:37:26 GMT</pubDate>
    <dc:creator>Daniel Finein</dc:creator>
    <dc:date>2019-03-28T21:37:26Z</dc:date>
    <item>
      <title>Cisco ISE, Python and PHP</title>
      <link>https://community.cisco.com/t5/network-devices/cisco-ise-python-and-php/m-p/3596230#M244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Everyone, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote a Python Class for ISE to find/add/remove devices.&amp;nbsp; It works great when I call it from another python program.&amp;nbsp; To help my Network Engineers, I want to embed this into a php page/form which will get information like Hostname and IP address so that I can create the device in ISE.&amp;nbsp; This is just a simple start of more to come. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I am running into issues when I try to call my python application from an PHP page run on Apache.&amp;nbsp; The issue I run into is with the requests module.&amp;nbsp; My python script, quits running when it gets to the get command.&amp;nbsp; Any help that anyone could provide would be greatly appreciated.&amp;nbsp; I am banging my head on the wall trying to figure out what is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have simplified my python script in order to figure what what is going wrong.&amp;nbsp; If someone has a better recommendation on how to call Python scripts from the web, I am open to suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The python script doesn't expect anything when it is called, I just removed the user and password from the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is what is returned when I run it from a command line:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$ python test.py&lt;/P&gt;&lt;P&gt;(u'172.18.251.225', u'25502760-d9a5-11e6-80af-00505684337f', u'MNIT LAN Device')&lt;/P&gt;&lt;P&gt;$&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is my python script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;#!/usr/bin python&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import json&lt;/P&gt;&lt;P&gt;import requests&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERSUser = 'user'&lt;/P&gt;&lt;P&gt;ERSPassword = 'pass'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;s = requests.session()&lt;/P&gt;&lt;P&gt;s.auth = (ERSUser, ERSPassword)&lt;/P&gt;&lt;P&gt;s.verify = True&lt;/P&gt;&lt;P&gt;s.headers.update({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Accept': 'application/json',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Connection': 'keep_alive',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Content_type': 'application/json'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;url = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://www.myserver.com:9060/ers/config/networkdevicefilter=ipaddress.EQ.172.18.251.225" rel="nofollow" target="_blank"&gt;https://www.myserver.com:9060/ers/config/networkdevicefilter=ipaddress.EQ.172.18.251.225&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;r = s.get(url)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i in r.json()['SearchResult']['resources']:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print (i['name'], i['id'], i['description'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the part of the php where I call the test.py script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$command = escapeshellcmd('/usr/bin/python /var/www/cgi-bin/test.py');&lt;/P&gt;&lt;P&gt;$output = shell_exec($command);&lt;/P&gt;&lt;P&gt;echo $output;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is from my Apache log:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error: cannot open Packages index using db5 - Permission denied (13)&lt;/P&gt;&lt;P&gt;error: cannot open Packages database in /var/lib/rpm&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/var/www/cgi-bin/test.py", line 19, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; r = s.get(url)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 476, in get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self.request('GET', url, **kwargs)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; resp = self.send(prep, **send_kwargs)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; r = adapter.send(request, **kwargs)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 415, in send&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise ConnectionError(err, request=request)&lt;/P&gt;&lt;P&gt;requests.exceptions.ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))&lt;/P&gt;&lt;P&gt;[dsampson@mnet-ws-dave httpd]$&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2018 20:43:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/cisco-ise-python-and-php/m-p/3596230#M244</guid>
      <dc:creator>dasampson</dc:creator>
      <dc:date>2018-05-10T20:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco ISE, Python and PHP</title>
      <link>https://community.cisco.com/t5/network-devices/cisco-ise-python-and-php/m-p/3828528#M245</link>
      <description>&lt;P&gt;Just reread and it looks like a possible issue with your permissions on the python modules you are calling.&amp;nbsp; If you didn't install them for everyone, it could be causing you issues.&amp;nbsp; Go look at what user is calling python (I suspect www-data or httpd) and make sure they are listed as being able to read the libraries.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 21:37:26 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/cisco-ise-python-and-php/m-p/3828528#M245</guid>
      <dc:creator>Daniel Finein</dc:creator>
      <dc:date>2019-03-28T21:37:26Z</dc:date>
    </item>
  </channel>
</rss>

