Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions automation/argo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def __init__(self, path: str):
self.web_api_endpoint = automation.get("web_api_endpoint")
self.web_api_token = automation.get("web_api_token")
self.default_ops_profile_file = automation.get("default_ops_profile_file")
self.default_metric_profile_file = automation.get("default_metric_profile_file")
self.default_agg_profile_file = automation.get("default_agg_profile_file")
self.default_services_file = automation.get("default_services_file")
self.default_report_file = automation.get("default_report_file")
self.hdfs_path = run.get("hdfs_path")
self.hdfs_check_path = run.get("hdfs_check_path")
self.flink_path = run.get("flink_path")
Expand Down
149 changes: 147 additions & 2 deletions automation/argo_web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ def create_ops_profile(
url, json=payload, headers=headers, timeout=REQUEST_TIMEOUT
)
response.raise_for_status()
logger.info(
f"tenant: {tenant_name} ({tenant_id}) - web-api ops profile created"
)
return response.json()["data"]["id"]

except requests.exceptions.HTTPError as e:
if e.response.status_code == 409:
logger.warning(
Expand All @@ -188,10 +193,150 @@ def create_ops_profile(
else:
raise

logger.info(
f"tenant: {tenant_name} ({tenant_id}) - web-api ops profile created"
def create_metric_profile(
self,
tenant_id: str,
tenant_name: str,
tenant_access_token: str,
payload: object,
):
"""Http call to web-api to create metric profile"""
logger.debug(
f"tenant: {tenant_name} ({tenant_id}) - web-api creating default metric profile..."
)

url = f"https://{self.config.web_api_endpoint}/api/v2/metric_profiles"
headers = {
"x-api-key": tenant_access_token,
"Accept": "application/json",
}
try:
response = requests.post(
url, json=payload, headers=headers, timeout=REQUEST_TIMEOUT
)
response.raise_for_status()
logger.info(
f"tenant: {tenant_name} ({tenant_id}) - web-api metric profile created"
)
return response.json()["data"]["id"]

except requests.exceptions.HTTPError as e:
if e.response.status_code == 409:
logger.warning(
f"tenant: {tenant_name} ({tenant_id}) - web-api metric profile already exists"
)
return
else:
raise

def create_aggregation_profile(
self,
tenant_id: str,
tenant_name: str,
tenant_access_token: str,
payload: object,
):
"""Http call to web-api to create aggregation profile"""
logger.debug(
f"tenant: {tenant_name} ({tenant_id}) - web-api creating default aggregation profile..."
)

url = f"https://{self.config.web_api_endpoint}/api/v2/aggregation_profiles"
headers = {
"x-api-key": tenant_access_token,
"Accept": "application/json",
}
try:
response = requests.post(
url, json=payload, headers=headers, timeout=REQUEST_TIMEOUT
)
response.raise_for_status()
logger.info(
f"tenant: {tenant_name} ({tenant_id}) - web-api aggregation profile created"
)
return response.json()["data"]["id"]

except requests.exceptions.HTTPError as e:
if e.response.status_code == 409:
logger.warning(
f"tenant: {tenant_name} ({tenant_id}) - web-api aggregation profile already exists"
)
return
else:
raise

def create_default_report(
self,
tenant_id: str,
tenant_name: str,
tenant_access_token: str,
payload: object,
):
"""Http call to web-api to create report"""
logger.debug(
f"tenant: {tenant_name} ({tenant_id}) - web-api creating default report..."
)

url = f"https://{self.config.web_api_endpoint}/api/v2/reports"
headers = {
"x-api-key": tenant_access_token,
"Accept": "application/json",
}
try:
response = requests.post(
url, json=payload, headers=headers, timeout=REQUEST_TIMEOUT
)
response.raise_for_status()
logger.info(
f"tenant: {tenant_name} ({tenant_id}) - web-api default report created"
)
return response.json()["data"]["id"]

except requests.exceptions.HTTPError as e:
if e.response.status_code == 409:
logger.warning(
f"tenant: {tenant_name} ({tenant_id}) - web-api default report already exists"
)
return
else:
raise

def create_topology_service_types(
self,
tenant_id: str,
tenant_name: str,
tenant_access_token: str,
payload: object,
):
"""Http call to web-api to create service types"""
logger.debug(
f"tenant: {tenant_name} ({tenant_id}) - web-api creating default service-types..."
)

url = f"https://{self.config.web_api_endpoint}/api/v2/topology/service-types"
headers = {
"x-api-key": tenant_access_token,
"Accept": "application/json",
}
try:
response = requests.post(
url, json=payload, headers=headers, timeout=REQUEST_TIMEOUT
)
response.raise_for_status()
logger.info(
f"tenant: {tenant_name} ({tenant_id}) - web-api topology service-types created"
)

except requests.exceptions.HTTPError as e:
if e.response.status_code == 409:
logger.warning(
f"tenant: {tenant_name} ({tenant_id}) - web-api topology service-types already exist for specific date"
)
return
else:
raise


def update_ready_state(
self,
tenant_id: str,
Expand Down
31 changes: 31 additions & 0 deletions automation/default.agg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "default_aggregation",
"namespace": "",
"endpoint_group": "SERVICEGROUPS",
"metric_operation": "AND",
"profile_operation": "AND",
"metric_profile": {
"name": "default_metric",
"id": ""
},
"groups": [
{
"name": "services",
"operation": "AND",
"services": [
{
"name": "iam",
"operation": "OR"
},
{
"name": "webportal",
"operation": "OR"
},
{
"name": "api",
"operation": "OR"
}
]
}
]
}
27 changes: 27 additions & 0 deletions automation/default.metric.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "default_metric",
"description": "Default metric profile",
"services": [
{
"service": "api",
"metrics": [
"generic.certificate.validity",
"generic.http.connect"
]
},
{
"service": "webportal",
"metrics": [
"generic.certificate.validity",
"generic.http.connect"
]
},
{
"service": "iam",
"metrics": [
"generic.certificate.validity",
"generic.http.connect"
]
}
]
}
33 changes: 33 additions & 0 deletions automation/default.report.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"disabled": false,
"info": {
"name": "Default",
"description": "Default A/R Report"
},
"computations": {
"ar": true,
"status": true,
"trends": [
"flapping",
"status",
"tags"
]
},
"thresholds": {
"availability": 80,
"reliability": 90,
"uptime": 0.8,
"unknown": 0.1,
"downtime": 0.1
},
"topology_schema": {
"group": {
"type": "PROJECT",
"group": {
"type": "SERVICEGROUPS"
}
}
},
"profiles": [],
"filter_tags": []
}
26 changes: 26 additions & 0 deletions automation/default.services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"name": "api",
"title": "API",
"description": "A generic rest api service accessible through http protocol",
"tags": [
"topology"
]
},
{
"name": "iam",
"title": "Identity Management",
"description": "A generic identity management service",
"tags": [
"topology"
]
},
{
"name": "webportal",
"title": "Webportal",
"description": "A generic web service accessible through http protocol",
"tags": [
"topology"
]
}
]
46 changes: 44 additions & 2 deletions automation/init_compute_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,51 @@ def init_compute_engine(
config.set_tenant_web_api_access(tenant_id, tenant_name, engine_user_key)
config.save()

ops_id = None
metric_id = None
agg_id = None

with open(config.default_ops_profile_file, "r") as f:

payload = json.load(f)
web_api.create_ops_profile(tenant_id, tenant_name, engine_user_key, payload)
ops_payload = json.load(f)
ops_id = web_api.create_ops_profile(
tenant_id, tenant_name, engine_user_key, ops_payload
)

with open(config.default_metric_profile_file, "r") as f:

metric_payload = json.load(f)
metric_id = web_api.create_metric_profile(
tenant_id, tenant_name, engine_user_key, metric_payload
)

with open(config.default_agg_profile_file, "r") as f:

agg_payload = json.load(f)
agg_payload["namespace"] = tenant_name
agg_payload["metric_profile"]["id"] = metric_id
agg_id = web_api.create_aggregation_profile(
tenant_id, tenant_name, engine_user_key, agg_payload
)

with open(config.default_report_file, "r") as f:

report_payload = json.load(f)
profiles = [
{"id": ops_id, "type": "operations"},
{"id": metric_id, "type": "metric"},
{"id": agg_id, "type": "aggregation"},
]
report_payload["profiles"] = profiles
web_api.create_default_report(
tenant_id, tenant_name, engine_user_key, report_payload
)

with open(config.default_services_file, "r") as f:

services_payload = json.load(f)
web_api.create_topology_service_types(
tenant_id, tenant_name, engine_user_key, services_payload
)

return True
Loading