Repository: stratos Updated Branches: refs/heads/stratos-4.1.x da6b7e43d -> 34c9d560f
Merging @agentmilindu's leftover fixes for Python CLI from the later PR #437 Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/a75c45d2 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/a75c45d2 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/a75c45d2 Branch: refs/heads/stratos-4.1.x Commit: a75c45d2a73746bc3f7088ba0f0915318bfcf566 Parents: da6b7e4 Author: Chamila de Alwis <[email protected]> Authored: Tue Oct 13 23:54:05 2015 +0530 Committer: Chamila de Alwis <[email protected]> Committed: Tue Oct 13 23:54:05 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/README.md | 17 +++++++++-- .../src/main/python/cli/CLI.py | 30 ++++++++++---------- .../src/main/python/cli/Stratos.py | 14 ++++----- .../src/main/python/setup.cfg | 2 +- .../src/main/python/setup.py | 3 +- .../src/main/python/tests/test_stratos_utils.py | 4 +-- 6 files changed, 40 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/a75c45d2/components/org.apache.stratos.python.cli/src/main/python/README.md ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/README.md b/components/org.apache.stratos.python.cli/src/main/python/README.md index 7b37a79..07f021f 100644 --- a/components/org.apache.stratos.python.cli/src/main/python/README.md +++ b/components/org.apache.stratos.python.cli/src/main/python/README.md @@ -8,9 +8,9 @@ Install the required Python packages by issuing the following `pip install` comm pip install cmd2 pip install texttable - ``` - + +#Build Build and install stratos CLI by, ``` @@ -28,8 +28,19 @@ instead `install` if developing To start the Python CLI issue, ``` -$ stratos +$ stratos-cli +``` + +Install with Pip + +``` +pip install stratos ``` + +or to install a specific version use +``` +pip install stratos==1.0 +``` http://git-wip-us.apache.org/repos/asf/stratos/blob/a75c45d2/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 5b2e865..f40e3b8 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 @@ -80,6 +80,7 @@ class CLI(Cmd): make_option('-e', '--email', type="str", help="Email of the user"), make_option('-o', '--profile_name', type="str", help="Profile name of the user") ]) + @auth def do_add_user(self, line , opts=None): """Add a user.""" try: @@ -88,8 +89,8 @@ class CLI(Cmd): " [-l <last name>] [-o <profile name>]") return else: - user = Stratos.add_users(opts.username_user, opts.password_user, opts.role_name, opts.first_name, opts.last_name, - opts.email, opts.profile_name) + user = Stratos.add_users(opts.username_user, opts.password_user, opts.role_name, opts.first_name, + opts.last_name, opts.email, opts.profile_name) if user: print("User successfully created") else: @@ -100,20 +101,20 @@ 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('-s', '--username_user', type="str", help="Username of the user"), - make_option('-a', '--password_user', type="str", help="Password of the user"), - make_option('-r', '--role_name', type="str", help="Role name of the user"), - make_option('-f', '--first_name', type="str", help="First name of the user"), - make_option('-l', '--last_name', type="str", help="Last name of the user"), - make_option('-e', '--email', type="str", help="Email of the user"), - make_option('-o', '--profile_name', type="str", help="Profile name of the user") + make_option('-s', '--username_user', type="str", help="Username of the user to be created"), + make_option('-a', '--password_user', type="str", help="Password of the user to be created"), + make_option('-r', '--role_name', type="str", help="Role name of the user to be created"), + make_option('-f', '--first_name', type="str", help="First name of the user to be created"), + make_option('-l', '--last_name', type="str", help="Last name of the user to be created"), + make_option('-e', '--email', type="str", help="Email of the user to be created"), + make_option('-o', '--profile_name', type="str", help="Profile name of the user to be created") ]) @auth def do_update_user(self, line , opts=None): """Update a specific user.""" try: - user = Stratos.update_user(opts.username_user, opts.password_user, opts.role_name, opts.first_name, opts.last_name, - opts.email, opts.profile_name) + user = Stratos.update_user(opts.username_user, opts.password_user, opts.role_name, opts.first_name, + opts.last_name, opts.email, opts.profile_name) if user: print("User successfully updated") else: @@ -133,7 +134,6 @@ class CLI(Cmd): print("usage: remove-user [username]") else: user_removed = Stratos.remove_user(name) - print(user_removed) if user_removed: print("You have successfully deleted user: "+name) else: @@ -190,7 +190,7 @@ class CLI(Cmd): print("Application not found in : "+application_id) else: print("Application : "+application_id) - PrintableJSON(application).pprint() + PrintableTree(application).print_tree() except BadResponseError as e: self.perror(str(e)) @@ -580,7 +580,7 @@ class CLI(Cmd): """Retrieve details of available cartridges.""" try: if not filter_text: - print("") + print("usage: describe-cartridge-by-filter [filter]") else: cartridges = Stratos.list_cartridges_by_filter(filter_text) table = PrintableTable() @@ -1527,4 +1527,4 @@ class CLI(Cmd): print("Could not delete domain: "+domain) except BadResponseError as e: self.perror(str(e)) - logging.error("HTTP "+e.error_code+" : "+str(e)) + http://git-wip-us.apache.org/repos/asf/stratos/blob/a75c45d2/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 89643b5..a1cf971 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 @@ -395,12 +395,11 @@ class Stratos: @staticmethod def remove_kubernetes_cluster(kubernetes_cluster_id): - return Stratos.delete('kubernetesClusters/'+kubernetes_cluster_id, - ) + return Stratos.delete('kubernetesClusters/'+kubernetes_cluster_id) + @staticmethod def remove_kubernetes_host(kubernetes_cluster_id, host_id): - return Stratos.delete('kubernetesClusters/'+kubernetes_cluster_id+"/hosts/"+host_id, - ) + return Stratos.delete('kubernetesClusters/'+kubernetes_cluster_id+"/hosts/"+host_id) """ # Domain Mapping @@ -420,8 +419,7 @@ class Stratos: @staticmethod def add_domain_mapping(application_id, json): - return Stratos.post('applications/'+application_id+'/domainMappings', json, - ) + return Stratos.post('applications/'+application_id+'/domainMappings', json) """ # Utils @@ -465,8 +463,8 @@ class Stratos: @staticmethod def response(r): - print(r) - print(r.text) + # print(r) + # print(r.text) if r.status_code == 200: return r.json() elif r.status_code == 201: http://git-wip-us.apache.org/repos/asf/stratos/blob/a75c45d2/components/org.apache.stratos.python.cli/src/main/python/setup.cfg ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/setup.cfg b/components/org.apache.stratos.python.cli/src/main/python/setup.cfg index 5e40900..a731f96 100644 --- a/components/org.apache.stratos.python.cli/src/main/python/setup.cfg +++ b/components/org.apache.stratos.python.cli/src/main/python/setup.cfg @@ -1,2 +1,2 @@ [wheel] -universal = 1 + http://git-wip-us.apache.org/repos/asf/stratos/blob/a75c45d2/components/org.apache.stratos.python.cli/src/main/python/setup.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/setup.py b/components/org.apache.stratos.python.cli/src/main/python/setup.py index fefef9b..d8366e9 100644 --- a/components/org.apache.stratos.python.cli/src/main/python/setup.py +++ b/components/org.apache.stratos.python.cli/src/main/python/setup.py @@ -24,7 +24,8 @@ def read(file_name): return open(os.path.join(os.path.dirname(__file__), file_name)).read() setup( - name="stratos", + name="stratos-cli", + version="4.1.4", version="4.1.4", author="Apache Stratos", author_email="[email protected]", http://git-wip-us.apache.org/repos/asf/stratos/blob/a75c45d2/components/org.apache.stratos.python.cli/src/main/python/tests/test_stratos_utils.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/tests/test_stratos_utils.py b/components/org.apache.stratos.python.cli/src/main/python/tests/test_stratos_utils.py index 85acb4b..73b72bf 100644 --- a/components/org.apache.stratos.python.cli/src/main/python/tests/test_stratos_utils.py +++ b/components/org.apache.stratos.python.cli/src/main/python/tests/test_stratos_utils.py @@ -31,7 +31,7 @@ class MyTestCase(unittest.TestCase): body='{"keyOne": "valueOne"}', status=200, content_type='application/json') - r = Stratos.post("") + r = Stratos.get("") assert r == {"keyOne": "valueOne"} @@ -94,4 +94,4 @@ class MyTestCase(unittest.TestCase): self.assertRaises(BadResponseError, Stratos.post("")) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()
