Lists security groups in the VPC.  If vpc_id is not provided, use self.vpc_id

        :param vpc_id: (str) VPC ID to list security groups for
        :return: (list) Security Group info
        :raises: AWSAPIError, EC2UtilError
501766
def list_security_groups_in_vpc(self, vpc_id=None):
        
        log = logging.getLogger(self.cls_logger + '.list_security_groups_in_vpc')
        if vpc_id is None and self.vpc_id is not None:
            vpc_id = self.vpc_id
        else:
            msg = 'Unable to determine VPC ID to use to create the Security Group'
            log.error(msg)
            raise EC2UtilError(msg)

        # Create a filter on the VPC ID
        filters = [
            {
                'Name': 'vpc-id',
                'Values': [vpc_id]
            }
        ]

        # Get a list of security groups in the VPC
        log.info('Querying for a list of security groups in VPC ID: {v}'.format(v=vpc_id))
        try:
            security_groups = self.client.describe_security_groups(DryRun=False, Filters=filters)
        except ClientError:
            _, ex, trace = sys.exc_info()
            msg = 'Unable to query AWS for a list of security groups in VPC ID: {v}\n{e}'.format(
                v=vpc_id, e=str(ex))
            raise AWSAPIError, msg, trace
        return security_groups
728065
def list(self, mask=None):
        
        if mask is None:
            mask = "mask[id, name, createDate, rule, guestCount, backendRouter[id, hostname]]"
        groups = self.client.call('Account', 'getPlacementGroups', mask=mask, iter=True)
        return groups
558344
def list_securitygroup_rules(self, group_id):
        
        return self.security_group.getRules(id=group_id, iter=True)
650103
def parse_security_group(self, global_params, region, group):
        
        vpc_id = group['VpcId'] if 'VpcId' in group and group['VpcId'] else ec2_classic
        manage_dictionary(self.vpcs, vpc_id, VPCConfig(self.vpc_resource_types))
        security_group = {}
        security_group['name'] = group['GroupName']
        security_group['id'] = group['GroupId']
        security_group['description'] = group['Description']
        security_group['owner_id'] = group['OwnerId']
        security_group['rules'] = {'ingress': {}, 'egress': {}}
        security_group['rules']['ingress']['protocols'], security_group['rules']['ingress']['count'] = self.__parse_security_group_rules(group['IpPermissions'])
        security_group['rules']['egress']['protocols'], security_group['rules']['egress']['count'] = self.__parse_security_group_rules(group['IpPermissionsEgress'])
        self.vpcs[vpc_id].security_groups[group['GroupId']] = security_group
