def dom_start(self, auth, dom, node, retry_count=1, wait_interval=3): retry = 0 dom.node = node try: wait_interval = float(wait_interval) except Exception as e: traceback.print_exc() LOGGER.info('Error converting wait_interval(' + str(wait_interval) + ') to float ' + 'default to 3') wait_interval = 3 try: retry_count = int(retry_count) except Exception as e: traceback.print_exc() LOGGER.info('Error converting retry_count(' + str(retry_count) + ') to int ' + 'default to 3') retry_count = 3 if retry < retry_count: try: tc = TaskCreator() task_id = tc.vm_action(auth, dom.id, node.id, constants.START, constants.CORE, constants.Maintenance) LOGGER.info('Trying to start the Virtual Machine:' + dom.name + '. Try:' + str(retry + 1) + '. Task:' + str(task_id)) wait_time = dom.get_wait_time(constants.START) wait_time = int(wait_time) + 3 finished,status = self.wait_for_task_completion(task_id, wait_time) # as status if finished == True and status == Task.SUCCEEDED: return True except Exception as e: traceback.print_exc() LOGGER.info('Error trying to start Virtual Machine,' + dom.name + '. ' + to_str(e)) if retry != retry_count - 1: time.sleep(wait_interval) retry += 1 return False
def dom_pause(self, auth, dom, node): dom.node = node try: tc = TaskCreator() task_id = tc.vm_action(auth, dom.id, node.id, constants.PAUSE, constants.CORE) LOGGER.info('Trying to pause the Virtual Machine:' + dom.name + '. Task:' + str(task_id)) wait_time = dom.get_wait_time(constants.PAUSE) wait_time = int(wait_time) + 3 finished,status = self.wait_for_task_completion(task_id, wait_time) if finished == True and status == Task.SUCCEEDED: return True except Exception as e: traceback.print_exc() LOGGER.info('Error trying to pause Virtual Machine,' + dom.name + '. ' + to_str(e)) return False