Retrieve the first datacenter id associated to an ISO.
330666
def from_iso(cls, iso):
        """"""
        result = cls.list({'sort_by': 'id ASC'})
        dc_isos = {}
        for dc in result:
            if dc['iso'] not in dc_isos:
                dc_isos[dc['iso']] = dc['id']

        return dc_isos.get(iso)
286729
def _pid_to_id(self, pid):
        """"""
        return d1_common.url.joinPathElements(
            self._base_url,
            self._version_tag,
            "resolve",
            d1_common.url.encodePathElement(pid),
        )
271208
private String getOriginAccessId() {
        String oaId = getExistingOriginAccessId();
        if (oaId != null) { // Use existing ID
            return oaId;
        } else { // Create a new ID
            return cfClient.createCloudFrontOriginAccessIdentity(
                new CreateCloudFrontOriginAccessIdentityRequest(
                    new CloudFrontOriginAccessIdentityConfig()
                        .withCallerReference("" + System.currentTimeMillis())
                        .withComment("DuraCloud Origin Access ID")))
                           .getCloudFrontOriginAccessIdentity().getId();
        }
    }
1179652
def get_datacenter(content, obj):
    '''
    
    '''
    datacenters = content.rootFolder.childEntity
    for d in datacenters:
        dch = get_all(content, d, type(obj))
        if dch is not None and obj in dch:
            return d
584234
private static int getMapperId(long key, int numReducers, int maxKeySpace) {
    key = key - getFirstSumKey(numReducers, maxKeySpace);
    return (int) (key / numReducers);
  }
746313
def create_unique_disk_operation_id(dd, offsets):
        # type: (blobxfer.models.download.Descriptor,
        #        blobxfer.models.download.Offsets) -> str
        
        return ';'.join(
            (str(dd.final_path), dd.entity._client.primary_endpoint,
             dd.entity.path, str(offsets.range_start))
        )
730955
private String getServerId() {
        UUID fullServerId = null;
        WsLocationAdmin locationService = this.wsLocationAdmin;
        if (locationService != null) {
            fullServerId = locationService.getServerId();
        }
        if (fullServerId == null) {
            fullServerId = UUID.randomUUID(); // shouldn't get here, but be careful just in case
        }
        return fullServerId.toString().toLowerCase(); // clone IDs need to be in lower case for consistency with tWAS
    }
637295
def get_gateway_id(self):
        """"""
        info = next(serial.tools.list_ports.grep(self.port), None)
        return info.serial_number if info is not None else None
4135
def is_opened(cls, dc_code, type_):
        """"""
        options = {'dc_code': dc_code, '%s_opened' % type_: True}
        datacenters = cls.safe_call('hosting.datacenter.list', options)
        if not datacenters:
            # try with ISO code
            options = {'iso': dc_code, '%s_opened' % type_: True}
            datacenters = cls.safe_call('hosting.datacenter.list', options)
            if not datacenters:
                raise DatacenterClosed(r'/!\ Datacenter %s is closed, please '
                                       'choose another datacenter.' % dc_code)

        datacenter = datacenters[0]
        if datacenter.get('%s_closed_for' % type_) == 'NEW':
            dc_close_date = datacenter.get('deactivate_at', '')
            if dc_close_date:
                dc_close_date = dc_close_date.strftime('%d/%m/%Y')
            raise DatacenterLimited(dc_close_date)
1183513
def output_vlan(gandi, vlan, datacenters, output_keys, justify=10):
    
    output_generic(gandi, vlan, output_keys, justify)

    if 'dc' in output_keys:
        for dc in datacenters:
            if dc['id'] == vlan.get('datacenter_id',
                                    vlan.get('datacenter', {}).get('id')):
                dc_name = dc.get('dc_code', dc.get('iso', ''))
                break

        output_line(gandi, 'datacenter', dc_name, justify)
1351167
def _get_worker_id(self, conn):
        """"""
        if self._worker_id is None:
            self._worker_id = conn.incr(self._key_worker())
        return self._worker_id
741984
function getUniqueIdentifier( root, libs, com ) {
  var id = root.attribs.id || ( com.name + ID++ );
  com.attr.id = id;
}
422256
async def get_initial_offset_async(self): # throws InterruptedException, ExecutionException
        
        _logger.info("Calling user-provided initial offset provider %r %r",
                     self.host.guid, self.partition_id)
        starting_checkpoint = await self.host.storage_manager.get_checkpoint_async(self.partition_id)
        if not starting_checkpoint:
            # No checkpoint was ever stored. Use the initialOffsetProvider instead
            # defaults to "-1"
            self.offset = self.host.eph_options.initial_offset_provider
            self.sequence_number = -1
        else:
            self.offset = starting_checkpoint.offset
            self.sequence_number = starting_checkpoint.sequence_number

        _logger.info("%r %r Initial offset/sequenceNumber provided %r/%r",
                     self.host.guid, self.partition_id, self.offset, self.sequence_number)
        return self.offset
18502
def get_machine_id(machine, cwd):
    '''
    
    '''
    name = __utils__['sdb.sdb_get'](_build_machine_uri(machine, cwd), __opts__)
    return name
950503
def first_setup(self):
        """"""
        if ATTR_FIRST_SETUP not in self.raw:
            return None
        return datetime.utcfromtimestamp(self.raw[ATTR_FIRST_SETUP])
456975
def get_datacenter(conn):
    '''
    
    '''
    datacenter_id = get_datacenter_id()

    for item in conn.list_datacenters()['items']:
        if item['id'] == datacenter_id:
            return item

    raise SaltCloudNotFound(
        'The specified datacenter \'{0}\' could not be found.'.format(
            datacenter_id
        )
    )
960135
def _get_history_id(self, connection, agent_id, instance_id):
        '''
        
        '''
        cache_key = (agent_id, instance_id, )
        if cache_key in self._history_id_cache:
            history_id = self._history_id_cache[cache_key]
            return history_id
        else:
            command = text_helper.format_block("""
            SELECT id FROM histories WHERE agent_id = ? AND instance_id = ?
            """)
            cursor = connection.cursor()
            cursor.execute(command, (agent_id, instance_id, ))
            res = cursor.fetchall()
            if res:
                history_id = res[0][0]
                self._history_id_cache[cache_key] = history_id
                return history_id
            else:
                command = 'INSERT INTO histories VALUES (NULL, ?, ?)'
                cursor.execute(command, (agent_id, instance_id, ))
                history_id = cursor.lastrowid
                self._history_id_cache[cache_key] = history_id
                return history_id