Return the firewall rule, given its ID.
166185
def get_fw_rule(self, rule_id):
        
        rule = None
        try:
            rule = self.neutronclient.show_firewall_rule(rule_id)
        except Exception as exc:
            LOG.error("Failed to get firewall rule for id %(id)s "
                      "Exc %(exc)s", {'id': rule_id, 'exc': str(exc)})
        return rule
148808
def get_rich_rules(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-rich-rules'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).splitlines()
412003
def configure_firewall(self, server, firewall_rule_bodies):
        
        server_uuid, server_instance = uuid_and_instance(server)

        return [
            self.create_firewall_rule(server_uuid, rule)
            for rule in firewall_rule_bodies
        ]
583900
def get_securitygroup(self, group_id, **kwargs):
        
        if 'mask' not in kwargs:
            kwargs['mask'] = (
                'id,'
                'name,'
                'description,'
                '''rules[id, remoteIp, remoteGroupId,
                         direction, ethertype, portRangeMin,
                         portRangeMax, protocol, createDate, modifyDate],'''
                '''networkComponentBindings[
                    networkComponent[
                        id,
                        port,
                        guest[
                            id,
                            hostname,
                            primaryBackendIpAddress,
                            primaryIpAddress
                        ]
                    ]
                ]'''
            )

        return self.security_group.getObject(id=group_id, **kwargs)
604995
def get(self):
        """"""
        q = queue.Queue()

        for u, j, k in urls:
            t = threading.Thread(target=self._get_ip_public, args=(q, u, j, k))
            t.daemon = True
            t.start()

        timer = Timer(self.timeout)
        ip = None
        while not timer.finished() and ip is None:
            if q.qsize() > 0:
                ip = q.get()

        return ', '.join(set([x.strip() for x in ip.split(',')]))
74747
def show_firewall_rule(self, firewall_rule, **_params):
        """"""
        return self.get(self.firewall_rule_path % (firewall_rule),
                        params=_params)
980035
def cli(env, identifier):
    """"""

    mgr = SoftLayer.FirewallManager(env.client)

    firewall_type, firewall_id = firewall.parse_id(identifier)
    if firewall_type == 'vlan':
        rules = mgr.get_dedicated_fwl_rules(firewall_id)
    else:
        rules = mgr.get_standard_fwl_rules(firewall_id)

    env.fout(get_rules_table(rules))
721151
def _fw_rule_delete(self, drvr_name, data):
        
        rule_id = data.get('firewall_rule_id')
        tenant_id = self.tenant_db.get_rule_tenant(rule_id)

        if tenant_id not in self.fwid_attr:
            LOG.error("Invalid tenant id for FW delete %s", tenant_id)
            return
        tenant_obj = self.fwid_attr[tenant_id]
        # Guess actual FW/policy need not be deleted if this is the active
        # rule, Openstack does not allow it to be deleted
        tenant_obj.delete_rule(rule_id)
        self.tenant_db.del_rule_tenant(rule_id)
1013255
public T getById(String id) throws NRE {
        T rule = rules.get(id);

        if (null == rule) {
            throw newNoRuleException(id);
        }

        return rule;
    }
19384
def create_rule(self):
        """"""
        return BlockRule(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
698586
def get_policy(table='filter', chain=None, family='ipv4'):
    '''
    
    '''
    if not chain:
        return 'Error: Chain needs to be specified'

    rules = _parse_conf(in_mem=True, family=family)
    try:
        return rules[table][chain]['policy']
    except KeyError:
        return None
789505
def get_firewall_rule(self, server_uuid, firewall_rule_position, server_instance=None):
        
        url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position)
        res = self.get_request(url)
        return FirewallRule(**res['firewall_rule'])
572509
def get_pd_by_id(self, id):
        
        for pd in self.conn.protection_domains:
            if pd.id == id:
                return pd
        raise KeyError("Protection Domain with ID " + id + " not found")
604984
def _get_rule_cmds(self, sg_id, sg_rule, delete=False):
        """"""
        rule_prefix = ""
        if delete:
            rule_prefix = "no "
        in_rules, eg_rules = self._format_rules_for_eos([sg_rule])
        cmds = []
        if in_rules:
            cmds.append("ip access-list %s dynamic" %
                        self._acl_name(sg_id, n_const.INGRESS_DIRECTION))
            for in_rule in in_rules:
                cmds.append(rule_prefix + in_rule)
            cmds.append("exit")
        if eg_rules:
            cmds.append("ip access-list %s dynamic" %
                        self._acl_name(sg_id, n_const.EGRESS_DIRECTION))
            for eg_rule in eg_rules:
                cmds.append(rule_prefix + eg_rule)
            cmds.append("exit")
        return cmds
322208
def get_rule(objectID, request_options = {})
      client.get(Protocol.rule_uri(name, objectID), :read, request_options)
    end
522908
def get_gateway_id(self):
        """"""
        host, _ = self.server_address
        try:
            ip_address = ipaddress.ip_address(host)
        except ValueError:
            # Only hosts using ip address supports unique id.
            return None
        if ip_address.version == 6:
            mac = get_mac_address(ip6=host)
        else:
            mac = get_mac_address(ip=host)
        return mac
274801
def list_bandwidth_limit_rules(self, policy_id,
                                   retrieve_all=True, **_params):
        """"""
        return self.list('bandwidth_limit_rules',
                         self.qos_bandwidth_limit_rules_path % policy_id,
                         retrieve_all, **_params)