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

Merge branch 'feature/cleanup' into 'develop'

Feature/cleanup

See merge request !18
parents b9a3897d b25e7012
No related branches found
No related tags found
1 merge request!18Feature/cleanup
[MAIN]
extension-pkg-whitelist=pydantic
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
# Note that it does not contain TODO, only the default FIXME and XXX
notes=FIXME,
XXX
"""
The main module, from where GSO is run.
"""
from orchestrator import OrchestratorCore from orchestrator import OrchestratorCore
from orchestrator.cli.main import app as core_cli from orchestrator.cli.main import app as core_cli
from orchestrator.settings import AppSettings from orchestrator.settings import AppSettings
import gso.products # noqa: F401 import gso.products # pylint: disable=unused-import
import gso.workflows # noqa: F401 import gso.workflows # pylint: disable=unused-import
app = OrchestratorCore(base_settings=AppSettings()) app = OrchestratorCore(base_settings=AppSettings())
......
"""
Module that updated the domain model of GSO. Should contain all types of
subscriptions.
"""
from orchestrator.domain import SUBSCRIPTION_MODEL_REGISTRY from orchestrator.domain import SUBSCRIPTION_MODEL_REGISTRY
from gso.products.product_types.device import Device from gso.products.product_types.device import Device
......
"""
The Provisioning Proxy service, which interacts with LSO running externally.
LSO is responsible for executing Ansible playbooks, that deploy subscriptions.
"""
import json import json
import logging import logging
...@@ -53,7 +57,8 @@ def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr, ...@@ -53,7 +57,8 @@ def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr,
callback_url = f'{settings.load_oss_params().GENERAL.public_hostname}' \ callback_url = f'{settings.load_oss_params().GENERAL.public_hostname}' \
f'/api/processes/{process_id}/resume' f'/api/processes/{process_id}/resume'
logger.debug(f'[provisioning proxy] provisioning for process {process_id}') logger.debug('[provisioning proxy] provisioning for process %s',
process_id)
parameters.update({'callback': callback_url}) parameters.update({'callback': callback_url})
url = f'{pp_params.scheme}://{pp_params.api_base}/api/{endpoint}' url = f'{pp_params.scheme}://{pp_params.api_base}/api/{endpoint}'
...@@ -61,11 +66,11 @@ def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr, ...@@ -61,11 +66,11 @@ def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr,
request = None request = None
if operation == CUDOperation.POST: if operation == CUDOperation.POST:
request = requests.post(url, json=parameters) request = requests.post(url, json=parameters, timeout=10000)
elif operation == CUDOperation.PUT: elif operation == CUDOperation.PUT:
request = requests.put(url, json=parameters) request = requests.put(url, json=parameters, timeout=10000)
elif operation == CUDOperation.DELETE: elif operation == CUDOperation.DELETE:
request = requests.delete(url, json=parameters) request = requests.delete(url, json=parameters, timeout=10000)
if request.status_code != 200: if request.status_code != 200:
print(request.content) print(request.content)
...@@ -136,7 +141,7 @@ def provision_ip_trunk(subscription: IptrunkProvisioning, ...@@ -136,7 +141,7 @@ def provision_ip_trunk(subscription: IptrunkProvisioning,
# 'dry_run': dry_run, # 'dry_run': dry_run,
# 'old_subscription': old_subscription, # 'old_subscription': old_subscription,
# 'subscription': new_subscription # 'subscription': new_subscription
# # FIXME missing parameters # # ... missing parameters
# } # }
# #
# _send_request('ip_trunk', parameters, process_id, CUDOperation.PUT) # _send_request('ip_trunk', parameters, process_id, CUDOperation.PUT)
......
"""
GSO settings, ensuring that the required parameters are set correctly.
"""
import ipaddress import ipaddress
import json import json
import os import os
from pydantic import BaseSettings from pydantic import BaseSettings, Field
class GeneralParams(BaseSettings): class GeneralParams(BaseSettings):
"""
General parameters for a GSO configuration file.
"""
#: The hostname that GSO is publicly served at, used for building the
#: callback URL that the provisioning proxy uses.
public_hostname: str public_hostname: str
class InfoBloxParams(BaseSettings): class InfoBloxParams(BaseSettings):
"""
Parameters related to InfoBlox.
"""
scheme: str scheme: str
wapi_version: str wapi_version: str
host: str host: str
...@@ -17,24 +28,37 @@ class InfoBloxParams(BaseSettings): ...@@ -17,24 +28,37 @@ class InfoBloxParams(BaseSettings):
class V4NetworkParams(BaseSettings): class V4NetworkParams(BaseSettings):
"""
A set of parameters that describe an IPv4 network in InfoBlox.
"""
containers: list[ipaddress.IPv4Network] containers: list[ipaddress.IPv4Network]
networks: list[ipaddress.IPv4Network] networks: list[ipaddress.IPv4Network]
mask: int # TODO: validation on mask? mask: int = Field(None, ge=0, le=32)
class V6NetworkParams(BaseSettings): class V6NetworkParams(BaseSettings):
"""
A set of parameters that describe an IPv6 network in InfoBlox.
"""
containers: list[ipaddress.IPv6Network] containers: list[ipaddress.IPv6Network]
networks: list[ipaddress.IPv6Network] networks: list[ipaddress.IPv6Network]
mask: int # TODO: validation on mask? mask: int = Field(None, ge=0, le=128)
class ServiceNetworkParams(BaseSettings): class ServiceNetworkParams(BaseSettings):
"""
Parameters for InfoBlox that describe IPv4 and v6 networks, and the
corresponding domain name that should be used as a suffix.
"""
V4: V4NetworkParams V4: V4NetworkParams
V6: V6NetworkParams V6: V6NetworkParams
domain_name: str domain_name: str
class IPAMParams(BaseSettings): class IPAMParams(BaseSettings):
"""
A set of parameters related to IPAM.
"""
INFOBLOX: InfoBloxParams INFOBLOX: InfoBloxParams
LO: ServiceNetworkParams LO: ServiceNetworkParams
TRUNK: ServiceNetworkParams TRUNK: ServiceNetworkParams
...@@ -42,6 +66,9 @@ class IPAMParams(BaseSettings): ...@@ -42,6 +66,9 @@ class IPAMParams(BaseSettings):
class ProvisioningProxyParams(BaseSettings): class ProvisioningProxyParams(BaseSettings):
"""
Parameters for the provisioning proxy.
"""
scheme: str scheme: str
api_base: str api_base: str
auth: str # FIXME: unfinished auth: str # FIXME: unfinished
...@@ -49,19 +76,22 @@ class ProvisioningProxyParams(BaseSettings): ...@@ -49,19 +76,22 @@ class ProvisioningProxyParams(BaseSettings):
class OSSParams(BaseSettings): class OSSParams(BaseSettings):
"""
The set of parameters required for running GSO.
"""
GENERAL: GeneralParams GENERAL: GeneralParams
IPAM: IPAMParams IPAM: IPAMParams
RESOURCE_MANAGER_API_PREFIX: str # api prefix RESOURCE_MANAGER_API_PREFIX: str
PROVISIONING_PROXY: ProvisioningProxyParams PROVISIONING_PROXY: ProvisioningProxyParams
def load_oss_params() -> OSSParams: def load_oss_params() -> OSSParams:
""" """
look for OSS_PARAMS_FILENAME in the environment and load the look for OSS_PARAMS_FILENAME in the environment and load the parameters
parameters from that file from that file.
""" """
with open(os.environ['OSS_PARAMS_FILENAME']) as f: with open(os.environ['OSS_PARAMS_FILENAME'], encoding='utf-8') as file:
return OSSParams(**json.loads(f.read())) return OSSParams(**json.loads(file.read()))
if __name__ == '__main__': if __name__ == '__main__':
......
"""
init class that imports all workflows into GSO.
"""
from orchestrator.workflows import LazyWorkflowInstance from orchestrator.workflows import LazyWorkflowInstance
LazyWorkflowInstance("gso.workflows.device.create_device", "create_device") LazyWorkflowInstance("gso.workflows.device.create_device", "create_device")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment