From 07bb34921da6eea1ee8352d269b45c120a637075 Mon Sep 17 00:00:00 2001 From: Peak Wongcharoen Date: Thu, 6 Mar 2025 20:36:58 -0600 Subject: [PATCH 1/4] bugfix: --json not render if --version not provide --- bin/akamai-cloudlets.py | 58 ++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/bin/akamai-cloudlets.py b/bin/akamai-cloudlets.py index 7d7cc68..0a5fbe6 100644 --- a/bin/akamai-cloudlets.py +++ b/bin/akamai-cloudlets.py @@ -1,5 +1,5 @@ """ -Copyright 2020 Akamai Technologies, Inc. All Rights Reserved.. +Copyright 2020 Akamai Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ Authors: vbhat@akamai.com, kchinnan@akamai.com, aetsai@akamai.com """ -PACKAGE_VERSION = '1.2.0' +PACKAGE_VERSION = '1.2.1' # setup logging if not os.path.exists('logs'): @@ -1166,29 +1166,39 @@ def alb_origin(config, type, name_contains, list, loadbalance, version, optjson) if activation_resp.status_code == 200: if len(activation_resp.json()) == 0: root_logger.info('\nno activation history') + if optjson: + print_json(data=lookup_resp.json()) else: - df = pd.DataFrame(activation_resp.json()) - df = df.rename(columns={'originId': 'Load Balancing ID', 'immutable': 'lock', - 'lastModifiedDate': 'Last Modified', 'lastModifiedBy': 'Last Editor', - 'description': 'Version Notes'}) - activation_df = df.pivot(index=['Load Balancing ID', 'version'], columns='network', values='status').reset_index() - activation_df = activation_df.fillna('') - activation_df = activation_df.sort_values(by='version', ascending=False) - activation_df = activation_df.reset_index(drop=True) - - if not activation_df.empty: - merged_df = pd.merge(version_df, activation_df, on=['Load Balancing ID', 'version'], how='left') - merged_df = merged_df.fillna('') - columns = ['Load Balancing ID', 'version', 'lock', 'Last Modified', 'Last Editor', 'deleted'] - if 'Version Notes' in merged_df.columns: - columns.insert(5, 'Version Notes') - if 'STAGING' in merged_df.columns: - columns.insert(6, 'STAGING') - if 'PRODUCTION' in merged_df.columns: - columns.insert(6, 'PRODUCTION') - root_logger.info(tabulate(merged_df[columns], headers=columns, numalign='center', tablefmt='psql', showindex=False)) - else: - root_logger.info(tabulate(version_df[version_columns], headers=version_columns, numalign='center', tablefmt='psql', showindex=False, maxcolwidths=30)) + if optjson: + albs = lookup_resp.json() + acts = activation_resp.json() + for alb in albs: + aa = [act for act in acts if act['version'] == alb['version']] + alb['activation'] = aa + print_json(data=albs) + else: + df = pd.DataFrame(activation_resp.json()) + df = df.rename(columns={'originId': 'Load Balancing ID', 'immutable': 'lock', + 'lastModifiedDate': 'Last Modified', 'lastModifiedBy': 'Last Editor', + 'description': 'Version Notes'}) + activation_df = df.pivot(index=['Load Balancing ID', 'version'], columns='network', values='status').reset_index() + activation_df = activation_df.fillna('') + activation_df = activation_df.sort_values(by='version', ascending=False) + activation_df = activation_df.reset_index(drop=True) + + if not activation_df.empty: + merged_df = pd.merge(version_df, activation_df, on=['Load Balancing ID', 'version'], how='left') + merged_df = merged_df.fillna('') + columns = ['Load Balancing ID', 'version', 'lock', 'Last Modified', 'Last Editor', 'deleted'] + if 'Version Notes' in merged_df.columns: + columns.insert(5, 'Version Notes') + if 'STAGING' in merged_df.columns: + columns.insert(6, 'STAGING') + if 'PRODUCTION' in merged_df.columns: + columns.insert(6, 'PRODUCTION') + root_logger.info(tabulate(merged_df[columns], headers=columns, numalign='center', tablefmt='psql', showindex=False)) + else: + root_logger.info(tabulate(version_df[version_columns], headers=version_columns, numalign='center', tablefmt='psql', showindex=False, maxcolwidths=30)) if loadbalance and version: version_resp = cloudlet_object.get_load_balancing_version(session, loadbalance, version) From 143f001e147fa6e5bcd5f317ef235f60b8435df9 Mon Sep 17 00:00:00 2001 From: Peak Wongcharoen Date: Thu, 6 Mar 2025 20:37:49 -0600 Subject: [PATCH 2/4] bump to v1.2.1 --- cli.json | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli.json b/cli.json index 421fa06..eeb5594 100644 --- a/cli.json +++ b/cli.json @@ -8,7 +8,7 @@ "aliases": [ "cloudlets" ], - "version": "1.2.0", + "version": "1.2.1", "description": "Manage Akamai Cloudlets" } ] diff --git a/requirements.txt b/requirements.txt index f189473..059be9a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ flake8==7.1.1 openpyxl==3.1.2 pandas==2.2.2 pre-commit==3.3.3 -prettytable==1.0.0 +prettytable==3.15.1 requests>=2.25.1,<3.0 rich==13.3.3 tabulate==0.9.0 From 8eca22df7754de17f3cc7df212c8e712417c3591 Mon Sep 17 00:00:00 2001 From: Peak Wongcharoen Date: Thu, 6 Mar 2025 20:44:36 -0600 Subject: [PATCH 3/4] bugfix: show normal table without --json --- bin/akamai-cloudlets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/akamai-cloudlets.py b/bin/akamai-cloudlets.py index 0a5fbe6..eb80e7c 100644 --- a/bin/akamai-cloudlets.py +++ b/bin/akamai-cloudlets.py @@ -1168,6 +1168,8 @@ def alb_origin(config, type, name_contains, list, loadbalance, version, optjson) root_logger.info('\nno activation history') if optjson: print_json(data=lookup_resp.json()) + else: + root_logger.info(tabulate(version_df[version_columns], headers=version_columns, numalign='center', tablefmt='psql', showindex=False, maxcolwidths=30)) else: if optjson: albs = lookup_resp.json() From faec885470d35697a3b33694745288b4775b2d2e Mon Sep 17 00:00:00 2001 From: Peak Wongcharoen Date: Thu, 6 Mar 2025 20:52:07 -0600 Subject: [PATCH 4/4] security update --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 059be9a..cc8207d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,5 @@ prettytable==3.15.1 requests>=2.25.1,<3.0 rich==13.3.3 tabulate==0.9.0 -urllib3==2.1.0 +urllib3>=2.2.2 xlsxwriter==3.0.9