Find a resource pool given a pool name for desired cluster
337349
def get_resource_pool(self, cluster, pool_name):
        
        pool_obj = None

        # get a list of all resource pools in this cluster
        cluster_pools_list = cluster.resourcePool.resourcePool

        # get list of all resource pools with a given text name
        pool_selections = self.get_obj(
            [vim.ResourcePool],
            pool_name,
            return_all=True
        )

        # get the first pool that exists in a given cluster
        if pool_selections:
            for p in pool_selections:
                if p in cluster_pools_list:
                    pool_obj = p
                    break

        return pool_obj
274189
def get_resources(resources):  # pylint:disable=too-many-branches
    
    limits = {}
    requests = {}
    if resources is None:
        return None
    if resources.cpu:
        if resources.cpu.limits:
            limits['cpu'] = resources.cpu.limits
        if resources.cpu.requests:
            requests['cpu'] = resources.cpu.requests

    if resources.memory:
        if resources.memory.limits:
            limits['memory'] = '{}Mi'.format(resources.memory.limits)
        if resources.memory.requests:
            requests['memory'] = '{}Mi'.format(resources.memory.requests)

    if resources.gpu:
        if resources.gpu.limits:
            limits[conf.get('K8S_GPU_RESOURCE_KEY')] = resources.gpu.limits
        if resources.gpu.requests:
            requests[conf.get('K8S_GPU_RESOURCE_KEY')] = resources.gpu.requests

    if resources.tpu:
        if resources.tpu.limits:
            limits[conf.get('K8S_TPU_RESOURCE_KEY')] = resources.tpu.limits
        if resources.tpu.requests:
            requests[conf.get('K8S_TPU_RESOURCE_KEY')] = resources.tpu.requests
    return client.V1ResourceRequirements(limits=limits or None, requests=requests or None)
59387
def get_cluster(dc_ref, cluster):
    '''
    
    '''
    dc_name = get_managed_object_name(dc_ref)
    log.trace('Retrieving cluster \'%s\' from datacenter \'%s\'',
              cluster, dc_name)
    si = get_service_instance_from_managed_object(dc_ref, name=dc_name)
    traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
        path='hostFolder',
        skip=True,
        type=vim.Datacenter,
        selectSet=[vmodl.query.PropertyCollector.TraversalSpec(
            path='childEntity',
            skip=False,
            type=vim.Folder)])
    items = [i['object'] for i in
             get_mors_with_properties(si,
                                      vim.ClusterComputeResource,
                                      container_ref=dc_ref,
                                      property_list=['name'],
                                      traversal_spec=traversal_spec)
             if i['name'] == cluster]
    if not items:
        raise salt.exceptions.VMwareObjectRetrievalError(
            'Cluster \'{0}\' was not found in datacenter '
            '\'{1}\''. format(cluster, dc_name))
    return items[0]
867978
def get_ecs_cluster_for_queue(queue_name, batch_client=None):
    """"""
    if batch_client is None:
        batch_client = boto3.client('batch')

    queue_resp = batch_client.describe_job_queues(jobQueues=[queue_name])
    if len(queue_resp['jobQueues']) == 1:
        queue = queue_resp['jobQueues'][0]
    else:
        raise BatchReadingError('Error finding queue with name %s.'
                                % queue_name)

    compute_env_names = queue['computeEnvironmentOrder']
    if len(compute_env_names) == 1:
        compute_env_name = compute_env_names[0]['computeEnvironment']
    else:
        raise BatchReadingError('Error finding the compute environment name '
                                'for %s.' % queue_name)

    compute_envs = batch_client.describe_compute_environments(
        computeEnvironments=[compute_env_name]
        )['computeEnvironments']
    if len(compute_envs) == 1:
        compute_env = compute_envs[0]
    else:
        raise BatchReadingError("Error getting compute environment %s for %s. "
                                "Got %d environments instead of 1."
                                % (compute_env_name, queue_name,
                                   len(compute_envs)))

    ecs_cluster_name = os.path.basename(compute_env['ecsClusterArn'])
    return ecs_cluster_name
307066
public V get(ResourceType type, PoolInfo poolInfo) {
    Map<PoolInfo, V> poolInfoMap = typePoolInfoMap.get(type);
    if (poolInfoMap == null) {
      return null;
    }
    return poolInfoMap.get(poolInfo);
  }
1065078
def get(self, name):
        
        if name not in self.clusters:
            raise ClusterNotFound("Cluster %s not found." % name)
        return self.clusters.get(name)
1204801
def cluster_path(cls, project, instance, cluster):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/instances/{instance}/clusters/{cluster}",
            project=project,
            instance=instance,
            cluster=cluster,
        )
318297
def _get_pool(name=None, session=None):
    '''
    
    '''
    if session is None:
        session = _get_session()
    pools = session.xenapi.pool.get_all()
    for pool in pools:
        pool_record = session.xenapi.pool.get_record(pool)
        if name in pool_record.get('name_label'):
            return pool
    return None
