Sha256: facd36c59ecf6c9f84efbb19d6384dbdaf4657ab68622f4783eb8387da3b5b5a
Contents?: true
Size: 1.36 KB
Versions: 9
Compression:
Stored size: 1.36 KB
Contents
module Fog module Compute class QingCloud class Real # Stop specified instance # {API Reference}[https://docs.qingcloud.com/api/instance/stop_instances.html] def stop_instances(instance_id, force = false) params = Fog::QingCloud.indexed_param('instances', instance_id) params['force'] = 1 if force request({ 'action' => 'StopInstances' }.merge!(params)) end end class Mock def stop_instances(instance_id, force = false) instance_ids = Array(instance_id) instance_set = self.data[:instances].select {|id, s| instance_ids.include?(id) } if instance_set.empty? raise Fog::QingCloud::Errors::NotFound, "The instance ID '#{instance_ids.join(', ')}' does not exist" else instance_set.map! do |x| x['status'] = 'pending' x['transition_status'] = 'stopping' self.data[:modified_at][x['instance_id']] = Time.now x end response = Excon::Response.new response.status = 200 response.body = { 'action' => 'StopInstancesResponse', 'job_id' => Fog::QingCloud::Mock.job_id, 'ret_code' => 0 } response end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems