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
5ae87782
Commit
5ae87782
authored
10 months ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
Removed hardcoded index references from config parsing. RE DBOARD3-965
parent
78963212
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/nokia.py
+16
-24
16 additions, 24 deletions
inventory_provider/nokia.py
with
16 additions
and
24 deletions
inventory_provider/nokia.py
+
16
−
24
View file @
5ae87782
...
...
@@ -173,12 +173,14 @@ def get_interfaces_state(state_doc):
def
get_ports_config
(
netconf_config
):
def
_port_info
(
e
):
pi
=
{
'
port-id
'
:
e
.
find
(
'
n:port-id
'
,
namespaces
=
NS
).
text
,
'
admin-state
'
:
e
.
find
(
'
n:admin-state
'
,
namespaces
=
NS
).
text
,
'
port-id
'
:
e
.
find
(
'
n:port-id
'
,
namespaces
=
NS
).
text
}
description
=
e
.
find
(
'
n:description
'
,
namespaces
=
NS
)
admin_state
=
e
.
find
(
'
n:admin-state
'
,
namespaces
=
NS
)
pi
[
'
admin-state
'
]
=
admin_state
.
text
if
admin_state
is
not
None
else
'
enabled
'
# assume enabled if not present
description
=
e
.
find
(
'
n:description
'
,
namespaces
=
NS
)
pi
[
'
description
'
]
=
description
.
text
if
description
is
not
None
else
''
breakout
=
e
.
find
(
'
./n:connector/n:breakout
'
,
namespaces
=
NS
)
if
breakout
is
not
None
:
breakout
=
breakout
.
text
...
...
@@ -207,8 +209,7 @@ def get_ports_config(netconf_config):
def
get_lags_config
(
netconf_config
):
enabled_ports
=
{
p
[
'
port-id
'
]
for
p
in
get_ports_config
(
netconf_config
)
if
p
[
'
admin-state
'
]
==
'
enable
'
p
[
'
port-id
'
]
for
p
in
get_ports_config
(
netconf_config
)
if
p
[
'
admin-state
'
]
==
'
enable
'
}
def
_lag_info
(
e
):
...
...
@@ -216,14 +217,14 @@ def get_lags_config(netconf_config):
port_elements
=
e
.
findall
(
'
./n:port
'
,
namespaces
=
NS
)
port_ids
=
(
p
.
find
(
'
./n:port-id
'
,
namespaces
=
NS
).
text
for
p
in
port_elements
)
admin_state
=
e
.
find
(
'
./n:admin-state
'
,
namespaces
=
NS
)
.
text
admin_state
=
e
.
find
(
'
./n:admin-state
'
,
namespaces
=
NS
)
description_e
=
e
.
find
(
'
n:description
'
,
namespaces
=
NS
)
ifc
=
{
'
name
'
:
_name
,
'
description
'
:
(
description_e
.
text
if
description_e
is
not
None
else
''
),
'
admin-state
'
:
admin_state
,
'
admin-state
'
:
admin_state
.
text
if
admin_state
is
not
None
else
'
enabled
'
,
# assume enabled if not present
'
ports
'
:
[
p_id
for
p_id
in
port_ids
if
p_id
in
enabled_ports
],
}
return
ifc
...
...
@@ -235,19 +236,6 @@ def get_lags_config(netconf_config):
def
get_interfaces_config
(
netconf_config
):
def
_get_address_node_info
(
_e
):
# HACKHACK: quick workaround for DBOARD3-965
# TODO: fix this properly
yield
from
_e
.
xpath
(
'
n:address
'
,
namespaces
=
NS
)
yield
from
_e
.
xpath
(
'
n:primary
'
,
namespaces
=
NS
)
def
_get_ip_address
(
e
):
for
_address_elem
in
_get_address_node_info
(
e
):
address
=
_address_elem
[
0
].
text
prefix_length
=
_address_elem
[
1
].
text
ip_string
=
f
'
{
address
}
/
{
prefix_length
}
'
yield
ip_string
interfaces
=
netconf_config
.
findall
(
'
n:configure/n:router/n:interface
'
,
namespaces
=
NS
)
for
interface
in
interfaces
:
...
...
@@ -263,10 +251,14 @@ def get_interfaces_config(netconf_config):
if
admin_state
is
not
None
:
details
[
"
admin-state
"
]
=
admin_state
.
text
for
element
in
interface
.
xpath
(
'
n:ipv4
'
,
namespaces
=
NS
):
details
[
"
ipv4
"
].
extend
(
_get_ip_address
(
element
))
for
element
in
interface
.
xpath
(
'
n:ipv4/n:primary | n:ipv4/n:secondary
'
,
namespaces
=
NS
):
address
=
element
.
find
(
'
n:address
'
,
namespaces
=
NS
).
text
prefix_length
=
element
.
find
(
'
n:prefix-length
'
,
namespaces
=
NS
).
text
details
[
"
ipv4
"
].
append
(
f
'
{
address
}
/
{
prefix_length
}
'
)
for
element
in
interface
.
xpath
(
'
n:ipv6
'
,
namespaces
=
NS
):
details
[
"
ipv6
"
].
extend
(
_get_ip_address
(
element
))
for
element
in
interface
.
xpath
(
'
n:ipv6/n:address
'
,
namespaces
=
NS
):
address
=
element
.
find
(
'
n:ipv6-address
'
,
namespaces
=
NS
).
text
prefix_length
=
element
.
find
(
'
n:prefix-length
'
,
namespaces
=
NS
).
text
details
[
"
ipv6
"
].
append
(
f
'
{
address
}
/
{
prefix_length
}
'
)
yield
details
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