7 Commits

Author SHA1 Message Date
e6e9a747ca Merge branch 'main' into add_cloud_environments
All checks were successful
Run Tox Check / tox-py312 (pull_request) Successful in 16s
Run Tox Check / tox-pep8 (pull_request) Successful in 15s
2025-08-13 12:05:28 +00:00
a957e7ff26 Merge branch 'add_cloud_environments' of ssh://gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata-rework into add_cloud_environments
All checks were successful
gl/check check status: success (a957e7ff269bb2bafe0dae90e38f4045e2ffdba8)
2025-07-15 12:45:06 +00:00
3e0dc71b90 fix pep8 issues 2025-07-15 12:43:42 +00:00
2c4002cb84 Merge branch 'main' into add_cloud_environments 2025-07-15 12:43:24 +00:00
5f367e0185 fix typo 2025-07-14 12:19:40 +00:00
2bb9971769 Merge branch 'main' into add_cloud_environments
Some checks failed
gl/check check status: failure (2bb9971769657ce3879a920db5a1dba2725ded65)
2025-07-14 12:18:50 +00:00
04bf5aaa52 add cloud_environments
Some checks are pending
gl/check check status: pending (04bf5aaa52cf68129fdc97d4ae6e6d673978366a)
2025-07-14 12:18:21 +00:00
7 changed files with 21 additions and 37 deletions

View File

@ -14,8 +14,7 @@
from pathlib import Path from pathlib import Path
import json import json
BASE_DIR = Path(__file__).resolve().parent analytics_path = Path("otc_metadata/analytics/public")
analytics_path = BASE_DIR / "public"
cloud_environments = [ cloud_environments = [
'eu_de', 'eu_de',
@ -25,8 +24,8 @@ analytics_data = {k: [] for k in cloud_environments}
# Open and read the json data files # Open and read the json data files
for env in cloud_environments: for env in cloud_environments:
file_path = analytics_path / f"{env}.json" file_path = analytics_path.joinpath(f"{env}.json")
with file_path.open(encoding="utf-8") as file: with open(file_path, 'r') as file:
analytics_data[env] = json.load(file) analytics_data[env] = json.load(file)

View File

@ -8,5 +8,5 @@
"sfs", "sfs",
"iam", "iam",
"elb", "elb",
"vpn" "apig"
] ]

View File

@ -7,6 +7,6 @@
"rds", "rds",
"iam", "iam",
"elb", "elb",
"vpn", "cbr",
"cbr" "vpc"
] ]

View File

@ -0,0 +1,2 @@
---
name: eu_de

View File

@ -0,0 +1,2 @@
---
name: swiss

View File

@ -17,6 +17,7 @@
# documents/services/service_categories is being merged with # documents/services/service_categories is being merged with
# the content here. # the content here.
--- ---
cloud_environments: []
documents: [] documents: []
service_categories: [] service_categories: []
services: [] services: []

View File

@ -62,10 +62,20 @@ class Services(object):
if other in self._service_data["service_categories"]: if other in self._service_data["service_categories"]:
self._service_data["service_categories"].remove(other) self._service_data["service_categories"].remove(other)
self._service_data["service_categories"].append(other) self._service_data["service_categories"].append(other)
# sort cloud environments by <name>
self._service_data["cloud_environments"] = sorted(
self._service_data["cloud_environments"],
key=lambda x: f"{x.get('name')}",
)
def _rewrite_data(self): def _rewrite_data(self):
otc_metadata.data.rewrite_data("services.yaml", self._service_data) otc_metadata.data.rewrite_data("services.yaml", self._service_data)
@property
def all_cloud_environments(self):
"Cloud Environments data listing."
return copy.deepcopy(self._service_data["cloud_environments"])
@property @property
def all_services(self): def all_services(self):
"Service Categories data listing." "Service Categories data listing."
@ -475,33 +485,3 @@ class Services(object):
res.sort(key=lambda x: x.get("service_title", "").lower()) res.sort(key=lambda x: x.get("service_title", "").lower())
return res return res
def all_services_by_cloud_environment_as_dict(self, cloud_environment, environments):
"""Retrieve all services filtered by cloud_environment
Returns a dict keyed by service_type.
"""
res = {}
if not (environments and cloud_environment):
raise Exception(
"No cloud_environment or environments specified in function all_services_by_cloud_environment."
)
for srv in self.all_services:
for srv_cloud_environment in srv.get("cloud_environments", []):
if srv_cloud_environment.get("name") == cloud_environment:
for environment in environments:
if srv_cloud_environment.get("visibility") == environment:
service_type = srv.get("service_type")
if service_type:
res[service_type] = srv
break
res = dict(
sorted(
res.items(),
key=lambda item: item[1].get("service_type", "").lower()
)
)
return res