<?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 from virtual systems via API in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152710#M6972</link>
    <description>&lt;P&gt;Yes, you would need to set your login shell to BASH to be able to test the command effectively on the command line.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jul 2022 16:06:08 GMT</pubDate>
    <dc:creator>Bob_Zimmerman</dc:creator>
    <dc:date>2022-07-11T16:06:08Z</dc:date>
    <item>
      <title>Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152496#M6956</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ref.&amp;nbsp;&lt;A href="https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-get-virtual-system-router-dynamic-routes-using-the-Run/td-p/116310" target="_self"&gt;https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-get-virtual-system-router-dynamic-routes-using-the-Run/td-p/116310&lt;/A&gt;&lt;/P&gt;&lt;P&gt;there is quite some old topic regarding my questions, but we have issues with this approach and it is also pretty ugly. We have been using&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sh -c 'printf "set virtual-system 4\nshow route\nexit\n" | clish'&lt;/PRE&gt;&lt;P&gt;but it randomly worked on R80 and it is failing all the way on R81 (after recent upgrade)&lt;/P&gt;&lt;P&gt;This is what we get in the logs on GW itself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Jul &amp;nbsp;6 14:56:53 2022 Gateway01 xpand[27931]: admin localhost t +volatile:clish:admin:23304 t&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jul &amp;nbsp;6 14:56:54 2022&amp;nbsp;Gateway01 clish[23304]: User admin logged in with ReadWrite permission&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jul &amp;nbsp;6 14:56:54 2022&amp;nbsp;Gateway01 clish[23304]: Failed to get terminal settings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jul &amp;nbsp;6 14:56:54 2022&amp;nbsp;Gateway01 xpand[27931]: admin localhost t -volatile:clish:admin:23304&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jul &amp;nbsp;6 14:56:54 2022&amp;nbsp;Gateway01 clish[23304]: User admin logged out due to an error from CLI shell&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any other way to get routing information via API including virtual systems?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 10:00:24 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152496#M6956</guid>
      <dc:creator>czinu</dc:creator>
      <dc:date>2022-07-07T10:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152514#M6958</link>
      <description>&lt;P&gt;Try the following script on your VSX. It will need to create a couple of local files to generate a clish dictionary that will be pushed with the -f flag. Output will be printed on screen and in routes_output.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/bash

#Import the vsenv shell to run vsenv commands
source /etc/profile.d/vsenv.sh

#Check if this is a VSX system, if not exit with error code 1.
vsenv 2&amp;amp;&amp;gt; /dev/null
if [[ ! "$? -eq 0" ]]; then
echo "This is not a VSX system, exiting."
exit 1
fi

#System variable definitions
#---------------------------

array_offset=1  #Since arrays begin with an index of 0 but VS count starts at 1
array_index=0   #Base array index is 0


#Read the output of vsx stat -v and search for virtual systems
readarray -t vs_index &amp;lt; &amp;lt;(vsx stat -v | awk '{if ($3 == "S") print $1}')
declare -p vs_index &amp;amp;&amp;gt;/dev/null

#Routing ile initialization
if test -f "./routefile"; then
        rm routefile; echo "File inialized"
fi

#Iterate array and create route dictionary
for i in ${vs_index[@]}
do
evaluator=$(($array_index+1))

#Verify if there is not a gap in VS index

if [[ ! " $evaluator -eq  $array_index " ]]; then
array_index=$(($array_index + 2))
fi

echo -e "set virtual-system $i\nshow route" &amp;gt;&amp;gt; routefile
clish -o pretty -f routefile &amp;gt; routes_output.txt

