Sha256: 5aec7dbba498e487345bb43cc873f43344b7d89a2159926be9f00122b3b57de1

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

module Fog
  module Compute
    class Aliyun
      class Real
        def delete_server(server_id)
          # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&deleteinstance]
          _action = 'DeleteInstance'
          _sigNonce = randonStr
          _time = Time.new.utc

          _parameters = defalutParameters(_action, _sigNonce, _time)
          _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

          _parameters['InstanceId'] = server_id
          _pathURL += '&InstanceId=' + server_id

          _signature = sign(@aliyun_accesskey_secret, _parameters)
          _pathURL += '&Signature=' + _signature

          request(
            expects: [200, 204],
            method: 'GET',
            path: _pathURL
          )
        end
      end

      class Mock
        def delete_server(server_id)
          response = Excon::Response.new
          if server = list_servers_detail.body['servers'].find { |_| _['id'] == server_id }
            if server['status'] == 'BUILD'
              response.status = 409
              raise(Excon::Errors.status_error({ expects: 204 }, response))
            else
              data[:last_modified][:servers].delete(server_id)
              data[:servers].delete(server_id)
              response.status = 204
            end
            response
          else
            raise Fog::Compute::OpenStack::NotFound
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
fog-aliyun-0.3.0 lib/fog/aliyun/requests/compute/delete_server.rb
fog-aliyun-0.2.2 lib/fog/aliyun/requests/compute/delete_server.rb
fog-xiaozhu-0.2.2 lib/fog/aliyun/requests/compute/delete_server.rb
fog-xiaozhu-0.2.1 lib/fog/aliyun/requests/compute/delete_server.rb
fog-aliyun-0.2.1 lib/fog/aliyun/requests/compute/delete_server.rb
fog-aliyun-0.2.0 lib/fog/aliyun/requests/compute/delete_server.rb