Sha256: ad3a484e5e5768584b0e25501eee3a68b5163781828ca8482e1ab24afdeb8f75

Contents?: true

Size: 1.49 KB

Versions: 40

Compression:

Stored size: 1.49 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

40 entries across 40 versions & 2 rubygems

Version Path
fog-1.22.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.21.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.20.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-1.19.0 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb