

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)
        from time import sleep
        sleep(60)
        return True
    except Exception:
        traceback = full_stack()
        workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
        workflow_dict['exceptions']['traceback'].append(traceback)
        return False

dataset/ETHPy150Open globocom/database-as-a-service/dbaas/workflow/steps/util/__init__.py start_vm/original