Create a single GCE instance from a data dict.
432768
def create(vm_=None, call=None):
    '''
    
    '''
    if call:
        raise SaltCloudSystemExit(
            'You cannot create an instance with -a or -f.'
        )

    node_info = request_instance(vm_)
    if isinstance(node_info, bool):
        raise SaltCloudSystemExit(
            'There was an error creating the GCE instance.'
        )
    node_dict = node_info[0]
    node_data = node_info[1]

    ssh_user, ssh_key = __get_ssh_credentials(vm_)
    vm_['ssh_host'] = __get_host(node_data, vm_)
    vm_['key_filename'] = ssh_key

    ret = __utils__['cloud.bootstrap'](vm_, __opts__)

    ret.update(node_dict)

    log.info('Created Cloud VM \'%s\'', vm_['name'])
    log.trace(
        '\'%s\' VM creation details:\n%s',
        vm_['name'], pprint.pformat(node_dict)
    )

    __utils__['cloud.fire_event'](
        'event',
        'created instance',
        'salt/cloud/{0}/created'.format(vm_['name']),
        args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']),
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    return ret
1329231
def from_dict(cls, d):
        
        return cls(xc=d.get("xc"), x=d.get("x"), c=d.get("c"))
121133
def from_dict(cls, d):
        """"""
        warnings.warn(
            'from_dict is deprecated and will be removed in v1.0!',
            stacklevel=2)
        d = d or {}
        return cls(**d)
946452
def create(self):
        """"""
        # url('datastores')
        content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
        content = content.decode('utf8')
        content = simplejson.loads(content)
        new = DataStore(content['name'],
                        content['type'],
                        content['ogrstring'])
        results = meta.Session.add(new)
        meta.Session.commit()
        response.status = 201
1307746
def from_dict(cls, d):
        """"""
        return cls(
            d['type'], tuple(d['parents']), list(d['properties'].items())
        )
137086
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'event_type' in _dict:
            args['event_type'] = _dict.get('event_type')
        if 'results' in _dict:
            args['results'] = [
                MetricTokenAggregationResult._from_dict(x)
                for x in (_dict.get('results'))
            ]
        return cls(**args)
1048817
def startup_gce_instance(instance_name, project, zone, username, machine_type,
                         image, public_key, disk_name=None):
    
    log_green("Started...")
    log_yellow("...Creating GCE Jenkins Slave Instance...")
    instance_config = get_gce_instance_config(
        instance_name, project, zone, machine_type, image,
        username, public_key, disk_name
    )
    operation = _get_gce_compute().instances().insert(
        project=project,
        zone=zone,
        body=instance_config
    ).execute()
    result = gce_wait_until_done(operation)
    if not result:
        raise RuntimeError("Creation of VM timed out or returned no result")
    log_green("Instance has booted")
88048
def _from_dict(cls, _dict):
        """"""
        args = {}
        xtra = _dict.copy()
        if 'id' in _dict:
            args['id'] = _dict.get('id')
            del xtra['id']
        if 'metadata' in _dict:
            args['metadata'] = _dict.get('metadata')
            del xtra['metadata']
        if 'collection_id' in _dict:
            args['collection_id'] = _dict.get('collection_id')
            del xtra['collection_id']
        if 'result_metadata' in _dict:
            args['result_metadata'] = QueryResultMetadata._from_dict(
                _dict.get('result_metadata'))
            del xtra['result_metadata']
        if 'title' in _dict:
            args['title'] = _dict.get('title')
            del xtra['title']
        if 'code' in _dict:
            args['code'] = _dict.get('code')
            del xtra['code']
        if 'filename' in _dict:
            args['filename'] = _dict.get('filename')
            del xtra['filename']
        if 'file_type' in _dict:
            args['file_type'] = _dict.get('file_type')
            del xtra['file_type']
        if 'sha1' in _dict:
            args['sha1'] = _dict.get('sha1')
            del xtra['sha1']
        if 'notices' in _dict:
            args['notices'] = [
                Notice._from_dict(x) for x in (_dict.get('notices'))
            ]
            del xtra['notices']
        args.update(xtra)
        return cls(**args)
1177990
def _from_dict(cls, _dict):
        """"""
        args = {}
        xtra = _dict.copy()
        if 'intent' in _dict:
            args['intent'] = _dict.get('intent')
            del xtra['intent']
        else:
            raise ValueError(
                'Required property \'intent\' not present in RuntimeIntent JSON'
            )
        if 'confidence' in _dict:
            args['confidence'] = _dict.get('confidence')
            del xtra['confidence']
        else:
            raise ValueError(
                'Required property \'confidence\' not present in RuntimeIntent JSON'
            )
        args.update(xtra)
        return cls(**args)
407313
def from_dict(data, ctx):
        

        data = data.copy()

        if data.get('units') is not None:
            data['units'] = ctx.convert_decimal_number(
                data.get('units')
            )

        if data.get('averagePrice') is not None:
            data['averagePrice'] = ctx.convert_decimal_number(
                data.get('averagePrice')
            )


        if data.get('pl') is not None:
            data['pl'] = ctx.convert_decimal_number(
                data.get('pl')
            )

        if data.get('unrealizedPL') is not None:
            data['unrealizedPL'] = ctx.convert_decimal_number(
                data.get('unrealizedPL')
            )

        if data.get('resettablePL') is not None:
            data['resettablePL'] = ctx.convert_decimal_number(
                data.get('resettablePL')
            )

        if data.get('financing') is not None:
            data['financing'] = ctx.convert_decimal_number(
                data.get('financing')
            )

        if data.get('guaranteedExecutionFees') is not None:
            data['guaranteedExecutionFees'] = ctx.convert_decimal_number(
                data.get('guaranteedExecutionFees')
            )

        return PositionSide(**data)
1214778
def from_dict(self, description):
        """"""
        assert(self.ident == description['ident'])
        self.partitions = description['partitions']
        self.indices    = description['indices']
447011
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'examples' in _dict:
            args['examples'] = [
                TrainingExample._from_dict(x) for x in (_dict.get('examples'))
            ]
        return cls(**args)
976239
def init_from_datastore(self):
    """"""
    self._data = {}
    client = self._datastore_client
    for entity in client.query_fetch(kind=KIND_CLASSIFICATION_BATCH):
      class_batch_id = entity.key.flat_path[-1]
      self.data[class_batch_id] = dict(entity)
136763
def from_dict(cls, d):
        """"""
        main_memory = MainMemory()
        caches = {}

        referred_caches = set()

        # First pass, create all named caches and collect references
        for name, conf in d.items():
            caches[name] = Cache(name=name,
                                 **{k: v for k, v in conf.items()
                                    if k not in ['store_to', 'load_from', 'victims_to']})
            if 'store_to' in conf:
                referred_caches.add(conf['store_to'])
            if 'load_from' in conf:
                referred_caches.add(conf['load_from'])
            if 'victims_to' in conf:
                referred_caches.add(conf['victims_to'])

        # Second pass, connect caches
        for name, conf in d.items():
            if 'store_to' in conf and conf['store_to'] is not None:
                caches[name].set_store_to(caches[conf['store_to']])
            if 'load_from' in conf and conf['load_from'] is not None:
                caches[name].set_load_from(caches[conf['load_from']])
            if 'victims_to' in conf and conf['victims_to'] is not None:
                caches[name].set_victims_to(caches[conf['victims_to']])

        # Find first level (not target of any load_from or store_to)
        first_level = set(d.keys()) - referred_caches
        assert len(first_level) == 1, "Unable to find first cache level."
        first_level = caches[list(first_level)[0]]

        # Find last level caches (has no load_from or store_to target)
        last_level_load = c = first_level
        while c is not None:
            last_level_load = c
            c = c.load_from
        assert last_level_load is not None, "Unable to find last cache level."
        last_level_store = c = first_level
        while c is not None:
            last_level_store = c
            c = c.store_to
        assert last_level_store is not None, "Unable to find last cache level."

        # Set main memory connections
        main_memory.load_to(last_level_load)
        main_memory.store_from(last_level_store)

        return cls(first_level, main_memory), caches, main_memory
1306002
def new_from_memory(cls, data):
        """"""

        size = len(data)
        copy = g_memdup(data, size)
        ptr = cast(copy, POINTER(guint8))
        try:
            with gerror(GIError) as error:
                return GITypelib._new_from_memory(ptr, size, error)
        except GIError:
            free(copy)
            raise
587550
def from_dict(cls, d):
        
        instance = super(Simulation, cls).from_dict(d)
        #  The instance's input_files and cmd_line_args members still point to data structures in the original
        #  dictionary.  Copy them to avoid surprises if they are changed in the original dictionary.
        instance.input_files = dict(instance.input_files)
        instance.cmd_line_args = list(instance.cmd_line_args)
        return instance
579915
def from_dict(cls, data):
        
        auth_info = AuthenticationInformation.from_dict(
            data.get("auth_info", {})
        )
        instance = cls(
            auth_info=auth_info,
            requester=data.get("requester"),
            requester_name=data.get("requester_name"),
            subject_id=data.get("subject_id"),
            subject_type=data.get("subject_type"),
            attributes=data.get("attributes"),
            user_id=data.get("user_id"),
            user_id_hash_type=data.get("hash_type"),
            name_id=data.get("name_id"),
            approved_attributes=data.get("approved_attributes"),
        )
        return instance