def start_vm(workflow_dict): try: environment = workflow_dict['environment'] cs_credentials = get_credentials_for( environment=environment, credential_type=CredentialType.CLOUDSTACK) cs_provider = CloudStackProvider(credentials=cs_credentials) instances_detail = workflow_dict['instances_detail'] for instance_detail in instances_detail: instance = instance_detail['instance'] host = instance.hostname host_csattr = HostAttr.objects.get(host=host) started = cs_provider.start_virtual_machine( vm_id=host_csattr.vm_id) if not started: raise Exception, "Could not start host {}".format(host) for instance_detail in instances_detail: instance = instance_detail['instance'] host = instance.hostname host_ready = check_ssh(host, wait=5, interval=10) if not host_ready: error = "Host %s is not ready..." % host LOG.warn(error) raise Exception, error return True except Exception, e: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0015) workflow_dict['exceptions']['traceback'].append(traceback) return False
def start_vm(workflow_dict): try: environment = workflow_dict['environment'] cs_credentials = get_credentials_for(environment = environment, credential_type = CredentialType.CLOUDSTACK) cs_provider = CloudStackProvider(credentials = cs_credentials) instances_detail = workflow_dict['instances_detail'] for instance_detail in instances_detail: instance = instance_detail['instance'] host = instance.hostname host_csattr = HostAttr.objects.get(host=host) started = cs_provider.start_virtual_machine(vm_id = host_csattr.vm_id) if not started: raise Exception, "Could not start host {}".format(host) for instance_detail in instances_detail: instance = instance_detail['instance'] host = instance.hostname host_csattr = HostAttr.objects.get(host=host) host_ready = check_ssh(server=host.address, username=host_csattr.vm_user, password=host_csattr.vm_password, wait=5, interval=10) if not host_ready: error = "Host %s is not ready..." % host LOG.warn(error) raise Exception, error return True except Exception, e: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0015) workflow_dict['exceptions']['traceback'].append(traceback) return False
def start_vm(workflow_dict): try: environment = workflow_dict['environment'] cs_credentials = get_credentials_for( environment=environment, credential_type=CredentialType.CLOUDSTACK) cs_provider = CloudStackProvider(credentials=cs_credentials) host = workflow_dict['host'] host_csattr = HostAttr.objects.get(host=host) started = cs_provider.start_virtual_machine(vm_id=host_csattr.vm_id) if not started: raise Exception("Could not start host {}".format(host)) host_ready = check_ssh(server=host.address, username=host_csattr.vm_user, password=host_csattr.vm_password, retries=50, wait=20, interval=30) if not host_ready: error = "Host %s is not ready..." % host LOG.warn(error) raise Exception(error) return True except Exception: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0015) workflow_dict['exceptions']['traceback'].append(traceback) return False