Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: third_party/gsutil/boto/boto/ec2/cloudwatch/metric.py

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/gsutil/boto/boto/ec2/cloudwatch/metric.py
diff --git a/third_party/gsutil/20110627/boto/boto/ec2/cloudwatch/metric.py b/third_party/gsutil/boto/boto/ec2/cloudwatch/metric.py
similarity index 50%
rename from third_party/gsutil/20110627/boto/boto/ec2/cloudwatch/metric.py
rename to third_party/gsutil/boto/boto/ec2/cloudwatch/metric.py
index cd8c4bc92598701f122ab305da6b4a29377437ce..847024e10f0c2f3e2d0b2331b4278a37cfc95087 100644
--- a/third_party/gsutil/20110627/boto/boto/ec2/cloudwatch/metric.py
+++ b/third_party/gsutil/boto/boto/ec2/cloudwatch/metric.py
@@ -20,24 +20,19 @@
# IN THE SOFTWARE.
#
-class Dimensions(dict):
-
- def startElement(self, name, attrs, connection):
- pass
-
- def endElement(self, name, value, connection):
- if name == 'Name':
- self._name = value
- elif name == 'Value':
- self[self._name] = value
- elif name != 'Dimensions' and name != 'member':
- self[name] = value
+from boto.ec2.cloudwatch.alarm import MetricAlarm
+from boto.ec2.cloudwatch.dimension import Dimension
class Metric(object):
Statistics = ['Minimum', 'Maximum', 'Sum', 'Average', 'SampleCount']
- Units = ['Seconds', 'Percent', 'Bytes', 'Bits', 'Count',
- 'Bytes/Second', 'Bits/Second', 'Count/Second']
+ Units = ['Seconds', 'Microseconds', 'Milliseconds', 'Bytes', 'Kilobytes',
+ 'Megabytes', 'Gigabytes', 'Terabytes', 'Bits', 'Kilobits',
+ 'Megabits', 'Gigabits', 'Terabits', 'Percent', 'Count',
+ 'Bytes/Second', 'Kilobytes/Second', 'Megabytes/Second',
+ 'Gigabytes/Second', 'Terabytes/Second', 'Bits/Second',
+ 'Kilobits/Second', 'Megabits/Second', 'Gigabits/Second',
+ 'Terabits/Second', 'Count/Second', None]
def __init__(self, connection=None):
self.connection = connection
@@ -46,15 +41,11 @@ class Metric(object):
self.dimensions = None
def __repr__(self):
- s = 'Metric:%s' % self.name
- if self.dimensions:
- for name,value in self.dimensions.items():
- s += '(%s,%s)' % (name, value)
- return s
+ return 'Metric:%s' % self.name
def startElement(self, name, attrs, connection):
if name == 'Dimensions':
- self.dimensions = Dimensions()
+ self.dimensions = Dimension()
return self.dimensions
def endElement(self, name, value, connection):
@@ -65,12 +56,36 @@ class Metric(object):
else:
setattr(self, name, value)
- def query(self, start_time, end_time, statistic, unit=None, period=60):
- return self.connection.get_metric_statistics(period, start_time, end_time,
- self.name, self.namespace, [statistic],
- self.dimensions, unit)
+ def query(self, start_time, end_time, statistics, unit=None, period=60):
+ if not isinstance(statistics, list):
+ statistics = [statistics]
+ return self.connection.get_metric_statistics(period,
+ start_time,
+ end_time,
+ self.name,
+ self.namespace,
+ statistics,
+ self.dimensions,
+ unit)
+
+ def create_alarm(self, name, comparison, threshold,
+ period, evaluation_periods,
+ statistic, enabled=True, description=None,
+ dimensions=None, alarm_actions=None, ok_actions=None,
+ insufficient_data_actions=None, unit=None):
+ if not dimensions:
+ dimensions = self.dimensions
+ alarm = MetricAlarm(self.connection, name, self.name,
+ self.namespace, statistic, comparison,
+ threshold, period, evaluation_periods,
+ unit, description, dimensions,
+ alarm_actions, insufficient_data_actions,
+ ok_actions)
+ if self.connection.put_metric_alarm(alarm):
+ return alarm
- def describe_alarms(self, period=None, statistic=None, dimensions=None, unit=None):
+ def describe_alarms(self, period=None, statistic=None,
+ dimensions=None, unit=None):
return self.connection.describe_alarms_for_metric(self.name,
self.namespace,
period,
@@ -78,3 +93,5 @@ class Metric(object):
dimensions,
unit)
+
+
« no previous file with comments | « third_party/gsutil/boto/boto/ec2/cloudwatch/listelement.py ('k') | third_party/gsutil/boto/boto/ec2/connection.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698