205265
def _get_store_by_name(self, name):
        """"""
        for cls in self.storage_type_map.values():
            cluster_files = glob.glob(
                '%s/%s.%s' % (self.storage_path, name, cls.file_ending))
            if cluster_files:
                try:
                    return cls(self.storage_path)
                except:
                    continue
        raise ClusterNotFound("No cluster %s was found" % name)
818986
def join_cluster(host, user='rabbit', ram_node=None, runas=None):
    '''
    
    '''
    cmd = [RABBITMQCTL, 'join_cluster']
    if ram_node:
        cmd.append('--ram')
    cmd.append('{0}@{1}'.format(user, host))

    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    stop_app(runas)
    res = __salt__['cmd.run_all'](cmd, reset_system_locale=False, runas=runas, python_shell=False)
    start_app(runas)

    return _format_response(res, 'Join')
1104567
def discovery(self, compute_resource):
        """"""
        # Find the first ClusterComputeResource
        if compute_resource is None:
            cr_list = ComputeResource.all(self.client)
            print("ERROR: You must specify a ComputeResource.")
            print("Available ComputeResource's:")
            for cr in cr_list:
                print(cr.name)
            sys.exit(1)

        try:
            ccr = ComputeResource.get(self.client, name=compute_resource)
        except ObjectNotFoundError:
            print("ERROR: Could not find ComputeResource with name %s" %
                  compute_resource)
            sys.exit(1)

        print('Cluster: %s (%s hosts)' % (ccr.name, len(ccr.host)))

        ccr.preload("host", properties=["name", "vm"])
        for host in ccr.host:
            print('  Host: %s (%s VMs)' % (host.name, len(host.vm)))
            # Get the vm views in one fell swoop
            host.preload("vm", properties=["name"])
            for vm in host.vm:
                print('    VM: %s' % vm.name)
830115
def get_connection_pool(self, pool_id, *args, **kwargs):
        
        assert isinstance(pool_id, (str, unicode))
        if not hasattr(self, '_pools'):
            self._pools = {}
        if pool_id not in self._pools:
            self._pools[pool_id] = ConnectionPool(*args, **kwargs)
        # logging.debug("%s: _connections = %d", pool_id, self._pools[pool_id]._connections)
        return self._pools[pool_id]
1078610
def get_host_template(resource_root, name, cluster_name):
  
  return call(resource_root.get,
      HOST_TEMPLATE_PATH % (cluster_name, name),
      ApiHostTemplate, api_version=3)
1165550
def get_cluster_assignment(self):
        """"""
        plan = self.get_cluster_plan()
        assignment = {}
        for elem in plan['partitions']:
            assignment[
                (elem['topic'], elem['partition'])
            ] = elem['replicas']

        return assignment
814321
static List<PartitionDefinition> findShardPartitions(Settings settings, MappingSet mappingSet, Map<String, NodeInfo> nodes,
                                                         List<List<Map<String, Object>>> shards, Log log) {
        Mapping resolvedMapping = mappingSet == null ? null : mappingSet.getResolvedView();
        List<PartitionDefinition> partitions = new ArrayList<PartitionDefinition>(shards.size());
        for (List<Map<String, Object>> group : shards) {
            String index = null;
            int shardId = -1;
            List<String> locationList = new ArrayList<String> ();
            for (Map<String, Object> replica : group) {
                ShardInfo shard = new ShardInfo(replica);
                index = shard.getIndex();
                shardId = shard.getName();
                if (nodes.containsKey(shard.getNode())) {
                    locationList.add(nodes.get(shard.getNode()).getPublishAddress());
                }
            }
            if (index == null) {
                // Could not find shards for this partition. Continue anyway?
                if (settings.getIndexReadAllowRedStatus()) {
                    log.warn("Shard information is missing from an index and will not be reached during job execution. " +
                            "Assuming shard is unavailable and cluster is red! Continuing with read operation by " +
                            "skipping this shard! This may result in incomplete data retrieval!");
                } else {
                    throw new IllegalStateException("Could not locate shard information for one of the read indices. " +
                            "Check your cluster status to see if it is unstable!");
                }
            } else {
                PartitionDefinition partition = new PartitionDefinition(settings, resolvedMapping, index, shardId,
                        locationList.toArray(new String[0]));
                partitions.add(partition);
            }
        }
        return partitions;
    }
1370548
def get_resources_nodes(call=None, resFilter=None):
    '''
    
    '''
    log.debug('Getting resource: nodes.. (filter: %s)', resFilter)
    resources = query('get', 'cluster/resources')

    ret = {}
    for resource in resources:
        if 'type' in resource and resource['type'] == 'node':
            name = resource['node']
            ret[name] = resource

    if resFilter is not None:
        log.debug('Filter given: %s, returning requested '
                  'resource: nodes', resFilter)
        return ret[resFilter]

    log.debug('Filter not given: %s, returning all resource: nodes', ret)
    return ret
1155628
def pool(self):
        """"""
        self._pool = self._pool or eventlet.GreenPool(size=self.pool_size)
        return self._pool