Sha256: aaad48fea3ff176e71077b75ca57e64a628a461a716269c6bc2ccd3bbc227faa

Contents?: true

Size: 1.6 KB

Versions: 55

Compression:

Stored size: 1.6 KB

Contents

#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#

module Fog
  module Compute
    class Softlayer

      class Mock
        def create_vm_tags(id, tags = [])
          raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
          response = Excon::Response.new
          response.status = self.get_vm(id).status

          if response.status != 404
            tags.each do |tag|
              @tags << {
                  'empRecordId'=>nil,
                  'id'=>Fog::Mock.random_numbers(7),
                  'resourceTableId'=>id,
                  'tagId'=> tagId = Fog::Mock.random_numbers(5),
                  'tagTypeId'=>1,
                  'usrRecordId'=>123456,
                  'tag'=>{'accountId'=>987654, 'id'=>tagId, 'internal'=>0, 'name'=>tag},
                  'tagType'=>{'description'=>'CCI', 'keyName'=>'GUEST'}
              }
            end
            response.body = true
          else
            response.body = {
                "error"=>"Unable to find object with id of '#{id}'.",
                "code"=>"SoftLayer_Exception_ObjectNotFound"
            }
          end
          response
        end
      end

      class Real
        def create_vm_tags(id, tags = [])
          raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
          self.request(:virtual_guest, "#{id}/set_tags", :body => tags.join(','), :http_method => :post)
        end
      end
    end
  end
end

Version data entries

55 entries across 53 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/compute/create_vm_tags.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/compute/create_vm_tags.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.1.4 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.1.3 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.1.2 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.1.1 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.1.0 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.0.3 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.0.2 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.0.1 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-1.0.0 lib/fog/softlayer/requests/compute/create_vm_tags.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-softlayer-0.4.7/lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-0.4.7 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-0.4.6 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-0.4.5 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-0.4.4 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-0.4.3 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-0.4.2 lib/fog/softlayer/requests/compute/create_vm_tags.rb
fog-softlayer-0.4.2.pre lib/fog/softlayer/requests/compute/create_vm_tags.rb