Provides a list of hostnames / private IPs that are public agents in the cluster
197805
def get_public_agents():
    """"""
    agent_list = []
    agents = __get_all_agents()
    for agent in agents:
        for reservation in agent["reserved_resources"]:
            if "slave_public" in reservation:
                agent_list.append(agent["hostname"])

    return agent_list
337295
def list_nodes_select(call=None):
    '''
    
    '''
    if not call:
        call = 'select'
    if not get_configured_provider():
        return
    info = ['id', 'name', 'image', 'size', 'state', 'public_ips', 'private_ips']
    return salt.utils.cloud.list_nodes_select(
        list_nodes_full(call='action'),
        __opts__.get('query.selection', info), call)
212455
def _list_available_hosts(self, *args):
        '''  '''

        return [ h for h in self.inventory.list_hosts(*args) if (h not in self.stats.failures) and (h not in self.stats.dark)]
613683
def ips(self):
        """"""
        r = []
        names = ['X_FORWARDED_FOR', 'CLIENT_IP', 'X_REAL_IP', 'X_FORWARDED', 
               'X_CLUSTER_CLIENT_IP', 'FORWARDED_FOR', 'FORWARDED', 'VIA',
               'REMOTE_ADDR']

        for name in names:
            vs = self.get_header(name, '')
            if vs:
                r.extend(map(lambda v: v.strip(), vs.split(',')))

            vs = self.environ.get(name, '')
            if vs:
                r.extend(map(lambda v: v.strip(), vs.split(',')))

        return r
898051
def list_domains():
    '''
    
    '''
    data = __salt__['vmadm.list'](keyed=True)
    vms = ["UUID                                  TYPE  RAM      STATE             ALIAS"]
    for vm in data:
        vms.append("{vmuuid}{vmtype}{vmram}{vmstate}{vmalias}".format(
            vmuuid=vm.ljust(38),
            vmtype=data[vm]['type'].ljust(6),
            vmram=data[vm]['ram'].ljust(9),
            vmstate=data[vm]['state'].ljust(18),
            vmalias=data[vm]['alias'],
        ))
    return vms
49736
def list_nodes_full(conn=None, call=None):
    '''
    

    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes_full function must be called with -f or --function.'
        )
    if conn is None:
        conn = get_conn()
    ret = {}
    for node in conn.list_servers(detailed=True):
        ret[node.name] = dict(node)
        ret[node.name]['id'] = node.id
        ret[node.name]['name'] = node.name
        ret[node.name]['size'] = node.flavor.name
        ret[node.name]['state'] = node.status
        ret[node.name]['private_ips'] = _get_ips(node, 'private')
        ret[node.name]['public_ips'] = _get_ips(node, 'public')
        ret[node.name]['floating_ips'] = _get_ips(node, 'floating')
        ret[node.name]['fixed_ips'] = _get_ips(node, 'fixed')
        ret[node.name]['image'] = node.image.name
    return ret
1374418
def hostnames_ips
      @hostnames.map do |hostname|
        ips.select { |ip, host| host == hostname }.keys
      end.flatten
    end
381683
def host_names(urls):
    '''
    
    '''
    host_names = StringCounter()
    for url in urls:
        host_names[urlparse(url).netloc] += urls[url]
    return host_names
678147
def list_ipsecpolicies(self, retrieve_all=True, **_params):
        """"""
        return self.list('ipsecpolicies',
                         self.ipsecpolicies_path,
                         retrieve_all,
                         **_params)
262858
def _process_reservations(self, reservations):
        

        reservations = reservations['Reservations']

        private_ip_addresses = []
        private_hostnames = []
        public_ips = []
        public_hostnames = []
        for reservation in reservations:
            for instance in reservation['Instances']:
                private_ip_addresses.append(instance['PrivateIpAddress'])
                private_hostnames.append(instance['PrivateDnsName'])

                if 'PublicIpAddress' in instance:
                    public_ips.append(instance['PublicIpAddress'])
                elif not self.remove_nones:
                    public_ips.append(None)

                if ('PublicDnsName' in instance) & (not self.remove_nones):
                    public_hostnames.append(instance['PublicDnsName'])
                elif not self.remove_nones:
                    public_hostnames.append(None)

        return {
            'private': {
                'ips': private_ip_addresses,
                'hostnames': private_hostnames
            },
            'public': {
                'ips': public_ips,
                'hostnames': public_hostnames
            },
            'reservations': reservations
        }
475862
def peer_ips(peer_relation='cluster', addr_key='private-address'):
    ''''''
    peers = {}
    for r_id in relation_ids(peer_relation):
        for unit in relation_list(r_id):
            peers[unit] = relation_get(addr_key, rid=r_id, unit=unit)
    return peers
937097
def get_ips(self, instance_id):
        
        self._init_az_api()
        cluster_name, node_name = instance_id
        # XXX: keep in sync with contents of `vm_deployment_template`
        ip_name = ('{node_name}-public-ip'.format(node_name=node_name))
        ip = self._network_client.public_ip_addresses.get(cluster_name, ip_name)
        if (ip.provisioning_state == 'Succeeded' and ip.ip_address):
            return [ip.ip_address]
        else:
            return []
1199304
def list_nodes(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    ret = {}
    items = query(action='ve')

    for item in items:
        name = item.attrib['name']
        node = show_instance(name, call='action')

        ret[name] = {
            'id': node['id'],
            'image': node['platform']['template-info']['name'],
            'state': node['state'],
        }
        if 'private-ip' in node['network']:
            ret[name]['private_ips'] = [node['network']['private-ip']]
        if 'public-ip' in node['network']:
            ret[name]['public_ips'] = [node['network']['public-ip']]

    return ret
419483
def all_host_infos():
    '''
        
    '''
    output = []
    output.append(["Operating system", os()])
    output.append(["CPUID information", cpu()])
    output.append(["CC information", compiler()])
    output.append(["JDK information", from_cmd("java -version")])
    output.append(["MPI information", from_cmd("mpirun -version")])
    output.append(["Scala information", from_cmd("scala -version")])
    output.append(["OpenCL headers", from_cmd(
        "find /usr/include|grep opencl.h")])
    output.append(["OpenCL libraries", from_cmd(
        "find /usr/lib/ -iname '*opencl*'")])
    output.append(["NVidia SMI", from_cmd("nvidia-smi -q")])
    output.append(["OpenCL Details", opencl()])
    return output
1268298
def get_peers_public_keys(self):
        """"""
        with self._lock:
            # Use a generator inside the list comprehension to filter out None
            # values in a single pass
            return [key for key
                    in (self._network.connection_id_to_public_key(peer)
                        for peer
                        in copy.copy(self._peers))
                    if key is not None]
969683
def _get_ips(networks):
    '''
    
    '''
    v4s = networks.get('v4')
    v6s = networks.get('v6')
    public_ips = []
    private_ips = []

    if v4s:
        for item in v4s:
            ip_type = item.get('type')
            ip_address = item.get('ip_address')
            if ip_type == 'public':
                public_ips.append(ip_address)
            if ip_type == 'private':
                private_ips.append(ip_address)

    if v6s:
        for item in v6s:
            ip_type = item.get('type')
            ip_address = item.get('ip_address')
            if ip_type == 'public':
                public_ips.append(ip_address)
            if ip_type == 'private':
                private_ips.append(ip_address)

    return public_ips, private_ips
844046
def list_hosts(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The list_hosts function must be called with '
            '-f or --function.'
        )

    return {'Hosts': salt.utils.vmware.list_hosts(_get_si())}