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
31495a06
Commit
31495a06
authored
10 months ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
added additional endpoint for Coriant RE. DBOARD3-1006
parent
e47a4618
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/routes/classifier.py
+40
-6
40 additions, 6 deletions
inventory_provider/routes/classifier.py
test/test_classifier_routes.py
+12
-6
12 additions, 6 deletions
test/test_classifier_routes.py
with
52 additions
and
12 deletions
inventory_provider/routes/classifier.py
+
40
−
6
View file @
31495a06
...
@@ -23,10 +23,15 @@ These endpoints are intended for use by Dashboard V3.
...
@@ -23,10 +23,15 @@ These endpoints are intended for use by Dashboard V3.
.. autofunction::
.. autofunction::
inventory_provider.routes.classifier.get_fiberlink_trap_metadata
inventory_provider.routes.classifier.get_fiberlink_trap_metadata
/classifier/coriant-info
/classifier/coriant-port-info
------------------------
-----------------------------
.. autofunction:: inventory_provider.routes.classifier.get_coriant_port_info
/classifier/coriant-tp-info
---------------------------
.. autofunction:: inventory_provider.routes.classifier.get_coriant_info
.. autofunction:: inventory_provider.routes.classifier.get_coriant_
tp_
info
/classifier/mtc-interface-info
/classifier/mtc-interface-info
...
@@ -985,8 +990,31 @@ def get_tnms_fibre_trap_metadata(enms_pc_name: str) -> Response:
...
@@ -985,8 +990,31 @@ def get_tnms_fibre_trap_metadata(enms_pc_name: str) -> Response:
@routes.route
(
'
/coriant-info/<equipment_name>/<path:entity_string>
'
,
@routes.route
(
'
/coriant-info/<equipment_name>/<path:entity_string>
'
,
methods
=
[
'
GET
'
])
methods
=
[
'
GET
'
])
@routes.route
(
'
/coriant-port-info/<equipment_name>/<path:entity_string>
'
,
methods
=
[
'
GET
'
])
@common.require_accepts_json
def
get_coriant_port_info
(
equipment_name
:
str
,
entity_string
:
str
)
->
Response
:
"""
Handler for /classifier/coriant-info that
returns metadata for a coriant path.
The response will be formatted according to the following schema:
.. asjson::
inventory_provider.routes.classifier_schema.CORIANT_INFO_RESPONSE_SCHEMA
:param equipment_name: grv hostname
:param entity_string: path name
:return:
"""
card_port_regex
=
r
'
^(\d+\-\d+)\.(\d+(\.\d+)*)
'
return
_get_coriant_info
(
equipment_name
,
entity_string
,
card_port_regex
)
@routes.route
(
'
/coriant-tp-info/<equipment_name>/<path:entity_string>
'
,
methods
=
[
'
GET
'
])
@common.require_accepts_json
@common.require_accepts_json
def
get_coriant_info
(
equipment_name
:
str
,
entity_string
:
str
)
->
Response
:
def
get_coriant_
tp_
info
(
equipment_name
:
str
,
entity_string
:
str
)
->
Response
:
"""
"""
Handler for /classifier/coriant-info that
Handler for /classifier/coriant-info that
returns metadata for a coriant path.
returns metadata for a coriant path.
...
@@ -996,10 +1024,16 @@ def get_coriant_info(equipment_name: str, entity_string: str) -> Response:
...
@@ -996,10 +1024,16 @@ def get_coriant_info(equipment_name: str, entity_string: str) -> Response:
.. asjson::
.. asjson::
inventory_provider.routes.classifier_schema.CORIANT_INFO_RESPONSE_SCHEMA
inventory_provider.routes.classifier_schema.CORIANT_INFO_RESPONSE_SCHEMA
:param
source_
equipment: grv hostname
:param equipment
_name
: grv hostname
:param entity_string: path name
:param entity_string: path name
:return:
:return:
"""
"""
card_port_regex
=
r
'
^(\d+\-\d+)\.(\d+)
'
return
_get_coriant_info
(
equipment_name
,
entity_string
,
card_port_regex
)
def
_get_coriant_info
(
equipment_name
:
str
,
entity_string
:
str
,
card_port_regex
:
str
)
->
Response
:
r
=
common
.
get_current_redis
()
r
=
common
.
get_current_redis
()
...
@@ -1013,7 +1047,7 @@ def get_coriant_info(equipment_name: str, entity_string: str) -> Response:
...
@@ -1013,7 +1047,7 @@ def get_coriant_info(equipment_name: str, entity_string: str) -> Response:
if
not
result
:
if
not
result
:
m
=
re
.
match
(
r
'
^(\d+\-\d+)\.((\d+)(\.\d+)*)
'
,
ims_interface
)
m
=
re
.
match
(
card_port_regex
,
ims_interface
)
if
not
m
:
if
not
m
:
logger
.
error
(
logger
.
error
(
f
'
invalid coriant entity string format:
{
ims_interface
}
'
)
f
'
invalid coriant entity string format:
{
ims_interface
}
'
)
...
...
This diff is collapsed.
Click to expand it.
test/test_classifier_routes.py
+
12
−
6
View file @
31495a06
...
@@ -121,14 +121,20 @@ def test_peer_not_found(client):
...
@@ -121,14 +121,20 @@ def test_peer_not_found(client):
assert
response_data
==
{
'
locations
'
:
[],
"
contacts
"
:
[]}
assert
response_data
==
{
'
locations
'
:
[],
"
contacts
"
:
[]}
@pytest.mark.parametrize
(
'
equipment,entity_name,expected_card_id,expected_port
'
,
[
@pytest.mark.parametrize
(
'
equipment,entity_name,expected_card_id,expected_port,endpoint
'
,
[
(
'
grv3.ams.nl.geant.net
'
,
'
1-3.3.1-Optical-10GbE-TTP
'
,
'
1/3
'
,
'
3.1
'
),
(
'
grv3.ams.nl.geant.net
'
,
'
1-3.3.1-Optical-10GbE-TTP
'
,
(
'
bogus-hostname.with&special.char
'
,
'
1/3
'
,
'
3.1
'
,
'
coriant-port-info
'
),
'
234-2345234.7878i234crazynamewithslash/1-2.3
'
,
'
234/2345234
'
,
'
7878
'
)
(
'
grv3.ams.nl.geant.net
'
,
'
1-3.3.1-Optical-10GbE-TTP
'
,
'
1/3
'
,
'
3.1
'
,
'
coriant-info
'
),
(
'
grv3.ams.nl.geant.net
'
,
'
1-1.3.1-100GbE-ODU4-TTP
'
,
'
1/1
'
,
'
3
'
,
'
coriant-tp-info
'
),
(
'
bogus-hostname.with&special.char
'
,
'
234-2345234.7878i234crazynamewithslash/1-2.3
'
,
'
234/2345234
'
,
'
7878
'
,
'
coriant-port-info
'
)
])
])
def
test_coriant_info
(
client
,
equipment
,
entity_name
,
expected_card_id
,
expected_port
):
def
test_coriant_info
(
client
,
equipment
,
entity_name
,
expected_card_id
,
expected_port
,
endpoint
):
rv
=
client
.
get
(
rv
=
client
.
get
(
f
'
/classifier/
coriant-info
/
{
equipment
}
/
{
entity_name
}
'
,
f
'
/classifier/
{
endpoint
}
/
{
equipment
}
/
{
entity_name
}
'
,
headers
=
DEFAULT_REQUEST_HEADERS
)
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
assert
rv
.
status_code
==
200
assert
rv
.
is_json
assert
rv
.
is_json
...
...
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