[Et-mgmt-commits-list] [SCM] virt-factory branch, master now at v0.0.3-210-gd7d094a
Adrian Likins
alikins at redhat.com
Fri Aug 24 18:41:09 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 d7d094a0598d022dfbdf19dd6fc74c2ea1a995c0 (commit)
via 82333522ef43f2b250d9618b7d550c586d56c0e2 (commit)
via 19e70a5b9d688f022929181f924f2dc3a5d71bae (commit)
via 13032fca31fae925f5a3352d899448c30b70c58a (commit)
from bb645396caf6c4feca6d3c2846de958e18fc8742 (commit)
- Log -----------------------------------------------------------------
commit d7d094a0598d022dfbdf19dd6fc74c2ea1a995c0
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date: Fri Aug 24 14:32:47 2007 -0400
more .gitignores
commit 82333522ef43f2b250d9618b7d550c586d56c0e2
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date: Fri Aug 24 14:32:12 2007 -0400
add new more "add" and make a "add user" sub-mode for it
example useage
/usr/bin/ampm add user --username adrian --password foobar --first Adrian --last Likins --email "adrian at likins.com" --description "Adrian is awesome"
commit 19e70a5b9d688f022929181f924f2dc3a5d71bae
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date: Fri Aug 24 14:30:27 2007 -0400
add vim .swp files too
commit 13032fca31fae925f5a3352d899448c30b70c58a
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date: Fri Aug 24 14:29:24 2007 -0400
virt-factory wide .gitignore
-----------------------------------------------------------------------
Diffstat:
.gitignore | 5 +
ampm/api_modules/user.py | 4 +-
ampm/client/.gitignore | 1 +
ampm/client/ampm_cli.py | 6 +-
ampm/command_modules/add.py | 132 +++++++++++++++++++++++++++
{ampm/client => service/modules}/.gitignore | 0
6 files changed, 145 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fee06c4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*~
+\#*\#
+*.pyc
+*.pyo
+*.swp
diff --git a/ampm/api_modules/user.py b/ampm/api_modules/user.py
index 9d36a0a..a90fa71 100644
--- a/ampm/api_modules/user.py
+++ b/ampm/api_modules/user.py
@@ -9,12 +9,12 @@ class User(base_module.BaseModule):
self.token = token
self.server = server
base_module.BaseModule.__init__(self)
- self.methods = ["user_list", "user_create", "user_delete"]
+ self.methods = ["user_list", "user_add", "user_delete"]
def user_list(self):
return self.server.user_list(self.token, {})
- def user_create(self, username,
+ def user_add(self, username,
password, first,
last,description, email, middle=None):
data = {'username': username,
diff --git a/ampm/client/.gitignore b/ampm/client/.gitignore
index 166b2df..140a8a2 100644
--- a/ampm/client/.gitignore
+++ b/ampm/client/.gitignore
@@ -1,4 +1,5 @@
*.pyc
*~
\#*\#
+*.pot
diff --git a/ampm/client/ampm_cli.py b/ampm/client/ampm_cli.py
index ba29c3b..e17050b 100644
--- a/ampm/client/ampm_cli.py
+++ b/ampm/client/ampm_cli.py
@@ -33,6 +33,7 @@ from command_modules import list
from command_modules import query
from command_modules import create
from command_modules import delete
+from command_modules import add
def print_help():
@@ -66,7 +67,7 @@ def main():
sys.exit()
- if mode not in ["help", "list", "query", "create", "delete"]:
+ if mode not in ["help", "list", "query", "create", "delete", "add"]:
print_help()
sys.exit()
@@ -84,6 +85,9 @@ def main():
if mode == "delete":
delete.run(modeargs, api=api)
+ if mode == "add":
+ add.run(modeargs, api=api)
+
if __name__ == "__main__":
main()
diff --git a/ampm/command_modules/add.py b/ampm/command_modules/add.py
new file mode 100644
index 0000000..13dd682
--- /dev/null
+++ b/ampm/command_modules/add.py
@@ -0,0 +1,132 @@
+#!/usr/bin/python
+
+import getopt
+import os
+import pprint
+import sys
+import time
+
+from rhpl.translate import _, N_, textdomain, utf8
+
+from client import ampmlib
+
+def run(args, api):
+ command = Add(args,api)
+
+
+class Add(object):
+ def __init__(self, args, api=None):
+ self.api = ampmlib.Api(url="http://127.0.0.1:5150",
+ username="admin",
+ password="fedora")
+ if api:
+ self.api = api
+ self.verbose = 0
+ self.__parse_args(args)
+
+ def print_help(self):
+ print "--username <username> --password <password> --first <first_name"
+ print " --middle <middle_name> --last <last_name> --email <email address>"
+ print " --description <desription>"
+
+ def __parse_args(self, args):
+
+ try:
+ opts, args = getopt.getopt(args, "hvm",
+ ["help",
+ "verbose",
+ "user"])
+ except getopt.error, e:
+ print _("Error parsing list arguments: %s") % e
+ self.print_help()
+ # FIXME: error handling
+
+
+ for (opt, val) in opts:
+ if opt in ["-h", "--help"]:
+ self.print_help()
+ return
+ if opt in ["-v", "--verbose"]:
+ self.verbose = self.verbose + 1
+
+ try:
+ mode = args[0]
+ except IndexError:
+ raise
+
+ if mode not in ["user"]:
+ # raise error?
+ print "incorrect mode"
+
+ if mode == "user":
+ self.add_user(args)
+
+
+ def add_user(self, args):
+ try:
+ opts, args = getopt.getopt(args[1:], "hvu:p:f:m:l:d:e:",
+ ["help",
+ "verbose",
+ "username=",
+ "password=",
+ "first=",
+ "middle=",
+ "last=",
+ "description=",
+ "email="])
+ except getopt.error, e:
+ print _("Error parsing list arguments: %s") % e
+ # FIXME: error handling
+
+ required_args = ["--username", "--password",
+ "--first", "--last",
+ "--description", "--email"]
+ passed_args = []
+ for (opt, val) in opts:
+ passed_args.append(opt)
+
+ missing_args = []
+ for required_arg in required_args:
+ if required_arg not in passed_args:
+ missing_args.append(required_arg)
+
+ if missing_args:
+ for missing_arg in missing_args:
+ print "%s is a required argument" % missing_arg
+ return
+
+ username = password = first = middle = None
+ last = description = email = None
+
+ for (opt, val) in opts:
+ if opt in ["-h", "--help"]:
+ self.print_help()
+ return
+ if opt in ["-v", "--verbose"]:
+ self.verbose = self.verbose + 1
+ if opt in ["-u", "--username"]:
+ username = val
+ if opt in ["-p", "--password"]:
+ password = val
+ if opt in ["-f", "--first"]:
+ first = val
+ if opt in ["-m", "--middle"]:
+ middle = val
+ if opt in ["-l", "--last"]:
+ last = val
+ if opt in ["-d", "--description"]:
+ description = val
+ if opt in ["-e", "--email"]:
+ email = val
+
+
+
+ (retcode, data) = self.api.user_add(username, password,
+ first, last,
+ description, email,
+ middle)
+
+ if self.verbose > 2:
+ pprint.pprint(data)
+
+
diff --git a/ampm/client/.gitignore b/service/modules/.gitignore
similarity index 100%
copy from ampm/client/.gitignore
copy to service/modules/.gitignore
hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
bb645396caf6c4feca6d3c2846de958e18fc8742 \
d7d094a0598d022dfbdf19dd6fc74c2ea1a995c0
More information about the Et-mgmt-commits-list
mailing list