From 107d71b96a3a12432c63297907e71cc6ad479f1b Mon Sep 17 00:00:00 2001 From: "k.kedron" Date: Fri, 25 Jun 2021 14:39:39 +0200 Subject: Fix a1pesim scripts - update dace-cli for new DCAE NB API - change 644 to 755 for all scripts Issue-ID: INT-1887 Signed-off-by: Krystian Kedron Change-Id: Id1f71235904ae8e99145c2aa2ce843042ea7ee53 --- operations/dcae/dcae-cli.py | 25 +++++++++++++------------ operations/dcae/dcae.sh | 0 operations/dcae/rapps.sh | 9 ++++++++- 3 files changed, 21 insertions(+), 13 deletions(-) mode change 100644 => 100755 operations/dcae/dcae-cli.py mode change 100644 => 100755 operations/dcae/dcae.sh mode change 100644 => 100755 operations/dcae/rapps.sh diff --git a/operations/dcae/dcae-cli.py b/operations/dcae/dcae-cli.py old mode 100644 new mode 100755 index 520037e..49db4f1 --- a/operations/dcae/dcae-cli.py +++ b/operations/dcae/dcae-cli.py @@ -13,14 +13,15 @@ https://git.onap.org/ccsdk/dashboard/tree/ccsdk-app-os/src/main/resources/swagge """ import argparse import base64 - -import requests import json -import yaml -import time import os -import sys import re +import sys +import time +from datetime import datetime + +import requests +import yaml try: from urllib.parse import quote @@ -64,10 +65,9 @@ def print_rows_formatted(matrix): print("".join(word.ljust(col_width) for word in row)) print -def epoch_2_date(epoch): - if len(epoch) > 10: - epoch = epoch[:10] - return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(float(epoch))) + +def str_2_date(_str): + return datetime.strptime(_str, '%Y-%m-%dT%H:%M:%S.%fZ').strftime('%Y-%m-%d %H:%M:%S') def create_filter(_filter): @@ -162,7 +162,7 @@ def list_deployments(): data = [list_headers] if "items" in r_json: for dep in r_json["items"]: - row = [dep['service_id'], epoch_2_date(dep['created']), epoch_2_date(dep['modified'])] + row = [dep['id'], str_2_date(dep['created_at']), str_2_date(dep['updated_at'])] data.append(row) print_rows_formatted(data) print("Total " + str(total_items) + " deployments.") @@ -281,15 +281,16 @@ def wait_deployment(deployment_id, operation, timeout=240): def get_workflow_id(deployment_id, operation): r = executions_status(deployment_id, args.tenant) print_get_payload(r) + print("Get status for operation: %s" % operation) return get_executions_items(r, "workflow_id", operation) failed = False - result = "" op_timeout = Timeout(timeout, "deployment " + deployment_id + " operation " + operation) while True: wf = get_workflow_id(deployment_id, operation) - if not wf: + if wf: status = wf[0]["status"] + print("Operation status is %s" % status) if status in ["terminated", "failed"]: result = "SUCCESS" if status == "terminated" else "FAILED" if status == "failed": diff --git a/operations/dcae/dcae.sh b/operations/dcae/dcae.sh old mode 100644 new mode 100755 diff --git a/operations/dcae/rapps.sh b/operations/dcae/rapps.sh old mode 100644 new mode 100755 index 9af8284..8d51f5b --- a/operations/dcae/rapps.sh +++ b/operations/dcae/rapps.sh @@ -50,7 +50,14 @@ case "$operation" in rapp_filter=$2 # Create inputs. Currently the only input to be provided is database password and that is only # applicable for datacollector r-app at the moment; - . ./inputs_database_password.sh + if [[ -z ${DATABASE_PASSWORD:-} ]]; then + echo "DATABASE_PASSWORD value is missing!" + echo "Run: " + echo "\"kubectl get secret \`kubectl get secrets | grep mariadb-galera-db-root-password | awk '{print \$1}'\` -o jsonpath="{.data.password}" | base64 --decode\" in the ONAP k8s" + echo "and after that export DATABASE_PASSWORD=\${command_out}" + exit 1 + fi + deployment_inputs="database_password=${DATABASE_PASSWORD}" do_deploy() { local blueprint_file=$1 -- cgit 1.2.3-korg