Activates an instance's disks.

    @type instance: string
    @param instance: Instance name
    @type ignore_size: bool
    @param ignore_size: Whether to ignore recorded size
    @return: job id
192670
def ActivateInstanceDisks(r, instance, ignore_size=False):
    

    return r.request("put", "/2/instances/%s/activate-disks" % instance,
                     query={"ignore_size": ignore_size})
701421
def Grow(self,size):
		

		if size>1024:  raise(clc.CLCException("Cannot grow disk beyond 1024GB"))
		if size<=self.size:  raise(clc.CLCException("New size must exceed current disk size"))
		# TODO - Raise exception if too much total size (4TB standard, 1TB HS)


		disk_set = [{'diskId': o.id, 'sizeGB': o.size} for o in self.parent.disks if o!=self]
		self.size = size
		disk_set.append({'diskId': self.id, 'sizeGB': self.size})
		self.parent.server.dirty = True
		return(clc.v2.Requests(clc.v2.API.Call('PATCH','servers/%s/%s' % (self.parent.server.alias,self.parent.server.id),
		                                       json.dumps([{"op": "set", "member": "disks", "value": disk_set}]),
											   session=self.session),
							   alias=self.parent.server.alias,
							   session=self.session))
773297
def new(batch_size=None, **options):
    

    if batch_size:
        new_context = AutoContext(batch_size=batch_size, **options)
    else:
        new_context = Context(**options)

    _local.get_local_context().registry.append(new_context)

    return new_context
653794
def instances(self, skip_exist_test=False):
        
        self.reset_result_type()
        self._instances = True
        self._instances_skip_exist_test = skip_exist_test
        return self
274220
def setBatchSize(self, size):
        
        self._batchSize = size
        try:
            self._worker.setBatchSize(size)
        except AttributeError:
            pass
996852
def do_startInstance(self,args):
        """"""
        parser = CommandArgumentParser("startInstance")
        parser.add_argument(dest='instance',help='instance index or name');
        args = vars(parser.parse_args(args))

        instanceId = args['instance']
        force = args['force']
        try:
            index = int(instanceId)
            instances = self.scalingGroupDescription['AutoScalingGroups'][0]['Instances']
            instanceId = instances[index]
        except ValueError:
            pass

        client = AwsConnectionFactory.getEc2Client()
        client.start_instances(InstanceIds=[instanceId['InstanceId']])
1064077
def is_instance_running(self, instance_id):
        

        # Here, it's always better if we update the instance.
        instance = self._load_instance(instance_id, force_reload=True)
        return instance.status == 'ACTIVE'
1050843
def get_instance_id():
    
    log = logging.getLogger(mod_logger + '.get_instance_id')

    # Exit if not running on AWS
    if not is_aws():
        log.info('This machine is not running in AWS, exiting...')
        return

    instance_id_url = metadata_url + 'instance-id'
    try:
        response = urllib.urlopen(instance_id_url)
    except(IOError, OSError) as ex:
        msg = 'Unable to query URL to get instance ID: {u}\n{e}'. \
            format(u=instance_id_url, e=ex)
        log.error(msg)
        return

    # Check the code
    if response.getcode() != 200:
        msg = 'There was a problem querying url: {u}, returned code: {c}, unable to get the instance-id'.format(
                u=instance_id_url, c=response.getcode())
        log.error(msg)
        return
    instance_id = response.read()
    return instance_id
665989
def insert(self, identified):
        

        if not isinstance(identified, self._class):
            raise self.Error("Passed instance is not of the needed class",
                             self.Error.INVALID_INSTANCE_CLASS, instance=identified)

        try:
            if self._objects[identified.key] != identified:
                raise self.Error("Passes instance's key '%s' is already occupied" % identified.key,
                                 self.Error.KEY_EXISTS, key=identified.key, instance=identified)
        except KeyError:
            self._objects[identified.key] = identified
            self._events.insert.trigger(list=self, instance=identified)
        return identified
997428
def _activate_thin_device(name, dm_id, size, pool):
        
        table = '0 %d thin /dev/mapper/%s %s' % (int(size) // 512, pool, dm_id)
        cmd = ['dmsetup', 'create', name, '--table', table]
        r = util.subp(cmd)
        if r.return_code != 0:
            raise MountError('Failed to create thin device: %s' %
                             r.stderr.decode(sys.getdefaultencoding()))
479424
def size_on_copy(root="."):
    
    total_size = 0
    exclusions = exclusion_policy()
    for dirpath, dirnames, filenames in os.walk(root, topdown=True):
        current_exclusions = exclusions(dirpath, os.listdir(dirpath))
        # Modifying dirnames in-place will prune the subsequent files and
        # directories visited by os.walk. This is only possible when
        # topdown = True
        dirnames[:] = [d for d in dirnames if d not in current_exclusions]
        legit_files = [f for f in filenames if f not in current_exclusions]
        for f in legit_files:
            fp = os.path.join(dirpath, f)
            total_size += os.path.getsize(fp)
    return total_size
65789
def resize(self, size=None):
        

        if not self.israw():
            return

        size = size or tty.size(self.stdout)

        if size is not None:
            rows, cols = size
            try:
                self.client.resize(self.container, height=rows, width=cols)
            except IOError: # Container already exited
                pass
1106934
def format_jid_instance_ext(jid, job):
    '''
    
    '''
    ret = format_job_instance(job)
    ret.update({
        'JID': jid,
        'StartTime': jid_to_time(jid)})
    return ret
8671
def start(instance_id, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The stop action must be called with -a or --action.'
        )

    log.info('Starting instance %s', instance_id)

    params = {
        'action': 'StartInstances',
        'zone': _get_specified_zone(provider=get_configured_provider()),
        'instances.1': instance_id,
    }
    result = query(params)

    return result
123804
def clone_(self, quiet=False):
        
        ds2 = self._duplicate_(quiet=True)
        if ds2 is None:
            self.err("Can not clone instance")
        else:
            if quiet is False:
                self.ok("Instance cloned")
        return ds2
1047393
def resume(instance_id, profile=None, **kwargs):
    '''
    

    '''
    conn = _auth(profile, **kwargs)
    return conn.resume(instance_id)
1220895
def stop_instance(self, instance_id):
        
        instance = self._load_instance(instance_id)
        instance.delete()
        del self._instances[instance_id]