Sha256: a5c3479fa7d6dcf16a30ad7370c4626dff30b2a3b341c39c8aaed90bc28ea17d

Contents?: true

Size: 1.48 KB

Versions: 57

Compression:

Stored size: 1.48 KB

Contents

module Fog
  module Parsers
    module Compute
      module VcloudDirector
        class VmsByMetadata < VcloudDirectorParser
          def reset
            @response = { :vm_records => [] }
          end

          def start_element(name, attributes)
            super
            case name
            when 'QueryResultRecords'
              results = extract_attributes(attributes)
              @response[:type] = results[:type]
              @response[:href] = results[:href]
              @response[:total] = results[:total].to_i
              # href "https://devlab.mdsol.com/api/vms/query?page=1&amp;pageSize=25&amp;format=records&amp;filter=metadata:unoo==STRING:janderr&amp;fields=name,containerName"
              key = @response[:href].scan(/filter=metadata:(.*)==STRING/).flatten.first
              value = @response[:href].scan(/STRING:(.*)&?/).flatten.first
              @response[:id] = "#{key}:#{value}"
            when 'VMRecord'
              results = extract_attributes(attributes)
              results[:id] = results[:href].split('/').last
              results[:vapp_name] = results.delete(:containerName)
              results[:vapp_id] = results.delete(:container).split('/').last
              results[:cpu] = results.delete(:numberOfCpus)
              results[:memory] = results.delete(:memoryMB)
              results[:type] = "application/vnd.vmware.vcloud.vm+xml"
              @response[:vm_records] << results
            end
          end
        end
      end
    end
  end
end

Version data entries

57 entries across 55 versions & 7 rubygems

Version Path
fog-2.3.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-ifeel-2.2.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-2.2.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-2.1.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.42.1 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-vcloud-director-0.2.2 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-vcloud-director-0.2.1 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-vcloud-director-0.2.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-vcloud-director-0.1.10 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-vcloud-director-0.1.9 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-2.0.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.42.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.41.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.40.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.39.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-vcloud-director-0.1.8 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-vcloud-director-0.1.7 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb