def _get_supportsave_status(session, ss_req_obj, ss_rsp_obj): status = show_status(ss_rsp_obj) ss_state = status.peek_status() sleep(5) print("\r\n") while ("in-progress" in ss_state or "queued" in ss_state or "done" in ss_state): resp = _post_supportsave(session, ss_req_obj) if pyfos_util.is_failed_resp(resp): ss_state = "failed" else: status = show_status(resp) ss_state = status.peek_status() percentage = status.peek_percentage_complete() print("Supportsave status: " + ss_state + " Completion percentage: " + str(percentage) + " ", end='\r', flush=True) sleep(5) print("\r\n") if ss_state == "failed": pyfos_util.response_print(resp)
def _get_firmwaredownload_status(session, ss_req_obj, ss_rsp_obj): status = show_status(ss_rsp_obj) ss_state = status.peek_status() if ss_state == "error": pyfos_util.response_print(ss_rsp_obj) return sleep(5) print("\r\n") while ("in-progress" in ss_state or "queued" in ss_state or "done" in ss_state): resp = ss_req_obj.post(session) if pyfos_util.is_failed_resp(resp): ss_state = "error" else: status = show_status(resp) ss_state = status.peek_status() percentage = status.peek_percentage_complete() print("Firmwawredownload status: " + ss_state + " Completion percentage: " + str(percentage) + " ", end='\r', flush=True) sleep(5) print("\r\n") if ss_state == "error": pyfos_util.response_print(resp)
def ss_show_status(session, ssObj): ss_obj = show_status(ssObj) ss_id = ss_obj.peek_message_id() status_obj = {"show-status": {"message-id": ss_id}} ss_req_obj = show_status(status_obj) ss_rsp_obj = _post_supportsave(session, ss_req_obj) if pyfos_util.is_failed_resp(ss_rsp_obj): print("Supportsave operation failed.\n") pyfos_util.response_print(ss_rsp_obj) return _get_supportsave_status(session, ss_req_obj, ss_rsp_obj) return
def _get_firmwaredownload_status(session, ss_req_obj, ss_rsp_obj): status = show_status(ss_rsp_obj) ss_state = status.peek_status() if ss_state == "error": pyfos_util.response_print(ss_rsp_obj) return sleep(10) print("\r\n") try: while ("in-progress" in ss_state or "queued" in ss_state or "done" in ss_state): resp = ss_req_obj.post(session) if pyfos_util.is_failed_resp(resp): ss_state = "error" print("\r\n") pyfos_util.response_print(resp) break else: status = show_status(resp) eula_text = status.peek_eula_text() if eula_text: print("EULA: \n", eula_text) break else: pyfos_util.response_print(status) ss_state = status.peek_status() if ss_state == "done": # stage = true, reponse displayed above now return break sleep(10) except socket_error as serr: if serr.errno == errno.ECONNREFUSED: print("Switch is rebooting as part of firmwaredownload. Use showstatus \ script with message-id as 20000 to track the firmwaredownload \ status after switch reboots.\n")
def fd_show_status(session, fd_dict): print(fd_dict) status_obj = {"show-status": {"message-id": fd_dict["show-status"] ["message-id"]}} ss_req_obj = show_status(status_obj) ss_rsp_obj = ss_req_obj.post(session) if pyfos_util.is_failed_resp(ss_rsp_obj): print("Firmwaredownload operation failed.\n") pyfos_util.response_print(ss_rsp_obj) return _get_firmwaredownload_status(session, ss_req_obj, ss_rsp_obj) return