2011-03-11 16:06:44 -05:00
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class AWS
|
2011-03-11 16:06:44 -05:00
|
|
|
|
|
|
|
class Real
|
|
|
|
|
|
|
|
require 'fog/compute/parsers/aws/monitor_unmonitor_instances'
|
|
|
|
|
|
|
|
# UnMonitor specified instance
|
|
|
|
# http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * instance_ids<~Array> - Arrays of instances Ids to monitor
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'instancesSet': http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-MonitorInstancesResponseSetItemType.html
|
2011-05-19 12:31:56 -04:00
|
|
|
#
|
|
|
|
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html]
|
2011-03-11 16:06:44 -05:00
|
|
|
def unmonitor_instances(instance_ids)
|
2011-06-16 19:28:54 -04:00
|
|
|
params = Fog::AWS.indexed_param('InstanceId', instance_ids)
|
2011-03-11 16:06:44 -05:00
|
|
|
request({
|
|
|
|
'Action' => 'UnmonitorInstances',
|
|
|
|
:idempotent => true,
|
2011-06-16 19:28:54 -04:00
|
|
|
:parser => Fog::Parsers::Compute::AWS::MonitorUnmonitorInstances.new
|
2011-03-11 16:06:44 -05:00
|
|
|
}.merge!(params))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
|
|
|
|
def unmonitor_instances(instance_ids)
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
2011-03-15 18:35:32 -04:00
|
|
|
[*instance_ids].each do |instance_id|
|
2011-05-19 18:35:33 -04:00
|
|
|
if instance = self.data[:instances][instance_id]
|
2011-03-15 18:35:32 -04:00
|
|
|
instance['monitoring']['state'] = 'enabled'
|
|
|
|
else
|
2011-06-16 19:28:54 -04:00
|
|
|
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_ids}' does not exist")
|
2011-03-15 18:35:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
instances_set = [*instance_ids].inject([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'disabled'} }
|
|
|
|
response.body = {'requestId' => 'some_request_id', 'instancesSet' => instances_set}
|
|
|
|
response
|
2011-03-11 16:06:44 -05:00
|
|
|
end
|
2011-03-15 18:35:32 -04:00
|
|
|
|
2011-03-11 16:06:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|