Updated Kubernates commands and Applications commands Signed-off-by: Imesh Gunaratne <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/24f70b27 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/24f70b27 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/24f70b27 Branch: refs/heads/stratos-4.1.x Commit: 24f70b27f621b02b1819f9f3025b023a75b4b054 Parents: 154f305 Author: Milindu Sanoj Kumarage <[email protected]> Authored: Wed Aug 12 07:20:03 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 16:32:49 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/cli/CLI.py | 173 ++++++++++++------- .../src/main/python/cli/Stratos.py | 51 ++++-- 2 files changed, 152 insertions(+), 72 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/24f70b27/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py b/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py index e9960f9..8073d97 100755 --- a/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py @@ -140,6 +140,7 @@ class CLI(Cmd): """ # Applications * list-applications + * describe-application * add-application * remove-application @@ -164,6 +165,24 @@ class CLI(Cmd): table.add_rows(rows) table.print_table() + + @options([ + make_option('-u', '--username', type="str", help="Username of the user"), + make_option('-p', '--password', type="str", help="Password of the user") + ]) + @auth + def do_describe_application(self, application_id , opts=None): + """Retrieve detailed information on the master node in a specific Kubernetes-CoreOS group""" + if not application_id: + print("usage: describe-application [cluster-id]") + return + application = Stratos.describe_application(application_id) + if not application: + print("Application not found in : "+application_id) + else: + print("Application : "+application_id) + PrintableJSON(application).pprint() + @options([ make_option('-u', '--username', type="str", help="Username of the user"), make_option('-p', '--password', type="str", help="Password of the user"), @@ -204,6 +223,53 @@ class CLI(Cmd): self.perror("Authentication Error") """ + # Application deployment + * describe-application-runtime + * deploy-application + + """ + + @options([ + make_option('-u', '--username', type="str", help="Username of the user"), + make_option('-p', '--password', type="str", help="Password of the user") + ]) + @auth + def do_describe_application_runtime(self, application_id , opts=None): + """Retrieve details of a specific auto-scaling policy.""" + if not application_id: + print("usage: describe-application-runtime [application-id]") + return + application_runtime = Stratos.describe_application_runtime(application_id) + if not application_runtime: + print("Application runtime not found") + else: + print("Application : "+application_id) + PrintableJSON(application_runtime).pprint() + + """ + # Application signup + * describe-application-signup + + """ + @options([ + make_option('-u', '--username', type="str", help="Username of the user"), + make_option('-p', '--password', type="str", help="Password of the user") + ]) + @auth + def do_describe_application_signup(self, line , opts=None): + """Retrieve details of a specific auto-scaling policy.""" + if not line.split(): + print("usage: describe-application-signup [application-id]") + return + application_signup = Stratos.describe_application_signup(line) + if not application_signup: + print("Application signup not found") + else: + PrintableJSON(application_signup).pprint() + + + + """ # Tenants * list-tenants * list-tenants-by-partial-domain @@ -797,9 +863,9 @@ class CLI(Cmd): else: autoscaling_policy = Stratos.update_autoscaling_policy(open(opts.json_file_path, 'r').read()) if autoscaling_policy: - print("Cartridge updated successfully") + print("Autoscaling policy updated successfully:") else: - print("Error updating Cartridge") + print("Error updating Autoscaling policy") except AuthenticationError as e: self.perror("Authentication Error") @@ -828,6 +894,8 @@ class CLI(Cmd): * describe-kubernetes-cluster * list-kubernetes-hosts * describe-kubernetes-master + * update-kubernetes-host + * update-kubernetes-master * remove-kubernetes-cluster * remove-kubernetes-host @@ -910,6 +978,47 @@ class CLI(Cmd): @options([ make_option('-u', '--username', type="str", help="Username of the user"), + make_option('-p', '--password', type="str", help="Password of the user"), + make_option('-c', '--cluster_id', type="str", help="Cluster id of the cluster"), + make_option('-f', '--json_file_path', type="str", help="Path of the JSON file") + ]) + @auth + def do_update_kubernetes_master(self, line , opts=None): + """Add a new user to the system""" + try: + if not opts.json_file_path: + print("usage: update-kubernetes-master [-c <cluster id>] [-p <resource path>]") + else: + cartridge = Stratos.update_kubernetes_master(opts.cluster_id, open(opts.json_file_path, 'r').read()) + if cartridge: + print("Kubernetes master updated successfully") + else: + print("Error updating Kubernetes master") + except AuthenticationError as e: + self.perror("Authentication Error") + + @options([ + make_option('-u', '--username', type="str", help="Username of the user"), + make_option('-p', '--password', type="str", help="Password of the user"), + make_option('-f', '--json_file_path', type="str", help="Path of the JSON file") + ]) + @auth + def do_update_kubernetes_host(self, line , opts=None): + """Add a new user to the system""" + try: + if not opts.json_file_path: + print("usage: update-kubernetes-host [-f <resource path>]") + else: + cartridge = Stratos.update_kubernetes_host(open(opts.json_file_path, 'r').read()) + if cartridge: + print("Kubernetes host updated successfully") + else: + print("Error updating Kubernetes host") + except AuthenticationError as e: + self.perror("Authentication Error") + + @options([ + make_option('-u', '--username', type="str", help="Username of the user"), make_option('-p', '--password', type="str", help="Password of the user") ]) @auth @@ -980,34 +1089,6 @@ class CLI(Cmd): except ValueError as e: self.perror("sdc") - @options([ - make_option('-u', '--username', type="str", help="Username of the user"), - make_option('-p', '--password', type="str", help="Password of the user") - ]) - @auth - def do_describe_application_signup(self, line , opts=None): - """Retrieve details of a specific auto-scaling policy.""" - if not line.split(): - print("usage: describe-application-signup [application-id]") - return - application_signup = Stratos.describe_application_signup(line) - if not application_signup: - print("Application signup not found") - else: - PrintableJSON(application_signup).pprint() - - - - - - - - - - - - - @options([ @@ -1049,38 +1130,6 @@ class CLI(Cmd): except AuthenticationError as e: self.perror("Authentication Error") - @options([ - make_option('-u', '--username', type="str", help="Username of the user"), - make_option('-p', '--password', type="str", help="Password of the user") - ]) - @auth - def do_describe_application_runtime(self, line , opts=None): - """Retrieve details of a specific auto-scaling policy.""" - if not line.split(): - print("usage: describe-application-runtime [application-id]") - return - application_runtime = Stratos.describe_application_runtime(line) - if not application_runtime: - print("Application runtime not found") - else: - PrintableJSON(application_runtime).pprint() - - - @options([ - make_option('-u', '--username', type="str", help="Username of the user"), - make_option('-p', '--password', type="str", help="Password of the user") - ]) - @auth - def do_describe_application(self, line , opts=None): - """Retrieve details of a specific auto-scaling policy.""" - if not line.split(): - print("usage: describe-application [application-id]") - return - application = Stratos.describe_application(line) - if not application: - print("Application not found") - else: - PrintableJSON(application).pprint() @options([ make_option('-u', '--username', type="str", help="Username of the user"), http://git-wip-us.apache.org/repos/asf/stratos/blob/24f70b27/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py b/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py index 164833b..24358fb 100755 --- a/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py @@ -70,6 +70,7 @@ class Stratos: """ # Applications * list-applications + * describe-applications * add-application * remove-application @@ -79,10 +80,33 @@ class Stratos: return Stratos.get('applications', error_message='No applications found') @staticmethod + def describe_application(application_id): + return Stratos.get('applications/'+application_id, + error_message='No application found') + + @staticmethod def remove_application(application): return Stratos.delete('application/'+application) """ + # Application deployment + * describe-application-runtime + + """ + @staticmethod + def describe_application_runtime(application_id): + return Stratos.get('applications/'+application_id+"/runtime", error_message='No application runtime found') + + """ + # Application signup + * describe-application-signup + + """ + @staticmethod + def describe_application_signup(application_id): + return Stratos.get('applications/'+application_id + '/signup', + error_message='No signup application found') + """ # Tenants * list-tenants * list-tenants-by-partial-domain @@ -262,6 +286,10 @@ class Stratos: return Stratos.get('autoscalingPolicies/'+autoscaling_policy_id, error_message='No autoscaling policy found') @staticmethod + def update_autoscaling_policy(json): + return Stratos.put('autoscalingPolicies', json, error_message='No cartridge found') + + @staticmethod def remove_autoscaling_policy(autoscaling_policy_id): return Stratos.delete('autoscalingPolicies/'+autoscaling_policy_id, error_message="Autoscaling policy not found") @@ -271,6 +299,10 @@ class Stratos: * describe-kubernetes-cluster * list-kubernetes-hosts * describe-kubernetes-master + * update-kubernetes-host + * update-kubernetes-master + * remove-kubernetes-cluster + * remove-kubernetes-host """ @staticmethod @@ -290,6 +322,14 @@ class Stratos: return Stratos.get('kubernetesClusters/'+kubernetes_cluster_id+'/master', error_message='No kubernetes clusters found') @staticmethod + def update_kubernetes_master(cluster_id, json): + return Stratos.put('kubernetesClusters/'+cluster_id+'/master', json, error_message='No cartridge found') + + @staticmethod + def update_kubernetes_host(json): + return Stratos.put('kubernetesClusters/update/host/', json, error_message='No cartridge found') + + @staticmethod def remove_kubernetes_cluster(kubernetes_cluster_id): return Stratos.delete('kubernetesClusters/'+kubernetes_cluster_id, error_message="Autoscaling policy not found") @@ -297,10 +337,7 @@ class Stratos: def remove_kubernetes_host(kubernetes_cluster_id, host_id): return Stratos.delete('kubernetesClusters/'+kubernetes_cluster_id+"/hosts/"+host_id, error_message="Autoscaling policy not found") - @staticmethod - def describe_application_signup(application_id): - return Stratos.get('applications/'+ application_id + '/signup', - error_message='No signup application found') + """ # Utils @@ -392,12 +429,6 @@ class Stratos: def remove_application_signup(signup): return Stratos.delete('applicationSignup/'+signup) - def describe_application_runtime(application): - return Stratos.get('applicationRuntime/'+application, error_message='No application runtime found') - - def describe_application(application): - return Stratos.get('application/'+application, error_message='No application found') - @staticmethod def add_network_partition(json): return Stratos.post('networkPartitions', json, error_message='No network partition found')
