Permalink
Browse files

fixing up some python weirdness

  • Loading branch information...
root
root committed Apr 20, 2011
1 parent 3c5c42c commit 3b64149f361080adf6ce94bf0df6650483c501ca
Showing with 250 additions and 2,811 deletions.
  1. +1 −0 Makedefs.in
  2. +2 −2 clc/eucadmin/Makefile
  3. +0 −82 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/__init__.py
  4. +0 −206 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/clusters.py
  5. +0 −82 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/command.py
  6. +0 −246 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/components.py
  7. +0 −72 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/generic.py
  8. +0 −121 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/groups.py
  9. +0 −74 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/heartbeat.py
  10. +0 −108 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/hypervregister.py
  11. +0 −177 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/properties.py
  12. +0 −198 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/storagecontrollers.py
  13. +0 −139 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/synckeys.py
  14. +0 −173 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/users.py
  15. +0 −190 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/walruses.py
  16. +0 −11 clc/eucadmin/build/scripts-2.6/euca-add-user
  17. +0 −11 clc/eucadmin/build/scripts-2.6/euca-add-user-group
  18. +0 −11 clc/eucadmin/build/scripts-2.6/euca-delete-user
  19. +0 −11 clc/eucadmin/build/scripts-2.6/euca-delete-user-group
  20. +0 −11 clc/eucadmin/build/scripts-2.6/euca-deregister-cluster
  21. +0 −11 clc/eucadmin/build/scripts-2.6/euca-deregister-storage-controller
  22. +0 −11 clc/eucadmin/build/scripts-2.6/euca-deregister-walrus
  23. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-clusters
  24. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-components
  25. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-properties
  26. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-services
  27. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-storage-controllers
  28. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-user-groups
  29. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-users
  30. +0 −11 clc/eucadmin/build/scripts-2.6/euca-describe-walruses
  31. +0 −21 clc/eucadmin/build/scripts-2.6/euca-get-credentials
  32. +0 −11 clc/eucadmin/build/scripts-2.6/euca-modify-cluster
  33. +0 −12 clc/eucadmin/build/scripts-2.6/euca-modify-property
  34. +0 −11 clc/eucadmin/build/scripts-2.6/euca-modify-storage-controller
  35. +0 −11 clc/eucadmin/build/scripts-2.6/euca-modify-walrus
  36. +0 −11 clc/eucadmin/build/scripts-2.6/euca-register-cluster
  37. +0 −11 clc/eucadmin/build/scripts-2.6/euca-register-storage-controller
  38. +0 −11 clc/eucadmin/build/scripts-2.6/euca-register-walrus
  39. +0 −486 clc/eucadmin/build/scripts-2.6/euca_conf
  40. +239 −191 configure
  41. +8 −0 configure.ac
