Compare commits
7 Commits
analytics-
...
add_cloud_
Author | SHA1 | Date | |
---|---|---|---|
e6e9a747ca | |||
a957e7ff26 | |||
3e0dc71b90 | |||
2c4002cb84 | |||
5f367e0185 | |||
2bb9971769 | |||
04bf5aaa52 |
@ -14,8 +14,7 @@
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
analytics_path = BASE_DIR / "public"
|
||||
analytics_path = Path("otc_metadata/analytics/public")
|
||||
|
||||
cloud_environments = [
|
||||
'eu_de',
|
||||
@ -25,8 +24,8 @@ analytics_data = {k: [] for k in cloud_environments}
|
||||
|
||||
# Open and read the json data files
|
||||
for env in cloud_environments:
|
||||
file_path = analytics_path / f"{env}.json"
|
||||
with file_path.open(encoding="utf-8") as file:
|
||||
file_path = analytics_path.joinpath(f"{env}.json")
|
||||
with open(file_path, 'r') as file:
|
||||
analytics_data[env] = json.load(file)
|
||||
|
||||
|
||||
|
@ -8,5 +8,5 @@
|
||||
"sfs",
|
||||
"iam",
|
||||
"elb",
|
||||
"vpn"
|
||||
"apig"
|
||||
]
|
@ -7,6 +7,6 @@
|
||||
"rds",
|
||||
"iam",
|
||||
"elb",
|
||||
"vpn",
|
||||
"cbr"
|
||||
"cbr",
|
||||
"vpc"
|
||||
]
|
2
otc_metadata/data/cloud_environments/eu_de.yaml
Normal file
2
otc_metadata/data/cloud_environments/eu_de.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
name: eu_de
|
2
otc_metadata/data/cloud_environments/swiss.yaml
Normal file
2
otc_metadata/data/cloud_environments/swiss.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
name: swiss
|
@ -17,6 +17,7 @@
|
||||
# documents/services/service_categories is being merged with
|
||||
# the content here.
|
||||
---
|
||||
cloud_environments: []
|
||||
documents: []
|
||||
service_categories: []
|
||||
services: []
|
||||
|
@ -62,10 +62,20 @@ class Services(object):
|
||||
if other in self._service_data["service_categories"]:
|
||||
self._service_data["service_categories"].remove(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):
|
||||
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
|
||||
def all_services(self):
|
||||
"Service Categories data listing."
|
||||
@ -475,33 +485,3 @@ class Services(object):
|
||||
res.sort(key=lambda x: x.get("service_title", "").lower())
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user