diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000000000000000000000000000000000000..d5b831302d169f0ce8adbc8835d2909eee7fd51b --- /dev/null +++ b/.pylintrc @@ -0,0 +1,9 @@ +[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 diff --git a/gso/main.py b/gso/main.py index ba2582a89cd363aa761b67b6dbcf4cddc388344e..6d9a9378446f72c501c57d1075822adfe630c96f 100644 --- a/gso/main.py +++ b/gso/main.py @@ -1,8 +1,11 @@ +""" +The main module, from where GSO is run. +""" from orchestrator import OrchestratorCore from orchestrator.cli.main import app as core_cli from orchestrator.settings import AppSettings -import gso.products # noqa: F401 -import gso.workflows # noqa: F401 +import gso.products # pylint: disable=unused-import +import gso.workflows # pylint: disable=unused-import app = OrchestratorCore(base_settings=AppSettings()) diff --git a/gso/products/__init__.py b/gso/products/__init__.py index 857128fb672bf6350e674bfc81e8d89fa2765af2..319d1578b865217c83359a744274ac41d1e41f3e 100644 --- a/gso/products/__init__.py +++ b/gso/products/__init__.py @@ -1,3 +1,7 @@ +""" +Module that updated the domain model of GSO. Should contain all types of +subscriptions. +""" from orchestrator.domain import SUBSCRIPTION_MODEL_REGISTRY from gso.products.product_types.device import Device diff --git a/gso/settings.py b/gso/settings.py index 7167785cb32245f51316809db517bd09bbc251d8..caebdcc34f2ecc16428e8757d6a9b8fb5fdec660 100644 --- a/gso/settings.py +++ b/gso/settings.py @@ -1,14 +1,25 @@ +""" +GSO settings, ensuring that the required parameters are set correctly. +""" import ipaddress import json import os -from pydantic import BaseSettings +from pydantic import BaseSettings, Field 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 class InfoBloxParams(BaseSettings): + """ + Parameters related to InfoBlox. + """ scheme: str wapi_version: str host: str @@ -17,24 +28,37 @@ class InfoBloxParams(BaseSettings): class V4NetworkParams(BaseSettings): + """ + A set of parameters that describe an IPv4 network in InfoBlox. + """ containers: list[ipaddress.IPv4Network] networks: list[ipaddress.IPv4Network] - mask: int # TODO: validation on mask? + mask: int = Field(None, ge=0, le=32) class V6NetworkParams(BaseSettings): + """ + A set of parameters that describe an IPv6 network in InfoBlox. + """ containers: list[ipaddress.IPv6Network] networks: list[ipaddress.IPv6Network] - mask: int # TODO: validation on mask? + mask: int = Field(None, ge=0, le=128) 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 V6: V6NetworkParams domain_name: str class IPAMParams(BaseSettings): + """ + A set of parameters related to IPAM. + """ INFOBLOX: InfoBloxParams LO: ServiceNetworkParams TRUNK: ServiceNetworkParams @@ -42,6 +66,9 @@ class IPAMParams(BaseSettings): class ProvisioningProxyParams(BaseSettings): + """ + Parameters for the provisioning proxy. + """ scheme: str api_base: str auth: str # FIXME: unfinished @@ -49,19 +76,22 @@ class ProvisioningProxyParams(BaseSettings): class OSSParams(BaseSettings): + """ + The set of parameters required for running GSO. + """ GENERAL: GeneralParams IPAM: IPAMParams - RESOURCE_MANAGER_API_PREFIX: str # api prefix + RESOURCE_MANAGER_API_PREFIX: str PROVISIONING_PROXY: ProvisioningProxyParams def load_oss_params() -> OSSParams: """ - look for OSS_PARAMS_FILENAME in the environment and load the - parameters from that file + look for OSS_PARAMS_FILENAME in the environment and load the parameters + from that file. """ - with open(os.environ['OSS_PARAMS_FILENAME']) as f: - return OSSParams(**json.loads(f.read())) + with open(os.environ['OSS_PARAMS_FILENAME']) as file: + return OSSParams(**json.loads(file.read())) if __name__ == '__main__':