<?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: Get routes through Panorama in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/get-routes-through-panorama/m-p/514289#M3110</link>
    <description>&lt;P&gt;Hi Czinu,&lt;/P&gt;&lt;P&gt;is possible to get routing tables using Python SDK and through API url. I prefer to use Python SDK. Follow bellow a sugestion:&lt;/P&gt;&lt;P&gt;1- Define authentication parameters:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from panos import network
from panos import policies
from panos import firewall
from panos import objects


api_user = 'admin'
api_password = 'admin'

device = 'fw.abc.com'

fw = firewall.Firewall(device, api_user, api_password)&lt;/LI-CODE&gt;&lt;P&gt;2- So now, you can get the vrouters names:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;vrouters_list = network.VirtualRouter.refreshall(fw)
for vrouter in vrouters_list:
    print(vrouter)&lt;/LI-CODE&gt;&lt;P&gt;#the output of commands above will be the name of vrouters created in your firewall.&lt;/P&gt;&lt;P&gt;If you want to know more details about each vrouter:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for vrouter in vrouters_list:
    print(vrouter.about())&lt;/LI-CODE&gt;&lt;P&gt;#the output of commands above will be the name of vrouters created in your firewall plus interfaces, virtual router&lt;BR /&gt;parameters. Below an example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;output: {'interface': ['ae1.30', 'tunnel.10', 'tunnel.11', 'ae1.20'],
'ad_static': None,
'ad_static_ipv6': None,
'ad_ospf_int': None,
'ad_ospf_ext': None,
'ad_ospfv3_int': None,
'ad_ospfv3_ext': None,
'ad_ibgp': None,
'ad_ebgp': None,
'ad_rip': None,
'name': 'default'}&lt;/LI-CODE&gt;&lt;P&gt;4- To verify the static routes applied in a specific routing table:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;vrouter = network.VirtualRouter(name='default')
fw.add(vrouter)
static_routes = network.StaticRoute.refreshall(vrouter)
for route in static_routes:
    print(route.about())
&lt;/LI-CODE&gt;&lt;P&gt;#the output of commands above will be the details about each static route in the vrouter:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;output: #{'destination': '10.11.77.11/32',
'nexthop_type': None,
'nexthop': None,
'interface': 'tunnel.22',
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': '10.11.77.11_32'}
{'destination': '10.20.20.0/27',
'nexthop_type': 'ip-address',
'nexthop': '10.10.10.1',
'interface': None,
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': '10.20.20.0_27'}
{'destination': '10.30.30.30/24',
'nexthop_type': 'ip-address',
'nexthop': '10.10.10.1',
'interface': None,
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': '10.30.30.0_24'}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5 - To deploy a static route in a routing table, you can follow the following procedure:&lt;BR /&gt;5.a - First, create a dictionary with required parameters:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;test_python_route = {'destination': '8.8.8.8/32',
'nexthop_type': None,
'nexthop': None,
'interface': None,
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': 'PYTHON_TESTE_GOOGLE_DNS'
}
#**If you don´t fill all the key values, the default value is assumed.&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.b - Second, you need to get the virtual routers configuration from the firewall:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;network.VirtualRouter.refreshall(fw)&lt;/LI-CODE&gt;&lt;P&gt;5.c - So, you can "search" and/or "find" the virtual-router that will receive the new static route:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;vrouter = fw.find('default', network.VirtualRouter)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.d - So now, you can "build" the configuration and associate the "route dictionary":&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;deploy_route = network.StaticRoute(**test_python_route)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.e - Bind the config to vrouter python instance:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;vrouter.add(deploy_route)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.f - create the route:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;deploy_route.create()&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.g - My sugestion is, not commit from the script. But if required, you can commit from the script:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fw.commit()&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;#to confirm the commit process ocurring in the firewall go to GUI interface and verify in Task the commit status.&lt;BR /&gt;&lt;BR /&gt;Hope that this be useful, and i my suggestion is verify how panos module really works in the official documentation.&lt;BR /&gt;I´m a beginer yet, but i already learned a lot. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 15:42:46 GMT</pubDate>
    <dc:creator>joaovictor</dc:creator>
    <dc:date>2022-09-08T15:42:46Z</dc:date>
    <item>
      <title>Get routes through Panorama</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/get-routes-through-panorama/m-p/513242#M3099</link>
      <description>&lt;P&gt;Hello Fellow Community Members,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;we are currently working on automation solution which involves getting routing tables from firewalls. Is there any way we can get routing tables from firewalls through Panorama's API?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 12:16:18 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/get-routes-through-panorama/m-p/513242#M3099</guid>
      <dc:creator>czinu</dc:creator>
      <dc:date>2022-08-29T12:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes through Panorama</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/get-routes-through-panorama/m-p/514289#M3110</link>
      <description>&lt;P&gt;Hi Czinu,&lt;/P&gt;&lt;P&gt;is possible to get routing tables using Python SDK and through API url. I prefer to use Python SDK. Follow bellow a sugestion:&lt;/P&gt;&lt;P&gt;1- Define authentication parameters:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from panos import network
from panos import policies
from panos import firewall
from panos import objects


api_user = 'admin'
api_password = 'admin'

device = 'fw.abc.com'

fw = firewall.Firewall(device, api_user, api_password)&lt;/LI-CODE&gt;&lt;P&gt;2- So now, you can get the vrouters names:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;vrouters_list = network.VirtualRouter.refreshall(fw)
for vrouter in vrouters_list:
    print(vrouter)&lt;/LI-CODE&gt;&lt;P&gt;#the output of commands above will be the name of vrouters created in your firewall.&lt;/P&gt;&lt;P&gt;If you want to know more details about each vrouter:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for vrouter in vrouters_list:
    print(vrouter.about())&lt;/LI-CODE&gt;&lt;P&gt;#the output of commands above will be the name of vrouters created in your firewall plus interfaces, virtual router&lt;BR /&gt;parameters. Below an example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;output: {'interface': ['ae1.30', 'tunnel.10', 'tunnel.11', 'ae1.20'],
'ad_static': None,
'ad_static_ipv6': None,
'ad_ospf_int': None,
'ad_ospf_ext': None,
'ad_ospfv3_int': None,
'ad_ospfv3_ext': None,
'ad_ibgp': None,
'ad_ebgp': None,
'ad_rip': None,
'name': 'default'}&lt;/LI-CODE&gt;&lt;P&gt;4- To verify the static routes applied in a specific routing table:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;vrouter = network.VirtualRouter(name='default')
fw.add(vrouter)
static_routes = network.StaticRoute.refreshall(vrouter)
for route in static_routes:
    print(route.about())
