From b7f6e248b3481ec4839106da143ffe6c96242f5b Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 15 Mar 2023 18:08:53 +0530 Subject: [PATCH] updating few lines as per the latest branch --- remote_monitoring_demo/demo.py | 19 +++++++++++-------- remote_monitoring_demo/kruize/kruize.py | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/remote_monitoring_demo/demo.py b/remote_monitoring_demo/demo.py index 4d7b64af..fbfb4643 100644 --- a/remote_monitoring_demo/demo.py +++ b/remote_monitoring_demo/demo.py @@ -39,8 +39,11 @@ def main(argv): json_data = json.load(open(create_exp_json_file)) find.append(json_data[0]['experiment_name']) - find.append(json_data[0]['deployment_name']) - find.append(json_data[0]['namespace']) + find.append(json_data[0]['kubernetes_objects'][0]['name']) + find.append(json_data[0]['kubernetes_objects'][0]['namespace']) + + print(find) + try: opts, _ = getopt.getopt(argv,"h:c:") @@ -71,11 +74,11 @@ def main(argv): create_experiment(tmp_create_exp_json_file) if i == 0: - json_data = json.load(open(create_exp_json_file)) + json_data = json.load(open(tmp_create_exp_json_file)) experiment_name = json_data[0]['experiment_name'] - deployment_name = json_data[0]['deployment_name'] - namespace = json_data[0]['namespace'] + deployment_name = json_data[0]['kubernetes_objects'][0]['name'] + namespace = json_data[0]['kubernetes_objects'][0]['namespace'] print("Experiment name = ", experiment_name) print("Deployment name = ", deployment_name) @@ -96,16 +99,16 @@ def main(argv): # Sleep time.sleep(5) - reco = list_recommendations(experiment_name, deployment_name, namespace) + reco = list_recommendations(experiment_name) recommendations_json_arr.append(reco) # Dump the results & recommendations into json files with open('recommendations_data.json', 'w') as f: - json.dump(recommendations_json_arr, f) + json.dump(recommendations_json_arr, f, indent=4) list_exp_json = list_experiments() with open('usage_data.json', 'w') as f: - json.dump(list_exp_json, f) + json.dump(list_exp_json, f, indent=4) if __name__ == '__main__': diff --git a/remote_monitoring_demo/kruize/kruize.py b/remote_monitoring_demo/kruize/kruize.py index fa87d6eb..517e175a 100644 --- a/remote_monitoring_demo/kruize/kruize.py +++ b/remote_monitoring_demo/kruize/kruize.py @@ -97,7 +97,7 @@ def update_results(result_json_file): print(response.text) return response -def list_recommendations(experiment_name, deployment_name, namespace): +def list_recommendations(experiment_name): """ Description: This function obtains the recommendations from Kruize using listRecommendations API @@ -108,7 +108,7 @@ def list_recommendations(experiment_name, deployment_name, namespace): url = URL + "/listRecommendations" print(f"URL = {url}") - PARAMS = {'experiment_name': experiment_name, 'deployment_name': deployment_name, 'namespace': namespace} + PARAMS = {'experiment_name': experiment_name} response = requests.get(url = url, params = PARAMS) print(f"Response status code = {response.status_code}")