From c3c750d338ffe20ee9fd79a70f6294760cb1bf66 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Wed, 3 May 2023 14:47:49 +0200 Subject: [PATCH] Update oss-params and add call to provisioning proxy --- gso/oss-params-example.json | 5 ++++- gso/services/provisioning_proxy.py | 20 ++++++++++++-------- gso/settings.py | 5 +++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/gso/oss-params-example.json b/gso/oss-params-example.json index 98ee26d5..86e65d7f 100644 --- a/gso/oss-params-example.json +++ b/gso/oss-params-example.json @@ -1,4 +1,7 @@ { + "GENERAL": { + "public_hostname": "https://gap.geant.org" + }, "RESOURCE_MANAGER_API_PREFIX": "http://localhost:44444", "IPAM": { "INFOBLOX": { @@ -22,4 +25,4 @@ "auth": "Bearer <token>", "api_version": 1123 } -} \ No newline at end of file +} diff --git a/gso/services/provisioning_proxy.py b/gso/services/provisioning_proxy.py index ec282b84..d1dd1864 100644 --- a/gso/services/provisioning_proxy.py +++ b/gso/services/provisioning_proxy.py @@ -1,9 +1,8 @@ import logging -from gso.products.product_types.device \ - import DeviceBlock +from gso.products.product_types.device import DeviceBlock from gso import settings -# import requests +import requests logger = logging.getLogger(__name__) @@ -17,8 +16,13 @@ def provision_node( logger.debug(f'[disabled] provisioning node {node_subscription_params}') - # r = requests.get( - # f'https://{pp_params.api_base}' - # f'/api/version', - # params=node_subscription_params.dict()) - # r.raise_for_status() + parameters = { + 'callback': oss.GENERAL.public_hostname, # TODO: implement + 'device': node_subscription_params.dict() + } + + r = requests.post( + f'https://{pp_params.api_base}' + f'/api/device', + params=parameters) + r.raise_for_status() diff --git a/gso/settings.py b/gso/settings.py index 0846e5f2..a5e13d6c 100644 --- a/gso/settings.py +++ b/gso/settings.py @@ -4,6 +4,10 @@ import os from pydantic import BaseSettings +class GeneralParams: + public_hostname: str + + class InfoBloxParams(BaseSettings): scheme: str wapi_version: str @@ -40,6 +44,7 @@ class ProvisioningProxyParams(BaseSettings): class OSSParams(BaseSettings): + GENERAL: GeneralParams IPAM: IPAMParams RESOURCE_MANAGER_API_PREFIX: str # api prefix PROVISIONING_PROXY: ProvisioningProxyParams -- GitLab