Commit 0052e9d1 by Mitsuhiro Tanda

(cloudwatch) add ec2_instance_attribute() query

parent c09d5062
...@@ -143,7 +143,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) { ...@@ -143,7 +143,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
return this.awsRequest({ return this.awsRequest({
region: region, region: region,
action: 'DescribeInstances', action: 'DescribeInstances',
parameters: { filter: filters, instanceIds: instanceIds } parameters: { filters: filters, instanceIds: instanceIds }
}); });
}; };
...@@ -205,6 +205,28 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) { ...@@ -205,6 +205,28 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
}); });
} }
var ec2InstanceAttributeQuery = query.match(/^ec2_instance_attribute\(([^,]+?),\s?([^,]+?),\s?([^)]+)\)/);
if (ec2InstanceAttributeQuery) {
region = templateSrv.replace(ec2InstanceAttributeQuery[1]);
var filterJson = JSON.parse(templateSrv.replace(ec2InstanceAttributeQuery[3]));
var filter = _.map(filterJson, function(f) {
return {
Name: f.slice(0, f.indexOf('=')),
Values: f.slice(f.indexOf('=') + 1).split(',')
};
});
var targetAttributeName = templateSrv.replace(ec2InstanceAttributeQuery[2]);
return this.performEC2DescribeInstances(region, filter, null).then(function(result) {
var attributes = _.chain(result.Reservations)
.map(function(reservations) {
return _.pluck(reservations.Instances, targetAttributeName);
})
.flatten().value();
return transformSuggestData(attributes);
});
}
return $q.when([]); return $q.when([]);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment