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

Adrian Likins alikins at redhat.com
Mon Aug 6 21:02:56 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  c4cda695eb05f2c5f0f384f9ad1cb3d07c0b6fe7 (commit)
      from  c4851bb2ddbccea33c318027dccd0567491d4f2d (commit)

- Log -----------------------------------------------------------------
commit c4cda695eb05f2c5f0f384f9ad1cb3d07c0b6fe7
Author: Adrian Likins <alikins at grimlock.devel.redhat.com>
Date:   Mon Aug 6 16:52:29 2007 -0400

    add a per user config file. debating over a system wide one, but will
    probably add one as well
    
    misc module loading/path shuffling
-----------------------------------------------------------------------

Diffstat:
 ampm/Makefile                  |    3 +
 ampm/ampm_cli.py               |   79 --------------------------
 ampm/ampmlib.py                |  120 ----------------------------------------
 ampm/client/ampm_cli.py        |   11 +++-
 ampm/client/ampmlib.py         |    3 +-
 ampm/command_modules/create.py |    2 +-
 ampm/command_modules/list.py   |    2 +-
 ampm/command_modules/query.py  |    2 +-
 ampm/scripts/ampm              |    4 +-
 9 files changed, 18 insertions(+), 208 deletions(-)

diff --git a/ampm/Makefile b/ampm/Makefile
index 8641c80..dd69d75 100644
--- a/ampm/Makefile
+++ b/ampm/Makefile
@@ -24,6 +24,9 @@ clean::
 	@rm -fv *.pyc *~ .*~ 
 	@find . -name .\#\* -exec rm -fv {} \;
 	@rm -fv *.rpm
+	@rm -rfv build/
+	@rm -rfv dist/
+	@rm -rfv rpm-build/
 
 
 new-rpms: bumprelease rpms
diff --git a/ampm/ampm_cli.py b/ampm/ampm_cli.py
deleted file mode 100644
index d5b133b..0000000
--- a/ampm/ampm_cli.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/python
-
-# cli tool for accessing virt-factory functionality
-
-
-# basic modes:
-#     status
-#     query
-#     list
-#     migrate
-#     pause
-#     resume
-#     create
-
-import ampmlib
-
-
-import getopt
-import os
-import sys
-
-api = ampmlib.Api(url="http://127.0.0.1/vf/",
-                  username="admin",
-                  password="fedora")
-
-
-from command_modules import list
-from command_modules import query
-from command_modules import create
-
-def print_help():
-    print "== This is a useless help string blurb =="
-    print
-
-
-def main():
-
-    try:
-        opts, args = getopt.getopt(sys.argv[1:], "hv", [
-            "help",
-            "verbose",
-            ])
-    except getopt.error, e:
-        print _("Error parsing command list arguments: %s") % e
-        showHelp() 
-        sys.exit(1)
-
-    for (opt, vals) in opts:
-        if opt in ["-h", "--help"]:
-            print_help()
-            sys.exit()
-        if opt in ["-v", "--verbose"]:
-            verbose = 1
-
-    try:
-        mode = args[0]
-    except IndexError:
-        print_help()
-        sys.exit()
-
-
-    if mode not in ["help", "list", "query", "create"]:
-        print_help()
-        sys.exit()
-
-    modeargs = args[args.index(mode)+1:]
-    
-    if mode == "list":
-        list.run(modeargs)
-
-    if mode == "query":
-        query.run(modeargs)
-
-    if mode == "create":
-        create.run(modeargs)
-if __name__ == "__main__":
-    main()
-
-  
diff --git a/ampm/ampmlib.py b/ampm/ampmlib.py
deleted file mode 100644
index 18d0f48..0000000
--- a/ampm/ampmlib.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/python
-
-# module for ampm functionality
-
-
-#import logger
-#logger.logfilepath = "/var/log/ampm/ampm.log"
-
-import module_loader
-
-from rhpl.translate import _, N_, textdomain, utf8
-I18N_DOMAIN = "ampm"
-
-
-import distutils
-import getopt
-import os
-import socket
-import sys
-import xmlrpclib
-
-
-#MODULE_PATH="modules/"
-#sys.path.insert(0, MODULE_PATH)
-#modules = module_loader.load_modules(module_path=MODULE_PATH)
-#print modules
-from api_modules import auth
-from api_modules import machine
-from api_modules import deployment
-from api_modules import profile
-
-class Server(xmlrpclib.ServerProxy):
-    def __init__(self, url=None):
-        xmlrpclib.ServerProxy.__init__(self, url)
-
-
-# class to handle storing, reading, updating, etc login info
-# client side
-class AuthInfo(object):
-    def __init__(self):
-        self.username = None
-        self.password = None
-        self.token = None
-        self.token_file = os.path.expanduser("~/.ampm_token")
-
-    def read_token(self):
-        try:
-            token = open(self.token_file, "r").readline().strip()
-        except:
-            raise
-        self.token = token
-        
-    def write_token(self):
-        f = open(self.token_file, "w")
-        f.write(self.token)
-        f.close()
-        
-
-# yes, having a class called Api is lame. But this is freaking
-# rpc folks. Pretending you are dealing with real objects will
-# just lead to pain and bitterness
-class Api(object):
-    def __init__(self, url=None, username=None, password=None):
-        self.url = url
-        self.server = Server(url)
-        self.username = username
-        self.password = password
-
-        self.auth_obj = AuthInfo()
-        self.modules = {}
-        self.api_classes = {}
-        self.api_methods = {}
-        
-
-        # FIXME: auto-dynamafy this module/method stuff
-        for module in [auth, machine, deployment, profile]:
-            self.api_classes[module] = module.api_class()
-
-        for api_class in self.api_classes.keys():
-            methods = self.api_classes[api_class].methods
-            for method in methods:
-                # for now we are going to pretend every nethod has a unique name
-                self.api_methods[method] = api_class
-
-    def __getattr__(self, attr):
-        self.login()
-        if attr in self.api_methods:
-            obj = self.api_methods[attr].api_class(server=self.server,
-                                                   token=self.token)
-            return getattr(obj,attr)
-        else:
-            raise AttributeError, attr
-
-    # most of the methods in this class are just wrappers around
-    # xmlrpc calls
-
-    def login(self):
-        
-
-        try:
-            self.token = self.server.user_login(self.username, self.password)[1]['data']
-        except:
-            # FIXME: fancy error handling here later
-            raise
-
-        
-
-
-if __name__ == "__main__":
-
-    # test stuff
-    ai = AuthInfo()
-    blip = "sdfjadflaksfi9q349wjeruifhs498ryw43ghfsreg"
-    ai.token = blip
-    ai.write_token()
-    ai.read_token()
-    print ai.token
-    print blip
-    if ai.token != blip:
-        print "something butestededededicated"
diff --git a/ampm/client/ampm_cli.py b/ampm/client/ampm_cli.py
index d5b133b..471ffe5 100644
--- a/ampm/client/ampm_cli.py
+++ b/ampm/client/ampm_cli.py
@@ -19,9 +19,14 @@ import getopt
 import os
 import sys
 
