<?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 Hi ChetanAPI is enable and in Network Security</title>
    <link>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669466#M917494</link>
    <description>&lt;P&gt;Hi Chetan&lt;/P&gt;&lt;P&gt;API is enable and how can I use it ?&lt;/P&gt;&lt;P&gt;Do I need a license ?&lt;/P&gt;&lt;P&gt;May I have an example script e.g. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks ,&lt;/P&gt;&lt;P&gt;Alfred&lt;/P&gt;</description>
    <pubDate>Thu, 20 Aug 2015 09:53:08 GMT</pubDate>
    <dc:creator>Alfred Berberich</dc:creator>
    <dc:date>2015-08-20T09:53:08Z</dc:date>
    <item>
      <title>need a CSV file ot txt --&gt; with interface name  , ip address and hostname - how to get ?</title>
      <link>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669464#M917492</link>
      <description>&lt;P&gt;Hallo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the Goal is a list like :&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;Firewall Name1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interface name1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;ip-address1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Interface Name 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ip-address2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&amp;nbsp;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;Firewall Name2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interface name1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;ip-address1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Interface Name 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ip-address2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;Question : &lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;Where are the config files saved in the CSM structure ?&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;Idea: copy them to a unix System and select it via perl script &lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&amp;nbsp;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;CSM Export Feature has no Output with needed Information ?&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;Idea : using CSM Export , but no Interface and IP will be exported&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&amp;nbsp;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;We have device expert for compliance checks &lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;Idea : write a regex to get my Information , but no way . Anybody else is using the device exprt and can help ?&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&amp;nbsp;&lt;/P&gt;&lt;P dir="LTR"&gt;&lt;FONT face="Trebuchet MS" size="2"&gt;sincerley Alfred&lt;/FONT&gt;&lt;/P&gt;&lt;P dir="LTR"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 13:32:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669464#M917492</guid>
      <dc:creator>Alfred Berberich</dc:creator>
      <dc:date>2020-02-21T13:32:43Z</dc:date>
    </item>
    <item>
      <title>If you have CSM REST API</title>
      <link>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669465#M917493</link>
      <description>&lt;P style="font-size: 14.3999996185303px; background-color: rgb(249, 249, 249);"&gt;If you have CSM REST API enabled, you can use 'getGroupList' method to get the information you are looking for in the single output and then parse through it to get it in any format you like.&lt;/P&gt;&lt;P style="font-size: 14.3999996185303px; background-color: rgb(249, 249, 249);"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="font-size: 14.3999996185303px; background-color: rgb(249, 249, 249);"&gt;Thanks,&lt;/P&gt;&lt;P style="font-size: 14.3999996185303px; background-color: rgb(249, 249, 249);"&gt;Chetan&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2015 22:54:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669465#M917493</guid>
      <dc:creator>Chetankumar Phulpagare</dc:creator>
      <dc:date>2015-08-17T22:54:10Z</dc:date>
    </item>
    <item>
      <title>Hi ChetanAPI is enable and</title>
      <link>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669466#M917494</link>
      <description>&lt;P&gt;Hi Chetan&lt;/P&gt;&lt;P&gt;API is enable and how can I use it ?&lt;/P&gt;&lt;P&gt;Do I need a license ?&lt;/P&gt;&lt;P&gt;May I have an example script e.g. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks ,&lt;/P&gt;&lt;P&gt;Alfred&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2015 09:53:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669466#M917494</guid>
      <dc:creator>Alfred Berberich</dc:creator>
      <dc:date>2015-08-20T09:53:08Z</dc:date>
    </item>
    <item>
      <title>Hi Alfred,</title>
      <link>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669467#M917496</link>
      <description>&lt;P&gt;Hi Alfred,&lt;/P&gt;