View
@@ -47,6 +47,7 @@ ANT = @ANT@ -e
WSDL2C = @WSDL2C@
JAVA_HOME = @JAVA_HOME@
RM = @RM@
+PYTHON_BIN = @PYTHON_BIN@
# compile time configurations
euca_theme = @INTERFACE_THEME@
View
@@ -27,10 +27,10 @@ all: euca_admin
build: euca_admin
euca_admin:
- python2.5 setup.py build
+ $(PYTHON_BIN) setup.py build
install: euca_admin
- python2.5 setup.py install
+ $(PYTHON_BIN) setup.py install
clean:
@$(RM) -fr ./dist
@@ -1,82 +0,0 @@
-# Copyright (c) 2011, Eucalyptus Systems, Inc.
-# All rights reserved.
-#
-# Redistribution and use of this software in source and binary forms, with or
-# without modification, are permitted provided that the following conditions
-# are met:
-#
-# Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the
-# following disclaimer.
-#
-# Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the
-# following disclaimer in the documentation and/or other
-# materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Mitch Garnaat mgarnaat@eucalyptus.com
-
-import boto
-import os
-import sys
-import re
-import urlparse
-from boto.ec2.regioninfo import RegionInfo
-
-__version__ = '1.0a'
-
-class EucAdmin:
-
- def __init__(self, path='/services/Configuration'):
- if not 'EC2_ACCESS_KEY' in os.environ:
- print 'Environment variable EC2_ACCESS_KEY is unset.'
- sys.exit(1)
- if not 'EC2_SECRET_KEY' in os.environ:
- print 'Environment variable EC2_SECRET_KEY is unset.'
- sys.exit(1)
- if not 'EC2_URL' in os.environ:
- print 'Environment variable EC2_URL is unset.'
- sys.exit(1)
- self.path = path
- self.region='eucalyptus'
- self.access_key = os.getenv('EC2_ACCESS_KEY')
- self.secret_key = os.getenv('EC2_SECRET_KEY')
- self.url = os.getenv('EC2_URL')
- self.parsed = urlparse.urlparse(self.url)
- self.connection = boto.connect_euca(self.parsed.hostname,
- self.access_key,
- self.secret_key,
- path=self.path)
- self.connection.APIVersion = 'eucalyptus'
-
- def get_connection(self):
- return self.conn
-
- def handle_error(self,ex):
- s = ""
- if not hasattr(ex,"errors"):
- s = 'ERROR %s' % (ex)
- else:
- if ex.errors.__len__() != 0:
- for i in ex.errors:
- s = '%sERROR %s %s %s: %s\n' % (s,ex.status,
- ex.reason,
- i[0], i[1])
- else:
- s = 'ERROR %s %s %s' % (ex.status, ex.reason, ex)
- while s.count("\n") != 3:
- s = re.sub(".*Exception.*\n", ": ", s)
- print s.replace("\n","")
- sys.exit(1)
@@ -1,206 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2011, Eucalyptus Systems, Inc.
-# All rights reserved.
-#
-# Redistribution and use of this software in source and binary forms, with or
-# without modification, are permitted provided that the following conditions
-# are met:
-#
-# Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the
-# following disclaimer.
-#
-# Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the
-# following disclaimer in the documentation and/or other
-# materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Mitch Garnaat mgarnaat@eucalyptus.com
-
-import sys
-import re
-from boto.exception import EC2ResponseError
-from eucadmin.generic import BooleanResponse
-from eucadmin import EucAdmin
-from optparse import OptionParser
-
-class Cluster():
-
- def __init__(self, cluster_name=None, host_name=None,
- port=None, partition=None, state=None):
- self.cluster_name = cluster_name
- self.host_name = host_name
- self.port = port
- self.partition = partition
- self.state = state
- self.euca = EucaAdmin()
- self.parser = None
-
- def __repr__(self):
- return 'CLUSTER\t%s\t%s\t%s\t%s\t%s' % (self.partition,
- self.cluster_name,
- self.host_name,
- self.state,
- self.detail)
-
- def error(self, msg):
- print msg
- if self.parser:
- self.parser.print_help()
- sys.exit(1)
-
- def startElement(self, name, attrs, connection):
- return None
-
- def endElement(self, name, value, connection):
- if name == 'euca:detail':
- self.detail = value
- elif name == 'euca:state':
- self.state = value
- elif name == 'euca:hostName':
- self.host_name = value
- elif name == 'euca:name':
- self.cluster_name = value
- elif name == 'euca:partition':
- self.partition = value
- else:
- setattr(self, name, value)
-
- def get_describe_parser(self):
- parser = OptionParser("usage: %prog [CLUSTERS...]",
- version="Eucalyptus %prog VERSION")
- return parser.parse_args()
-
- def cli_describe(self):
- (options, args) = self.get_describe_parser()
- self.cluster_describe(args)
-
- def cluster_describe(self,clusters=None):
- params = {}
- if clusters:
- self.euca.connection.build_list_params(params,clusters,'Name')
- try:
- list = self.euca.connection.get_list('DescribeClusters', params,
- [('euca:item', Cluster)])
- for i in list:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_register_parser(self):
- self.parser = OptionParser("usage: %prog [options]",
- version="Eucalyptus %prog VERSION")
- self.parser.add_option("-H","--host",dest="host",
- help="Hostname of the cluster.")
- self.parser.add_option("-p","--port",dest="port",type="int",
- default=8774,
- help="Port for the cluster.")
- self.parser.add_option("-P","--partition",dest="partition",
- help="Partition for the cluster.")
- (options,args) = self.parser.parse_args()
- if len(args) != 1:
- s = "ERROR Required argument CLUSTERNAME is missing or malformed."
- self.error(s)
- else:
- return (options,args)
-
- def cli_register(self):
- (options,args) = self.get_register_parser()
- self.register(args[0], options.host,
- options.port, options.partition)
-
- def register(self, name, host, port=8773, partition=None):
- params = {'Name':name,
- 'Host':host,
- 'Port':port}
- if partition:
- params['Partition'] = partition
- try:
- reply = self.euca.connection.get_object('RegisterCluster',
- params,
- BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_deregister_parser(self):
- self.parser = OptionParser("usage: %prog [options] CLUSTERNAME",
- version="Eucalyptus %prog VERSION")
- self.parser.add_option("-P","--partition",dest="partition",
- help="Partition for the cluster.")
- (options,args) = self.parser.parse_args()
- if len(args) != 1:
- s = "ERROR Required argument CLUSTERNAME is missing or malformed."
- self.error(s)
- else:
- return (options,args)
-
- def cli_deregister(self):
- (options,args) = self.get_deregister_parser()
- self.deregister(args[0])
-
- def deregister(self, name, partition=None):
- params = {'Name':name}
- if partition:
- params['Partition'] = partition
- try:
- reply = self.euca.connection.get_object('DeregisterCluster',
- params,
- BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_modify_parser(self):
- self.parser = OptionParser("usage: %prog [options]",
- version="Eucalyptus %prog VERSION")
- self.parser.add_option("-p","--property",dest="props",
- action="append",
- help="Modify KEY to be VALUE. Can be given multiple times.",
- metavar="KEY=VALUE")
- self.parser.add_option("-P","--partition",dest="partition",
- help="Partition for the cluster.")
- (options,args) = self.parser.parse_args()
- if len(args) != 1:
- s = "ERROR Required argument CLUSTERNAME is missing or malformed."
- self.error(s)
- if not options.props:
- self.error("ERROR No options were specified.")
- for i in options.props:
- if not re.match("^[\w.]+=[\w\.]+$", i):
- s = "ERROR Options must be of the form KEY=VALUE. "
- s += "Illegally formatted option: %s" % i
- self.error(s)
- return (options,args)
-
- def cli_modify(self):
- (options,args) = self.get_modify_parser()
- self.modify(options.partition,args[0], options.props)
-
- def modify(self,partition,name,modify_list):
- for entry in modify_list:
- key, value = entry.split("=")
- try:
- params = {'Partition' : partition,
- 'Name' : name,
- 'Attribute' : key,
- 'Value' : value},
- r = self.euca.connection.get_object('ModifyClusterAttribute',
- params,
- BooleanResponse)
- print r
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
@@ -1,82 +0,0 @@
-# Copyright (c) 2011, Eucalyptus Systems, Inc.
-# All rights reserved.
-#
-# Redistribution and use of this software in source and binary forms, with or
-# without modification, are permitted provided that the following conditions
-# are met:
-#
-# Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the
-# following disclaimer.
-#
-# Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the
-# following disclaimer in the documentation and/or other
-# materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Mitch Garnaat mgarnaat@eucalyptus.com
-
-import StringIO
-import subprocess
-import time
-
-class Command(object):
- """
- A little utility class to wrap calls to shell commands.
- You pass in the command name and any command args.
- The command will then be executed in a pipe and the output
- and status will be available as the attributes "output"
- and "status". The value of the "status" attribute will
- be zero if the command was successful or non-zero if it
- was not successful.
- """
-
- def __init__(self, command, test=False):
- self.exit_code = 0
- self.error = None
- self._stdout_fp = StringIO.StringIO()
- self._stderr_fp = StringIO.StringIO()
- self.command = command
- self.run()
-
- def run(self):
- if self.test:
- print self.command
- return 0
- self.process = subprocess.Popen(self.command, shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- while self.process.poll() == None:
- time.sleep(1)
- t = self.process.communicate()
- self._stdout_fp.write(t[0])
- self._stderr_fp.write(t[1])
- self.exit_code = self.process.returncode
- return self.exit_code
-
- @property
- def status(self):
- return self.exit_code
-
- @property
- def stdout(self):
- return self._stdout_fp.getvalue()
-
- @property
- def stderr(self):
- return self._stderr_fp.getvalue()
-
-
Oops, something went wrong.

0 comments on commit 3b64149

Please sign in to comment.