Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Resource Manager
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
Resource Manager
Commits
ca13d19b
Commit
ca13d19b
authored
2 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
filter non-eth physical interfaces
parent
b45f08ef
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
resource_management/alembic.ini
+0
-1
0 additions, 1 deletion
resource_management/alembic.ini
resource_management/juniper.py
+10
-0
10 additions, 0 deletions
resource_management/juniper.py
test/test_parse_router.py
+1
-1
1 addition, 1 deletion
test/test_parse_router.py
with
11 additions
and
2 deletions
resource_management/alembic.ini
+
0
−
1
View file @
ca13d19b
...
...
@@ -4,6 +4,5 @@
# a migration for
script_location
=
migrations
sqlalchemy.url
=
sqlite:////absolute/path/to/foo.db
sqlalchemy.url
=
sqlite:////Users/reid/workspace/nat/resource-management/resource_management/foo.db
# or here is an example of a mysql dsn
# sqlalchemy.url = mysql://dummy:dummy-pass@localhost/resources_db_name
This diff is collapsed.
Click to expand it.
resource_management/juniper.py
+
10
−
0
View file @
ca13d19b
...
...
@@ -77,6 +77,12 @@ LINE_CARDS_LIST_SCHEMA = {
}
def
_is_physical_ifc_name
(
name
):
# TODO: is there a better way to filter out lags? other interfaces?
# cf. https://github.com/Juniper/py-junos-eznc/blob/master/lib/jnpr/junos/op/ethport.yml#L6 # noqa: E501
return
re
.
match
(
'
[fgxe][et]-
'
,
name
)
is
not
None
def
_slot_number
(
name
):
"""
parses names like
'
FPC 2
'
,
'
PIC 17
'
and returns
...
...
@@ -371,6 +377,8 @@ def load_logical_interfaces(router: 'jnpr.junos.Device'):
interfaces
=
{}
for
lu
in
LogicalInterfacesTable
(
router
).
get
():
assert
lu
.
logical
.
startswith
(
lu
.
physical
)
# sanity
if
not
_is_physical_ifc_name
(
lu
.
physical
):
continue
interfaces
.
setdefault
(
lu
.
physical
,
set
()).
add
(
lu
.
logical
)
return
interfaces
...
...
@@ -416,6 +424,8 @@ def load_installed_ethernet_ports(router: 'jnpr.junos.Device'):
interfaces
=
{}
for
ifc
in
PhysicalInterfacesTable
(
router
).
get
():
if
not
_is_physical_ifc_name
(
ifc
.
interface
):
continue
interfaces
[
ifc
.
interface
]
=
{
'
admin
'
:
ifc
.
admin
==
'
up
'
,
'
oper
'
:
ifc
.
admin
==
'
up
'
...
...
This diff is collapsed.
Click to expand it.
test/test_parse_router.py
+
1
−
1
View file @
ca13d19b
...
...
@@ -94,7 +94,7 @@ def test_physical_no_lag(mocked_router):
ssh_config
=
ssh
)
as
dev
:
physical
=
juniper
.
load_installed_ethernet_ports
(
dev
)
assert
all
(
p
[
'
name
'
]
.
startswith
(
'
ae
'
)
is
False
for
p
in
physical
)
assert
all
(
p
.
startswith
(
'
ae
'
)
is
False
for
p
in
physical
.
keys
()
)
...
...
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