464616
def list_nodes(call=None):
    '''
    

    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called '
            'with -f or --function.'
        )

    providers = __opts__.get('providers', {})

    ret = {}
    providers_to_check = [_f for _f in [cfg.get('libvirt') for cfg in six.itervalues(providers)] if _f]
    for provider in providers_to_check:
        conn = __get_conn(provider['url'])
        domains = conn.listAllDomains()
        for domain in domains:
            data = {
                'id': domain.UUIDString(),
                'image': '',
                'size': '',
                'state': VIRT_STATE_NAME_MAP[domain.state()[0]],
                'private_ips': [],
                'public_ips': get_domain_ips(domain, libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE)}
            # TODO: Annoyingly name is not guaranteed to be unique, but the id will not work in other places
            ret[domain.name()] = data

    return ret
1117522
def list_by_instance(self, instance_id):
        
        ports = port_list(self.request, device_id=instance_id)
        sg_ids = []
        for p in ports:
            sg_ids += p.security_groups
        return self._list(id=set(sg_ids)) if sg_ids else []
46527
def get_securitygroup(vm_):
    '''
    
    '''
    sgs = list_securitygroup()
    securitygroup = config.get_cloud_config_value(
        'securitygroup', vm_, __opts__, search_global=False
    )

    if not securitygroup:
        raise SaltCloudNotFound('No securitygroup ID specified for this VM.')

    if securitygroup and six.text_type(securitygroup) in sgs:
        return sgs[securitygroup]['SecurityGroupId']
    raise SaltCloudNotFound(
        'The specified security group, \'{0}\', could not be found.'.format(
            securitygroup)
    )
249452
def _check_security_group(self, name):
        
        connection = self._connect()

        filters = {}
        if self._vpc:
            filters = {'vpc-id': self._vpc_id}

        security_groups = connection.get_all_security_groups(filters=filters)

        matching_groups = [
            group
            for group
             in security_groups
             if name in [group.name, group.id]
        ]
        if len(matching_groups) == 0:
            raise SecurityGroupError(
                "the specified security group %s does not exist" % name)
        elif len(matching_groups) == 1:
            return matching_groups[0].id
        elif self._vpc and len(matching_groups) > 1:
            raise SecurityGroupError(
                "the specified security group name %s matches "
                "more than one security group" % name)
333203
def adjust_security_groups(options)
      return options unless options[:network_configuration] &&
                     options[:network_configuration][:awsvpc_configuration]

      awsvpc_conf = options[:network_configuration][:awsvpc_configuration]

      security_groups = awsvpc_conf[:security_groups]
      if [nil, '', 'nil'].include?(security_groups)
        security_groups = []
      end
      if security_groups.empty?
        fetch = Network::Fetch.new(network[:vpc])
        sg = fetch.security_group_id
        security_groups << sg
        security_groups.uniq!
      end

      # override security groups
      options[:network_configuration][:awsvpc_configuration][:security_groups] = security_groups
      options
    end
1126515
def show_security_group(self, security_group, **_params):
        """"""
        return self.get(self.security_group_path % (security_group),
                        params=_params)
111083
def ip_access_control_lists(self):
        
        if self._ip_access_control_lists is None:
            self._ip_access_control_lists = IpAccessControlListList(
                self._version,
                trunk_sid=self._solution['sid'],
            )
        return self._ip_access_control_lists
30868
def list_certificates(self):

        '''
            
        '''

        title = '%s.list_certificates' % self.__class__.__name__

    # send request for list of certificates
        self.printer('Querying AWS for server certificates.')
        try:
            response = self.connection.list_server_certificates()
        except:
            raise AWSConnectionError(title)

    # construct certificate list from response
        cert_list = []
        if 'ServerCertificateMetadataList' in response.keys():
            for certificate in response['ServerCertificateMetadataList']:
                cert_list.append(certificate['ServerCertificateName'])

    # report results and return list
        if cert_list:
            print_out = 'Found server certificate'
            if len(cert_list) > 1:
                print_out += 's'
            from labpack.parsing.grammar import join_words
            print_out += ' %s.' % join_words(cert_list)
            self.printer(print_out)
        else:
            self.printer('No server certificates found.')

        self.certificate_list = cert_list
        
        return self.certificate_list
1359308
def get_security_group_id(self, name):
        
        # Memoize entire list of groups
        if not hasattr(self, '_security_groups'):
            self._security_groups = {}
            for group in self.get_all_security_groups():
                self._security_groups[group.name] = group.id
        return self._security_groups[name]
528648
def parse_cluster(self, global_params, region, cluster):
        
        vpc_id = cluster.pop('VpcId') if 'VpcId' in cluster else ec2_classic
        manage_dictionary(self.vpcs, vpc_id, VPCConfig(self.vpc_resource_types))
        name = cluster.pop('ClusterIdentifier')
        cluster['name'] = name
        self.vpcs[vpc_id].clusters[name] = cluster
331113
def list_security_groups(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_security_groups function must be called with -f or --function.'
        )

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    secgroup_pool = server.one.secgrouppool.info(auth, -2, -1, -1)[1]

    groups = {}
    for group in _get_xml(secgroup_pool):
        groups[group.find('NAME').text] = _xml_to_dict(group)

    return groups
581420
def list_cache_subnet_groups(region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    return [g['CacheSubnetGroupName'] for g in
            describe_cache_subnet_groups(None, region, key, keyid, profile)]
127323
def list(self, spec=None):
        

        if spec is None:
            spec = {}

        xmlrpc = XMLRPCConnection()
        try:
            pool_list = xmlrpc.connection.list_pool(
                {
                    'pool': spec,
                    'auth': AuthOptions().options
                })
        except xmlrpclib.Fault as xml_fault:
            raise _fault_to_exception(xml_fault)
        res = list()
        for pool in pool_list:
            p = Pool.from_dict(pool)
            res.append(p)

        return res