<?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: python-script How to add source address to gpolicy (XML API) in General Topics</title>
    <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/69307#M40256</link>
    <description>&lt;P&gt;Here is my full code :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://pastebin.com/YDqNQvVE" target="_blank"&gt;http://pastebin.com/YDqNQvVE&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2015 08:23:37 GMT</pubDate>
    <dc:creator>gombodorj</dc:creator>
    <dc:date>2015-12-10T08:23:37Z</dc:date>
    <item>
      <title>python-script How to add source address to gpolicy (XML API)</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68400#M39902</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;i would like to add source address and destination address in a policy using XML API. below syntax is right?&lt;/P&gt;
&lt;P&gt;/api/?type=config&amp;amp;action=set&amp;amp;key=key_value&amp;amp;xpath=/config/devices/entry/vsys/entry/rulebase/security/rules/entry[@name='test']&amp;amp;element=&amp;lt;source&amp;gt;&amp;lt;member&amp;gt;192.168.1.1&amp;lt;/member&amp;gt;&amp;lt;/source&amp;gt;&amp;lt;destination&amp;gt;&amp;lt;member&amp;gt;192.168.2.2&amp;lt;/member&amp;gt;&amp;lt;/destination&amp;gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2015 07:29:04 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68400#M39902</guid>
      <dc:creator>gombodorj</dc:creator>
      <dc:date>2015-11-20T07:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: python-script How to add source address to gpolicy (XML API)</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68404#M39903</link>
      <description>&lt;P&gt;Yup the below syntax is right. I have test the same below is the screenshot. This command can add source and destination to existing rule or can create a new rule and in that rule it will have only source address and destination address&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/1286i5B4666907ACAF4F1/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="API_Output.png" title="API_Output.png" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2015 09:08:27 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68404#M39903</guid>
      <dc:creator>pankaku</dc:creator>
      <dc:date>2015-11-20T09:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: python-script How to add source address to gpolicy (XML API)</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68411#M39907</link>
      <description>&lt;P&gt;You are right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;also, if you are not building a custom tool then you could use what exists already :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://live.paloaltonetworks.com/t5/SDK-API-Articles/rules-edit-php-to-manage-edit-export-rules-from-CLI/ta-p/53321" target="_blank"&gt;https://live.paloaltonetworks.com/t5/SDK-API-Articles/rules-edit-php-to-manage-edit-export-rules-from-CLI/ta-p/53321&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it is built on a library that allows to you to any change in 2 lines of code or less.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cheers&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2015 12:54:53 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68411#M39907</guid>
      <dc:creator>cpainchaud</dc:creator>
      <dc:date>2015-11-20T12:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: python-script How to add source address to gpolicy (XML API)</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68791#M40058</link>
      <description>&lt;P&gt;thanks guys for response. One more question.&lt;/P&gt;
&lt;P&gt;I am new for python programming and this code does not working . Pls review&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;def key_api():&lt;BR /&gt; logging.debug("In API key")&lt;BR /&gt; conn = httplib.HTTPSConnection(ip)&lt;BR /&gt; try:&lt;BR /&gt; conn.request("GET", "/api/?type=keygen&amp;amp;user="+username+"&amp;amp;password=" + password1)&lt;BR /&gt; except IOError:&lt;BR /&gt; print " Unable to get the device's API key"&lt;BR /&gt; logging.debug("Error occured")&lt;BR /&gt; raise SystemExit(1)&lt;BR /&gt; r1 = conn.getresponse()&lt;BR /&gt; data1 = r1.read()&lt;BR /&gt; m=re.search(r"(&amp;lt;key&amp;gt;)(\w+)", data1)&lt;BR /&gt; try:&lt;BR /&gt; api_key = m.group(2)&lt;BR /&gt; except AttributeError:&lt;BR /&gt; print "NO API key is returned , Possibly incorrect creden"&lt;BR /&gt; logging.debug("Possible ")&lt;BR /&gt; conn.close() &lt;BR /&gt; raise SystemExit(1)&lt;BR /&gt; conn.close()&lt;BR /&gt; print "Working correct1"&lt;BR /&gt; return api_key&lt;BR /&gt; &lt;BR /&gt; def send_command(source_address,destination_address):&lt;BR /&gt; conn = httplib.HTTPSConnection(ip)&lt;BR /&gt; conn.request("GET", "/api/?type=config&amp;amp;action=set&amp;amp;key="+str(api_key)+"&amp;amp;xpath=/config/devices/entry/vsys/entry/rulebase/security/rules/entry[@name='test_Gombodorj']&amp;amp;element=&amp;lt;source&amp;gt;&amp;lt;member&amp;gt;"+source_address+"&amp;lt;/member&amp;gt;&amp;lt;/sou rce&amp;gt;&amp;lt;destination&amp;gt;&amp;lt;member&amp;gt;"+destination_address+"&amp;lt;/member&amp;gt;&amp;lt;/destination&amp;gt;")&lt;BR /&gt; print "Working correct2"&lt;BR /&gt;type=config&amp;amp;action=set&amp;amp;key="+str(api_key)+"&amp;amp;xpath=/config/devices/entry/vsys/entry/rulebase/security/rules/entry[@name='test_Gombodorj']&amp;amp;element=&amp;lt;source&amp;gt;&amp;lt;member&amp;gt;"+source_address+"&amp;lt;/member&amp;gt;&amp;lt;/sou rce&amp;gt;&amp;lt;destination&amp;gt;&amp;lt;member&amp;gt;"+destination_address+"&amp;lt;/member&amp;gt;&amp;lt;/destination&amp;gt;")&lt;BR /&gt; 38 print "Working correct2"&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 03:46:18 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68791#M40058</guid>
      <dc:creator>gombodorj</dc:creator>
      <dc:date>2015-11-30T03:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: python-script How to add source address to gpolicy (XML API)</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68871#M40081</link>
      <description>&lt;P&gt;Is this all of your code, what kind of error are you getting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure you lost your indentation when pasting the code but if not you may want to make sure it's properly indented as white space is significant in python.&amp;nbsp; Towards the end of the send_command function it looks like you are defining a variable named 'type' but after the = sign I don't see a quotation mark.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 22:53:25 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/68871#M40081</guid>
      <dc:creator>bgirdner</dc:creator>
      <dc:date>2015-12-01T22:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: python-script How to add source address to gpolicy (XML API)</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/69306#M40255</link>
      <description>&lt;P&gt;any error is not occured. But didnt source and destination address added into policy&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 08:18:58 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/69306#M40255</guid>
      <dc:creator>gombodorj</dc:creator>
      <dc:date>2015-12-10T08:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: python-script How to add source address to gpolicy (XML API)</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/69307#M40256</link>
      <description>&lt;P&gt;Here is my full code :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://pastebin.com/YDqNQvVE" target="_blank"&gt;http://pastebin.com/YDqNQvVE&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 08:23:37 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/python-script-how-to-add-source-address-to-gpolicy-xml-api/m-p/69307#M40256</guid>
      <dc:creator>gombodorj</dc:creator>
      <dc:date>2015-12-10T08:23:37Z</dc:date>
    </item>
  </channel>
</rss>

