Fetches a list of BGP speakers hosted by Dynamic Routing agent.
975934
def list_bgp_speaker_on_dragent(self, bgp_dragent, **_params):
        """"""
        return self.get((self.agent_path + self.BGP_DRINSTANCES)
                        % bgp_dragent, params=_params)
1259152
def get_bgp_config(self, group="", neighbor=""):
        

        bgp_config = {}

        def build_prefix_limit(af_table, limit, prefix_percent, prefix_timeout):
            prefix_limit = {}
            inet = False
            inet6 = False
            preifx_type = "inet"
            if isinstance(af_table, list):
                af_table = str(af_table)
            if "ipv4" in af_table.lower():
                inet = True
            if "ipv6" in af_table.lower():
                inet6 = True
                preifx_type = "inet6"
            if len(af_table.split()) == 2:
                safi = "unicast"
            else:
                safi = af_table.split()[-1]
            if inet or inet6:
                prefix_limit = {
                    preifx_type: {
                        safi: {
                            "limit": limit,
                            "teardown": {
                                "threshold": prefix_percent,
                                "timeout": prefix_timeout,
                            },
                        }
                    }
                }
            return prefix_limit

        # Get BGP config using ciscoconfparse because some old devices dont support "| sec bgp"
        cfg = self.get_config(retrieve="running")
        cfg = cfg["running"].splitlines()
        bgp_config_text = napalm.base.helpers.cisco_conf_parse_objects(
            "router bgp", cfg
        )
        bgp_asn = napalm.base.helpers.regex_find_txt(
            r"router bgp (\d+)", bgp_config_text, default=0
        )
        # Get a list of all neighbors and groups in the config
        all_neighbors = set()
        all_groups = set()
        bgp_group_neighbors = {}
        all_groups.add("_")
        for line in bgp_config_text:
            if " neighbor " in line:
                if re.search(IP_ADDR_REGEX, line) is not None:
                    all_neighbors.add(re.search(IP_ADDR_REGEX, line).group())
                elif re.search(IPV6_ADDR_REGEX_2, line) is not None:
                    all_neighbors.add(re.search(IPV6_ADDR_REGEX_2, line).group())
                else:
                    bgp_group = re.search(r" neighbor [^\s]+", line).group()
                    bgp_group = bgp_group.split()[1]
                    all_groups.add(bgp_group)

        # Get the neighrbor level config for each neighbor
        for bgp_neighbor in all_neighbors:
            # If neighbor_filter is passed in, only continue for that neighbor
            if neighbor:
                if bgp_neighbor != neighbor:
                    continue
            afi_list = napalm.base.helpers.cisco_conf_parse_parents(
                r"\s+address-family.*", bgp_neighbor, bgp_config_text
            )
            afi = afi_list[0]
            # Skipping neighbors in VRFs for now
            if "vrf" in str(afi_list):
                continue
            else:
                neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(
                    bgp_neighbor, bgp_config_text
                )
            # For group_name- use peer-group name, else VRF name, else "_" for no group
            group_name = napalm.base.helpers.regex_find_txt(
                " peer-group ([^']+)", neighbor_config, default="_"
            )
            # Start finding attributes for the neighbor config
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            password = napalm.base.helpers.regex_find_txt(
                r"password (?:[0-9] )?([^\']+\')", neighbor_config
            )
            nhs = bool(
                napalm.base.helpers.regex_find_txt(r" next-hop-self", neighbor_config)
            )
            route_reflector_client = bool(
                napalm.base.helpers.regex_find_txt(
                    r"route-reflector-client", neighbor_config
                )
            )

            # Add the group name to bgp_group_neighbors if its not there already
            if group_name not in bgp_group_neighbors.keys():
                bgp_group_neighbors[group_name] = {}

            # Build the neighbor dict of attributes
            bgp_group_neighbors[group_name][bgp_neighbor] = {
                "description": description,
                "remote_as": peer_as,
                "prefix_limit": build_prefix_limit(
                    afi, prefix_limit, prefix_percent, prefix_timeout
                ),
                "export_policy": export_policy,
                "import_policy": import_policy,
                "local_address": local_address,
                "local_as": local_as,
                "authentication_key": password,
                "nhs": nhs,
                "route_reflector_client": route_reflector_client,
            }

        # Get the peer-group level config for each group
        for group_name in bgp_group_neighbors.keys():
            # If a group is passed in params, only continue on that group
            if group:
                if group_name != group:
                    continue
            # Default no group
            if group_name == "_":
                bgp_config["_"] = {
                    "apply_groups": [],
                    "description": "",
                    "local_as": 0,
                    "type": "",
                    "import_policy": "",
                    "export_policy": "",
                    "local_address": "",
                    "multipath": False,
                    "multihop_ttl": 0,
                    "remote_as": 0,
                    "remove_private_as": False,
                    "prefix_limit": {},
                    "neighbors": bgp_group_neighbors.get("_", {}),
                }
                continue
            neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(
                group_name, bgp_config_text
            )
            multipath = False
            afi_list = napalm.base.helpers.cisco_conf_parse_parents(
                r"\s+address-family.*", group_name, neighbor_config
            )
            for afi in afi_list:
                afi_config = napalm.base.helpers.cisco_conf_parse_objects(
                    afi, bgp_config_text
                )
                multipath = bool(
                    napalm.base.helpers.regex_find_txt(r" multipath", str(afi_config))
                )
                if multipath:
                    break
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            multihop_ttl = napalm.base.helpers.regex_find_txt(
                r"ebgp-multihop {\d+}", neighbor_config, default=0
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            remove_private_as = bool(
                napalm.base.helpers.regex_find_txt(
                    r"remove-private-as", neighbor_config
                )
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            bgp_type = "external"
            if local_as:
                if local_as == peer_as:
                    bgp_type = "internal"
            elif bgp_asn == peer_as:
                bgp_type = "internal"

            bgp_config[group_name] = {
                "apply_groups": [],  # on IOS will always be empty list!
                "description": description,
                "local_as": local_as,
                "type": bgp_type,
                "import_policy": import_policy,
                "export_policy": export_policy,
                "local_address": local_address,
                "multipath": multipath,
                "multihop_ttl": multihop_ttl,
                "remote_as": peer_as,
                "remove_private_as": remove_private_as,
                "prefix_limit": build_prefix_limit(
                    afi, prefix_limit, prefix_percent, prefix_timeout
                ),
                "neighbors": bgp_group_neighbors.get(group_name, {}),
            }
        return bgp_config
1055541
def _base_get_list(self, url, limit=None, *, query=None, order_by=None,
                       batch=None):
        

        if limit is None or limit > self.protocol.max_top_value:
            batch = self.protocol.max_top_value

        params = {'$top': batch if batch else limit}

        if order_by:
            params['$orderby'] = order_by

        if query:
            if query.has_filters:
                warnings.warn(
                    'Filters are not allowed by the Api Provider '
                    'in this method')
                query.clear_filters()
            if isinstance(query, str):
                params['$filter'] = query
            else:
                params.update(query.as_params())

        response = self.con.get(url, params=params)
        if not response:
            return iter(())

        data = response.json()

        # Everything received from cloud must be passed as self._cloud_data_key
        items = (
            self._classifier(item)(parent=self, **{self._cloud_data_key: item})
            for item in data.get('value', []))
        next_link = data.get(NEXT_LINK_KEYWORD, None)
        if batch and next_link:
            return Pagination(parent=self, data=items,
                              constructor=self._classifier,
                              next_link=next_link, limit=limit)
        else:
            return items
1341502
def get_members_of_group(self, gname):
        
        hostgroup = self.find_by_name(gname)
        if hostgroup:
            return hostgroup.get_hosts()
        return []
1187370
def list(self, environment_vip=None):
        

        uri = 'api/networkv4/?'
        if environment_vip:
            uri += 'environment_vip=%s' % environment_vip

        return super(ApiNetworkIPv4, self).get(uri)
588986
def router_connections(self):
        """"""
        clients = []
        for server in self._routers:
            if Servers().is_alive(server):
                client = self.create_connection(Servers().hostname(server))
                clients.append(client)
        return clients
108934
def list(gandi, resource):
    """"""
    keys = gandi.dnssec.list(resource)
    gandi.pretty_echo(keys)

    return keys
146948
def get_all_hosting_devices(self, context):
        """"""
        cctxt = self.client.prepare()
        return cctxt.call(context,
                          'get_all_hosting_devices',
                          host=self.host)
1136197
def _get_underscheduled_routers(self, plugin, context):
        """"""
        underscheduled_routers = []
        max_agents_for_ha = plugin.get_number_of_agents_for_scheduling(context)

        for router, count in plugin.get_routers_l3_agents_count(context):
            if (router[routertype.TYPE_ATTR] !=
                    plugin.get_namespace_router_type_id(context)):
                # ignore non-namespace routers
                continue
            if (count < 1 or
                router.get('ha', False) and count < max_agents_for_ha):
                # Either the router was un-scheduled (scheduled to 0 agents),
                # or it's an HA router and it was under-scheduled (scheduled to
                # less than max_agents_for_ha). Either way, it should be added
                # to the list of routers we want to handle.
                underscheduled_routers.append(router)
        return underscheduled_routers
108098
def get(self):
        
        config = self.get_block('^router bgp .*')
        if not config:
            return None

        response = dict()
        response.update(self._parse_bgp_as(config))
        response.update(self._parse_router_id(config))
        response.update(self._parse_max_paths(config))
        response.update(self._parse_shutdown(config))
        response.update(self._parse_networks(config))

        response['neighbors'] = self.neighbors.getall()

        return response
776550
protected List<Shape> getAvoidList (Name speaker)
    {
        List<Shape> avoid = Lists.newArrayList();
        if (_provider == null) {
            return avoid;
        }

        // for now we don't accept low-priority avoids
        _provider.getAvoidables(speaker, avoid, null);

        // add the existing chatbub non-tail areas from other speakers
        for (BubbleGlyph bub : _bubbles) {
            if (!bub.isSpeaker(speaker)) {
                avoid.add(bub.getBubbleTerritory());
            }
        }

        return avoid;
    }
378477
def get_cfg_router_ids(self, context, host, router_ids=None,
                       hosting_device_ids=None):
        """"""
        return self._l3plugin.cfg_list_router_ids_on_host(context, host,
                                                      router_ids,
                                                      hosting_device_ids)
346526
def add_network_to_bgp_speaker(self, speaker_id, body=None):
        """"""
        return self.put((self.bgp_speaker_path % speaker_id) +
                        "/add_gateway_network", body=body)
1324477
def show_bgp_peer(self, peer_id, **_params):
        """"""
        return self.get(self.bgp_peer_path % peer_id,
                        params=_params)
1122481
def getBlizzBotPlayers():
    """"""
    ret = {}
    for pName,p in iteritems(getKnownPlayers()):
        if p.isComputer:
            ret[pName] = p
    return ret
148005
def get_bcbio_nodes(path):
    
    with open(path, 'r') as file_handle:
        hosts = collections.defaultdict(dict)
        for line in file_handle:
            matches = re.search(r'\]\s([^:]+):', line)
            if not matches:
                continue
            # Format of the record will be "[Date] host: Timing: Step" if distributed,
            # otherwise the host will be missing and it means its a local run, we can stop
            elif 'Timing: ' in line and line.split(': ')[1] != 'Timing':
                hosts = collections.defaultdict(dict, {socket.gethostname() : {}})
                break

            hosts[matches.group(1)]

    return hosts
1297769
def get_network_events(self):
        
        return github.PaginatedList.PaginatedList(
            github.Event.Event,
            self._requester,
            "/networks/" + self.owner.login + "/" + self.name + "/events",
            None
        )