Skip to content

Commit

Permalink
fixed bugs in options 3 and 4
Browse files Browse the repository at this point in the history
both options didnt do anything, they only worked with --session-file or -sid,
also I fixed this bug:
Traceback (most recent call last):
  File "import_export_package.py", line 49, in <module>
    export_package(client, args)
  File "/home/admin/ExportImportPolicyPackage-master/exporting/export_package.py", line 39, in export_package
    = export_access_rulebase(show_package.data["name"], access_layer["name"], access_layer["uid"], client, timestamp, tar_file)
  File "/home/admin/ExportImportPolicyPackage-master/exporting/export_access_rulebase.py", line 16, in export_access_rulebase
    get_query_rulebase_data(client, "access-rulebase", {"name": layer, "uid": layer_uid, "package": package})
  File "/home/admin/ExportImportPolicyPackage-master/exporting/export_objects.py", line 38, in get_query_rulebase_data
    if compare_versions(client.api_version, "1.1") != -1:
  File "/home/admin/ExportImportPolicyPackage-master/utils.py", line 126, in compare_versions
    v1_nums = version1.split('.')
AttributeError: 'NoneType' object has no attribute 'split'
  • Loading branch information
chkp-maxcalderon committed Jun 17, 2019
1 parent 48061f5 commit 269199c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions import_export_package.py
Expand Up @@ -13,6 +13,13 @@
client = None


def get_version(client):
if not client.api_version:
res = client.api_call("show-api-versions")
handle_login_fail(not res.success, "couldn't get api version")
client.api_version = res.data["current-version"]


if __name__ == "__main__":

arg_parser = argparse.ArgumentParser(description="R80.X Policy Package Export/Import Tool, V3.0")
Expand All @@ -36,15 +43,18 @@
payload["session-timeout"] = args.session_timeout
client.login_as_root(domain=args.domain, payload=payload)
elif args.login == '3':
args.session_file = raw_input("Please enter path to session file: ")
client.sid = extract_sid_from_session_file(args.session_file)
handle_login_fail(not client.sid, "Could not extract SID form Session-File!")
test_reply = client.api_call("show-hosts", {"limit": 1})
handle_login_fail(not test_reply.success, "Extract SID is invalid!")

get_version(client)
elif args.login == '4':
client.sid = raw_input("Please enter sid: ")
test_reply = client.api_call("show-hosts", {"limit": 1})
handle_login_fail(not test_reply.success, "Supplied SID is invalid!")

get_version(client)

if args.operation == "export":
export_package(client, args)
else:
Expand Down

0 comments on commit 269199c

Please sign in to comment.