From a5e62f870e4699a861bc83eab308cb96965bdc87 Mon Sep 17 00:00:00 2001 From: Devdatta Kulkarni Date: Sat, 3 Aug 2024 20:24:36 +0000 Subject: [PATCH] License support - review feedback update --- deploy/kubeconfiggenerator.py | 20 ++++++++++---------- plugins/crlicense.py | 2 +- plugins/kubectl-license-delete | 2 -- plugins/kubectl-license-get | 2 -- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/deploy/kubeconfiggenerator.py b/deploy/kubeconfiggenerator.py index fba44ff1..aee3140d 100644 --- a/deploy/kubeconfiggenerator.py +++ b/deploy/kubeconfiggenerator.py @@ -1209,17 +1209,17 @@ def check_license(): msg = "" - cmd1 = "kubectl get " + kind - out1, err1 = run_command(cmd1) - created_instances = 0 - for line in out1.split("\n"): - line = line.strip() - app.logger.info("Line:" + line + "\n") - if "NAME" not in line and "AGE" not in line and line != "": - created_instances = created_instances + 1 - app.logger.info("Already created instances:" + str(created_instances)) - if allowed_instances != "": + cmd1 = "kubectl get " + kind + out1, err1 = run_command(cmd1) + created_instances = 0 + for line in out1.split("\n"): + line = line.strip() + app.logger.info("Line:" + line + "\n") + if "NAME" not in line and "AGE" not in line and line != "": + created_instances = created_instances + 1 + app.logger.info("Already created instances:" + str(created_instances)) + if created_instances >= int(allowed_instances): msg = msg + "Allowed number of instances reached." diff --git a/plugins/crlicense.py b/plugins/crlicense.py index 12597e49..cd0e2c0e 100644 --- a/plugins/crlicense.py +++ b/plugins/crlicense.py @@ -68,7 +68,7 @@ def create_license(self, kind, license_file, expiry, num_of_instances, kubeconfi appinstances = '' if args.appinstances: appinstances = args.appinstances - if int(appinstances) < 0: + if int(appinstances) <= 0: print("App instances should be > 0.") exit(0) diff --git a/plugins/kubectl-license-delete b/plugins/kubectl-license-delete index 29f4cd8c..29a209a9 100755 --- a/plugins/kubectl-license-delete +++ b/plugins/kubectl-license-delete @@ -1,7 +1,5 @@ #!/bin/bash -#python3 crlicense.py delete "$@" - source utils.sh print_help () { diff --git a/plugins/kubectl-license-get b/plugins/kubectl-license-get index 14f6f54d..973fe533 100755 --- a/plugins/kubectl-license-get +++ b/plugins/kubectl-license-get @@ -1,7 +1,5 @@ #!/bin/bash -#python3 crlicense.py get "$@" - source utils.sh print_help () {