Commit 78e3556e by Mitsuhiro Tanda

remove performEC2DescribeInstances()

parent 8fba6dcb
...@@ -18,7 +18,6 @@ import ( ...@@ -18,7 +18,6 @@ import (
"github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudwatch" "github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/sts" "github.com/aws/aws-sdk-go/service/sts"
"github.com/grafana/grafana/pkg/metrics" "github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/middleware"
...@@ -78,7 +77,6 @@ func init() { ...@@ -78,7 +77,6 @@ func init() {
"DescribeAlarms": handleDescribeAlarms, "DescribeAlarms": handleDescribeAlarms,
"DescribeAlarmsForMetric": handleDescribeAlarmsForMetric, "DescribeAlarmsForMetric": handleDescribeAlarmsForMetric,
"DescribeAlarmHistory": handleDescribeAlarmHistory, "DescribeAlarmHistory": handleDescribeAlarmHistory,
"DescribeInstances": handleDescribeInstances,
} }
} }
...@@ -402,52 +400,6 @@ func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) { ...@@ -402,52 +400,6 @@ func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) {
c.JSON(200, resp) c.JSON(200, resp)
} }
func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
cfg, err := getAwsConfig(req)
if err != nil {
c.JsonApiErr(500, "Unable to call AWS API", err)
return
}
sess, err := session.NewSession(cfg)
if err != nil {
c.JsonApiErr(500, "Unable to call AWS API", err)
return
}
svc := ec2.New(sess, cfg)
reqParam := &struct {
Parameters struct {
Filters []*ec2.Filter `json:"filters"`
InstanceIds []*string `json:"instanceIds"`
} `json:"parameters"`
}{}
json.Unmarshal(req.Body, reqParam)
params := &ec2.DescribeInstancesInput{}
if len(reqParam.Parameters.Filters) > 0 {
params.Filters = reqParam.Parameters.Filters
}
if len(reqParam.Parameters.InstanceIds) > 0 {
params.InstanceIds = reqParam.Parameters.InstanceIds
}
var resp ec2.DescribeInstancesOutput
err = svc.DescribeInstancesPages(params,
func(page *ec2.DescribeInstancesOutput, lastPage bool) bool {
reservations, _ := awsutil.ValuesAtPath(page, "Reservations")
for _, reservation := range reservations {
resp.Reservations = append(resp.Reservations, reservation.(*ec2.Reservation))
}
return !lastPage
})
if err != nil {
c.JsonApiErr(500, "Unable to call AWS API", err)
return
}
c.JSON(200, resp)
}
func HandleRequest(c *middleware.Context, ds *m.DataSource) { func HandleRequest(c *middleware.Context, ds *m.DataSource) {
var req cwRequest var req cwRequest
req.Body, _ = ioutil.ReadAll(c.Req.Request.Body) req.Body, _ = ioutil.ReadAll(c.Req.Request.Body)
......
...@@ -293,14 +293,6 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot ...@@ -293,14 +293,6 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot
}).then(function (r) { return transformSuggestDataFromTable(r); }); }).then(function (r) { return transformSuggestDataFromTable(r); });
}; };
this.performEC2DescribeInstances = function(region, filters, instanceIds) {
return this.awsRequest({
region: region,
action: 'DescribeInstances',
parameters: { filters: filters, instanceIds: instanceIds }
});
};
this.metricFindQuery = function(query) { this.metricFindQuery = function(query) {
var region; var region;
var namespace; var namespace;
......
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