Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LSO
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
LSO
Commits
711e78da
Verified
Commit
711e78da
authored
2 years ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
update device endpoint to match output from GSO
parent
592a0d95
No related branches found
No related tags found
1 merge request
!16
update device endpoint to match output from GSO
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lso/routes/device.py
+22
-32
22 additions, 32 deletions
lso/routes/device.py
test/test_playbook_utils.py
+2
-2
2 additions, 2 deletions
test/test_playbook_utils.py
with
24 additions
and
34 deletions
lso/routes/device.py
+
22
−
32
View file @
711e78da
...
...
@@ -48,28 +48,19 @@ class DeviceParams(pydantic.BaseModel):
This device can either be a router or a switch, from the different vendors
that are supported.
:param fqdn:
:type fqdn: str
:param lo_address:
:type lo_address: :class:`InterfaceAddress`
:param lo_iso_address:
:type lo_iso_address: str
:param si_ipv4_network:
:type si_ipv4_network: ipaddress.IPv4Network
:param ias_lt_network:
:type ias_lt_network: :class:`InterfaceNetwork`
:param site_country_code:
:type site_country_code: str
:param site_city:
:type site_city: str
:param site_latitude:
:type site_latitude: str
:type site_longitude:
:type site_longitude: str
:param device_type:
:type device_type: str
:param device_vendor:
:type device_vendor: str
:param str fqdn:
:param InterfaceAddress lo_address:
:param str lo_iso_address:
:param IPv4Network si_ipv4_network:
:param InterfaceNetwork ias_lt_network:
:param str site_country_code:
:param str site_city:
:param str site_latitude:
:param str site_longitude:
:param str device_type:
:param str device_vendor:
:param str ts_address:
:param int ts_port:
"""
#: FQDN of a device, TODO: add some validation
fqdn
:
str
...
...
@@ -90,10 +81,17 @@ class DeviceParams(pydantic.BaseModel):
site_latitude
:
str
#: Longitude of the device site.
site_longitude
:
str
#: SNMP location of a device
snmp_location
:
str
#: Type of device, either ``router`` or ``switch``.
device_type
:
str
#: The device vendor, for specific configuration.
device_vendor
:
str
#: Host address that ansible should point to, most likely a terminal
#: server.
ts_address
:
str
#: Similar to the ``ansible_host``, but for a port number.
ts_port
:
int
class
NodeProvisioningParams
(
pydantic
.
BaseModel
):
...
...
@@ -116,11 +114,6 @@ class NodeProvisioningParams(pydantic.BaseModel):
callback
:
pydantic
.
HttpUrl
# TODO: NAT-151
#: Parameters for the new device.
device
:
DeviceParams
#: Host address that ansible should point to, most likely a terminal
#: server.
ansible_host
:
ipaddress
.
IPv4Address
|
ipaddress
.
IPv6Address
#: Similar to the ``ansible_host``, but for a port number.
ansible_port
:
int
#: Whether this playbook execution should be a dry run, or run for real.
#: defaults to ``True`` for obvious reasons, also making it an optional
#: parameter.
...
...
@@ -147,10 +140,7 @@ async def provision_node(params: NodeProvisioningParams) \
'
ias_lt_ipv4_network
'
:
str
(
params
.
device
.
ias_lt_network
.
v4
),
'
ias_lt_ipv6_network
'
:
str
(
params
.
device
.
ias_lt_network
.
v6
),
'
site_country_code
'
:
params
.
device
.
site_country_code
,
'
snmp_location
'
:
f
'
{
params
.
device
.
site_city
}
,
'
f
'
{
params
.
device
.
site_country_code
}
'
f
'
[
{
params
.
device
.
site_latitude
}
,
'
f
'
{
params
.
device
.
site_longitude
}
]
'
,
'
snmp_location
'
:
params
.
device
.
snmp_location
,
'
site_city
'
:
params
.
device
.
site_city
,
'
site_latitude
'
:
params
.
device
.
site_latitude
,
'
site_longitude
'
:
params
.
device
.
site_longitude
,
...
...
@@ -162,6 +152,6 @@ async def provision_node(params: NodeProvisioningParams) \
return
common
.
run_playbook
(
playbook
=
'
base_config.yaml
'
,
inventory
=
f
'
{
params
.
ansible_host
}
:
{
params
.
ansible
_port
}
'
,
inventory
=
f
'
{
params
.
device
.
ts_address
}
:
{
params
.
device
.
ts
_port
}
'
,
extra_vars
=
extra_vars
,
callback
=
params
.
callback
)
This diff is collapsed.
Click to expand it.
test/test_playbook_utils.py
+
2
−
2
View file @
711e78da
...
...
@@ -12,9 +12,9 @@ def test_run_playbook(ansible_playbook_bin, playbook_filename):
TODO: figure out how to use this venv with ansible_runner
TODO: call the ansible_runner.run thread proc
:param
temp_
ansible_
env
: Fixture that points to a temporary venv with
:param ansible_
playbook_bin
: Fixture that points to a temporary venv with
Ansible installed.
:param
temp_ansible_playbook
: Fixture that points to a dummy Ansible
:param
playbook_filename
: Fixture that points to a dummy Ansible
playbook in a temporary location.
"""
playbook_run
=
subprocess
.
run
(
...
...
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