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
32af0a13
Commit
32af0a13
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
load junosspace devices
parent
af6eefe7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/juniper.py
+24
-0
24 additions, 0 deletions
inventory_provider/juniper.py
with
24 additions
and
0 deletions
inventory_provider/juniper.py
+
24
−
0
View file @
32af0a13
...
...
@@ -2,6 +2,8 @@ import logging
from
jnpr.junos
import
Device
from
lxml
import
etree
import
requests
from
requests.auth
import
HTTPBasicAuth
from
inventory_provider.constants
import
JUNIPER_LOGGER_NAME
...
...
@@ -101,6 +103,7 @@ UNIT_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
"""
# noqa: E501
def
_rpc
(
hostname
,
ssh
):
dev
=
Device
(
host
=
hostname
,
...
...
@@ -218,3 +221,24 @@ def list_bgp_routes(netconf_config):
#
# return _loads(output[1]) if output[1] else {}
#
def
load_routers_from_junosspace
(
config
):
"""
query junosspace for configured devices
:param config: junosspace config element from app config
:return: list of dictionaries, each element of which describes a router
"""
api_url
=
config
[
'
api
'
]
if
not
api_url
.
endswith
(
'
/
'
):
api_url
+=
'
/
'
r
=
requests
.
get
(
api_url
+
'
device-management/devices
'
,
auth
=
HTTPBasicAuth
(
config
[
'
username
'
],
config
[
'
password
'
]),
# TODO: seems server doesn't send the full chain
# ... add the terena cert locally & reenable cert validateion
verify
=
False
)
# TODO: use a proper exception type
assert
r
.
status_code
==
200
return
etree
.
fromstring
(
r
.
text
.
encode
(
'
utf-8
'
))
\ No newline at end of file
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