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
c3a71b48
Commit
c3a71b48
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature/DBOARD3-386' into develop
parents
98d1d157
48d501c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/juniper.py
+7
-3
7 additions, 3 deletions
inventory_provider/juniper.py
inventory_provider/routes/testing.py
+12
-0
12 additions, 0 deletions
inventory_provider/routes/testing.py
with
19 additions
and
3 deletions
inventory_provider/juniper.py
+
7
−
3
View file @
c3a71b48
...
...
@@ -43,6 +43,8 @@ CONFIG_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs=
"
1
"
maxOccurs=
"
unbounded
"
>
<xs:element name=
"
transfer-on-commit
"
minOccurs=
"
0
"
type=
"
xs:string
"
/>
<xs:element name=
"
archive-sites
"
minOccurs=
"
0
"
type=
"
generic-sequence
"
/>
<xs:element name=
"
version
"
minOccurs=
"
0
"
type=
"
xs:string
"
/>
<xs:element name=
"
groups
"
minOccurs=
"
0
"
type=
"
generic-sequence
"
/>
<xs:element name=
"
apply-groups
"
minOccurs=
"
0
"
type=
"
xs:string
"
/>
...
...
@@ -155,20 +157,22 @@ def validate_netconf_config(config_doc):
_validate
(
unit_schema
,
u
)
def
load_config
(
hostname
,
ssh_params
):
def
load_config
(
hostname
,
ssh_params
,
validate
=
True
):
"""
loads netconf data from the router, validates and
loads netconf data from the router, validates
(by default)
and
returns as an lxml etree doc
:param hostname: router hostname
:param ssh_params:
'
ssh
'
config element(cf. config.py:CONFIG_SCHEMA)
:param validate: whether or not to validate netconf data (default True)
:return:
:raises: NetconfHandlingError from validate_netconf_config
"""
logger
=
logging
.
getLogger
(
__name__
)
logger
.
info
(
"
capturing netconf data for
'
%s
'"
%
hostname
)
config
=
_rpc
(
hostname
,
ssh_params
).
get_config
()
validate_netconf_config
(
config
)
if
validate
:
validate_netconf_config
(
config
)
return
config
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/routes/testing.py
+
12
−
0
View file @
c3a71b48
...
...
@@ -189,6 +189,18 @@ def snmp_ids(hostname):
return
jsonify
(
ifc_data
)
@routes.route
(
"
netconf/<hostname>
"
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
get_netconf
(
hostname
):
config
=
current_app
.
config
[
"
INVENTORY_PROVIDER_CONFIG
"
]
try
:
netconf_doc
=
juniper
.
load_config
(
hostname
,
config
[
"
ssh
"
],
validate
=
False
)
msg
=
etree
.
tostring
(
netconf_doc
,
encoding
=
'
unicode
'
)
except
(
ConnectionError
,
juniper
.
NetconfHandlingError
)
as
e
:
msg
=
f
'
error loading netconf data from
{
hostname
}
\n
{
e
}
'
return
msg
@routes.route
(
"
latchdb
"
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
latch_db
():
config
=
current_app
.
config
[
"
INVENTORY_PROVIDER_CONFIG
"
]
...
...
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