&lt;/LI-CODE&gt;&lt;P&gt;#the output of commands above will be the details about each static route in the vrouter:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;output: #{'destination': '10.11.77.11/32',
'nexthop_type': None,
'nexthop': None,
'interface': 'tunnel.22',
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': '10.11.77.11_32'}
{'destination': '10.20.20.0/27',
'nexthop_type': 'ip-address',
'nexthop': '10.10.10.1',
'interface': None,
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': '10.20.20.0_27'}
{'destination': '10.30.30.30/24',
'nexthop_type': 'ip-address',
'nexthop': '10.10.10.1',
'interface': None,
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': '10.30.30.0_24'}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5 - To deploy a static route in a routing table, you can follow the following procedure:&lt;BR /&gt;5.a - First, create a dictionary with required parameters:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;test_python_route = {'destination': '8.8.8.8/32',
'nexthop_type': None,
'nexthop': None,
'interface': None,
'admin_dist': 10,
'metric': 10,
'enable_path_monitor': False,
'failure_condition': 'any',
'preemptive_hold_time': 2,
'name': 'PYTHON_TESTE_GOOGLE_DNS'
}
#**If you don´t fill all the key values, the default value is assumed.&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.b - Second, you need to get the virtual routers configuration from the firewall:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;network.VirtualRouter.refreshall(fw)&lt;/LI-CODE&gt;&lt;P&gt;5.c - So, you can "search" and/or "find" the virtual-router that will receive the new static route:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;vrouter = fw.find('default', network.VirtualRouter)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.d - So now, you can "build" the configuration and associate the "route dictionary":&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;deploy_route = network.StaticRoute(**test_python_route)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.e - Bind the config to vrouter python instance:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;vrouter.add(deploy_route)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.f - create the route:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;deploy_route.create()&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;5.g - My sugestion is, not commit from the script. But if required, you can commit from the script:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fw.commit()&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;#to confirm the commit process ocurring in the firewall go to GUI interface and verify in Task the commit status.&lt;BR /&gt;&lt;BR /&gt;Hope that this be useful, and i my suggestion is verify how panos module really works in the official documentation.&lt;BR /&gt;I´m a beginer yet, but i already learned a lot. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 15:42:46 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/get-routes-through-panorama/m-p/514289#M3110</guid>
      <dc:creator>joaovictor</dc:creator>
      <dc:date>2022-09-08T15:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes through Panorama</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/get-routes-through-panorama/m-p/514410#M3111</link>
      <description>&lt;P&gt;Thanks for extensive answer. This is not directly what I was asking for, but it has guided me in the right direction. For anyone else looking for the same thing this is how you can access devices with panorama as a proxy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Take a look at option 2 from here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pan-os-python.readthedocs.io/en/latest/howto.html#connect-via-panorama" target="_blank"&gt;https://pan-os-python.readthedocs.io/en/latest/howto.html#connect-via-panorama&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 10:49:06 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/get-routes-through-panorama/m-p/514410#M3111</guid>
      <dc:creator>czinu</dc:creator>
      <dc:date>2022-09-09T10:49:06Z</dc:date>
    </item>
  </channel>
</rss>

