<?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: WebAPI one time script stucks at 10% in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/141708#M6604</link>
    <description>&lt;P&gt;Have you succeeded to fix this issue?&lt;/P&gt;&lt;P&gt;I have the same issue too.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 18:39:37 GMT</pubDate>
    <dc:creator>gkgkd534</dc:creator>
    <dc:date>2022-02-16T18:39:37Z</dc:date>
    <item>
      <title>WebAPI one time script stucks at 10%</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51849#M3360</link>
      <description>&lt;P&gt;Hello. I wrote python script to get result of &amp;nbsp;&lt;STRONG&gt;cpstat fw&lt;/STRONG&gt; command:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def api_call(ip_addr, port, command, json_payload, sid):
    url = 'https://' + ip_addr + ':' + str(port) + '/web_api/' + command
    if sid == '':
        request_headers = {'Content-Type' : 'application/json'}
    else:
        request_headers = {'Content-Type' : 'application/json', 'X-chkp-sid' : sid}
    r = requests.post(url,data=json.dumps(json_payload), headers=request_headers, verify=False)
    return r.json()


def login(user,password):
    payload = {'user':user, 'password' : password}
    response = api_call(mgmt_server, 443, 'login',payload, '')
    return response["sid"]

def run_script(script_name, script_command,sid):
    payload = {'script-name':script_name, 'script':script_command, 'targets':otr_gws}
    response = api_call(mgmt_server, 443, 'run-script', payload, sid)
    return response

def show_task(task_id, sid):
    payload = {'task-id':task_id, 'details-level':'full'}
    response = api_call(mgmt_server, 443, 'show-task', payload, sid)
    return response


def main():
    sid = login(mgmt_username,mgmt_password)
    print("session id: " + sid)

    cpstat = run_script("cpstat","cpstat fw",sid)
    
    print(cpstat)
    print("------------------------------")
    print("cpstat result: " + json.dumps(cpstat))
    print("------------------------------")
    
    task_id=cpstat["tasks"][0]["task-id"]
    result=show_task(task_id, sid)
    print(result)


    logout_result = api_call(mgmt_server, 443,"logout", {},sid)
    print("logout result: " + json.dumps(logout_result))


if __name__ == '__main__':
    main()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2019-04-25_16-41-38.png" style="width: 330px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/981iCFBD31766FFDAFE2/image-size/large?v=v2&amp;amp;px=999" role="button" title="2019-04-25_16-41-38.png" alt="2019-04-25_16-41-38.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I run script it just stucks on the management server and nothing hashappened. What could be the problem?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;P.S. The main idea is I want to make script to check ISP Redundancy status and to switch ISP Manually.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 14:05:31 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51849#M3360</guid>
      <dc:creator>AntonMakarychev</dc:creator>
      <dc:date>2019-04-25T14:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: WebAPI one time script stucks at 10%</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51900#M3364</link>
      <description>I'm not a python programmer, but where are you defining the gateways on which to execute the cpstat fw command?&lt;BR /&gt;I don't see you passing it to your run_script function or defined anywhere in the script you pasted above.</description>
      <pubDate>Thu, 25 Apr 2019 23:45:17 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51900#M3364</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-04-25T23:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: WebAPI one time script stucks at 10%</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51935#M3368</link>
      <description>&lt;P&gt;The first part of script is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import requests&lt;BR /&gt;import json&lt;/P&gt;&lt;P&gt;mgmt_username = ‘user’&lt;BR /&gt;mgmt_password = ‘pass’&lt;BR /&gt;mgmt_server = ‘x.x.x.x’&lt;BR /&gt;otr_gws = [‘gw-2’]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 07:14:03 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51935#M3368</guid>
      <dc:creator>AntonMakarychev</dc:creator>
      <dc:date>2019-04-26T07:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: WebAPI one time script stucks at 10%</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51986#M3372</link>
      <description>&lt;P&gt;I don’t see you doing a base64 decoding of the command output either.&lt;/P&gt;
&lt;P&gt;See:&amp;nbsp;&lt;A href="https://community.checkpoint.com/t5/Developers-API-CLI/run-script-output/m-p/2835#M213" target="_blank"&gt;https://community.checkpoint.com/t5/Developers-API-CLI/run-script-output/m-p/2835#M213&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 18:09:53 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/51986#M3372</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-04-26T18:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: WebAPI one time script stucks at 10%</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/52242#M3388</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the solution - &lt;A href="https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&amp;amp;solutionid=sk147213&amp;amp;partition=Advanced&amp;amp;product=Multi-Domain" target="_blank"&gt;https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&amp;amp;solutionid=sk147213&amp;amp;partition=Advanced&amp;amp;product=Multi-Domain&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 10:36:41 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/52242#M3388</guid>
      <dc:creator>Valeriy_Denisov</dc:creator>
      <dc:date>2019-04-30T10:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: WebAPI one time script stucks at 10%</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/141708#M6604</link>
      <description>&lt;P&gt;Have you succeeded to fix this issue?&lt;/P&gt;&lt;P&gt;I have the same issue too.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 18:39:37 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/141708#M6604</guid>
      <dc:creator>gkgkd534</dc:creator>
      <dc:date>2022-02-16T18:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: WebAPI one time script stucks at 10%</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/149532#M6829</link>
      <description>&lt;P&gt;I had the same problem when i did it in PHP. But i did some tests and i found what it is and how to bypass the problem.&lt;/P&gt;&lt;P&gt;That's a bug in WEBAPI. I'm using R81, so i don't know about other versions.&lt;/P&gt;&lt;P&gt;When you use teh "run-script", the issue will occur if you use a LIST on the "target" parameter. So, if there's more than 1 gateway on target, the tasks will stuck.&lt;/P&gt;&lt;P&gt;Instead a LIST on "target" parameter, try to use a Loop passing one gateway at time.&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 13:03:39 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/WebAPI-one-time-script-stucks-at-10/m-p/149532#M6829</guid>
      <dc:creator>brunomelo</dc:creator>
      <dc:date>2022-05-26T13:03:39Z</dc:date>
    </item>
  </channel>
</rss>