-api = ampmlib.Api(url="http://127.0.0.1/vf/",
-                  username="admin",
-                  password="fedora")
+import config
+cfg = config.AmpmConfig()
+cfg.load()
+
+
+api = ampmlib.Api(url=cfg.get("server", "url"),
+                  username=cfg.get("user", "username"),
+                  password=cfg.get("user", "password"))
 
 
 from command_modules import list
diff --git a/ampm/client/ampmlib.py b/ampm/client/ampmlib.py
index 640d809..4f3c6fc 100644
--- a/ampm/client/ampmlib.py
+++ b/ampm/client/ampmlib.py
@@ -25,7 +25,8 @@ import xmlrpclib
 #modules = module_loader.load_modules(module_path=MODULE_PATH)
 #print modules
 
-print sys.path
+#print sys.path
+from client import config
 from api_modules import auth
 from api_modules import machine
 from api_modules import deployment
diff --git a/ampm/command_modules/create.py b/ampm/command_modules/create.py
index c805ccd..1fb16e9 100644
--- a/ampm/command_modules/create.py
+++ b/ampm/command_modules/create.py
@@ -7,7 +7,7 @@ import sys
 
 from rhpl.translate import _, N_, textdomain, utf8
 
-from ampm import ampmlib
+from client import ampmlib
 
 def run(args):
     command = Create(args)
diff --git a/ampm/command_modules/list.py b/ampm/command_modules/list.py
index c69c831..7efe12f 100644
--- a/ampm/command_modules/list.py
+++ b/ampm/command_modules/list.py
@@ -7,7 +7,7 @@ import sys
 
 from rhpl.translate import _, N_, textdomain, utf8
 
-from ampm import ampmlib
+from client import ampmlib
 
 def run(args):
     command = List(args)
diff --git a/ampm/command_modules/query.py b/ampm/command_modules/query.py
index cafb89c..72c3450 100644
--- a/ampm/command_modules/query.py
+++ b/ampm/command_modules/query.py
@@ -7,7 +7,7 @@ import sys
 
 from rhpl.translate import _, N_, textdomain, utf8
 
-from ampm import ampmlib
+from client import ampmlib
 
 def run(args):
     command = Query(args)
diff --git a/ampm/scripts/ampm b/ampm/scripts/ampm
index db634af..d0c1b9c 100644
--- a/ampm/scripts/ampm
+++ b/ampm/scripts/ampm
@@ -4,9 +4,9 @@
 import sys
 import distutils.sysconfig
 
-sys.path.append("%s/virt-factory" % distutils.sysconfig.get_python_lib())
+sys.path.insert(0, "%s/virt-factory/ampm" % distutils.sysconfig.get_python_lib())
 
-from ampm import ampm_cli
+from client import ampm_cli
 if __name__ == "__main__":
 
     ampm_cli.main()

hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
  c4851bb2ddbccea33c318027dccd0567491d4f2d \
  c4cda695eb05f2c5f0f384f9ad1cb3d07c0b6fe7




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