&lt;P&gt;CSM 4.7 onwards includes a demo license. If not, you need a license to use API. Simplest way to test it using 'Advanced REST Client' extension in chrome.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are relevant snippets from the Python script I use for working with CSM API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE&gt;
&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;import re
import csv
import logging
import datetime
from httplib2 import Http
from bs4 import BeautifulSoup&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;headers = {'Content-Type': 'application/xml'}
connection = Http(disable_ssl_certificate_validation=True)
csm = {}
csm['reqid'] = '123'&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;####### MAIN STARTS HERE #######
def main():
  # Log all the messages
  logging.basicConfig(
    filename='C:/Users/Chetan/Documents/CSM/nb api/output.txt',
    level=logging.DEBUG,
    format='%(asctime)s-%(levelname)s: %(message)s',
    datefmt='%m/%d/%Y %I:%M:%S %p')
  
  # Login to CSM
  response_login = api_login('10.1.1.10', 'csmuser', 'password')
  if response_login[0]:
    logging.debug('Successful Login!')
  else :
    logging.debug('Login FAILED')
    print_response(response_login)&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;  # Verify Service Info - can use as heartbeat
  response_srvInfo = getServiceInfo()
  if response_srvInfo[0]:
    logging.debug(
      'Service Info: ' + response_srvInfo[1].servicedesc.string)
  else :
    logging.debug('getServiceInfo FAILED')
    print_response(response_srvInfo)&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;  ######### ADD SCRIPT HERE ##########
  response_getGroupList = getGroupList()
  if response_getGroupList[0]:
    logging.debug(
      'Service Info: ' + response_getGroupList[1].prettify() )
  else :
    logging.debug('getGroupList FAILED')
    print_response(response_getGroupList)&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;  
  response_logout = api_logout()    # Logout CSM API session
  logging.debug('Logout response: ' + str(response_login[0]))&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;####### MAIN ENDS HERE #######&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;def make_tuple(response):
  """Returns a tuple of usable objects from the HTTP server response.
  USAGE: 
  tuple_resp = make_tuple(response)
  tuple_resp[0]: TRUE for successful server response
  tuple_resp[1]: BeatifulSoup object for XML payload
  """
  tuple_resp = (response[0]['status'] == '200', BeautifulSoup(response[1]))
  return tuple_resp&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;def print_response(response):
  """Print XML response data returned by CSM API in BeautifulSoup
  format. Note that BeautifulSoup module converts all XML tags to
  lower case.
  """
  logging.debug(response[1].prettify())&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;def api_login(csmanager, csm_user='csmuser', csm_pass='password', reqid='123'):
  """CSM API CLIENT AUTHENTICATION
  
  csmanager: CSM Server IP address or hostname
  csm_user: username
  csm_pass: password
  reqid (optional): CSM API request ID. Default is '123'
  
  After successful login, cookies are updated in the HTTP header for
  further communication.
  """
  csm['host'] = csmanager    # CSM Server IP address or hostname
  csm['reqid'] = reqid       # CSM API request ID
  url = 'https://' + csm['host'] + '/nbi/login'
  body = '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;' 
  body += '&amp;lt;ns1:loginRequest xmlns:ns1="csm"&amp;gt;' 
  body += '&amp;lt;protVersion&amp;gt;1.0&amp;lt;/protVersion&amp;gt;&amp;lt;reqId&amp;gt;'+ csm['reqid'] +'&amp;lt;/reqId&amp;gt;'
  body += '&amp;lt;username&amp;gt;' + csm_user + '&amp;lt;/username&amp;gt;'
  body += '&amp;lt;password&amp;gt;' + csm_pass + '&amp;lt;/password&amp;gt;'
  body += '&amp;lt;heartbeatRequested&amp;gt;false&amp;lt;/heartbeatRequested&amp;gt;'
  body += '&amp;lt;/ns1:loginRequest&amp;gt;'
  response = connection.request(url, "POST", body, headers)
  if response[0]['status'] == '200':
    # Update the HTTP header with cookies received from the server.
    headers['Cookie'] = response[0]['set-cookie']
  return make_tuple(response)&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;def api_logout():
  """Log out of current CSM API session. Old cookies are removed from
  the HTTP header.
  """
  url = 'https://' + csm['host'] + '/nbi/logout'
  body =  '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;' 
  body += '&amp;lt;ns1:logoutRequest xmlns:ns1="csm"&amp;gt;'
  body += '&amp;lt;protVersion&amp;gt;1.0&amp;lt;/protVersion&amp;gt;&amp;lt;reqId&amp;gt;'+ csm['reqid'] +'&amp;lt;/reqId&amp;gt;'
  body += '&amp;lt;/ns1:logoutRequest&amp;gt;'
  response = connection.request(url, "POST", body, headers)
  headers.pop('Cookie')    # Remove the cookie from HTTP header
  return make_tuple(response)&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;### GET-SERVICE-INFO
def getServiceInfo():
  url = 'https://' + csm['host'] + '/nbi/configservice/GetServiceInfo'
  body =  '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;'
  body += '&amp;lt;ns1:getServiceInfoRequest xmlns:ns1="csm"&amp;gt;'
  body += '&amp;lt;protVersion&amp;gt;1.0&amp;lt;/protVersion&amp;gt;&amp;lt;reqId&amp;gt;'+ csm['reqid'] +'&amp;lt;/reqId&amp;gt;'
  body += '&amp;lt;/ns1:getServiceInfoRequest&amp;gt;'
  response = connection.request(url, "POST", body, headers)
  return make_tuple(response)&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;### GET GROUP LIST
# The GetGroupList method returns the list of devices groups.
def getGroupList():
  url = 'https://' + csm['host'] + '/nbi/configservice/getGroupList'
  body =  '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;'
  body += '&amp;lt;ns1:groupListRequest xmlns:ns1="csm"&amp;gt;'
  body += '&amp;lt;protVersion&amp;gt;1.0&amp;lt;/protVersion&amp;gt;&amp;lt;reqId&amp;gt;'+ csm['reqid'] +'&amp;lt;/reqId&amp;gt;'
  body += '&amp;lt;includeEmptyGroups&amp;gt;false&amp;lt;/includeEmptyGroups&amp;gt;'
  body += '&amp;lt;/ns1:groupListRequest&amp;gt;'
  response = connection.request(url, "POST", body, headers)
  return make_tuple(response)&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size:10px;"&gt;&lt;SPAN style="font-family:courier new,courier,monospace;"&gt;# Standard boilerplate to call main() function.
if __name__ == '__main__':
  main()&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Chetan&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 18:50:30 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/need-a-csv-file-ot-txt-gt-with-interface-name-ip-address-and/m-p/2669467#M917496</guid>
      <dc:creator>Chetankumar Phulpagare</dc:creator>
      <dc:date>2015-08-21T18:50:30Z</dc:date>
    </item>
  </channel>
</rss>

