Sha256: 1a9cb75d439b8e895293a4ed3fd3e20b41479f2f6cb9e87036c5771286a1b7b6

Contents?: true

Size: 1.42 KB

Versions: 15

Compression:

Stored size: 1.42 KB

Contents

unless Fog.mocking?

  module Fog
    module AWS
      class EC2

        # Reboot specified instances
        #
        # ==== Parameters
        # * instance_id<~Array> - Ids of instances to reboot
        #
        # ==== Returns
        # # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'requestId'<~String> - Id of request
        #     * 'return'<~Boolean> - success?
        def reboot_instances(instance_id = [])
          params = AWS.indexed_param('InstanceId', instance_id)
          request({
            'Action' => 'RebootInstances'
          }.merge!(params), Fog::Parsers::AWS::EC2::Basic.new)
        end

      end
    end
  end

else

  module Fog
    module AWS
      class EC2

        def reboot_instances(instance_id = [])
          response = Excon::Response.new
          instance_id = [*instance_id]
          if (Fog::AWS::EC2.data[:instances].keys & instance_id).length == instance_id.length
            for instance_id in instance_id
              Fog::AWS::EC2.data[:instances][instance_id]['status'] = 'rebooting'
            end
            response.status = 200
            response.body = {
              'requestId' => Fog::AWS::Mock.request_id,
              'return'    => true
            }
          else
            response.status = 400
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
          response
        end

      end
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fog-0.0.56 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.55 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.54 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.53 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.52 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.51 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.50 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.49 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.48 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.47 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.46 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.45 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.44 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.43 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.42 lib/fog/aws/requests/ec2/reboot_instances.rb