done
cat routes_output.txt
echo -e "-------------------------------------------------------------\n"
echo "VS routes saved to routes_output.txt"
exit 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 14:33:15 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152514#M6958</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2022-07-07T14:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152550#M6959</link>
      <description>&lt;P&gt;This is even more dirty. We cannot create files on customer boxes, so this is not viable for us. Thanks anyways, maybe it will be useful for someone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone else where we can do this actually via API without dirty hacks? It is a bit shame that something that basic like routing has not been taken into account to have separate call.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 06:35:01 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152550#M6959</guid>
      <dc:creator>czinu</dc:creator>
      <dc:date>2022-07-08T06:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152599#M6966</link>
      <description>&lt;P&gt;At this point, you should take the command you're pushing and try running it locally. Does it still fail? Might give a more useful error message.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 16:20:04 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152599#M6966</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-07-08T16:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152610#M6968</link>
      <description>&lt;P&gt;There is a Gaia API, but not sure you can use it to fetch routes for a given VS.&lt;BR /&gt;Possibly you can run the above command (or a similar one) via run-script.&lt;BR /&gt;You can also use run-script via the regular management API.&lt;BR /&gt;See:&amp;nbsp;&lt;A href="https://sc1.checkpoint.com/documents/latest/GaiaAPIs/#api_access~v1.6%20" target="_blank"&gt;https://sc1.checkpoint.com/documents/latest/GaiaAPIs/#api_access~v1.6%20&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 20:11:19 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152610#M6968</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2022-07-08T20:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152670#M6971</link>
      <description>&lt;P&gt;Directly on the cli I get what you see below. I think is obvious as I am using clish to access it in the first place.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[Expert@Gateway01:0]# printf "set virtual-system 4\nshow route\nexit\n" | clish&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CLINFR0479 &amp;nbsp;You can't start interactive session from another interactive session&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I try from Smatconsole CLI on CMA I get what you can see in the attachment. Looks like problem might be with piping clish command. What do you think?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 09:05:27 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152670#M6971</guid>
      <dc:creator>czinu</dc:creator>
      <dc:date>2022-07-11T09:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152710#M6972</link>
      <description>&lt;P&gt;Yes, you would need to set your login shell to BASH to be able to test the command effectively on the command line.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 16:06:08 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152710#M6972</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-07-11T16:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152816#M6975</link>
      <description>&lt;P&gt;I remember having to pull these out of vs_slot_objects in the old days..!&lt;/P&gt;&lt;P&gt;With the funky new database, the same data is retrievable via:&lt;/P&gt;&lt;P&gt;PAGER="" psql_client -t -c "select fwset from dleobjectderef_data where name='vFW-NAME' and objclass='com.checkpoint.objects.vsx_classes.dummy.CpmiVsSlotObj' and dlesession=0;" cpm postgres|sed 's/[+]$//'&lt;/P&gt;&lt;P&gt;One could potentially do something clever with the routes_installed and interfaces_installed collections therein?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 15:31:01 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152816#M6975</guid>
      <dc:creator>stallwoodj</dc:creator>
      <dc:date>2022-07-12T15:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152866#M6980</link>
      <description>&lt;P&gt;Definitely not something that we are looking for, but once again maybe someone will come across this topic and it fits into ones solution. Thanks for your input!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 08:01:08 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152866#M6980</guid>
      <dc:creator>czinu</dc:creator>
      <dc:date>2022-07-13T08:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152875#M6984</link>
      <description>&lt;DIV class=""&gt;
&lt;P&gt;I recommend to load the CP environment first:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;. /etc/profile.d/CP.sh;‍‍. /etc/profile.d/vsenv.sh;‍‍vsenv 4;netstat -rn&lt;/LI-CODE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 13 Jul 2022 10:42:08 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152875#M6984</guid>
      <dc:creator>Danny</dc:creator>
      <dc:date>2022-07-13T10:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152880#M6985</link>
      <description>&lt;P&gt;This did the trick. Thanks a lot Danny for your time and efforts!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final script looks like this if someone needs this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run-script script-name "show routes" script "source /etc/profile.d/CP.sh;source /etc/profile.d/vsenv.sh;vsenv x;netstat -rn" targets.1 "VSX_GATEWAY_NAME" --format json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'vsenv x' where x is the vs number. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Take into account netstat -rn limitations which were mentioned in other posts (will not show loadbalanced nexthops)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 11:28:06 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/152880#M6985</guid>
      <dc:creator>czinu</dc:creator>
      <dc:date>2022-07-13T11:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get routes from virtual systems via API</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/155465#M7068</link>
      <description>&lt;P&gt;It looks like in versions with the 3.10 kernel, clish no longer accepts piped input at all. Confirmed this is a problem on R80.40, R81, and R81.10.&lt;/P&gt;
&lt;P&gt;clish has always been a pain, but now it's just shockingly bad for dealing with VSX.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 22:22:21 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Get-routes-from-virtual-systems-via-API/m-p/155465#M7068</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2022-08-22T22:22:21Z</dc:date>
    </item>
  </channel>
</rss>

