~ubuntu-branches/ubuntu/precise/euca2ools/precise-proposed

« back to all changes in this revision

Viewing changes to .pc/debian-changes-2.0.0~bzr464-0ubuntu1/euca2ools/commands/euca/describevolumes.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Moser
  • Date: 2011-08-15 11:16:29 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110815111629-3u49jvtwabwozpb7
Tags: 2.0.0~bzr464-0ubuntu1
* new upstream snapshot of bzr revno 464. (LP: #826022)
* Note, previous upload was incorrectly named 'bzr451'.  It should have
  been named bzr461 as it was a snapshot of revision 461.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Software License Agreement (BSD License)
 
2
#
 
3
# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
 
4
# All rights reserved.
 
5
#
 
6
# Redistribution and use of this software in source and binary forms, with or
 
7
# without modification, are permitted provided that the following conditions
 
8
# are met:
 
9
#
 
10
#   Redistributions of source code must retain the above
 
11
#   copyright notice, this list of conditions and the
 
12
#   following disclaimer.
 
13
#
 
14
#   Redistributions in binary form must reproduce the above
 
15
#   copyright notice, this list of conditions and the
 
16
#   following disclaimer in the documentation and/or other
 
17
#   materials provided with the distribution.
 
18
#
 
19
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
20
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
21
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
22
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
23
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
24
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
25
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
26
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
27
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
28
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
29
# POSSIBILITY OF SUCH DAMAGE.
 
30
#
 
31
# Author: Neil Soman neil@eucalyptus.com
 
32
#         Mitch Garnaat mgarnaat@eucalyptus.com
 
33
import euca2ools.commands.eucacommand
 
34
from boto.roboto.param import Param
 
35
 
 
36
class DescribeVolumes(euca2ools.commands.eucacommand.EucaCommand):
 
37
 
 
38
    APIVersion = '2010-08-31'
 
39
    Description = 'Shows information about volumes.'
 
40
    Args = [Param(name='volume_id', ptype='string',
 
41
                  doc='volumes to describe',
 
42
                  cardinality='+', optional=True)]
 
43
    Filters = [Param(name='attachment.attach-time', ptype='string',
 
44
                     doc='Time stamp when the attachment initiated.'),
 
45
               Param(name='attachment.delete-on-termination', ptype='string',
 
46
                     doc="""Whether the volume will be deleted on
 
47
                     instance termination."""),
 
48
               Param(name='attachment.device', ptype='string',
 
49
                     doc="""How the volume is exposed to the
 
50
                     instance (e.g., /dev/sda1)."""),
 
51
               Param(name='attachment.instance-id', ptype='string',
 
52
                     doc='ID of the instance the volume is attached to.'),
 
53
               Param(name='attachment.status', ptype='datetime',
 
54
                     doc="""Attachment state.
 
55
                     Valid Values: attaching | attached | detaching | detached"""),
 
56
               Param(name='availability-zone', ptype='string',
 
57
                     doc='Availability Zone in which the volume was created.'),
 
58
               Param(name='create-time', ptype='datetime',
 
59
                     doc='Time stamp when the volume was created.'),
 
60
               Param(name='size', ptype='integer',
 
61
                     doc='Size of the volume, in GiB (e.g., 20).'),
 
62
               Param(name='snapshot-id', ptype='string',
 
63
                     doc='Snapshot from which the volume was created.'),
 
64
               Param(name='status', ptype='string',
 
65
                     doc="""Status of the volume.
 
66
                     Valid values: pending | completed | error."""),
 
67
               Param(name='tag-key', ptype='string',
 
68
                     doc='Key of a tag assigned to the resource.'),
 
69
               Param(name='tag-value', ptype='string',
 
70
                     doc='Value of a tag assigned to the resource.'),
 
71
               Param(name='tag:key', ptype='string',
 
72
                     doc="""Filters the results based on a specific
 
73
                     tag/value combination."""),
 
74
               Param(name='volume-id', ptype='string',
 
75
                     doc='ID of the volume the snapshot is for')]
 
76
    
 
77
    def display_volumes(self, volumes):
 
78
        for volume in volumes:
 
79
            volume_string = '%s\t ' % volume.id
 
80
            if volume.size:
 
81
                volume_string += '%d' % volume.size
 
82
            if volume.snapshot_id:
 
83
                volume_string += '\t%s' % volume.snapshot_id
 
84
            else:
 
85
                volume_string += '\t'
 
86
 
 
87
            az = getattr(volume, 'availabilityZone', object)
 
88
            if az is object:
 
89
                az = volume.zone
 
90
            if az:
 
91
                volume_string += '\t%s' % az
 
92
 
 
93
            volume_string += '\t%s\t%s' % (volume.status,
 
94
                    volume.create_time)
 
95
            print 'VOLUME\t%s' % volume_string
 
96
            if volume.status == 'in-use':
 
97
                attachment_string = '%s\t%s\t%s\t%s' % (volume.id,
 
98
                        volume.attach_data.instance_id,
 
99
                        volume.attach_data.device,
 
100
                        volume.attach_data.attach_time)
 
101
                print 'ATTACHMENT\t%s' % attachment_string
 
102
 
 
103
    def main(self):
 
104
        conn = self.make_connection_cli()
 
105
        return self.make_request_cli(conn, 'get_all_volumes',
 
106
                                     volume_ids=self.volume_id)
 
107
 
 
108
    def main_cli(self):
 
109
        volumes = self.main()
 
110
        self.display_volumes(volumes)
 
111