Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merging @agentmilindu's leftover fixes for Python CLI from the later PR
Browse files Browse the repository at this point in the history
  • Loading branch information
chamilad committed Oct 13, 2015
1 parent da6b7e4 commit a75c45d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
17 changes: 14 additions & 3 deletions components/org.apache.stratos.python.cli/src/main/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,

```
Expand All @@ -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
```


30 changes: 15 additions & 15 deletions components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def do_list_users(self, line , opts=None):
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:
Expand All @@ -88,8 +89,8 @@ def do_add_user(self, line , opts=None):
" [-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:
Expand All @@ -100,20 +101,20 @@ def do_add_user(self, line , opts=None):
@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:
Expand All @@ -133,7 +134,6 @@ def do_remove_user(self, name , opts=None):
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:
Expand Down Expand Up @@ -190,7 +190,7 @@ def do_describe_application(self, application_id , opts=None):
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))

Expand Down Expand Up @@ -580,7 +580,7 @@ def do_list_cartridges_by_filter(self, filter_text , opts=None):
"""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()
Expand Down Expand Up @@ -1527,4 +1527,4 @@ def do_remove_domain_mappings(self, domain , opts=None):
print("Could not delete domain: "+domain)
except BadResponseError as e:
self.perror(str(e))
logging.error("HTTP "+e.error_code+" : "+str(e))

Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,11 @@ def update_kubernetes_host(json):

@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
Expand All @@ -420,8 +419,7 @@ def remove_domain_mappings(application_id):

@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
Expand Down Expand Up @@ -465,8 +463,8 @@ def put(resource, data):

@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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[wheel]
universal = 1

Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_http_get_handler_on_200(self):
body='{"keyOne": "valueOne"}', status=200,
content_type='application/json')

r = Stratos.post("")
r = Stratos.get("")

assert r == {"keyOne": "valueOne"}

Expand Down Expand Up @@ -94,4 +94,4 @@ def test_http_post_handler_on_500(self):
self.assertRaises(BadResponseError, Stratos.post(""))

if __name__ == '__main__':
unittest.main()
unittest.main()

0 comments on commit a75c45d

Please sign in to comment.