def wait_bmc(self, key=None, value_target=None, token=None, minutes=10): ''' Wait on BMC Given a token, target, key wait for a match ''' # handles data as a dictionary or string timeout = time.time() + 60*minutes while True: r = self.conf.util_bmc_server.get(uri=token, minutes=minutes) if type(r.json().get('data')) == type(dict()): if key is None: for key, value in r.json().get('data'): if r.json().get('data').get(key) == value_target: break else: if r.json().get('data').get(key) == value_target: break else: if value_target in r.json().get('data'): break if time.time() > timeout: log.warning("We timed out waiting for \"{}\", we waited {} minutes for \"{}\"".format(token, minutes, value_target)) raise HTTPCheck(message="HTTP problem getting \"{}\", we waited {} minutes for \"{}\"".format(token, minutes, value_target)) time.sleep(5) return True
def get_bmc_state(self): ''' Get BMC State ''' # caller drives retry uri = "/xyz/openbmc_project/state/bmc0/attr/CurrentBMCState" r = self.conf.util_bmc_server.get(uri=uri) if r.status_code != requests.codes.ok: problem = "[{}] Description={}".format(r.json().get('message'), "".join(r.json().get('data').get('description'))) raise HTTPCheck(message="HTTP problem getting CurrentBMCState {}".format(problem)) return r.json().get('data')
def image_ready_for_activation(self, id, timeout=10): ''' Image Activation Ready IS THIS USED ? CAN IT BE REMOVED ? ''' timeout = time.time() + 60*timeout while True: json_data = self.image_data(id, minutes=BMC_CONST.HTTP_RETRY) log.debug("Image JSON : {}".format(json_data)) if json_data.get('data').get('Activation') \ == "xyz.openbmc_project.Software.Activation.Activations.Ready": log.debug("Image upload is successful & Ready for activation") break if time.time() > timeout: raise HTTPCheck(message="Image is not ready for activation/Timeout happened") time.sleep(5) return True
def wait_for_image_active_complete(self, id, timeout=10): ''' Wait For Image Active Complete ''' timeout = time.time() + 60*timeout while True: json_data = self.image_data(id, minutes=BMC_CONST.HTTP_RETRY) if json_data.get('data').get('Activation') \ == "xyz.openbmc_project.Software.Activation.Activations.Activating": log.info("Image activation is in progress") if json_data.get('data').get('Activation') \ == "xyz.openbmc_project.Software.Activation.Activations.Active": log.info("Image activated successfully, Good to go for power on....") break if json_data.get('data').get('Activation') \ == "xyz.openbmc_project.Software.Activation.Activations.Failed": log.error("Image activation failed. Good luck.") return False if time.time() > timeout: raise HTTPCheck(message="Image is failed to activate/Timeout happened") time.sleep(5) return True