def aws_start(self): """AWS start Start a VM in AWS. """ try: self.ec2c.start_instances( InstanceIds=[self.dataset_obj['aws_instance_id']], DryRun=True) except ClientError as e: if 'DryRunOperation' not in str(e): raise try: response = self.ec2c.start_instances( InstanceIds=[self.dataset_obj['aws_instance_id']], DryRun=False) current_state = ( response['StartingInstances'][0]['CurrentState']['Code']) log.debug(response) if current_state and current_state == AWS_RETURN_CODES['running']: log.info('{} is already running.'.format( self.dataset_obj['hostname'])) return except ClientError as e: raise VMError(e) host_up = wait_until( str(self.dataset_obj['intern_ip']), waitmsg='Waiting for SSH to respond', ) if not host_up: raise VMError('The server is not reachable with SSH')
def start(self, force_stop_failed=True, transaction=None): self.hypervisor.start_vm(self) if not self.wait_for_running(running=True): raise VMError('VM did not come online in time') host_up = wait_until( str(self.dataset_obj['intern_ip']), waitmsg='Waiting for SSH to respond', ) if not host_up and force_stop_failed: # If there is a network or booting error VM must be destroyed # if starting has failed. self.hypervisor.stop_vm_force(self) if not host_up: raise VMError('The server is not reachable with SSH') if transaction: transaction.on_rollback('stop VM', self.shutdown)