Skip to content

Commit

Permalink
add example for creating support zips (#712)
Browse files Browse the repository at this point in the history
* adds support for generating support zips, and get_cluster_alive_nodes.

* add example for creating support zips
skymoore authored Jan 29, 2021
1 parent f04a88a commit cbe4186
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/jira/jira_dc_create_support_zips.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# coding=utf-8
from atlassian import Jira

jira = Jira(url="https://jira.example.com", username="mskymoore", password="admin")

alive_node_ids = [_["nodeId"] for _ in jira.get_cluster_alive_nodes()]

zips_creation_task_id = jira.generate_support_zip_on_nodes(alive_node_ids)["clusterTaskId"]

in_progress_zips = list()

while True:

for task in jira.check_support_zip_status(zips_creation_task_id)["tasks"]:

if task["status"] == "IN_PROGRESS":
print(f"file {task['fileName']} {task['progressMessage']}")

if task["fileName"] not in in_progress_zips:
in_progress_zips.append(task["fileName"])

else:
support_zip = jira.download_support_zip(task["fileName"])

with open(task["fileName"], "wb") as fp:
fp.write(support_zip)

print(f"{task['fileName']} written.")

if task["fileName"] in in_progress_zips:
in_progress_zips.remove(task["fileName"])

if len(in_progress_zips) == 0:
break

0 comments on commit cbe4186

Please sign in to comment.