mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
remove performEC2DescribeInstances()
This commit is contained in:
parent
8fba6dcb0d
commit
78e3556e95
@ -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() {
|
|||||||
"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) {
|
|||||||
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
|
|||||||
}).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;
|
||||||
|
Loading…
Reference in New Issue
Block a user