1
# Copyright (c) 2011, Eucalyptus Systems, Inc.
4
# Redistribution and use of this software in source and binary forms, with or
5
# without modification, are permitted provided that the following conditions
8
# Redistributions of source code must retain the above
9
# copyright notice, this list of conditions and the
10
# following disclaimer.
12
# Redistributions in binary form must reproduce the above
13
# copyright notice, this list of conditions and the
14
# following disclaimer in the documentation and/or other
15
# materials provided with the distribution.
17
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
29
# Author: Mitch Garnaat mgarnaat@eucalyptus.com
31
from boto.roboto.awsqueryrequest import AWSQueryRequest
32
from boto.roboto.param import Param
36
class DescribeRequest(AWSQueryRequest):
39
ServicePath = '/services/Configuration'
40
ServiceClass = eucadmin.EucAdmin
42
def __init__(self, **args):
43
AWSQueryRequest.__init__(self, **args)
44
self.list_markers = ['euca:registered']
45
self.item_markers = ['euca:item']
47
def get_connection(self, **args):
48
if self.connection is None:
49
args['path'] = self.ServicePath
50
self.connection = self.ServiceClass(**args)
51
return self.connection
53
def cli_formatter(self, data):
54
services = getattr(data, 'euca:registered')
55
fields = {'euca:partition' : 15,
59
if s.get('euca:hostName', None) != 'detail':
60
for field_name in fields:
61
field_size = math.ceil(fields[field_name]/5.0)*5
62
if len(s.get(field_name)) > field_size:
63
fields[field_name] = field_size
64
fmt = '%%s\t%%-%s.%ss\t%%-%d.%ds\t%%-%ds\t%%s\t%%s' % (fields['euca:partition'],
65
fields['euca:partition'],
68
fields['euca:hostName'])
70
if s.get('euca:hostName', None) != 'detail':
72
self.ServiceName.upper(),
73
s.get('euca:partition', None),
74
s.get('euca:name', None),
75
s.get('euca:hostName', None),
76
s.get('euca:state', None),
77
s.get('euca:detail', None))
79
def main(self, **args):
80
return self.send(**args)
83
eucadmin.print_version_if_necessary()