Get details about a security group.
9048
def cli(env, identifier):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)

    secgroup = mgr.get_securitygroup(identifier)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['id', secgroup['id']])
    table.add_row(['name', secgroup.get('name') or formatting.blank()])
    table.add_row(['description',
                   secgroup.get('description') or formatting.blank()])

    rule_table = formatting.Table(['id', 'remoteIp', 'remoteGroupId',
                                   'direction', 'ethertype', 'portRangeMin',
                                   'portRangeMax', 'protocol'])
    for rule in secgroup.get('rules', []):
        rg_id = rule.get('remoteGroup', {}).get('id') or formatting.blank()
        port_min = rule.get('portRangeMin')
        port_max = rule.get('portRangeMax')
        if port_min is None:
            port_min = formatting.blank()
        if port_max is None:
            port_max = formatting.blank()
        rule_table.add_row([rule['id'],
                            rule.get('remoteIp') or formatting.blank(),
                            rule.get('remoteGroupId', rg_id),
                            rule['direction'],
                            rule.get('ethertype') or formatting.blank(),
                            port_min,
                            port_max,
                            rule.get('protocol') or formatting.blank()])

    table.add_row(['rules', rule_table])

    vsi_table = formatting.Table(['id', 'hostname', 'interface', 'ipAddress'])

    for binding in secgroup.get('networkComponentBindings', []):
        try:
            vsi = binding['networkComponent']['guest']
            vsi_id = vsi['id']
            hostname = vsi['hostname']
            interface = ('PRIVATE' if binding['networkComponent']['port'] == 0
                         else 'PUBLIC')
            ip_address = (vsi['primaryBackendIpAddress']
                          if binding['networkComponent']['port'] == 0
                          else vsi['primaryIpAddress'])
        except KeyError:
            vsi_id = "N/A"
            hostname = "Not enough permission to view"
            interface = "N/A"
            ip_address = "N/A"
        vsi_table.add_row([vsi_id, hostname, interface, ip_address])

    table.add_row(['servers', vsi_table])

    env.fout(table)
910474
def get_by_details(self, name, type, clazz):
        """"""
        entry = DNSEntry(name, type, clazz)
        return self.get(entry)
575552
def filter(self, table, security_groups, filter_string):
        """"""
        query = filter_string.lower()
        return [security_group for security_group in security_groups
                if query in security_group.name.lower()]
412424
def data(self):
        """"""
        # add attributes
        if self._attributes:
            self._group_data['attribute'] = []
            for attr in self._attributes:
                if attr.valid:
                    self._group_data['attribute'].append(attr.data)
        # add security labels
        if self._labels:
            self._group_data['securityLabel'] = []
            for label in self._labels:
                self._group_data['securityLabel'].append(label.data)
        # add tags
        if self._tags:
            self._group_data['tag'] = []
            for tag in self._tags:
                if tag.valid:
                    self._group_data['tag'].append(tag.data)
        return self._group_data
776087
def group_get_info(attribs, dir_info)
      attribs = group_record_name_alternatives(attribs)

      check_critical_attribute( attribs, :record_name )

      command = {action: 'read', scope: 'Groups', value: nil}
      user_attrs = attribs.merge(command)

      dscl( user_attrs, dir_info )
    end
126510
def _extract_info_from_useragent(user_agent):
    """"""
    parsed_string = user_agent_parser.Parse(user_agent)
    return {
        'os': parsed_string.get('os', {}).get('family'),
        'browser': parsed_string.get('user_agent', {}).get('family'),
        'browser_version': parsed_string.get('user_agent', {}).get('major'),
        'device': parsed_string.get('device', {}).get('family'),
    }
10009
def update_security_group(self, sec_grp, name=None, desc=None):
        '''
        
        '''
        sec_grp_id = self._find_security_group_id(sec_grp)
        body = {'security_group': {}}
        if name:
            body['security_group']['name'] = name
        if desc:
            body['security_group']['description'] = desc
        return self.network_conn.update_security_group(sec_grp_id,
                                                       body=body)
1320887
def get_auth_info(self, **params):
        """"""
        response = self._get('v2', 'user', 'auth', params=params)
        return self._make_api_object(response, APIObject)
1239462
def get_group_id(name, vpc_id=None, vpc_name=None, region=None, key=None,
                 keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if name.startswith('sg-'):
        log.debug('group %s is a group id. get_group_id not called.', name)
        return name
    group = _get_group(conn=conn, name=name, vpc_id=vpc_id, vpc_name=vpc_name,
                       region=region, key=key, keyid=keyid, profile=profile)
    return getattr(group, 'id', None)
400981
def _get_key_info(self):
        """"""
        if self._key_info_cache is None:
            self._key_info_cache = ssh_key_info_from_key_data(self.key_id,
                                                              self.priv_key)
        return self._key_info_cache
1261605
def generate_security_data(self):
        """"""
        timestamp = int(time.time())
        security_dict = {
            'content_type': str(self.target_object._meta),
            'object_pk': str(self.target_object._get_pk_val()),
            'timestamp': str(timestamp),
            'security_hash': self.initial_security_hash(timestamp),
        }
        return security_dict
609237
def permissions(self):
        """"""
        perms = set()
        for g in self.groups:
            perms = perms | set(g.permissions)
        return perms
123435
def get_delete_security_group_rule_commands(self, sg_id, sg_rule):
        """"""
        return self._get_rule_cmds(sg_id, sg_rule, delete=True)
1020147
def _find_usage_security_groups(self):
        """"""
        num_groups = 0
        # If EC2-Classic isn't available (e.g., a new account)
        # this method will fail with:
        #   Code:    "InvalidParameterValue"
        #   Message: "Use of cache security groups is not permitted in
        #             this API version for your account."
        #   Type:    "Sender"
        try:
            paginator = self.conn.get_paginator(
                'describe_cache_security_groups')
            for page in paginator.paginate():
                for secgroup in page['CacheSecurityGroups']:
                    num_groups += 1
        except ClientError as ex:
            if ex.response['Error']['Code'] != 'InvalidParameterValue':
                raise ex
            logger.debug("caught ClientError checking ElastiCache security "
                         "groups (account without EC2-Classic?)")

        self.limits['Security Groups']._add_current_usage(
            num_groups,
            aws_type='WS::ElastiCache::SecurityGroup'
        )
1189442
def cli(env, securitygroup_id):
    """"""
    mgr = SoftLayer.NetworkManager(env.client)
    if not mgr.delete_securitygroup(securitygroup_id):
        raise exceptions.CLIAbort("Failed to delete security group")
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
641481
def secgroup_delete(self, name):
        '''
        
        '''
        nt_ks = self.compute_conn
        for item in nt_ks.security_groups.list():
            if item.name == name:
                nt_ks.security_groups.delete(item.id)
                return {name: 'Deleted security group: {0}'.format(name)}
        return 'Security group not found: {0}'.format(name)