[Et-mgmt-commits-list] [SCM] virt-factory branch, master now at v0.0.3-204-gc48fff2

Adrian Likins alikins at redhat.com
Fri Aug 24 15:19:19 UTC 2007


Hello,

This is an automated email from the git hooks/update script, it was
generated because a ref change was pushed to the repository.

Updating branch, master,
       via  c48fff2ab65c90e3b1116bde96f7ebbb49b037b0 (commit)
       via  c86c65576667b50e623e36399805d9da187c0c8a (commit)
       via  f3e6729a014b353566eb293593b2c322795f3564 (commit)
      from  a47a453960437cd69075983a316e65a95131f4c8 (commit)

- Log -----------------------------------------------------------------
commit c48fff2ab65c90e3b1116bde96f7ebbb49b037b0
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date:   Fri Aug 24 11:10:47 2007 -0400

    test "ampm list users"

commit c86c65576667b50e623e36399805d9da187c0c8a
Merge: f3e6729... a47a453...
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date:   Fri Aug 24 11:10:27 2007 -0400

    Merge branch 'master' of git+ssh://g-alikins@et.redhat.com/git/virt-factory

commit f3e6729a014b353566eb293593b2c322795f3564
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date:   Fri Aug 24 11:09:37 2007 -0400

    add "list users" and "delete --user_id "
-----------------------------------------------------------------------

Diffstat:
 ampm/api_modules/user.py       |   35 +++++++++++++++++++++++++++++++++++
 ampm/client/ampmlib.py         |    3 ++-
 ampm/command_modules/delete.py |   14 +++++++++++++-
 ampm/command_modules/list.py   |   18 ++++++++++++++++--
 build/test-it-all.sh           |    3 +++
 5 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/ampm/api_modules/user.py b/ampm/api_modules/user.py
new file mode 100644
index 0000000..9d36a0a
--- /dev/null
+++ b/ampm/api_modules/user.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import base_module
+import pprint
+
+
+class User(base_module.BaseModule):
+    def __init__(self, server=None, token=None):
+        self.token = token
+        self.server = server
+        base_module.BaseModule.__init__(self)
+        self.methods = ["user_list", "user_create", "user_delete"]
+
+    def user_list(self):
+        return self.server.user_list(self.token, {})
+
+    def user_create(self, username,
+                    password, first,
+                    last,description, email, middle=None):
+        data = {'username': username,
+                'password': password,
+                "first": first,
+                'last': last,
+                'description': description,
+                'email': email}
+        if middle:
+            data['middle'] = middle
+
+        return self.server.user_add(self.token, data)
+
+    def user_delete(self, user_id):
+        return self.server.user_delete(self.token, {'id':user_id})
+        
+                                                 
+api_class = User
diff --git a/ampm/client/ampmlib.py b/ampm/client/ampmlib.py
index 89ca554..81edb58 100644
--- a/ampm/client/ampmlib.py
+++ b/ampm/client/ampmlib.py
@@ -32,6 +32,7 @@ from api_modules import machine
 from api_modules import deployment
 from api_modules import profile
 from api_modules import task
+from api_modules import user
 
 class Server(xmlrpclib.ServerProxy):
     def __init__(self, url=None):
@@ -77,7 +78,7 @@ class Api(object):
         
 
         # FIXME: auto-dynamafy this module/method stuff
-        for module in [auth, machine, deployment, profile, task]:
+        for module in [auth, machine, deployment, profile, task, user]:
             self.api_classes[module] = module.api_class()
 
         for api_class in self.api_classes.keys():
diff --git a/ampm/command_modules/delete.py b/ampm/command_modules/delete.py
index 5287e78..22491ea 100644
--- a/ampm/command_modules/delete.py
+++ b/ampm/command_modules/delete.py
@@ -27,13 +27,15 @@ class Delete(object):
 
         task_id = None
         profile = None
+        user_id = None
         
         try:
             opts, args = getopt.getopt(args, "hvm",
                                        ["help",
                                         "verbose",
                                         "task_id=",
-                                        "profile="])
+                                        "profile=",
+                                        "user_id="])
         except getopt.error, e:
             print _("Error parsing list arguments: %s") % e
             # FIXME: error handling
@@ -48,14 +50,24 @@ class Delete(object):
                 task_id = val
             if opt in ["--profile"]:
                 profile = val
+            if opt in ["--user_id"]:
+                user_id = val
 
         if task_id is not None:
             self.delete_task(task_id)
 
+        if user_id is not None:
+            self.delete_user(user_id)
+
     def delete_task(self, task_id=None):
         (retcode, data) = self.api.task_delete(task_id)
         if self.verbose > 2:
             pprint.pprint(data)
 
+    def delete_user(self, user_id=None):
+        (retcode, data) = self.api.user_delete(user_id)
+        if self.verbose > 2:
+            pprint.pprint(data)
+
             
         
diff --git a/ampm/command_modules/list.py b/ampm/command_modules/list.py
index e26cbd2..d64eb70 100644
--- a/ampm/command_modules/list.py
+++ b/ampm/command_modules/list.py
@@ -26,7 +26,7 @@ class List(object):
         self.__parse_args(args)
 
     def print_help(self):
-        print "valid modes are hosts, guests, status, profiles, tasks"
+        print "valid modes are hosts, guests, status, profiles, tasks, users"
 
     def __parse_args(self, args):
 
@@ -51,7 +51,7 @@ class List(object):
         except IndexError:
             raise
 
-        if mode not in ["hosts", "guests", "status", "profiles", "tasks"]:
+        if mode not in ["hosts", "guests", "status", "profiles", "tasks", "users"]:
             # raise error?
             print "incorrect mode"
 
@@ -70,6 +70,9 @@ class List(object):
         if mode == "tasks":
             self.list_tasks()
 
+        if mode == "users":
+            self.list_users()
+
     def list_machines(self):
         (retcode, data) = self.api.machine_list()
         if self.verbose > 2:
@@ -112,6 +115,17 @@ class List(object):
                                    
         
         
+    def list_users(self):
+        (retcode, data) = self.api.user_list()
+        if self.verbose > 2:
+            pprint.pprint(data)
+
+        for user in data['data']:
+            if user['id'] == -1:
+                continue
+
+            print "%(id)s %(username)s %(email)s %(first)s %(last)s %(description)s" % user 
+
 
     def list_profiles(self):
         (retcode, data) = self.api.profile_list()
diff --git a/build/test-it-all.sh b/build/test-it-all.sh
index 0a4c153..5587bc4 100755
--- a/build/test-it-all.sh
+++ b/build/test-it-all.sh
@@ -401,6 +401,9 @@ test_ampm()
     msg "ampm list tasks"
     /usr/bin/ampm list tasks
 
+    msg "ampm list users"
+    /usr/bin/ampm list users
+
     msg "ampm query <profiles>"
     for i in `/usr/bin/ampm list profiles | cut -f1 -d' '`
     do

hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
  a47a453960437cd69075983a316e65a95131f4c8 \
  c48fff2ab65c90e3b1116bde96f7ebbb49b037b0




More information about the Et-mgmt-commits-list mailing list