diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/__init__.py | 0 | ||||
| -rw-r--r-- | client/dumb_client.py | 42 | ||||
| -rw-r--r-- | client/test_func.py | 26 |
3 files changed, 68 insertions, 0 deletions
diff --git a/client/__init__.py b/client/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/client/__init__.py diff --git a/client/dumb_client.py b/client/dumb_client.py new file mode 100644 index 0000000..173b3a3 --- /dev/null +++ b/client/dumb_client.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + + +# all the cool kids would use optparse instead +import getopt +import sys +import xmlrpclib + + +verbose = 0 + +try: + opts, args = getopt.getopt(sys.argv, "hvs:", + ["help", + "verbose", + "server="]) +except getopt.error, e: + print _("Error parsing list arguments: %s") % e + self.print_help() + # FIXME: error handling + + +server = "http://127.0.0.1:51234" +for (opt, val) in opts: + if opt in ["-h", "--help"]: + self.print_help() + sys.exit() + if opt in ["-v", "--verbose"]: + verbose = verbose + 1 + if opt in ["-s", "--server"]: + server = val + +s = xmlrpclib.ServerProxy(server) + +args = args[1:] +method = args[0] +print "calling %s with args: %s" % (method, args[1:]) + +# thats some pretty code right there aint it? -akl +# we can't call "call" on s, since thats a rpc, so +# we call gettatr around it. +print getattr(s, method)(*args[1:]) diff --git a/client/test_func.py b/client/test_func.py index 35ce100..a108c47 100644 --- a/client/test_func.py +++ b/client/test_func.py @@ -1,11 +1,37 @@ #!/usr/bin/python +# FIXME: should import the client lib, not XMLRPC lib, when we are done + import xmlrpclib +TEST_VIRT = True +TEST_SERVICES = True + +# get a connecton (to be replaced by client lib logic) s = xmlrpclib.ServerProxy("http://127.0.0.1:51234") +# here's the basic test... print s.test_add(1, 2) +# here's the service module testing +if TEST_SERVICES: + print s.service_restart("httpd") + +# this is so I can remember how the virt module works +if TEST_VIRT: + + # example of using koan to install a virtual machine + # s.virt_install("mdehaan.rdu.redhat.com","fc7webserver",False) + + # wait ... + vms = s.virt_list_vms() + # example of stopping all stopped virtual machines + print "list of virtual instances = %s" % vms + for vm in vms: + status = s.virt_status(vm) + if status == "stopped": + s.virt_start(vm) +# add more tests here |
