[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:29:47 UTC 2013


The following commit has been merged in the master branch:
commit be56d6a642833a4c125f191411e7015158000943
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Mon Apr 23 22:19:00 2012 -0700

    Rewrite DescribeSnapshots

diff --git a/bin/euca-describe-snapshots b/bin/euca-describe-snapshots
index 79bb59f..21c4bba 100755
--- a/bin/euca-describe-snapshots
+++ b/bin/euca-describe-snapshots
@@ -1,42 +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: Neil Soman neil at eucalyptus.com
-#         Mitch Garnaat mgarnaat at eucalyptus.com
+#!/usr/bin/python -tt
 
 import euca2ools.commands.euca.describesnapshots
 
 if __name__ == '__main__':
-    cmd = euca2ools.commands.euca.describesnapshots.DescribeSnapshots()
-    cmd.main_cli()
-
+    euca2ools.commands.euca.describesnapshots.DescribeSnapshots().do_cli()
diff --git a/euca2ools/commands/euca/__init__.py b/euca2ools/commands/euca/__init__.py
index b2dc07c..0022597 100644
--- a/euca2ools/commands/euca/__init__.py
+++ b/euca2ools/commands/euca/__init__.py
@@ -225,6 +225,16 @@ class EucalyptusRequest(Euca2oolsRequest, TabifyingCommand):
                     [attachment.get(attr) for attr in
                      ('instanceId', 'device', 'status', 'attachTime')])
 
+    def print_snapshot(self, snap):
+        print self.tabify(['SNAPSHOT', snap.get('snapshotId'),
+                           snap.get('volumeId'),  snap.get('status'),
+                           snap.get('startTime'), snap.get('progress'),
+                           snap.get('ownerId'),   snap.get('volumeSize'),
+                           snap.get('description')])
+        for tag in snap.get('tagSet', []):
+            print self.tabify(['TAG', 'snapshot', snap.get('snapshotId'),
+                               tag.get('key'), tag.get('value')])
+
     def print_bundle_task(self, task):
         print self.tabify(['BUNDLE', task.get('bundleId'),
                            task.get('instanceId'),
diff --git a/euca2ools/commands/euca/describesnapshots.py b/euca2ools/commands/euca/describesnapshots.py
index 4705623..389885e 100644
--- a/euca2ools/commands/euca/describesnapshots.py
+++ b/euca2ools/commands/euca/describesnapshots.py
@@ -1,6 +1,6 @@
 # Software License Agreement (BSD License)
 #
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
+# Copyright (c) 2009-2012, Eucalyptus Systems, Inc.
 # All rights reserved.
 #
 # Redistribution and use of this software in source and binary forms, with or
@@ -27,71 +27,41 @@
 # 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: Neil Soman neil at eucalyptus.com
-#         Mitch Garnaat mgarnaat at eucalyptus.com
-
-import euca2ools.commands.eucacommand
-from boto.roboto.param import Param
 
-class DescribeSnapshots(euca2ools.commands.eucacommand.EucaCommand):
+from argparse import SUPPRESS
+from requestbuilder import Arg, Filter, GenericTagFilter
+from . import EucalyptusRequest
 
+class DescribeSnapshots(EucalyptusRequest):
     APIVersion = '2010-08-31'
-    Description = 'Shows information about snapshots.'
-    Options = [Param(name='owner', short_name='o', long_name='owner',
-                     optional=True, ptype='string',
-                     doc='ID of the user who owns the snapshot.'),
-               Param(name='restorable_by',
-                     short_name='r', long_name='restorable-by',
-                     optional=True, ptype='string',
-                     doc="""restorable by (user id of the user that can
-                     create volumes from the snapshot).""")]
-    Args = [Param(name='snapshot', ptype='string',
-                  doc='snapshots to describe',
-                  cardinality='+', optional=True)]
-    Filters = [Param(name='description', ptype='string',
-                     doc='Description of the snapshot'),
-               Param(name='owner-alias', ptype='string',
-                     doc="""AWS account alias (e.g., amazon or self) or
-                     AWS account ID that owns the snapshot."""),
-               Param(name='owner-id', ptype='string',
-                     doc='AWS account ID of the snapshot owner.'),
-               Param(name='progress', ptype='string',
-                     doc='The progress of the snapshot, in percentage.'),
-               Param(name='snapshot-id', ptype='string',
-                     doc='The ID of the snapshot.'),
-               Param(name='start-time', ptype='datetime',
-                     doc='Time stamp when the snapshot was initiated.'),
-               Param(name='status', ptype='string',
-                     doc="""Status of the snapshost.
-                     Valid values: pending | completed | error."""),
-               Param(name='tag-key', ptype='string',
-                     doc='Key of a tag assigned to the resource.'),
-               Param(name='tag-value', ptype='string',
-                     doc='Value of a tag assigned to the resource.'),
-               Param(name='tag:key', ptype='string',
-                     doc="""Filters the results based on a specific
-                     tag/value combination."""),
-               Param(name='volume-id', ptype='string',
-                     doc='ID of the volume the snapshot is for'),
-               Param(name='volume-size', ptype='integer',
-                     doc='The size of the volume, in GiB.')]
-    
-    def display_snapshots(self, snapshots):
-        for snapshot in snapshots:
-            snapshot_string = '%s\t%s\t%s\t%s\t%s' % (snapshot.id,
-                    snapshot.volume_id, snapshot.status,
-                    snapshot.start_time, snapshot.progress)
-            print 'SNAPSHOT\t%s' % snapshot_string
-
-    def main(self):
-        conn = self.make_connection_cli()
-        return self.make_request_cli(conn, 'get_all_snapshots',
-                                     snapshot_ids=self.snapshot,
-                                     owner=self.owner,
-                                     restorable_by=self.restorable_by)
-
-    def main_cli(self):
-        snapshots = self.main()
-        self.display_snapshots(snapshots)
+    Description = 'Display information about snapshots'
+    Args = [Arg('SnapshotId', nargs='*', metavar='SNAPSHOT',
+                help='limit results to specific snapshots'),
+            # noop for a little ec2dsnap compatibility
+            Arg('--all', action='store_true', route_to=None, help=SUPPRESS),
+            Arg('-o', '--owner', dest='Owner', metavar='ACCOUNT',
+                action='append', default=[],
+                help='limit results to snapshots owned by specific accounts'),
+            Arg('-r', '--restorable-by', dest='RestorableBy', action='append',
+                metavar='ACCOUNT', default=[], help='''limit results to
+                snapahots restorable by specific accounts''')]
+    Filters = [Filter('description', help='snapshot description'),
+               Filter('owner-alias', help="snapshot owner's account alias"),
+               Filter('owner-id', help="snapshot owner's account ID"),
+               Filter('progress', help='snapshot progress, in percentage'),
+               Filter('snapshot-id'),
+               Filter('start-time', help='snapshot initiation time'),
+               Filter('status', choices=('pending', 'completed', 'error')),
+               Filter('tag-key', help='key of a tag assigned to the snapshot'),
+               Filter('tag-value',
+                      help='value of a tag assigned to the snapshot'),
+               GenericTagFilter('tag:KEY',
+                                help='specific tag/value combination'),
+               Filter('volume-id', help='source volume ID'),
+               Filter('volume-size', type=int)]
+    ListMarkers = ['snapshotSet', 'tagSet']
+    ItemMarkers = ['item']
 
+    def print_result(self, result):
+        for snapshot in result.get('snapshotSet', []):
+            self.print_snapshot(snapshot)

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list