Provided an array of security groups return that array if all
security groups are present
@param [Array] sgs The array of security group names
@return [Array] The array of security group names
433743
def security_groups sgs
      for sg in sgs
        @logger.debug "Openstack: Looking up security group '#{sg}'"
        @compute_client.security_groups.find { |x| x.name == sg } || raise("Couldn't find security group: #{sg}")
        sgs
      end
    end
1124299
def find_secgroup(self, name):
        
        groups = self.nova.security_groups.findall(name=name)
        if groups:
            return NovaSecGroup(groups[0])
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
289989
public void setSecurityGroups(java.util.Collection<SecurityGroup> securityGroups) {
        if (securityGroups == null) {
            this.securityGroups = null;
            return;
        }

        this.securityGroups = new java.util.ArrayList<SecurityGroup>(securityGroups);
    }
585535
@Override
    public List<String> getGroupsForUser(String userSecurityName) throws EntryNotFoundException, RegistryException {
        if (userSecurityName == null) {
            throw new IllegalArgumentException("userSecurityName is null");
        }
        if (userSecurityName.isEmpty()) {
            throw new IllegalArgumentException("userSecurityName is an empty String");
        }

        if (!isValidUser(userSecurityName)) {
            throw new EntryNotFoundException(userSecurityName + " does not exist");
        }

        List<String> matched = new ArrayList<String>();
        Set<String> groupNames = state.groups.keySet();
        Iterator<String> itr = groupNames.iterator();
        while (itr.hasNext()) {
            String groupName = itr.next();
            if (state.groups.get(groupName).contains(userSecurityName)) {
                matched.add(groupName);
            }
        }

        return matched;
    }
1343095
def get_groups_by_names(self, names):
        """"""
        if not names:
            return []
        client = utils.local_session(
            self.manager.session_factory).client('ec2')
        sgs = self.manager.retry(
            client.describe_security_groups,
            Filters=[{
                'Name': 'group-name', 'Values': names}]).get(
                    'SecurityGroups', [])

        unresolved = set(names)
        for s in sgs:
            if s['GroupName'] in unresolved:
                unresolved.remove(s['GroupName'])

        if unresolved:
            raise PolicyExecutionError(self._format_error(
                "policy:{policy} security groups not found "
                "requested: {names}, found: {groups}",
                names=list(unresolved), groups=[g['GroupId'] for g in sgs]))
        return sgs
1000147
def role_groups
      groups = []
      user_account_class.role_groups.map{|k,v| groups << k if user_account.has_any_role?(v)}
      groups
    end
1338389
def _get_sg_ids(self):
        
        try:
            lambda_extras = self.settings['security_groups']['lambda_extras']
        except KeyError:
            lambda_extras = []

        security_groups = [self.app_name] + lambda_extras
        sg_ids = []
        for security_group in security_groups:
            sg_id = get_security_group_id(name=security_group, env=self.env, region=self.region)
            sg_ids.append(sg_id)
        return sg_ids
594677
public void setSecurityGroups(java.util.Collection<SecurityGroup> securityGroups) {
        if (securityGroups == null) {
            this.securityGroups = null;
            return;
        }

        this.securityGroups = new com.amazonaws.internal.SdkInternalList<SecurityGroup>(securityGroups);
    }
594357
def delete_security_group(self, sec_grp):
        '''
        
        '''
        sec_grp_id = self._find_security_group_id(sec_grp)
        ret = self.network_conn.delete_security_group(sec_grp_id)
        return ret if ret else True
900967
def servicegroup_exists(sg_name, sg_type=None, **connection_args):
    '''
    
    '''
    sg = _servicegroup_get(sg_name, **connection_args)
    if sg is None:
        return False
    if sg_type is not None and sg_type.upper() != sg.get_servicetype():
        return False
    return True
1111629
def remove_security_group(self, name):
        
        for group in self.security_groups:
            if group.isc_name == name:
                group.delete()
912465
def get_secgroup_id(kwargs=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The get_secgroup_id function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    if name is None:
        raise SaltCloudSystemExit(
            'The get_secgroup_id function requires a \'name\'.'
        )

    try:
        ret = list_security_groups()[name]['id']
    except KeyError:
        raise SaltCloudSystemExit(
            'The security group \'{0}\' could not be found.'.format(name)
        )

    return ret
1315380
private Set<ISharedObjectSecurity> getSecurityHandlers() {
        ISharedObjectSecurityService security = (ISharedObjectSecurityService) ScopeUtils.getScopeService(getParent(), ISharedObjectSecurityService.class);
        if (security == null) {
            return null;
        }
        return security.getSharedObjectSecurity();
    }
357465
def groups(self):
        
        return Groups(url="%s/groups" % self.root,
                       securityHandler=self._securityHandler,
                       proxy_url=self._proxy_url,
                       proxy_port=self._proxy_port,
                       initalize=False)
760328
def get_expected_acls(self):
        
        security_groups = db_lib.get_security_groups()

        expected_acls = collections.defaultdict(set)
        for sg in security_groups:
            in_rules, out_rules = self._format_rules_for_eos(sg['rules'])
            ingress_acl_name = self._acl_name(sg['id'],
                                              n_const.INGRESS_DIRECTION)
            egress_acl_name = self._acl_name(sg['id'],
                                             n_const.EGRESS_DIRECTION)
            expected_acls[ingress_acl_name].update(in_rules)
            expected_acls[egress_acl_name].update(out_rules)
        return expected_acls
199524
function groupMembershipMiddleware(groups) {
		if (typeof groups === 'string') {
			groups = [groups];
		}
		return function hasGroupMembership(req, res, next) {
			if (req.locals.user) {
				const userGroups = req.locals.user.groups || [];
				for (let group of groups) {
					if (userGroups.indexOf(group) !== -1) {
						debug(`User has the '${group}' Group.`);
						return next();
					}
				}
			}
			debug(`User is not a member of one of [${groups.join(',')}] Group(s).`);
			next(new restifyErrors.ForbiddenError('No execute permissions on endpoint'));
		}
	}