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
411bb772
Commit
411bb772
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
filter test router list by those with netconf data available
parent
d12917d0
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
test/per_router/conftest.py
+20
-11
20 additions, 11 deletions
test/per_router/conftest.py
with
20 additions
and
11 deletions
test/per_router/conftest.py
+
20
−
11
View file @
411bb772
import
glob
import
os
import
re
from
lxml
import
etree
...
...
@@ -12,14 +13,22 @@ TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
def
pytest_generate_tests
(
metafunc
):
filename
=
os
.
path
.
join
(
TEST_DATA_DIRNAME
,
"
junosspace-devices.xml
"
)
with
open
(
filename
)
as
f
:
doc
=
etree
.
fromstring
(
f
.
read
().
encode
(
'
utf-8
'
))
routers
=
[]
for
name
in
doc
.
xpath
(
'
//devices/device/name/text()
'
):
m
=
re
.
match
(
'
^(mx[1|2].*)\.re0
'
,
name
)
if
m
:
routers
.
append
({
'
hostname
'
:
m
.
group
(
1
)
+
'
.geant.net
'
})
metafunc
.
parametrize
(
"
router
"
,
list
([
r
[
'
hostname
'
]
for
r
in
routers
]))
def
_junosspace_hosts
():
filename
=
os
.
path
.
join
(
TEST_DATA_DIRNAME
,
"
junosspace-devices.xml
"
)
with
open
(
filename
)
as
f
:
doc
=
etree
.
fromstring
(
f
.
read
().
encode
(
'
utf-8
'
))
for
name
in
doc
.
xpath
(
'
//devices/device/name/text()
'
):
m
=
re
.
match
(
r
'
^(mx[12].*)\.re0
'
,
name
)
if
m
:
yield
m
.
group
(
1
)
+
'
.geant.net
'
# TODO: can we really not get netconf data for all routers?
def
_available_netconf_hosts
():
for
fn
in
glob
.
glob
(
os
.
path
.
join
(
TEST_DATA_DIRNAME
,
'
*-netconf.xml
'
)):
m
=
re
.
match
(
'
(.*)-netconf.xml
'
,
os
.
path
.
basename
(
fn
))
assert
m
# sanity
yield
m
.
group
(
1
)
routers
=
list
(
set
(
_junosspace_hosts
())
&
set
(
_available_netconf_hosts
()))
metafunc
.
parametrize
(
"
router
"
,
routers
)
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