[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:30:44 UTC 2013


The following commit has been merged in the master branch:
commit 4045ac00276e8c4a6ef21edecbadd18fb7b418f4
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Wed Mar 20 17:54:22 2013 -0700

    Fix bugs in delimited_list

diff --git a/euca2ools/commands/argtypes.py b/euca2ools/commands/argtypes.py
index 6674334..da0900a 100644
--- a/euca2ools/commands/argtypes.py
+++ b/euca2ools/commands/argtypes.py
@@ -248,10 +248,11 @@ def ternary_tag_def(tag_str):
         return {'Key': tag_str}
 
 
-def delimited_list(delimiter):
+def delimited_list(delimiter, item_type=str):
     def _concrete_delimited_list(list_as_str):
         if isinstance(list_as_str, str) and len(list_as_str) > 0:
-            return list(filter(None, list_as_str.split(',')))
+            return [item_type(item.strip()) for item in
+                    list_as_str.split(delimiter) if len(item.strip()) > 0]
         else:
             return []
     return _concrete_delimited_list
diff --git a/euca2ools/commands/bundle/__init__.py b/euca2ools/commands/monitoring/argtypes.py
similarity index 81%
copy from euca2ools/commands/bundle/__init__.py
copy to euca2ools/commands/monitoring/argtypes.py
index 505e8cd..fce192e 100644
--- a/euca2ools/commands/bundle/__init__.py
+++ b/euca2ools/commands/monitoring/argtypes.py
@@ -27,3 +27,14 @@
 # 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.
+
+import argparse
+
+
+def cloudwatch_dimension(dim_as_str):
+    try:
+        name, val = dim_as_str.split('=', 1)
+        return {'Name': name, 'Value': val}
+    except ValueError:
+        raise argparse.ArgumentTypeError('dimension filter "{0}" must have '
+                                         'form KEY=VALUE'.format(dim_as_str))
diff --git a/euca2ools/commands/monitoring/listmetrics.py b/euca2ools/commands/monitoring/listmetrics.py
index eaeed9b..fb26ede 100644
--- a/euca2ools/commands/monitoring/listmetrics.py
+++ b/euca2ools/commands/monitoring/listmetrics.py
@@ -28,28 +28,19 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-import argparse
 from euca2ools.commands.argtypes import delimited_list
 from euca2ools.commands.monitoring import CloudWatchRequest
+from euca2ools.commands.monitoring.argtypes import cloudwatch_dimension
 from requestbuilder import Arg
 from requestbuilder.mixins import TabifyingCommand
 from requestbuilder.response import PaginatedResponse
 
 
-def dimension_filter(dim_as_str):
-    try:
-        name, val = dim_as_str.split('=', 1)
-        return {'Name': key, 'Value': val}
-    except ValueError:
-        raise argparse.ArgumentTypeError('dimension filter "{0}" must have '
-                                         'form KEY=VALUE'.format(dim_as_str))
-
-
 class ListMetrics(CloudWatchRequest, TabifyingCommand):
     DESCRIPTION = 'Show a list of monitoring metrics'
     ARGS = [Arg('-d', '--dimensions', dest='Dimensions.member',
                 metavar='KEY1=VALUE1,KEY2=VALUE2,...',
-                type=delimited_list(dimension_filter),
+                type=delimited_list(',', item_type=cloudwatch_dimension),
                 help='limit results to metrics with specific dimensions'),
             Arg('-m', '--metric-name', dest='MetricName', metavar='METRIC',
                 help='limit results to a specific metric'),

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list