Skip to content
Snippets Groups Projects
Commit b013d2e7 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Merge branch 'feature/update-device-signature' into 'develop'

update device endpoint to match output from GSO

See merge request !16
parents 592a0d95 711e78da
No related branches found
No related tags found
1 merge request!16update device endpoint to match output from GSO
...@@ -48,28 +48,19 @@ class DeviceParams(pydantic.BaseModel): ...@@ -48,28 +48,19 @@ class DeviceParams(pydantic.BaseModel):
This device can either be a router or a switch, from the different vendors This device can either be a router or a switch, from the different vendors
that are supported. that are supported.
:param fqdn: :param str fqdn:
:type fqdn: str :param InterfaceAddress lo_address:
:param lo_address: :param str lo_iso_address:
:type lo_address: :class:`InterfaceAddress` :param IPv4Network si_ipv4_network:
:param lo_iso_address: :param InterfaceNetwork ias_lt_network:
:type lo_iso_address: str :param str site_country_code:
:param si_ipv4_network: :param str site_city:
:type si_ipv4_network: ipaddress.IPv4Network :param str site_latitude:
:param ias_lt_network: :param str site_longitude:
:type ias_lt_network: :class:`InterfaceNetwork` :param str device_type:
:param site_country_code: :param str device_vendor:
:type site_country_code: str :param str ts_address:
:param site_city: :param int ts_port:
: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
""" """
#: FQDN of a device, TODO: add some validation #: FQDN of a device, TODO: add some validation
fqdn: str fqdn: str
...@@ -90,10 +81,17 @@ class DeviceParams(pydantic.BaseModel): ...@@ -90,10 +81,17 @@ class DeviceParams(pydantic.BaseModel):
site_latitude: str site_latitude: str
#: Longitude of the device site. #: Longitude of the device site.
site_longitude: str site_longitude: str
#: SNMP location of a device
snmp_location: str
#: Type of device, either ``router`` or ``switch``. #: Type of device, either ``router`` or ``switch``.
device_type: str device_type: str
#: The device vendor, for specific configuration. #: The device vendor, for specific configuration.
device_vendor: str 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): class NodeProvisioningParams(pydantic.BaseModel):
...@@ -116,11 +114,6 @@ class NodeProvisioningParams(pydantic.BaseModel): ...@@ -116,11 +114,6 @@ class NodeProvisioningParams(pydantic.BaseModel):
callback: pydantic.HttpUrl # TODO: NAT-151 callback: pydantic.HttpUrl # TODO: NAT-151
#: Parameters for the new device. #: Parameters for the new device.
device: DeviceParams 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. #: Whether this playbook execution should be a dry run, or run for real.
#: defaults to ``True`` for obvious reasons, also making it an optional #: defaults to ``True`` for obvious reasons, also making it an optional
#: parameter. #: parameter.
...@@ -147,10 +140,7 @@ async def provision_node(params: NodeProvisioningParams) \ ...@@ -147,10 +140,7 @@ async def provision_node(params: NodeProvisioningParams) \
'ias_lt_ipv4_network': str(params.device.ias_lt_network.v4), 'ias_lt_ipv4_network': str(params.device.ias_lt_network.v4),
'ias_lt_ipv6_network': str(params.device.ias_lt_network.v6), 'ias_lt_ipv6_network': str(params.device.ias_lt_network.v6),
'site_country_code': params.device.site_country_code, 'site_country_code': params.device.site_country_code,
'snmp_location': f'{params.device.site_city},' 'snmp_location': params.device.snmp_location,
f'{params.device.site_country_code}'
f'[{params.device.site_latitude},'
f'{params.device.site_longitude}]',
'site_city': params.device.site_city, 'site_city': params.device.site_city,
'site_latitude': params.device.site_latitude, 'site_latitude': params.device.site_latitude,
'site_longitude': params.device.site_longitude, 'site_longitude': params.device.site_longitude,
...@@ -162,6 +152,6 @@ async def provision_node(params: NodeProvisioningParams) \ ...@@ -162,6 +152,6 @@ async def provision_node(params: NodeProvisioningParams) \
return common.run_playbook( return common.run_playbook(
playbook='base_config.yaml', 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, extra_vars=extra_vars,
callback=params.callback) callback=params.callback)
...@@ -12,9 +12,9 @@ def test_run_playbook(ansible_playbook_bin, playbook_filename): ...@@ -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: figure out how to use this venv with ansible_runner
TODO: call the ansible_runner.run thread proc 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. 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 in a temporary location.
""" """
playbook_run = subprocess.run( playbook_run = subprocess.run(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment