bug 624 fix user management for sol005 33/7133/3
authortierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 29 Jan 2019 11:43:10 +0000 (11:43 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 30 Jan 2019 10:31:22 +0000 (10:31 +0000)
Change-Id: I3aa13a9f9c5c22411af90ba98dbe5d0d5a0cfd5d
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osmclient/scripts/osm.py
osmclient/sol005/user.py

index 0a4c465..194196b 100755 (executable)
@@ -2236,7 +2236,8 @@ def project_show(ctx, name):
               confirmation_prompt=True,
               help='user password')
 @click.option('--projects',
-              default=None,
+              prompt=True,
+              multiple=True,
               help='list of project ids that the user belongs to')
 #@click.option('--description',
 #              default='no description',
@@ -2289,7 +2290,7 @@ def user_list(ctx, filter):
         exit(1)
     table = PrettyTable(['name', 'id'])
     for user in resp:
-        table.add_row([user['name'], user['_id']])
+        table.add_row([user['username'], user['_id']])
     table.align = 'l'
     print(table)
 
index ee572f1..ad8027d 100644 (file)
@@ -23,7 +23,7 @@ from osmclient.common import utils
 from osmclient.common.exceptions import ClientException
 from osmclient.common.exceptions import NotFound
 import json
-import yaml
+import yaml
 
 
 class User(object):
@@ -39,8 +39,6 @@ class User(object):
     def create(self, name, user):
         """Creates a new OSM user
         """
-        if 'projects' in user and user['projects'] is not None:
-            user['projects'] = yaml.safe_load(user['projects'])
         http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=user)
         #print('HTTP CODE: {}'.format(http_code))
@@ -132,7 +130,7 @@ class User(object):
                     return user
         else:
             for user in self.list():
-                if name == user['name']:
+                if name == user['username']:
                     return user
         raise NotFound("User {} not found".format(name))