Sha256: e0dd55a179920f867345ee57bd4197fb7507e4ba810b59b4cbf82a70397e7adc

Contents?: true

Size: 1.74 KB

Versions: 14

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

module Fog
  module Compute
    class Aliyun
      class Real
        # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/other&describeinstancetypes]
        def list_server_types
          _action = 'DescribeInstanceTypes'
          _sigNonce = randonStr
          _time = Time.new.utc

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

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

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

        def get_instance_type(cpuCount, memorySize)
          _action = 'DescribeInstanceTypes'
          _sigNonce = randonStr
          _time = Time.new.utc

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

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

          response = request(
            expects: [200, 203],
            method: 'GET',
            path: _pathURL
          )

          _InstanceTypeId = nil
          _InstanceTypeList = response.body['InstanceTypes']['InstanceType']
          _InstanceTypeList.each do |instance_type|
            next unless (instance_type['CpuCoreCount'] == cpuCount) && (instance_type['MemorySize'] == memorySize)
            _InstanceTypeId = instance_type['InstanceTypeId']
            puts '_instanceTypeId: ' + _InstanceTypeId
            break
          end
          _InstanceTypeId
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.19 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.18 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.17 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.16 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.15 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.13 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.12 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.11 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.10 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.9 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.8 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.7 lib/fog/aliyun/requests/compute/list_server_types.rb
fog-aliyun-0.3.6 lib/fog/aliyun/requests/compute/list_server_types.rb