[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a
Garrett Holmstrom
gholms at fedoraproject.org
Sun Jun 16 02:31:04 UTC 2013
The following commit has been merged in the master branch:
commit e0e8ee5d135da63e157624e8d8d75279e9eb8db7
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Tue Apr 16 17:14:04 2013 -0700
Port eustore-describe-images to requestbuilder
Fixes TOOLS-199
diff --git a/bin/eustore-describe-images b/bin/eustore-describe-images
index 571676f..f7ee0ea 100755
--- a/bin/eustore-describe-images
+++ b/bin/eustore-describe-images
@@ -1,40 +1,6 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009-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: David Kavanagh david.kavanagh at eucalyptus.com
+#!/usr/bin/python -tt
import euca2ools.commands.eustore.describeimages
if __name__ == '__main__':
- cmd = euca2ools.commands.eustore.describeimages.DescribeImages()
- cmd.main_cli()
+ euca2ools.commands.eustore.describeimages.DescribeImages.run()
diff --git a/euca2ools/commands/eustore/__init__.py b/euca2ools/commands/eustore/__init__.py
index ad6f196..c22f2c0 100644
--- a/euca2ools/commands/eustore/__init__.py
+++ b/euca2ools/commands/eustore/__init__.py
@@ -1,6 +1,6 @@
# Software License Agreement (BSD License)
#
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
+# Copyright (c) 2011-2013, Eucalyptus Systems, Inc.
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms, with or
@@ -27,43 +27,26 @@
# 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: David Kavanagh david.kavanagh at eucalyptus.com
-
-import sys
-from boto.roboto.awsqueryservice import AWSQueryService
+from euca2ools.commands import Euca2ools
+from requestbuilder import Arg
+from requestbuilder.request import BaseRequest
+from requestbuilder.service import BaseService
-class Eustore(AWSQueryService):
- Name = 'eustore'
- Description = 'Eucalyptus Image Store'
- APIVersion = '2011-01-01'
- Authentication = 'sign-v2'
- Path = '/'
- Port = 443
- Provider = 'aws'
- EnvURL = 'EC2_URL'
+class EuStore(BaseService):
+ NAME = 'eustore'
+ DESCRIPTION = 'Eucalyptus Image Store'
+ URL_ENVVAR = 'EUSTORE_URL'
+ ARGS = [Arg('-U', '--url', default='http://emis.eucalyptus.com/',
+ help='''EuStore service URL (default:
+ http://emis.eucalyptus.com)''')]
- StoreBaseURL = 'http://emis.eucalyptus.com/'
- EuStoreVersion = 'eustore-catalog-2011-12-29'
- RequestHeaders = {'User-Agent': 'euca2ools/eustore',
- 'eustore-version': EuStoreVersion}
-class progressBar:
- def __init__(self, maxVal):
- self.maxVal=maxVal
- self.currVal=0
- print "0-----1-----2-----3-----4-----5-----6-----7-----8-----9-----10"
- self.progShowing=0
+class EuStoreRequest(BaseRequest):
+ SUITE = Euca2ools
+ SERVICE_CLASS = EuStore
- def update(self, val):
- count=min(val, self.maxVal)
- progDone=62*count/self.maxVal
- if self.progShowing < progDone:
- for i in range(progDone - self.progShowing):
- sys.stdout.write("#")
- sys.stdout.flush()
- self.progShowing = progDone
- if progDone==62:
- sys.stdout.write("\n")
+ @property
+ def default_routes(self):
+ return ()
diff --git a/euca2ools/commands/eustore/describeimages.py b/euca2ools/commands/eustore/describeimages.py
index 9b93ea1..a6753d3 100644
--- a/euca2ools/commands/eustore/describeimages.py
+++ b/euca2ools/commands/eustore/describeimages.py
@@ -1,8 +1,6 @@
-# -*- coding: utf-8 -*-
-
# Software License Agreement (BSD License)
#
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
+# Copyright (c) 2011-2013, Eucalyptus Systems, Inc.
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms, with or
@@ -29,66 +27,37 @@
# 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: David Kavanagh david.kavanagh at eucalyptus.com
-
-import os
-import urllib2
-from boto.roboto.param import Param
-from boto.roboto.awsqueryrequest import AWSQueryRequest
-import euca2ools.commands.eustore
-import euca2ools.utils
-
-try:
- import simplejson as json
-except ImportError:
- import json
-
-class DescribeImages(AWSQueryRequest):
-
- ServiceClass = euca2ools.commands.eustore.Eustore
-
- Description = """lists images from Eucalyptus.com"""
- Params = [
- Param(name='verbose',
- short_name='v',
- long_name='verbose',
- optional=True,
- ptype='boolean',
- doc="""display more information about images""")
- ]
-
- def fmtCol(self, value, width):
- valLen = len(value)
- if valLen > width:
- return value[0:width-2]+".."
- else:
- return value.ljust(width, ' ')
-
- def main(self):
- self.eustore_url = self.ServiceClass.StoreBaseURL
- if os.environ.has_key('EUSTORE_URL'):
- self.eustore_url = os.environ['EUSTORE_URL']
- catURL = self.eustore_url + "catalog"
- req = urllib2.Request(catURL, headers=self.ServiceClass.RequestHeaders)
- response = urllib2.urlopen(req).read()
- parsed_cat = json.loads(response)
- if len(parsed_cat) > 0:
- image_list = parsed_cat['images']
- for image in image_list:
- print self.fmtCol(image['name'],11)+ \
- self.fmtCol(image['os'],12)+ \
- self.fmtCol(image['architecture'],8)+ \
- self.fmtCol(image['version'],15)+ \
- self.fmtCol(', '.join(image['hypervisors-supported']),18)+ \
- image['description']
- if self.cli_options.verbose:
- print " "+self.fmtCol(image['date'],20)+ \
- self.fmtCol(image['stamp'],12)+ \
- self.fmtCol(image['recipe'],23)+ \
- image['contact']
-
- def main_cli(self):
- euca2ools.utils.print_version_if_necessary()
- self.do_cli()
+from euca2ools.commands.eustore import EuStoreRequest
+from requestbuilder import Arg
+from requestbuilder.mixins import TabifyingCommand
+
+
+class DescribeImages(EuStoreRequest, TabifyingCommand):
+ DESCRIPTION = 'List images available for installation from EuStore'
+ ARGS = [Arg('-v', '--verbose', action='store_true',
+ help='display more information about images than the default')]
+
+ def preprocess(self):
+ self.path = 'catalog'
+ # Requests 1 adds Transfer-Encoding: chunked unconditionally when
+ # self.body is None. emis.eucalyptus.com currently runs nginx without
+ # the module needed for that loaded, so this hacks around it.
+ self.body = ''
+
+ def parse_response(self, response):
+ self.log.debug('-- response content --\n', extra={'append': True})
+ self.log.debug(response.text, extra={'append': True})
+ self.log.debug('-- end of response content --')
+ return response.json()
+
+ def print_result(self, catalog):
+ for image in catalog.get('images', []):
+ hypervisors = image.get('hypervisors-supported', [])
+ bits = [image.get('name'), image.get('os'),
+ image.get('architecture'), image.get('version'),
+ ','.join(hypervisors), image.get('description')]
+ if self.args['verbose']:
+ bits.extend([image.get('date'), image.get('stamp'),
+ image.get('recipe'), image.get('contact')])
+ print self.tabify(bits)
--
managing cloud instances for Eucalyptus
More information about the pkg-eucalyptus-commits
mailing list