Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing up some python weirdness

  • Loading branch information...
commit 3b64149f361080adf6ce94bf0df6650483c501ca 1 parent 3c5c42c
root authored
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
1  Makedefs.in
@@ -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
4 clc/eucadmin/Makefile
@@ -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
View
82 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/__init__.py
@@ -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)
View
206 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/clusters.py
@@ -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)
-
View
82 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/command.py
@@ -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()
-
-
View
246 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/components.py
@@ -1,246 +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 boto,sys,eucadmin,re
-from boto.exception import EC2ResponseError
-from eucadmin.generic import BooleanResponse
-from eucadmin.generic import StringList
-from eucadmin import EucaAdmin
-from optparse import OptionParser
-
-SERVICE_PATH = '/services/Configuration'
-class Component():
-
- def __init__(self, component_name=None, host_name=None,
- port=None, partition=None, state=None):
- self.component_name = component_name
- self.host_name = host_name
- self.port = port
- self.partition = partition
- self.state = state
- self.euca = EucaAdmin(path=SERVICE_PATH)
- self.verbose = False
-
- def __repr__(self):
- return 'COMPONENT\t%-15.15s\t%-15.15s\t%-25s\t%s\t%s' % (self.partition, self.component_name,
- self.host_name, self.state, self.detail )
-
- 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.component_name = value
- elif name == 'euca:partition':
- self.partition = value
- else:
- setattr(self, name, value)
-
- def get_describe_parser(self):
- parser = OptionParser("usage: %prog [COMPONENTS...]",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-v", "--verbose", dest="verbose", default=False, action="store_true", help="Report verbose details about the state of the component.")
- return parser.parse_args()
-
- def cli_describe(self):
- (options, args) = self.get_describe_parser()
- self.component_describe(args,options.verbose)
-
- def component_describe(self,components=None,verbose=False):
- params = {}
- if components:
- self.euca.connection.build_list_params(params,components,'Name')
- try:
- list = self.euca.connection.get_list('DescribeComponents', params,
- [('euca:item', Component)])
- for i in list:
- if verbose:
- print i
- elif not verbose and not i.host_name == 'detail':
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_modify_parser(self):
- parser = OptionParser("usage: %prog [options]",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-p","--property",dest="props",
- action="append",
- help="Modify KEY to be VALUE. Can be given multiple times.",
- metavar="KEY=VALUE")
- parser.add_option("-P","--partition",dest="partition",
- help="Partition for the component.")
- (options,args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument COMPONENTNAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- if not options.props:
- print "ERROR No options were specified."
- parser.print_help()
- sys.exit(1)
- for i in options.props:
- if not re.match("^[\w.]+=[\w\.]+$",i):
- print "ERROR Options must be of the form KEY=VALUE. Illegally formatted option: %s" % i
- parser.print_help()
- sys.exit(1)
- 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:
- reply = self.euca.connection.get_object('ModifyComponentAttribute',
- {'Partition' : partition, 'Name' : name, 'Attribute' : key,'Value' : value},
- BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
-class ServiceStatus():
- def __init__(self, service_uuid=None, service_name=None, service_partition=None, service_type=None, service_url=None):
- self.service_uuid = service_uuid
- self.service_name = service_name
- self.service_partition = service_partition
- self.service_type = service_type
- self.service_url = service_url
-
- def __repr__(self):
- return '%-15.15s\t%s' % (self.service_type.upper(), ('%s.%s'% (self.service_partition, self.service_name)))
-
- def startElement(self, name, attrs, connection):
- return None
-
- def endElement(self, name, value, connection):
- if name == 'euca:uuid':
- self.service_uuid = value
- elif name == 'euca:partition':
- self.service_partition = value
- elif name == 'euca:name':
- self.service_name = value
- elif name == 'euca:type':
- self.service_type = value
- elif name == 'euca:uri':
- self.service_uri = value
- else:
- setattr(self, name, value)
-
-
-class Service():
-
- def __init__(self, service_epoch=None, service_state=None, service_detail=None):
- self.service_epoch = service_epoch
- self.service_state = service_state
- self.service_detail = StringList()
- self.service_id = ServiceStatus()
- self.euca = EucaAdmin(path=SERVICE_PATH)
- self.verbose = False
-
- def __repr__(self):
- return 'SERVICE\t%s\t%s\t%s\t%s' % (self.service_id, self.service_state, self.service_epoch, self.service_id.service_url )
-
- def startElement(self, name, attrs, connection):
- if name == 'euca:serviceId':
- return self.service_id
- elif name == 'euca:details':
- return self.service_detail
- else:
- return None
-
- def endElement(self, name, value, connection):
- if name == 'euca:item':
- self.service_detail = '%s, %s' % (self.service_detail, value)
- elif name == 'euca:localState':
- self.service_state = value
- elif name == 'euca:localEpoch':
- self.service_epoch = value
- else:
- setattr(self, name, value)
-
- def get_describe_parser(self):
- parser = OptionParser("usage: %prog [COMPONENTS...]",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-v", "--verbose", dest="verbose", default=False, action="store_true", help="Report verbose details about the state of the component.")
- return parser.parse_args()
-
- def cli_describe(self):
- (options, args) = self.get_describe_parser()
- self.service_describe(args,options.verbose)
-
- def service_describe(self,components=None,verbose=False):
- params = {}
- if components:
- self.euca.connection.build_list_params(params,components,'Name')
- try:
- list = self.euca.connection.get_list('DescribeServices', params,
- [('euca:item', Service)])
- for i in list:
- if verbose:
- print i
- elif not verbose:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_modify_parser(self):
- parser = OptionParser("usage: %prog [COMPONENTS...]",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-s", "--state", dest="state", default=False, action="store_true", help="Attempt to change the state of the service to be <state>.")
- return parser.parse_args()
-
- def cli_modify(self):
- (options, args) = self.get_modify_parser()
- self.service_modify(args,options.verbose)
-
- def service_modify(self,operation=None,service_type=None,service_partition=None,service_name=None,verbose=False):
- params = {}
- if components:
- self.euca.connection.build_list_params(params,components,'Name')
- try:
- list = self.euca.connection.get_list('DescribeServices', params,
- [('euca:item', Service)])
- for i in list:
- if verbose:
- print i
- elif not verbose:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
View
72 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/generic.py
@@ -1,72 +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 boto,sys
-
-class BooleanResponse:
- def __init__(self, reply=False):
- self.reply = reply
- self.error = None
-
- def __repr__(self):
- if self.error:
- print 'RESPONSE %s' % self.error
- sys.exit(1)
- else:
- return 'RESPONSE %s' % self.reply
-
- def startElement(self, name, attrs, connection):
- return None
-
- def endElement(self, name, value, connection):
- if name == 'euca:_return':
- self.reply = value
- elif name == 'Message':
- self.error = value
- else:
- setattr(self, name, value)
-
-
-class StringList(list):
-
- def __repr__(self):
- r = ""
- for i in self:
- r = "%s %s" % (r,i)
- return r
-
- def startElement(self, name, attrs, connection):
- pass
-
- def endElement(self, name, value, connection):
- if name == 'euca:entry':
- self.append(value)
-
View
121 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/groups.py
@@ -1,121 +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 boto,sys,eucadmin
-from boto.exception import EC2ResponseError
-from eucadmin.generic import BooleanResponse
-from eucadmin.generic import StringList
-from boto.resultset import ResultSet
-from eucadmin import EucaAdmin
-from optparse import OptionParser
-
-SERVICE_PATH = '/services/Accounts'
-class Group():
-
-
- def __init__(self, groupName=None):
- self.group_groupName = groupName
- self.group_users = StringList()
- self.group_auths = StringList()
- self.euca = EucaAdmin(path=SERVICE_PATH)
-
- def __repr__(self):
- r = 'GROUP \t%s\t' % (self.group_groupName)
- r = '%s\nUSERS\t%s\t%s' % (r,self.group_groupName,self.group_users)
- r = '%s\nAUTH\t%s\t%s' % (r,self.group_groupName,self.group_auths)
- return r
-
- def startElement(self, name, attrs, connection):
- if name == 'euca:users':
- return self.group_users
- if name == 'euca:authorizations':
- return self.group_auths
- else:
- return None
-
- def endElement(self, name, value, connection):
- if name == 'euca:groupName':
- self.group_groupName = value
- else:
- setattr(self, name, value)
-
- def get_describe_parser(self):
- parser = OptionParser("usage: %prog [GROUPS...]",version="Eucalyptus %prog VERSION")
- return parser.parse_args()
-
- def cli_describe(self):
- (options, args) = self.get_describe_parser()
- self.group_describe(args)
-
- def group_describe(self,groups=None):
- params = {}
- if groups:
- self.euca.connection.build_list_params(params,groups,'GroupNames')
- try:
- list = self.euca.connection.get_list('DescribeGroups', params, [('euca:item', Group)])
- for i in list:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_single_parser(self):
- parser = OptionParser("usage: %prog GROUPNAME",version="Eucalyptus %prog VERSION")
- (options,args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument GROUPNAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- else:
- return (options,args)
-
- def cli_add(self):
- (options, args) = self.get_single_parser()
- self.group_add(args[0])
-
- def group_add(self, groupName):
- try:
- reply = self.euca.connection.get_object('AddGroup', {'GroupName':groupName}, BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def cli_delete(self):
- (options, args) = self.get_single_parser()
- self.group_delete(args[0])
-
- def group_delete(self, groupName):
- try:
- reply = self.euca.connection.get_object('DeleteGroup', {'GroupName':groupName},BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
-
View
74 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/heartbeat.py
@@ -1,74 +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.utils
-import urlparse
-
-class Heartbeat(object):
-
- def __init__(self, host, port=8773,
- path='services/Heartbeat',
- is_secure=False):
- self.host = host
- self.service = service
- self.port = port
- self.path = path
- self.is_secure = is_secure
- if self.is_secure:
- self.scheme = 'https'
- else:
- self.scheme = 'http'
- t = (self.scheme, '%s:%s' % (self.host, self.port), self.path, '', '')
- self.url = urlparse.urlunsplit(t)
- self.data = None
- self.get_heartbeat_data()
-
- def __repr__(self):
- return '<Heartbeat: %s>' % self.url
-
- def _get_value(self, value):
- if value == 'true':
- value = True
- elif value == 'false':
- value = False
- return value
-
- def get_heartbeat_data(self):
- resp = boto.utils.retry_url(self.url)
- lines = resp.splitlines()
- self.data = {}
- for line in lines:
- pairs = line.split()
- t = pairs[0].split('=')
- d = {}
- self.data[t[1]] = d
- for pair in pairs[1:]:
- t = pair.split('=')
- d[t[0]] = self._get_value(t[1])
View
108 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/hypervregister.py
@@ -1,108 +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 os
-import sys
-import tempfile
-import shutil
-import command
-
-class HyperVRegister(object):
-
- KeyDirPath = "%s/var/lib/eucalyptus/keys"
-
- def __init__(self, hostname, registration_password,
- euca_dir='/opt/eucalyptus', debug=False):
- self.hostname = hostname
- self.registration_password = registration_password
- self.euca_dir = euca_dir
- self.euca_key_dir = self.KeyDirPath % self.euca_dir
- self.tmp_dir = self.create_tmp_dir()
- self.debug = debug
- self.commands = []
-
- def create_tmp_dir(self):
- return tempfile.mkdtemp()
-
- def delete_tmp_dir(self):
- if not self.debug:
- if os.path.isdir(self.tmp_dir):
- shutil.rmtree(self.tmp_dir)
-
- def error(self, msg):
- self.delete_tmp_dir()
- print msg
- sys.exit(1)
-
- def copy_key_file(self, file_name):
- file_path = os.path.join(self.euca_key_dir, file_name)
- if not os.path.exists(file_path):
- self.error('%s not found' % file_path)
- try:
- shutil.copy(file_path, self.tmp_dir)
- except:
- self.error('Error copying %s to %s' % (file_path, self.tmp_dir))
-
- def copy_files_to_node(self):
- files = ['node.p12', 'cluster-cert.pem', 'cloud-cert.pem']
- cur_dir = os.getcwd()
- os.chdir(self.tmp_dir)
- cmd = 'smbclient "//%s/EucaKeyShare"' % self.hostname
- cmd += ' --user=Administrator'
- l = ['put %s' % fn for fn in files]
- cmd += ' --command "%s%' % '; '.join(l)
- cmd = command.Command(cmd)
- os.chdir(cur_dir)
- for fn in files:
- if cmd.stderr.find('putting file %s' % fn) < 0:
- self.error('REGISTRATION FAILED')
- self.commands.append(cmd)
-
- def generate_nodep12(self):
- node_cert = os.path.join(self.tmp_dir, 'node-cert.pem')
- node_pk = os.path.join(self.tmp_dir, 'node-pk.pem')
- p12_file = os.path.join(self.tmp_dir, 'node.p12')
- cmd = 'openssl pkcs12 -export -in %s' % node_cert
- cmd += ' -inkey %s' % node_pk
- cmd += ' -password "pass:%s"' % self.registration_password
- cmd += ' -out %s' % p12_file
- self.commands.append(command.Command(cmd))
- if not os.path.isfile(p12_file):
- self.error('%s file was not created' % p12_file)
-
- def main(self):
- self.copy_key_file('node-cert.pem')
- self.copy_key_file('node-pk.pem')
- self.copy_key_file('cloud-cert.pem')
- self.copy_key_file('cluster-cert.pem')
- self.generate_nodep12()
- self.copy_files_to_node()
- self.delete_tmp_dir()
-
View
177 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/properties.py
@@ -1,177 +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 boto,sys,eucadmin,re,os
-from boto.exception import EC2ResponseError
-from eucadmin.generic import BooleanResponse
-from eucadmin import EucaAdmin
-from optparse import OptionParser
-from string import split
-import pdb
-
-SERVICE_PATH = '/services/Properties'
-VERBOSE = False
-class Property():
-
-
- def __init__(self, property_name=None, property_value=None,
- property_description=None, property_old_value=None):
- self.property_name = property_name
- self.property_value = property_value
- self.property_description = property_description
- self.property_old_value = property_old_value
- self.euca = EucaAdmin(path=SERVICE_PATH)
-
-
- def __repr__(self):
- global VERBOSE
- str = 'PROPERTY\t%s\t%s' % (self.property_name, self.property_value)
- if self.property_old_value is not None:
- str = '%s was %s' % (str, self.property_old_value)
- elif VERBOSE:
- str = '%s\nDESCRIPTION\t%s\t%s' % (str, self.property_name, self.property_description)
- return str
-
- def startElement(self, name, attrs, connection):
- return None
-
- def endElement(self, name, value, connection):
- if name == 'euca:name':
- self.property_name = value
- elif name == 'euca:value':
- self.property_value = value
- elif name == 'euca:oldValue':
- self.property_old_value = value
- elif name == 'euca:description':
- self.property_description = value
- else:
- setattr(self, name, value)
-
- def get_parser(self):
- parser = OptionParser("usage: %prog [PROPERTY...]", version="Eucalyptus %prog VERSION")
- parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
- help="Show property descriptions.")
- return parser
-
- def parse_describe(self):
- global VERBOSE
- (options,args) = self.get_parser().parse_args()
- if options.verbose:
- VERBOSE = True
- return (options,args)
-
- def cli_describe(self):
- (options,args) = self.parse_describe()
- self.describe(args)
-
- def describe(self,props=None):
- params = {}
- if props:
- self.euca.connection.build_list_params(params,props,'Properties')
- try:
- list = self.euca.connection.get_list('DescribeProperties',
- params, [('euca:item', Property)])
- for i in list:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_parse_modify(self):
- parser = self.get_parser()
- parser.add_option("-p","--property",dest="props",action="append",
- help="Modify KEY to be VALUE. Can be given multiple times.",
- metavar="KEY=VALUE")
- parser.add_option("-f","--property-from-file",dest="files",action="append",
- help="Modify KEY to be modified with content of a file.",
- metavar="KEY=<path to file>")
- global VERBOSE
- (options,args) = parser.parse_args()
- if options.verbose:
- VERBOSE = True
- if not options.props and not options.files:
- print "ERROR No options were specified."
- parser.print_help()
- sys.exit(1)
- else:
- if options.props:
- for i in options.props:
- if not re.match("^[\w.]+=[/\w\.]+$",i):
- print "ERROR Options must be of the form KEY=VALUE. Illegally formatted option: %s" % i
- parser.print_help()
- sys.exit(1)
- elif options.files:
- pass
- return (options,args)
-
- def cli_modify(self):
- (options,args) = self.get_parse_modify()
- self.modify(options.props)
- self.modify_from_file(options.files)
-
- def _modify(self, name, value):
- try:
- result = self.euca.connection.get_object('ModifyPropertyValue',
- {'Name' : name, 'Value' : value},
- Property, verb='POST')
- print result
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def modify(self,modify_list):
- if modify_list:
- for i in modify_list:
- new_prop = split(i,"=")
- if not len(new_prop) == 2:
- print "ERROR Options must be of the form KEY=VALUE. Illegally formatted option: %s" % i
- sys.exit(1)
- self._modify(new_prop[0], new_prop[1])
-
- def modify_from_file(self,modify_list):
- if modify_list:
- for i in modify_list:
- new_prop = split(i,"=")
- if not len(new_prop) == 2:
- print "ERROR Options must be of the form KEY=VALUE. Illegally formatted option: %s" % i
- sys.exit(1)
- file_path = new_prop[1]
- if file_path == '-':
- value = sys.stdin.read()
- else:
- file_path = os.path.expanduser(file_path)
- file_path = os.path.expandvars(file_path)
- if not os.path.isfile(file_path):
- print "ERROR File %s does not exist" % file_path
- sys.exit(1)
- fp = open(file_path)
- value = fp.read()
- fp.close()
- self._modify(new_prop[0], value)
-
View
198 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/storagecontrollers.py
@@ -1,198 +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 boto,sys,eucadmin,re
-from boto.exception import EC2ResponseError
-from eucadmin.generic import BooleanResponse
-from eucadmin import EucaAdmin
-from optparse import OptionParser
-
-SERVICE_PATH = '/services/Configuration'
-
-class StorageController():
-
- def __init__(self, storage_name=None, host_name=None,
- port=None, partition=None, state=None):
- self.storage_name = storage_name
- self.host_name = host_name
- self.port = port
- self.partition = partition
- self.state = state
- self.euca = EucaAdmin(path=SERVICE_PATH)
-
- def __repr__(self):
- return 'STORAGE\t%s\t%s\t%s\t%s\t%s' % (self.partition, self.storage_name,
- self.host_name, self.state, self.detail)
-
- 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.storage_name = value
- elif name == 'euca:partition':
- self.partition = value
- else:
- setattr(self, name, value)
-
- def get_describe_parser(self):
- parser = OptionParser("usage: %prog [NAME...]",
- version="Eucalyptus %prog VERSION")
- return parser.parse_args()
-
- def cli_describe(self):
- (options, args) = self.get_describe_parser()
- self.describe(args)
-
- def describe(self,scs=None):
- params = {}
- if scs:
- self.euca.connection.build_list_params(params,groups,'Names')
- try:
- list = self.euca.connection.get_list('DescribeStorageControllers',
- params,
- [('euca:item', StorageController)])
- for i in list:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_register_parser(self):
- parser = OptionParser("usage: %prog [options] NAME",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-H","--host",dest="host",
- help="Hostname of the storage.")
- parser.add_option("-p","--port",dest="port",type="int",default=8773,
- help="Port for the storage.")
- parser.add_option("-P","--partition",dest="partition",
- help="Partition for the storage.")
- (options,args) = parser.parse_args()
- if options.host == None:
- self.euca.handle_error("You must provide a hostname (-H or --host)")
- if len(args) != 1:
- print "ERROR Required argument NAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- 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('RegisterStorageController',
- params, BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_deregister_parser(self):
- parser = OptionParser("usage: %prog [options] NAME",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-P","--partition",dest="partition",
- help="Partition for the storage.")
- (options,args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument NAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- 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('DeregisterStorageController',
- params,
- BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_modify_parser(self):
- parser = OptionParser("usage: %prog [options]",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-p","--property",dest="props",
- action="append",
- help="Modify KEY to be VALUE. Can be given multiple times.",
- metavar="KEY=VALUE")
- parser.add_option("-P","--partition",dest="partition",
- help="Partition for the storage.")
- (options,args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument SCNAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- if not options.props:
- print "ERROR No options were specified."
- parser.print_help()
- sys.exit(1)
- for i in options.props:
- if not re.match("^[\w.]+=[\w\.]+$",i):
- print "ERROR Options must be of the form KEY=VALUE. Illegally formatted option: %s" % i
- parser.print_help()
- sys.exit(1)
- 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:
- reply = self.euca.connection.get_object('ModifyStorageControllerAttribute',
- {'Partition' : partition, 'Name' : name, 'Attribute' : key,'Value' : value},
- BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
View
139 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/synckeys.py
@@ -1,139 +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 os
-import sys
-import socket
-import shutil
-
-import command
-
-def mklist(v):
- if not isinstance(v, (list, tuple)):
- v = [v]
- return v
-
-SyncMethods = ['local', 'rsync', 'scp', 'smb']
-
-class SyncKeys(object):
-
- def __init__(self, src_dirs, dst_dir, remote_host, file_names,
- use_rsync=True, use_scp=True, use_smb=False):
- self.src_dirs = mklist(src_dirs)
- self.src_dirs = [os.path.expanduser(sd) for sd in self.src_dirs]
- self.src_dirs = [os.path.expandvars(sd) for sd in self.src_dirs]
- self.dst_dir = dst_dir
- self.remote_host = remote_host
- self.file_names = mklist(file_names)
- self.use_rsync = use_rsync
- self.use_scp = use_scp
- self.use_smb = use_smb
- self.files = []
- self.is_remote = True
-
- def error(self, msg):
- print 'Error: %s' % msg
- sys.exit(1)
-
- def warning(self, msg):
- print 'Warning: %s' % msg
-
- def get_file_list(self):
- found = []
- for fn in self.file_names:
- for sd in self.src_dirs:
- path = os.path.join(sd, fn)
- if os.path.isfile(path):
- self.files.append(path)
- found.append(fn)
- not_found = [fn for fn in self.file_names if fn not in found]
- if not_found:
- self.warning("Can't find %s in %s" % (not_found, self.src_dirs))
-
- def check_remote(self):
- if remote_host == '127.0.0.1':
- self.is_remote = False
- elif remote_host == 'localhost':
- self.is_remote = False
- elif remote_host == socket.gethostname():
- self.is_remote = False
-
- def sync_local(self):
- for fn in self.files:
- if not os.path.isfile(fn):
- self.error('cannot find cluster credentials')
- else:
- try:
- shutil.copystat(fn, self.dst_dir)
- except:
- self.error('cannot copy %s to %s' % (fn, self.dst_dir))
-
- def sync_rsync(self):
- if not self.use_rsync:
- return
- print
- print 'Trying rsync to sync keys with %s' % self.remote_host
- cmd = 'rsync -az '
- cmd += ' '.join(self.files)
- cmd += ' %s:%s/' % (self.remote_host, self.dst_dir)
- cmd = Command(cmd, test=True)
- if cmd.status == 0:
- print 'done'
- return True
- else:
- print 'failed.'
- return False
-
- def get_euca_user(self):
- euca_user = os.environ.get('EUCA_USER', None)
- if not euca_user:
- try:
- pwd.getpwname('eucalyptus')
- euca_user = 'eucalyptus'
- except KeyError:
- self.error('EUCA_USER is not defined!')
- return euca_user
-
- def sync_scp(self):
- euca_user = self.get_euca_user()
- print
- print 'Trying scp to sync keys with %s (user %s)' % (self.remote_host,
- euca_user)
- # TODO: handle sudo password prompt
- cmd = 'sudo -u %s scp ' % euca_user
- cmd += ' '.join(self.files)
- cmd += ' %s@%s:%s' % (euca_user, self.remote_host, self.dst_dir)
- cmd = Command(cmd, test=True)
- if cmd.status == 0:
- print 'done'
- return True
- else:
- print 'failed.'
- return False
View
173 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/users.py
@@ -1,173 +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 boto, sys, eucadmin
-from eucadmin.generic import StringList
-from boto.exception import EC2ResponseError
-from eucadmin.generic import BooleanResponse
-from eucadmin import EucaAdmin
-from optparse import OptionParser
-
-SERVICE_PATH = '/services/Accounts'
-class User():
-
-
- def __init__(self, userName=None, email="N/A", certificateCode=None, confirmationCode=None, accessKey=None, secretKey=None, confirmed=False, admin=False, enabled=False, distinguishedName=None, certificateSerial=None):
- self.user_userName = userName
- self.user_email = email
- self.user_distinguishedName = distinguishedName
- self.user_certificateSerial = certificateSerial
- self.user_certificateCode = certificateCode
- self.user_confirmationCode = confirmationCode
- self.user_accessKey = accessKey
- self.user_secretKey = secretKey
- self.user_confirmed = confirmed
- self.user_admin = admin
- self.user_enabled = enabled
- self.user_groups = StringList()
- self.user_revoked = StringList()
- self.user_list = self.user_groups
- self.euca = EucaAdmin(path=SERVICE_PATH)
-
- def __repr__(self):
- r = 'USER\t\t%s\t%s%s\t%s' % (self.user_userName, self.user_email, '\tADMIN' if self.user_admin == 'true' else ' ', 'ENABLED' if self.user_enabled == 'true' else 'DISABLED')
- r = '%s\nUSER-GROUP\t%s\t%s' % (r, self.user_userName, self.user_groups)
- r = '%s\nUSER-CERT\t%s\t%s\t%s' % (r, self.user_userName, self.user_distinguishedName, self.user_certificateSerial)
-# for s in self.user_revoked:
-# r = '%s\nUSER-REVOKED\t%s\t%s' % (r,self.user_userName,s)
- r = '%s\nUSER-KEYS\t%s\t%s\t%s' % (r, self.user_userName, self.user_accessKey, self.user_secretKey)
- r = '%s\nUSER-CODE\t%s\t%s' % (r, self.user_userName, self.user_certificateCode)
- r = '%s\nUSER-WEB \t%s\t%s' % (r, self.user_userName, self.user_confirmationCode)
- return r
-
- def startElement(self, name, attrs, connection):
- if name == 'euca:groups':
- return self.user_groups
- elif name == 'euca:revoked':
- return self.user_revoked
- else:
- return None
-
- def endElement(self, name, value, connection):
- if name == 'euca:userName':
- self.user_userName = value
- elif name == 'euca:email':
- self.user_email = value
- elif name == 'euca:admin':
- self.user_admin = value
- elif name == 'euca:confirmed':
- self.user_confirmed = value
- elif name == 'euca:enabled':
- self.user_enabled = value
- elif name == 'euca:distinguishedName':
- self.user_distinguishedName = value
- elif name == 'euca:certificateSerial':
- self.user_certificateSerial = value
- elif name == 'euca:certificateCode':
- self.user_certificateCode = value
- elif name == 'euca:confirmationCode':
- self.user_confirmationCode = value
- elif name == 'euca:accessKey':
- self.user_accessKey = value
- elif name == 'euca:secretKey':
- self.user_secretKey = value
- elif name == 'euca:entry':
- self.user_list.append(value)
- else:
- setattr(self, name, value)
-
- def get_describe_parser(self):
- parser = OptionParser("usage: %prog [USERNAME...", version="Eucalyptus %prog VERSION")
- (options, args) = parser.parse_args()
- return (options, args)
-
- def cli_describe(self):
- (options, args) = self.get_describe_parser()
- self.describe(args)
-
-
- def describe(self,users):
- params = {}
- if users:
- self.euca.connection.build_list_params(params, users, 'UserNames')
- try:
- list = self.euca.connection.get_list('DescribeUsers', params, [('euca:item', User)])
- for i in list:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
-
- def get_add_parser(self):
- parser = OptionParser("usage: %prog [options] USERNAME", version="Eucalyptus %prog VERSION")
- parser.add_option("-e", "--email", dest="email", default="N/A", help="Email of the User.")
- parser.add_option("-a", "--admin", dest="admin", default=False, action="store_true", help="Mark user as admin.")
- (options, args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument USERNAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- else:
- return (options, args)
-
- def cli_add(self):
- (options, args) = self.get_add_parser();
- self.add(args[0], options.email, options.admin)
-
- def add(self, user_userName, user_email, user_admin):
- try:
- reply = self.euca.connection.get_object('AddUser', {'UserName':user_userName, 'Email':user_email, 'Admin':user_admin}, BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_delete_parser(self):
- parser = OptionParser("usage: %prog [options] USERNAME", version="Eucalyptus %prog VERSION")
- (options, args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument USERNAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- else:
- return (options, args)
-
- def cli_delete(self):
- (options, args) = self.get_delete_parser();
- self.delete(args[0])
-
- def delete(self, user_name):
- try:
- reply = self.euca.connection.get_object('DeleteUser', {'UserName':user_name}, BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
-
View
190 clc/eucadmin/build/lib.linux-x86_64-2.6/eucadmin/walruses.py
@@ -1,190 +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 boto,sys,eucadmin,re
-from boto.exception import EC2ResponseError
-from eucadmin.generic import BooleanResponse
-from eucadmin import EucaAdmin
-from optparse import OptionParser
-
-SERVICE_PATH = '/services/Configuration'
-class Walrus():
-
- def __init__(self, walrus_name=None, host_name=None,
- port=None, partition=None, state=None):
- self.walrus_name = walrus_name
- self.host_name = host_name
- self.port = port
- self.partition = partition
- self.state = state
- self.euca = EucaAdmin(path=SERVICE_PATH)
-
- def __repr__(self):
- return 'WALRUS\t%s\t%s\t%s\t%s\t%s' % (self.partition, self.walrus_name,
- self.host_name, self.state, self.detail)
-
- 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.walrus_name = value
- elif name == 'euca:partition':
- self.partition = value
- else:
- setattr(self, name, value)
-
- def describe(self):
- parser = OptionParser("usage: %prog [options]",
- version="Eucalyptus %prog VERSION")
- (options, args) = parser.parse_args()
- try:
- list = self.euca.connection.get_list('DescribeWalruses', {},
- [('euca:item', Walrus)])
- for i in list:
- print i
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_register_parser(self):
- parser = OptionParser("usage: %prog [options]",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-H","--host",dest="host",
- help="Hostname of the walrus.")
- parser.add_option("-p","--port",dest="port",type="int",
- default=8773,help="Port for the walrus.")
- parser.add_option("-P","--partition",dest="partition",
- help="Partition for the walrus.")
- (options,args) = parser.parse_args()
- if options.host == None:
- self.euca.handle_error("You must provide a hostname (-H or --host)")
- return (options,args)
-
- def cli_register(self):
- (options, args) = self.get_register_parser()
- if len(args) != 1:
- self.register(options.host,port=options.port)
- else:
- self.register(options.host,name=args[0],
- port=options.port, partition=options.partition)
-
- def register(self, host, name='walrus', port=8773, partition=None):
- if host == None:
- self.euca.handle_error("Missing hostname")
- params = {'Name':'walrus',
- 'Host':host,
- 'Port':port}
- if partition:
- params['Partition'] = partition
- try:
- reply = self.euca.connection.get_object('RegisterWalrus',
- params,
- BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_deregister_parser(self):
- parser = OptionParser("usage: %prog [options] NAME",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-P","--partition",dest="partition",
- help="Partition for the walrus.")
- (options,args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument NAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- else:
- return (options,args)
-
- def cli_deregister(self):
- (options, args) = self.get_deregister_parser()
- if len(args) != 1:
- self.deregister()
- else:
- self.deregister(args[0])
-
- def deregister(self, name, partition='walrus'):
- params = {'Name':name}
- if partition:
- params['Partition'] = partition
- try:
- reply = self.euca.connection.get_object('DeregisterWalrus',
- {'Name':name},BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
-
- def get_modify_parser(self):
- parser = OptionParser("usage: %prog [options]",
- version="Eucalyptus %prog VERSION")
- parser.add_option("-p","--property",dest="props",
- action="append",
- help="Modify KEY to be VALUE. Can be given multiple times.",
- metavar="KEY=VALUE")
- parser.add_option("-P","--partition",dest="partition",
- help="Partition for the storage.")
- (options,args) = parser.parse_args()
- if len(args) != 1:
- print "ERROR Required argument WALRUSNAME is missing or malformed."
- parser.print_help()
- sys.exit(1)
- if not options.props:
- print "ERROR No options were specified."
- parser.print_help()
- sys.exit(1)
- for i in options.props:
- if not re.match("^[\w.]+=[\w\.]+$",i):
- print "ERROR Options must be of the form KEY=VALUE. Illegally formatted option: %s" % i
- parser.print_help()
- sys.exit(1)
- 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:
- reply = self.euca.connection.get_object('ModifyWalrusAttribute',
- {'Partition' : partition, 'Name' : name, 'Attribute' : key,'Value' : value},
- BooleanResponse)
- print reply
- except EC2ResponseError, ex:
- self.euca.handle_error(ex)
View
11 clc/eucadmin/build/scripts-2.6/euca-add-user
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.users import User
-
-def main():
- c = User().cli_add()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-add-user-group
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.groups import Group
-
-def main():
- c = Group().cli_add()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-delete-user
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.users import User
-
-def main():
- c = User().cli_delete()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-delete-user-group
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.groups import Group
-
-def main():
- c = Group().cli_delete()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-deregister-cluster
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.clusters import Cluster
-
-def main():
- c = Cluster().cli_deregister()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-deregister-storage-controller
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.storagecontrollers import StorageController
-
-def main():
- c = StorageController().cli_deregister()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-deregister-walrus
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.walruses import Walrus
-
-def main():
- c = Walrus().cli_deregister()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-clusters
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.clusters import Cluster
-
-def main():
- c = Cluster().cli_describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-components
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.components import Component
-
-def main():
- c = Component().cli_describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-properties
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.properties import Property
-
-def main():
- c = Property().cli_describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-services
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.components import Service
-
-def main():
- c = Service().cli_describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-storage-controllers
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.storagecontrollers import StorageController
-
-def main():
- c = StorageController().cli_describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-user-groups
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.groups import Group
-
-def main():
- Group().cli_describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-users
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.users import User
-
-def main():
- c = User().cli_describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-describe-walruses
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.walruses import Walrus
-
-def main():
- c = Walrus().describe()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
21 clc/eucadmin/build/scripts-2.6/euca-get-credentials
@@ -1,21 +0,0 @@
-#!/usr/bin/python
-import sys, os, boto, psutil, re, getpass
-from eucadmin import local
-from optparse import OptionParser
-
-def main():
- parser = OptionParser("usage: %prog FILENAME",version="Eucalyptus %prog VERSION",description="Download the admin credentials for the locally hosted Eucalyptus installation")
- parser.add_option("-s","--source",dest="source",default=False,action="store_true",help="Unzip (and remove zipfile) and output 'eucarc'. If FILENAME is specified the archive will be extracted to `dirname FILENAME`. Otherwise, the archive is extracted to the current working directory.")
- (options,args) = parser.parse_args()
- file = None
- if len(args) != 1 and not options.source:
- parser.print_help()
- sys.exit()
- elif len(args) != 0:
- file = args[0]
- local.get_credentials(file,options.source)
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-modify-cluster
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.clusters import Cluster
-
-def main():
- c = Cluster().cli_modify()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
12 clc/eucadmin/build/scripts-2.6/euca-modify-property
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-import getopt, sys, os, boto
-from boto.ec2.regioninfo import RegionInfo
-from eucadmin.properties import Property
-
-def main():
- c = Property().cli_modify()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-modify-storage-controller
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.storagecontrollers import StorageController
-
-def main():
- c = StorageController().cli_modify()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-modify-walrus
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.walruses import Walrus
-
-def main():
- c = Walrus().cli_modify()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-register-cluster
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.clusters import Cluster
-
-def main():
- c = Cluster().cli_register()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-register-storage-controller
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.storagecontrollers import StorageController
-
-def main():
- c = StorageController().cli_register()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
11 clc/eucadmin/build/scripts-2.6/euca-register-walrus
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-import sys
-from eucadmin.walruses import Walrus
-
-def main():
- c = Walrus().cli_register()
- sys.exit()
-
-if __name__ == "__main__":
- main()
-
View
486 clc/eucadmin/build/scripts-2.6/euca_conf
@@ -1,486 +0,0 @@
-#!/usr/bin/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 optparse
-import inspect
-import os
-import sys
-import boto.utils
-import eucadmin.configfile
-
-DefaultEucaDir = '/opt/eucalyptus/eee-root'
-DefaultEucaConfPath = 'etc/eucalyptus/eucalyptus.conf'
-
-class EucaConf(object):
-
- # list of services which can be checked
- CheckedServices = ['cc', 'cloud', 'nc', 'sc',
- 'walrus', 'vmware', 'vmwarebroker']
-
- # list of services which can be enabled/disabled
- EnabledServices = ['cloud', 'walrus', 'sc', 'vmwarebroker']
-
- def __init__(self, filepath=None):
- self.debug = 0
- self.config = None
- self.specified_options = {}
- self.parser = optparse.OptionParser()
- self.parser.add_option('--heartbeat', action='store', type='string',
- help='get heartbeat data for <host>')
- self.parser.add_option('--synckey', action='store_true',
- dest='sync_keys', help='',
- default=False)
- self.parser.add_option('--no-rsync', action='store_true',
- dest='no_rsync', default=False,
- help="Don't use rsync when registering"),
- self.parser.add_option('--no-scp', action='store_true',
- dest='no_scp', help="don't use scp",
- default=False)
- self.parser.add_option('--skip-scp-hostcheck', action='store_true',
- dest='skip_scp_hostcheck',
- help='skip scp interactive host keycheck',
- default=False)
- self.parser.add_option('--get-credentials', action='store',
- type='string', dest='get_credentials',
- metavar='<zipfile>',
- help='download credentials to <zipfile>')
- self.parser.add_option('--cred-account', action='store',
- type='string', dest='cred_account',
- metavar='<accountname>', default='eucalyptus',
- help="set get-credentials account")
- self.parser.add_option('--cred-user', action='store',
- type='string', dest='cred_user',
- metavar='<accountname>', default='admin',
- help="set get-credentials user")
- self.parser.add_option('--register-nodes',
- action='append', type='string',
- dest='reg_nodes', metavar='"host host..."',
- help='add new nodes to EUCALYPTUS')
- self.parser.add_option('--deregister-nodes',
- action='append', type='string',
- dest='dereg_nodes', metavar='"host host..."',
- help='remove nodes from EUCALYPTUS')
- self.parser.add_option('--register-cluster',
- action='store', type='string',
- dest='reg_clusters', nargs=3,
- metavar='<partition> <clustername> <host>',
- help='add new cluster to EUCALYPTUS')
- self.parser.add_option('--deregister-cluster', nargs=2,
- type='string', dest='dereg_clusters',
- metavar='<partition> <clustername>',
- help='remove cluster from EUCALYPTUS')
- self.parser.add_option('--register-walrus', nargs=3,
- type='string', dest='reg_walruses',
- metavar='<partition> <clustername> <host>',
- help='add new walrus to EUCALYPTUS')
- self.parser.add_option('--deregister-walrus', nargs=2,
- type='string', dest='dereg_walruses',
- metavar='<partition> <host>',
- help='remove walrus from EUCALYPTUS')
- self.parser.add_option('--register-sc',