Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
8f9da6e0
Commit
8f9da6e0
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
remove some commented code, updated some docstrings
parent
97831d60
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/juniper.py
+25
-31
25 additions, 31 deletions
inventory_provider/juniper.py
with
25 additions
and
31 deletions
inventory_provider/juniper.py
+
25
−
31
View file @
8f9da6e0
...
...
@@ -109,30 +109,6 @@ UNIT_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
</xs:schema>
"""
# noqa: E501
# PEERING_LIST_SCHEMA = {
# "$schema": "http://json-schema.org/draft-07/schema#",
# "definitions": {
# "peering": {
# "type": "object",
# "properties": {
# "group": {"type": "string"},
# "description": {"type": "string"},
# "address": {"type": "string"},
# "remote-asn": {"type": "integer"},
# "local-asn": {"type": "integer"},
# "instance": {"type": "string"},
# "logical-system": {"type": "string"},
# "hostname": {"type": "string"}
# },
# # lots of internal peerings - so maybe no explicit asn's
# "required": ["group", "address", "hostname"],
# "additionalProperties": False
# }
# },
# "type": "array",
# "items": {"$ref": "#/definitions/peering"}
# }
class
NetconfHandlingError
(
Exception
):
pass
...
...
@@ -294,6 +270,20 @@ def _system_bgp_peers(system_node):
def
all_bgp_peers
(
netconf_config
):
"""
Return all active bgp peering sessions defined for this router.
The response will be a generator, which renders a list
formatted according to the following schema:
.. asjson::
inventory_provider.routes.msr.PEERING_LIST_SCHEMA
EXCEPT: the
'
hostname
'
parameter is not present
:param netconf_config:
:return: yields active peering sessions
"""
for
base_system
in
netconf_config
.
xpath
(
'
//configuration
'
):
# there should only be one
...
...
@@ -309,7 +299,8 @@ def all_bgp_peers(netconf_config):
def
interface_addresses
(
netconf_config
):
"""
yields a list of all distinct interface addresses
Yields a list of all distinct interface addresses.
:param netconf_config:
:return:
"""
...
...
@@ -324,7 +315,7 @@ def interface_addresses(netconf_config):
def
load_routers_from_netdash
(
url
):
"""
q
uery url for a linefeed-delmitted list of managed router hostnames
Q
uery url for a linefeed-del
i
mitted list of managed router hostnames
.
:param url: url of alldevices.txt file
:return: list of router hostnames
...
...
@@ -341,8 +332,10 @@ def local_interfaces(
omit_link_local
=
True
,
omit_loopback
=
True
):
"""
generator yielding IPv4Interface or IPv6Interface objects,
depending on the value of type
Generator yielding IPv4Interface or IPv6Interface objects for
the interfaces present on the local system,
depending on the value of type.
:param type: hopefully AF_INET or AF_INET6
:param omit_link_local: skip v6 fe80* addresses if true
:param omit_loopback: skip lo* interfaces if true
...
...
@@ -378,11 +371,12 @@ def snmp_community_string(netconf_config):
def
netconf_changed_timestamp
(
netconf_config
):
'''
return the last change timestamp published by the config document
"""
Return the last change timestamp published by the config document.
:param netconf_config: netconf lxml etree document
:return: an epoch timestamp (integer number of seconds) or None
'''
"""
for
ts
in
netconf_config
.
xpath
(
'
/configuration/@changed-seconds
'
):
if
re
.
match
(
r
'
^\d+$
'
,
ts
):
return
int
(
ts
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment