Class: Fog::Compute::VcloudDirector::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/vcloud_director/compute.rb,
lib/fog/vcloud_director/requests/compute/get_vm.rb,
lib/fog/vcloud_director/requests/compute/put_vm.rb,
lib/fog/vcloud_director/requests/compute/get_vdc.rb,
lib/fog/vcloud_director/requests/compute/get_vms.rb,
lib/fog/vcloud_director/requests/compute/put_cpu.rb,
lib/fog/vcloud_director/requests/compute/get_disk.rb,
lib/fog/vcloud_director/requests/compute/get_task.rb,
lib/fog/vcloud_director/requests/compute/get_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_media.rb,
lib/fog/vcloud_director/requests/compute/get_vcloud.rb,
lib/fog/vcloud_director/requests/compute/put_memory.rb,
lib/fog/vcloud_director/requests/compute/delete_disk.rb,
lib/fog/vcloud_director/requests/compute/delete_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_catalog.rb,
lib/fog/vcloud_director/requests/compute/get_network.rb,
lib/fog/vcloud_director/requests/compute/put_network.rb,
lib/fog/vcloud_director/requests/compute/delete_media.rb,
lib/fog/vcloud_director/requests/compute/get_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_vm_disks.rb,
lib/fog/vcloud_director/requests/compute/get_task_list.rb,
lib/fog/vcloud_director/requests/compute/delete_network.rb,
lib/fog/vcloud_director/requests/compute/get_disk_owner.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb,
lib/fog/vcloud_director/requests/compute/get_vm_network.rb,
lib/fog/vcloud_director/requests/compute/get_media_owner.rb,
lib/fog/vcloud_director/requests/compute/get_template_vm.rb,
lib/fog/vcloud_director/requests/compute/get_catalog_item.rb,
lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb,
lib/fog/vcloud_director/requests/compute/get_organization.rb,
lib/fog/vcloud_director/requests/compute/get_template_vms.rb,
lib/fog/vcloud_director/requests/compute/post_cancel_task.rb,
lib/fog/vcloud_director/requests/compute/post_clone_media.rb,
lib/fog/vcloud_director/requests/compute/post_upload_disk.rb,
lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb,
lib/fog/vcloud_director/requests/compute/get_execute_query.rb,
lib/fog/vcloud_director/requests/compute/get_organizations.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_upload_media.rb,
lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_current_session.rb,
lib/fog/vcloud_director/requests/compute/get_startup_section.rb,
lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb,
lib/fog/vcloud_director/requests/compute/post_reconfigure_vm.rb,
lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb,
lib/fog/vcloud_director/requests/compute/get_network_complete.rb,
lib/fog/vcloud_director/requests/compute/get_org_vdc_gateways.rb,
lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb,
lib/fog/vcloud_director/requests/compute/get_vdc_storage_class.rb,
lib/fog/vcloud_director/requests/compute/get_supported_versions.rb,
lib/fog/vcloud_director/requests/compute/get_vms_disk_attached_to.rb,
lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb,
lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_supported_systems_info.rb,
lib/fog/vcloud_director/requests/compute/get_vms_in_lease_from_query.rb,
lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb,
lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb,
lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb,
lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb,
lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/put_vapp_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb,
lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb,
lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'lib/fog/vcloud_director/compute.rb', line 791

def initialize(options={})
  @vcloud_director_password = options[:vcloud_director_password]
  @vcloud_director_username = options[:vcloud_director_username]
  #@connection_options = options[:connection_options] || {}
  @host = options[:vcloud_director_host]
  @path = options[:path] || Fog::Compute::VcloudDirector::Defaults::PATH
  @persistent = options[:persistent] || false
  @port = options[:port] || Fog::Compute::VcloudDirector::Defaults::PORT
  @scheme = options[:scheme] || Fog::Compute::VcloudDirector::Defaults::SCHEME
  #@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
  @end_point    = "#{@scheme}://#{@host}#{@path}/"
  @api_version  = options[:vcloud_director_api_version] || Fog::Compute::VcloudDirector::Defaults::API_VERSION
  @vcloud_token = options[:vcloud_token]
end

Instance Attribute Details

#api_versionObject (readonly)

Returns the value of attribute api_version.



520
521
522
# File 'lib/fog/vcloud_director/compute.rb', line 520

def api_version
  @api_version
end

#end_pointObject (readonly)

Returns the value of attribute end_point.



520
521
522
# File 'lib/fog/vcloud_director/compute.rb', line 520

def end_point
  @end_point
end

Instance Method Details

#add_id_from_href!(data = {}) ⇒ Object



893
894
895
# File 'lib/fog/vcloud_director/compute.rb', line 893

def add_id_from_href!(data={})
  data[:id] = data[:href].split('/').last
end

#dataObject



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
# File 'lib/fog/vcloud_director/compute.rb', line 527

def data
  @@data ||= Hash.new do |hash, key|

    vdc1_uuid = uuid
    vdc2_uuid = uuid
    uplink_network_uuid  = uuid
    isolated_vdc1_network_uuid = uuid
    isolated_vdc2_network_uuid = uuid
    vapp1_id = "vapp-#{uuid}"
    vapp2_id = "vapp-#{uuid}"
    vapp1vm1_id = "vm-#{uuid}"
    vapp2vm1_id = "vm-#{uuid}"
    vapp2vm2_id = "vm-#{uuid}"
    catalog_uuid = uuid
    template_uuid = uuid

    hash[key] = {
      :catalogs => {
        catalog_uuid => {
          :name => 'Default Catalog'
        }
      },
      :catalog_items => {
        uuid => {
          :type    => 'vAppTemplate',
          :name    => 'vAppTemplate 1',
          :catalog => catalog_uuid,
          :template_id => template_uuid
        }
      },
      :disks => {
        uuid => {
          :name => 'Hard Disk 1',
          :capacity => 10240,
          :parent_vm => vapp1vm1_id
        }
      },
      :edge_gateways => {
        uuid => {
          :name => 'MockEdgeGateway',
          :networks => [uplink_network_uuid, default_network_uuid],
          :vdc => vdc1_uuid,
          :Configuration => {
            :GatewayBackingConfig => "compact",
            :GatewayInterfaces => {
              :GatewayInterface => []},
            :EdgeGatewayServiceConfiguration => {
              :FirewallService => {
                :IsEnabled => "true",
                :DefaultAction => "drop",
                :LogDefaultAction => "false",
                :FirewallRule => []
              },
              :NatService => {:IsEnabled => "true"}},
            :HaEnabled => "false",
            :UseDefaultRouteForDnsRelay => "false"
          }
        }
      },

      :medias => {},

      :networks => {

        default_network_uuid => {
          :IsShared => true,
          :vdc => vdc1_uuid,
          :FenceMode => 'natRouted',
          :ApplyRateLimit => "false",
          :Description => 'Org Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :Gateway => '192.168.1.1',
          :InterfaceType => "internal",
          :IpRanges => [{
            :StartAddress=>'192.168.1.2',
            :EndAddress=>'192.168.1.254'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'vDC1 Default Network',
          :SubnetParticipation => {
              :Gateway => "192.168.1.0",
              :Netmask => "255.255.0.0",
              :IpAddress => "192.168.1.0"
          },
          :UseForDefaultRoute => "false"
        },

        isolated_vdc1_network_uuid => {
          :IsShared => false,
          :vdc => vdc1_uuid,
          :ApplyRateLimit => "false",
          :FenceMode => 'isolated',
          :Description => 'Org Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :InterfaceType => "internal",
          :IpRanges => [{
            :StartAddress=>'10.1.0.100',
            :EndAddress=>'10.1.0.200'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'vDC1 backend network',
          :SubnetParticipation => {
              :Gateway => "192.168.1.0",
              :Netmask => "255.255.0.0",
              :IpAddress => "192.168.1.0"
          },
          :UseForDefaultRoute => "false"
        },

        isolated_vdc2_network_uuid => {
          :IsShared => false,
          :vdc => vdc2_uuid,
          :ApplyRateLimit => "false",
          :Description => 'Org Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :InterfaceType => "internal",
          :IpRanges => [{
            :StartAddress=>'10.2.0.100',
            :EndAddress=>'10.2.0.200'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'vDC2 backend network',
          :SubnetParticipation => {
              :Gateway => "192.168.1.0",
              :Netmask => "255.255.0.0",
              :IpAddress => "192.168.1.0"
          },
          :UseForDefaultRoute => "false"
        },

        uplink_network_uuid => {
          :IsShared => false,
          :vdc => vdc1_uuid,
          :ApplyRateLimit => "false",
          :FenceMode => 'bridged',
          :Description => 'Uplink Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :Gateway => '198.51.100.1',
          :InterfaceType => "uplink",
          :IpRanges => [{
            :StartAddress=>'198.51.100.2',
            :EndAddress=>'198.51.100.254'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'uplink Network',
          :SubnetParticipation => {
            :Gateway => "198.51.100.81",
            :Netmask => "255.255.255.248",
            :IpAddress => "198.51.100.83",
            :IpRanges => {
              :IpRange => {
                :StartAddress => "198.51.100.84",
                :EndAddress => "198.51.100.86"
              }
            }
          },
          :UseForDefaultRoute => "true"
        }

      },
      :org => {
        :description => 'Organization for mocking',
        :full_name => 'Mock Organization',
        :name => org_name,
        :uuid => uuid
      },

      :tags => {},

      :tasks => {},

      :vapps => {
        vapp1_id => {
          :name => 'mock-vapp-1',
          :vdc_id => vdc1_uuid,
          :description => "Mock vApp 1",
          :networks => [
            { :parent_id => default_network_uuid, },
          ],
        },
        vapp2_id => {
          :name => 'mock-vapp-2',
          :vdc_id => vdc2_uuid,
          :description => "Mock vApp 2",
          :networks => [
            { :parent_id => default_network_uuid },
          ]
        },
      },

      :vdc_storage_classes => {
        uuid => {
          :default => true,
          :enabled => true,
          :limit => 2 * 1024 * 1024,
          :name => 'DefaultMockStorageClass',
          :units => 'MB',
          :vdc => vdc1_uuid,
        }
      },

      :vdcs => {
        vdc1_uuid => {
          :description => 'vDC1 for mocking',
          :name => 'MockVDC 1'
        },
        vdc2_uuid => {
          :description => 'vDC2 for mocking',
          :name => 'MockVDC 2'
        },
      },

      :vms => {
        vapp1vm1_id => {
          :name => 'mock-vm-1-1',
          :parent_vapp => vapp1_id,
          :nics => [
            {
              :network_name => 'Default Network',
              :mac_address => "00:50:56:aa:bb:01",
              :ip_address => "192.168.1.33",
            },
          ],
        },
        vapp2vm1_id => {
          :name => 'mock-vm-2-1',
          :parent_vapp => vapp2_id,
          :nics => [
            {
              :network_name => 'Default Network',
              :mac_address => "00:50:56:aa:bb:02",
              :ip_address => "192.168.1.34",
            },
          ],
        },
        vapp2vm2_id => {
          :name => 'mock-vm-2-2',
          :parent_vapp => vapp2_id,
          :nics => [
            {
              :network_name => 'Default Network',
              :mac_address => "00:50:56:aa:bb:03",
              :ip_address => "192.168.1.35",
            },
          ],
        },
      },

    }
  end[@vcloud_director_username]
end

#default_network_uuidObject

This is used in some mocks so it’s a method rather than a variable



523
524
525
# File 'lib/fog/vcloud_director/compute.rb', line 523

def default_network_uuid
  @default_network_uuid ||= uuid
end

#delete_disk(id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/vcloud_director/requests/compute/delete_disk.rb', line 27

def delete_disk(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.disk:#{id})\""
    )
  end

  owner = {
    :href => make_href("disk/#{id}"),
    :type => 'application/vnd.vmware.vcloud.disk+xml'
  }
  task_id = enqueue_task(
    "Deleting Disk(#{id})", 'vdcDeleteDisk', owner,
    :on_success => lambda do
      data[:disks].delete(id)
    end
  )

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#delete_media(id) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/fog/vcloud_director/requests/compute/delete_media.rb', line 90

def delete_media(id)
  unless media = data[:medias][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.media:#{id})\""
    )
  end

  owner = {
    :href => make_href("media/#{id}"),
    :type => 'application/vnd.vmware.vcloud.media+xml'
  }
  task_id = enqueue_task(
    "Deleting Media File(#{media[:file][:uuid]})", 'vdcDeleteMedia', owner,
    :on_success => lambda do
      data[:medias].delete(id)
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#delete_network(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/vcloud_director/requests/compute/delete_network.rb', line 29

def delete_network(id)
  unless data[:networks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.orgVdcNetwork:#{id})\""
    )
  end

  owner = {
    :href => make_href("network/#{id}"),
    :type => 'application/vnd.vmware.vcloud.network+xml'
  }
  task_id = enqueue_task(
    "Deleting Network(#{id})", 'DeleteNetwork', owner,
    :on_success => lambda do
      data[:networks].delete(id)
    end
  )

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#delete_vapp(id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/vcloud_director/requests/compute/delete_vapp.rb', line 28

def delete_vapp(id)
  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Deleting Virtual Application (#{id})", 'vdcDeleteVapp', owner,
    :on_success => lambda do
      data[:vapps].delete(id)
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#enqueue_task(operation, operation_name, owner, options = {}) ⇒ String

Create a task.

Parameters:

  • operation (String)

    A message describing the operation that is tracked by this task.

  • operation_name (String)

    The short name of the operation that is tracked by this task.

  • owner (Hash)

    Reference to the owner of the task. This is typically the object that the task is creating or updating.

    • :href<~String> - Contains the URI to the entity.

    • :type<~String> - Contains the MIME type of the entity.

Returns:

  • (String)

    Object identifier of the task.



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
# File 'lib/fog/vcloud_director/compute.rb', line 846

def enqueue_task(operation, operation_name, owner, options={})
  task_id = uuid
  now = DateTime.now

  data[:tasks][task_id] = {
    :cancel_requested => false,
    :details => '',
    :expiry_time => now + 86400, # in 24 hours
    :name => 'task',
    :progress => 1,
    :service_namespace => 'com.vmware.vcloud',
    :start_time => now,
    :end_time => now + 86400,
    :status => 'running',
  }.merge(options).merge(
    :operation => operation,
    :operation_name => operation_name,
    :owner => owner
  )

  task_id
end

#get_catalog(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/vcloud_director/requests/compute/get_catalog.rb', line 29

def get_catalog(id)
  unless catalog = data[:catalogs][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.catalog:#{id})\"."
    )
  end
  
  items = data[:catalog_items].select {|_,v| v[:catalog] == id}
  
  body = {
    :href => make_href("catalog/#{id}"),
    :type => 'application/vnd.vmware.vcloud.catalog+xml',
    :id   => id,
    :name => catalog[:name],
    :CatalogItems => {
      :CatalogItem => items.map do |uuid,item|
        {
          :href => make_href("catalogItem/#{uuid}"),
          :id   => uuid,
          :name => item[:name],
          :type => 'application/vnd.vmware.vcloud.catalogItem+xml'
        }
      end
    },
  }
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_catalog_item(id) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/vcloud_director/requests/compute/get_catalog_item.rb', line 24

def get_catalog_item(id)
  unless item = data[:catalog_items][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.catalogItem:#{id})\"."
    )
  end
  body = {
    :href => make_href("catalogItem/#{id}"),
    :id   => id,
    :name => item[:name],
    :type => 'application/vnd.vmware.vcloud.catalogItem+xml',
    :Entity => {
      :href => make_href("vAppTemplate/#{item[:template_id]}")              
    }
  }
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_cpu_rasd_item(id) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb', line 30

def get_cpu_rasd_item(id)
  type = 'application/vnd.vmware.vcloud.rasdItem+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_cpu_rasd_item_body(id, vm)
  )
end

#get_cpu_rasd_item_body(id, vm) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb', line 46

def get_cpu_rasd_item_body(id, vm)
  {
    :ns12_href => make_href("vApp/#{id}/virtualHardwareSection/cpu"),
    :ns12_type => "application/vnd.vmware.vcloud.rasdItem+xml",
    :"rasd:AllocationUnits"=>"hertz * 10^6",
    :"rasd:Description"=>"Number of Virtual CPUs",
    :"rasd:ElementName"=>"#{vm[:cpu_count]} virtual CPU(s)",
    :"rasd:InstanceID"=>"4",
    :"rasd:Reservation"=>"0",
    :"rasd:ResourceType"=>"3",
    :"rasd:VirtualQuantity"=>"#{vm[:cpu_count]}",
    :"rasd:Weight"=>"0",
  }
end

#get_current_sessionObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fog/vcloud_director/requests/compute/get_current_session.rb', line 42

def get_current_session
  body =
    {:href => make_href('session/'),
     :type => 'application/vnd.vmware.vcloud.session+xml',
     :org => data[:org][:name],
     :user => user_name,
     :Link =>
      [{:href => make_href('org/'),
        :type => 'application/vnd.vmware.vcloud.orgList+xml',
        :rel => 'down'},
       {:href => make_href('admin/'),
        :type => 'application/vnd.vmware.admin.vcloud+xml',
        :rel => 'down'},
       {:href => make_href("org/#{data[:org][:uuid]}"),
        :name => data[:org][:name],
        :type => 'application/vnd.vmware.vcloud.org+xml',
        :rel => 'down'},
       {:href => make_href('query'),
        :type => 'application/vnd.vmware.vcloud.query.queryList+xml',
        :rel => 'down'},
       {:href => make_href('entity/'),
        :type => 'application/vnd.vmware.vcloud.entity+xml',
        :rel => 'entityResolver'}]}

  if @api_version.to_f >= 5.1
    body[:Link] << {
      :href => make_href('extensibility'),
      :type => 'application/vnd.vmware.vcloud.apiextensibility+xml',
      :rel => 'down:extensibility'
    }
  end

  Excon::Response.new(
    :body => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status => 200
  )
end

#get_disk(id) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/vcloud_director/requests/compute/get_disk.rb', line 44

def get_disk(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.disk:%s".' % id
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(disk_body(id))

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{@version}"},
    :body => body
  )
end

#get_disk_owner(id) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fog/vcloud_director/requests/compute/get_disk_owner.rb', line 38

def get_disk_owner(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.disk:%s".' % id
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :Link => {
      :href => make_href("disk/#{id}"),
      :type => 'application/vnd.vmware.vcloud.disk+xml',
      :rel => 'up'
    },
    :User => {
      :href => make_href("admin/user/#{user_uuid}"),
      :name => user_name,
      :type => 'application/vnd.vmware.admin.user+xml',
    }
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{@version}"},
    :body => body
  )
end

#get_disks(vapp) ⇒ Object



65
66
67
68
69
# File 'lib/fog/vcloud_director/requests/compute/get_vm.rb', line 65

def get_disks(vapp)
  hardware = vapp[:"ovf:VirtualHardwareSection"][:"ovf:Item"]
  disks = hardware.select {|h| h[:"rasd:ResourceType"].to_i == 17}
  disks.map {|d| {d[:"rasd:ElementName"] => d[:"rasd:HostResource"][:ns12_capacity].to_i}}
end

#get_disks_rasd_items_list(id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb', line 27

def get_disks_rasd_items_list(id)
  type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :type => type,
    :href => make_href("vApp/#{id}/virtualHardwareSection/disks"),
    :Link => {
      :rel=>"edit",
      :type=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
      :href=>make_href("vApp/#{id}/virtualHardwareSection/disks"),
    },
    :Item => [
      get_disks_rasd_items_list_body(id, vm),
      get_media_rasd_item_ide_controller_body(id, vm),
    ].flatten
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => body
  )
end

#get_disks_rasd_items_list_body(id, vm) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb', line 57

def get_disks_rasd_items_list_body(id, vm)
  [
    {
      :"rasd:Address"=>"0",
      :"rasd:Description"=>"SCSI Controller",
      :"rasd:ElementName"=>"SCSI Controller 0",
      :"rasd:InstanceID"=>"2",
      :"rasd:ResourceSubType"=>"lsilogic",
      :"rasd:ResourceType"=>"6"
    },

    # TODO: Add support for adding disks
    {
      :"rasd:AddressOnParent"=>"0",
      :"rasd:Description"=>"Hard disk",
      :"rasd:ElementName"=>"Hard disk 1",
      :"rasd:HostResource"=>{
        :ns12_capacity=>"51200",
        :ns12_busSubType=>"lsilogic",
        :ns12_busType=>"6"
      },
      :"rasd:InstanceID"=>"2000",
      :"rasd:Parent"=>"2",
      :"rasd:ResourceType"=>"17"
    },

  ]
end

#get_edge_gateway(id) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb', line 54

def get_edge_gateway(id)
  unless edge_gateway = data[:edge_gateways][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.gateway:#{id})\""
    )
  end

  vdc_id = edge_gateway[:vdc]
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :status => "1",
    :name => edge_gateway[:name],
    :id => "urn:vcloud:gateway:#{id}",
    :type => "application/vnd.vmware.admin.edgeGateway+xml",
    :href => make_href("admin/edgeGateway/#{id}"),
    :xsi_schemaLocation => xsi_schema_location,
    :Link =>[{:rel => "up",
              :type => "application/vnd.vmware.vcloud.vdc+xml",
              :href => make_href("vdc/#{vdc_id}")},
             {:rel => "edgeGateway:redeploy",
              :href => make_href("admin/edgeGateway/#{id}/action/redeploy")},
             {:rel => "edgeGateway:configureServices",
              :type => "application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml",
              :href => make_href("admin/edgeGateway/#{id}/action/configureServices")},
             {:rel => "edgeGateway:reapplyServices",
              :href => make_href("admin/edgeGateway/#{id}/action/reapplyServices")},
             {:rel => "edgeGateway:syncSyslogSettings",
              :href => make_href("admin/edgeGateway/#{id}/action/syncSyslogServerSettings")}],
    :Description => "vCloud CI (nft00052i2)",
    :Configuration => edge_gateway[:Configuration].dup
  }

  body[:Configuration][:GatewayInterfaces][:GatewayInterface] += edge_gateway[:networks].map do |network|
    extras = {
      :Network => {
        :type => "application/vnd.vmware.admin.network+xml",
        :name => "anything",
        :href => make_href("admin/network/#{network}")
      },
      :Name => data[:networks][network][:name],
      :DisplayName => data[:networks][network][:name]
    }
    data[:networks][network].merge extras
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_execute_query(type = nil, options = {}) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/fog/vcloud_director/requests/compute/get_execute_query.rb', line 123

def get_execute_query(type=nil, options={})
  unless options[:fields].nil?
    Fog::Mock.not_implemented("Fields are not yet implemented in get_execute_query Mock for #{type}")
  end

  unless options[:format].nil? || options[:format] == 'records'
    Fog::Mock.not_implemented("Formats #{options[:format]} is not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default is to sort by 'Database ID' (uuid?). Does this matter?
  unless options[:sortAsc].nil? && options[:sortDesc].nil?
    Fog::Mock.not_implemented("Sorting by field is not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default offset is 0
  unless options[:offset].nil?
    Fog::Mock.not_implemented("Offset results are not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default page is 1
  if options.key?(:page) && options[:page].to_i != 1
    Fog::Mock.not_implemented("Paginated results are not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default pageSize is 25
  unless options[:pageSize].nil?
    Fog::Mock.not_implemented("Paginated results are not yet implemented in get_execute_query Mock for #{type}")
  end

  if type.nil?
    body = all_types
  else
    body = fetch_items(type, options)
  end

  Excon::Response.new(
    :status  => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body    => body
  )
end

#get_guest_customization_system_section_vapp(id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb', line 25

def get_guest_customization_system_section_vapp(id)

  type = 'application/vnd.vmware.vcloud.guestCustomizationSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_guest_customization_section_body(id, vm)
  )
end

#get_hardware(vapp, resource_type) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/fog/vcloud_director/requests/compute/get_vm.rb', line 55

def get_hardware(vapp, resource_type)
  hardware = vapp[:"ovf:VirtualHardwareSection"][:"ovf:Item"]
  item = hardware.find {|h| h[:"rasd:ResourceType"].to_i == resource_type}
  if item and item.key? :"rasd:VirtualQuantity"
    item[:"rasd:VirtualQuantity"].to_i
  else
    nil
  end
end

#get_lease_settings_section_vapp(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb', line 26

def get_lease_settings_section_vapp(id)

  type = 'application/vnd.vmware.vcloud.leaseSettingsSection+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vapp_lease_settings_section_body(id)
  )

end

#get_media(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/vcloud_director/requests/compute/get_media.rb', line 29

def get_media(id)
  unless data[:medias][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.media:#{id})\"."
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(media_body(id))

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=>#{@api_version}"},
    :body => body
  )
end

#get_media_drives_rasd_items_list(id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb', line 27

def get_media_drives_rasd_items_list(id)
  type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :type => type,
    :href => make_href("vApp/#{id}/virtualHardwareSection/media"),
    :Item => [
      get_media_rasd_item_ide_controller_body(id, vm),
      get_media_rasd_item_cdrom_body(id, vm),
      get_media_rasd_item_floppy_body(id, vm),
    ]
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => body
  )
end

#get_media_owner(id) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fog/vcloud_director/requests/compute/get_media_owner.rb', line 38

def get_media_owner(id)
  unless data[:medias][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.media:%s".' % id
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :Link => {
      :href => make_href("media/#{id}"),
      :type => 'application/vnd.vmware.vcloud.media+xml',
      :rel => 'up'
    },
    :User => {
      :href => make_href("admin/user/#{user_uuid}"),
      :name => user_name,
      :type => 'application/vnd.vmware.admin.user+xml',
    }
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{@version}"},
    :body => body
  )
end

#get_media_rasd_item_cdrom_body(id, vm) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb', line 63

def get_media_rasd_item_cdrom_body(id, vm)
  {
    :"rasd:AddressOnParent"=>"1",
    :"rasd:AutomaticAllocation"=>"true",
    :"rasd:Description"=>"CD/DVD Drive",
    :"rasd:ElementName"=>"CD/DVD Drive 1",
    :"rasd:HostResource"=>"",
    :"rasd:InstanceID"=>"3000",
    :"rasd:Parent"=>"3",
    :"rasd:ResourceType"=>"15"
  }
end

#get_media_rasd_item_floppy_body(id, vm) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb', line 76

def get_media_rasd_item_floppy_body(id, vm)
  {
    :"rasd:AddressOnParent"=>"0",
    :"rasd:AutomaticAllocation"=>"false",
    :"rasd:Description"=>"Floppy Drive",
    :"rasd:ElementName"=>"Floppy Drive 1",
    :"rasd:HostResource"=>"",
    :"rasd:InstanceID"=>"8000",
    :"rasd:ResourceType"=>"14"
  }
end

#get_media_rasd_item_ide_controller_body(id, vm) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb', line 53

def get_media_rasd_item_ide_controller_body(id, vm)
  {
    :"rasd:Address"=>"0",
    :"rasd:Description"=>"IDE Controller",
    :"rasd:ElementName"=>"IDE Controller 0",
    :"rasd:InstanceID"=>"3",
    :"rasd:ResourceType"=>"5"
  }
end

#get_memory_rasd_item(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb', line 29

def get_memory_rasd_item(id)
  type = 'application/vnd.vmware.vcloud.rasdItem+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_memory_rasd_item_body(id, vm)
  )
end

#get_memory_rasd_item_body(id, vm) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb', line 45

def get_memory_rasd_item_body(id, vm)
  {
    :ns12_href => make_href("vApp/#{id}/virtualHardwareSection/memory"),
    :ns12_type=>"application/vnd.vmware.vcloud.rasdItem+xml",
    :"rasd:AllocationUnits"=>"byte * 2^20",
    :"rasd:Description"=>"Memory Size",
    :"rasd:ElementName"=>"#{vm[:memory_in_mb]} MB of memory",
    :"rasd:InstanceID"=>"5",
    :"rasd:Reservation"=>"0",
    :"rasd:ResourceType"=>"4",
    :"rasd:VirtualQuantity"=>"#{vm[:memory_in_mb]}",
    :"rasd:Weight"=>"0",
  }
end

#get_metadata(id) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/fog/vcloud_director/requests/compute/get_metadata.rb', line 29

def (id)
  tags = data[:tags][id] || {}
  body = {:type => 'application/vnd.vmware.vcloud.metadata+xml', :metadata => tags}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_mock_vapp_body(id) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 82

def get_mock_vapp_body(id)

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :deployed => "true",
    :status => vapp[:status],
    :name => vapp[:name],
    :type => "application/vnd.vmware.vcloud.vApp+xml",
    :href => make_href("vApp/#{id}"),
    :LeaseSettingsSection => get_vapp_lease_settings_section_body(id),
    :"ovf:StartupSection" => get_vapp_ovf_startup_section_body(id, vapp),
    :"ovf:NetworkSection" => get_vapp_ovf_network_section_body(id, vapp),
    :NetworkConfigSection => get_vapp_network_config_section_body(id, vapp),
    :SnapshotSection      => get_snapshot_section_body(id),
    :DateCreated => vapp[:date_created], # eg "2014-03-16T10:52:31.874Z"
    :Owner => get_owner_section_body(id),
    :InMaintenanceMode => "false",
    :Children => {
      :Vm => get_vapp_children_vms_body(id)
    },
  }
  body
end

#get_mock_vm_body(id) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 52

def get_mock_vm_body(id)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :name => vm[:name],
    :href => make_href("vApp/#{id}"),
    :type => "application/application/vnd.vmware.vcloud.vm+xml",
    :status => vm[:status],
    :deployed => vm[:deployed],
    :needsCustomization => vm[:needs_customization],
    :Description => vm[:description],
    :"ovf:VirtualHardwareSection" => get_vm_virtual_hardware_section_body(id, vm),
    :"ovf:OperatingSystemSection" => get_vm_operating_system_section_body(id, vm),
    :NetworkConnectionSection     => get_vm_network_connection_section_body(id, vm),
    :GuestCustomizationSection    => get_vm_guest_customization_section_body(id, vm),
    :RuntimeInfoSection           => get_vm_runtime_info_section_body(id, vm),
    :SnapshotSection              => get_snapshot_section_body(id),
    :DateCreated       => vm[:date_created], # eg "2014-03-16T10:52:31.874Z"
    :VAppScopedLocalId => vm[:parent_vapp].split('-').last, # strip the vapp- prefix
    :"ovfenv:Environment" => get_vm_ovfenv_environment_section_body(id, vm),
    :VmCapabilities => get_vm_capabilities_section_body(id, vm),
    :StorageProfile => get_vm_storage_profile_section_body(id, vm),
  }
  body
end

#get_network(id) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fog/vcloud_director/requests/compute/get_network.rb', line 32

def get_network(id)
  Fog::Logger.deprecation("#{self} => #get_network is deprecated, use #get_network_complete instead [light_black](#{caller.first})[/]")
  unless network = data[:networks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body =
    {:name=>network[:name],
     :href=>make_href("network/#{id}"),
     :type=>"application/vnd.vmware.vcloud.orgNetwork+xml",
     :id=>id,
     :description=>nil,
     :is_inherited=>network[:IsInherited],
     :gateway=>network[:Gateway],
     :netmask=>network[:Netmask],
     :dns1=>network[:Dns1],
     :dns2=>network[:Dns2],
     :dns_suffix=>network[:DnsSuffix]}

  body[:ip_ranges] = network[:IpRanges].map do |ip_range|
    {:start_address=>ip_range[:StartAddress],
     :end_address=>ip_range[:EndAddress]}
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_network_cards_items_list(id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb', line 25

def get_network_cards_items_list(id)
  type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :type => type,
    :href => make_href("vApp/#{id}/virtualHardwareSection/networkCards"),
    :Link => {
      :rel=>"edit",
      :type=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
      :href=>make_href("vApp/#{id}/virtualHardwareSection/networkCards"),
    },
    :Item => get_network_cards_rasd_items_list_body(id, vm)
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => body
  )

end

#get_network_cards_rasd_items_list_body(id, vm) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb', line 53

def get_network_cards_rasd_items_list_body(id, vm)
  [{
    :"rasd:Address" => vm[:nics][0][:mac_address],
    :"rasd:AddressOnParent" => "0",
    :"rasd:AutomaticAllocation" => "true",
    :"rasd:Connection" => vm[:nics][0][:network_name],
    :"rasd:Description" => "E1000 ethernet adapter",
    :"rasd:ElementName" => "Network adapter 0",
    :"rasd:InstanceID" => "1",
    :"rasd:ResourceSubType" => "E1000",
    :"rasd:ResourceType" => "10"
  }]
end

#get_network_complete(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fog/vcloud_director/requests/compute/get_network_complete.rb', line 29

def get_network_complete(id)
  unless network = data[:networks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :name => network[:name],
    :href => make_href("network/#{id}"),
    :type => "application/vnd.vmware.vcloud.orgNetwork+xml",
    :id   => id,
    :Description => network[:Description],
    :Configuration => {
      :IpScopes => {
        :IpScope => {
          :IsInherited => network[:IsInherited].to_s,
          :Gateway     => network[:Gateway],
          :Netmask     => network[:Netmask],
          :Dns1        => network[:Dns1],
          :Dns2        => network[:Dns2],
          :DnsSuffix   => network[:DnsSuffix],
          :IsEnabled   => true.to_s,
          :IpRanges    => {
            :IpRange => [],
          },
        }
      },
      :FenceMode => network[:FenceMode],
      :RetainNetInfoAcrossDeployments => false.to_s,
    },
    :IsShared => network[:IsShared].to_s,
  }

  body[:Configuration][:IpScopes][:IpScope][:IpRanges][:IpRange] =
    network[:IpRanges].map do |ip_range|
      {:StartAddress => ip_range[:StartAddress],
       :EndAddress   => ip_range[:EndAddress]}
    end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_network_config_section_vapp(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb', line 26

def get_network_config_section_vapp(id)

  type = 'application/vnd.vmware.vcloud.networkConfigSection+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vapp_network_config_section_body(id, vapp)
  )

end

#get_network_connection_system_section_vapp(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb', line 26

def get_network_connection_system_section_vapp(id)
  type = 'application/vnd.vmware.vcloud.networkConnectionSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_network_connection_section_body(id, vm)
  )

end

#get_operating_system_section(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb', line 26

def get_operating_system_section(id)

  type = 'application/vnd.vmware.vcloud.operatingSystemSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_operating_system_section_body(id, vm)
  )

end

#get_org_vdc_gateways(vdc_id) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fog/vcloud_director/requests/compute/get_org_vdc_gateways.rb', line 32

def get_org_vdc_gateways(vdc_id)
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  body =
    {:xmlns => xmlns,
     :xmlns_xsi => xmlns_xsi,
     :total => "1",
     :pageSize => "25",
     :page => "1",
     :name => "edgeGateways",
     :type => "application/vnd.vmware.vcloud.query.records+xml",
     :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=records"),
     :xsi_schemaLocation => xsi_schema_location,
     :Link =>
      [{:rel => "alternate",
        :type => "application/vnd.vmware.vcloud.query.references+xml",
        :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=references")},
       {:rel => "alternate",
        :type => "application/vnd.vmware.vcloud.query.idrecords+xml",
        :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=records")}],
     :EdgeGatewayRecord => []}

  vdc_edge_gateways = data[:edge_gateways].select do |id, edge_gateway|
    edge_gateway[:vdc] == vdc_id
  end

  body[:EdgeGatewayRecord] += vdc_edge_gateways.map do |id, edge_gateway|
    {:vdc => make_href("vdc/#{vdc_id}"),
     :numberOfOrgNetworks => "1",
     :numberOfExtNetworks => "1",
     :name => edge_gateway[:name],
     :isBusy => "false",
     :haStatus => "DISABLED",
     :gatewayStatus => "READY",
     :href => make_href("admin/edgeGateway/#{id}"),
     :isSyslogServerSettingInSync => "true"}
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_organization(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/fog/vcloud_director/requests/compute/get_organization.rb', line 29

def get_organization(id)
  unless id == data[:org][:uuid]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"com.vmware.vcloud.entity.org:#{id}\""
    )
  end
  org = data[:org]

  body =
    {:href=>make_href("org/#{id}"),
     :type=>"application/vnd.vmware.vcloud.org+xml",
     :id=>"urn:vcloud:org:#{id}",
     :name=>org[:name],
     :Link=>
      [{:href=>make_href("tasksList/#{id}"),
        :type=>"application/vnd.vmware.vcloud.tasksList+xml",
        :rel=>"down"},
       {:href=>make_href("admin/org/#{id}/catalogs"),
        :type=>"application/vnd.vmware.admin.catalog+xml",
        :rel=>"add"},
       {:href=>make_href("org/#{id}/metadata"),
        :type=>"application/vnd.vmware.vcloud.metadata+xml",
        :rel=>"down"}],
     :Description=>org[:description]||'',
     :Tasks=>{:Task=>[]},
     :FullName=>org[:full_name]}

  body[:Link] += data[:catalogs].map do |catalog_id, catalog|
    [{:href=>make_href("catalog/#{catalog_id}"),
      :name=>catalog[:name],
      :type=>"application/vnd.vmware.vcloud.catalog+xml",
      :rel=>"down"},
     {:href=>make_href("org/#{id}/catalog/#{catalog_id}/controlAccess/"),
      :type=>"application/vnd.vmware.vcloud.controlAccess+xml",
      :rel=>"down"},
     {:href=>
       make_href("org/#{id}/catalog/#{catalog_id}/action/controlAccess"),
      :type=>"application/vnd.vmware.vcloud.controlAccess+xml",
      :rel=>"controlAccess"}]
  end.flatten

  body[:Link] += data[:networks].map do |network_id, network|
    {:href=>make_href("network/#{network_id}"),
     :name=>network[:name],
     :type=>"application/vnd.vmware.vcloud.orgNetwork+xml",
     :rel=>"down"}
  end

  body[:Link] += data[:vdcs].map do |vdc_id, vdc|
    {:href=>make_href("vdc/#{vdc_id}"),
     :name=>vdc[:name],
     :type=>"application/vnd.vmware.vcloud.vdc+xml",
     :rel=>"down"}
  end

  if api_version.to_f >= 5.1
    body[:Link] <<
      {:href=>make_href('supportedSystemsInfo/'),
       :type=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",
       :rel=>"down"}
  end

  Excon::Response.new(
    :body    => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status  => 200
  )
end

#get_organizationsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/vcloud_director/requests/compute/get_organizations.rb', line 34

def get_organizations
  body =
    {:href=>make_href('org/'),
     :type=>"application/vnd.vmware.vcloud.orgList+xml",
     :Org=>
      [{:href=>make_href("org/#{data[:org][:uuid]}"),
        :name=>data[:org][:name],
        :type=>"application/vnd.vmware.vcloud.org+xml"}]}

  Excon::Response.new(
    :body => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status => 200
  )
end

#get_owner_section_body(id) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb', line 43

def get_owner_section_body(id)
  {
    :type => 'application/vnd.vmware.vcloud.owner+xml',
    :User => {
      :type => "application/vnd.vmware.admin.user+xml",
      :name => "mockuser",
      :href => make_href("user/12345678-1234-1234-1234-12345678df2b"),
    }
  }
end

#get_runtime_info_section_type(id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb', line 25

def get_runtime_info_section_type(id)

  type = 'application/vnd.vmware.vcloud.virtualHardwareSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_runtime_info_section_body(id, vm)
  )
end

#get_snapshot_section(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb', line 26

def get_snapshot_section(id)
  type = 'application/vnd.vmware.vcloud.snapshotSection+xml'

  unless data[:vms][id] || data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_snapshot_section_body(id)
  )
end

#get_snapshot_section_body(id) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb', line 42

def get_snapshot_section_body(id)
  {
    :type => "application/vnd.vmware.vcloud.snapshotSection+xml",
    :href => make_href("vApp/#{id}/snapshotSection"),
    :ovf_required => "false",
    :"ovf:Info"   => "Snapshot information section"
  }
end

#get_startup_section(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/requests/compute/get_startup_section.rb', line 26

def get_startup_section(id)

  type = 'application/vnd.vmware.vcloud.startupSection+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vapp_ovf_startup_section_body(id, vapp)
  )

end

#get_supported_systems_infoObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/fog/vcloud_director/requests/compute/get_supported_systems_info.rb', line 25

def get_supported_systems_info
  body = # this is a subset of the full list
    {:xmlns=>xmlns,
     :xmlns_xsi=>xmlns_xsi,
     :type=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",
     :href=>make_href('supportedSystemsInfo/'),
     :xsi_schemaLocation=>xsi_schema_location,
     :OperatingSystemFamilyInfo=>
      [{:Name=>"Microsoft Windows",
        :OperatingSystemFamilyId=>"1",
        :OperatingSystem=>
         [{:OperatingSystemId=>"85",
           :DefaultHardDiskAdapterType=>"4",
           :MinimumHardDiskSizeGigabytes=>"40",
           :MinimumMemoryMegabytes=>"512",
           :Name=>"Microsoft Windows Server 2012 (64-bit)",
           :InternalName=>"windows8Server64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"8",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"true",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"74",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"3",
           :DefaultHardDiskAdapterType=>"4",
           :MinimumHardDiskSizeGigabytes=>"40",
           :MinimumMemoryMegabytes=>"512",
           :Name=>"Microsoft Windows Server 2008 R2 (64-bit)",
           :InternalName=>"windows7Server64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"true",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"102",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"4",
           :DefaultHardDiskAdapterType=>"4",
           :MinimumHardDiskSizeGigabytes=>"40",
           :MinimumMemoryMegabytes=>"512",
           :Name=>"Microsoft Windows Server 2008 (32-bit)",
           :InternalName=>"winLonghornGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"true",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"73",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"}]},
       {:Name=>"Linux",
        :OperatingSystemFamilyId=>"2",
        :OperatingSystem=>
         [{:OperatingSystemId=>"48",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"64",
           :Name=>"Ubuntu Linux (64-bit)",
           :InternalName=>"ubuntu64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"94",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"47",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"64",
           :Name=>"Ubuntu Linux (32-bit)",
           :InternalName=>"ubuntuGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"93",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"50",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other 2.6.x Linux (64-bit)",
           :InternalName=>"other26xLinux64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"7",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"100",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"49",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other 2.6.x Linux (32-bit)",
           :InternalName=>"other26xLinuxGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"7",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"99",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"54",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other Linux (64-bit)",
           :InternalName=>"otherLinux64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"false",
           :cimOsId=>"101",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"53",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other Linux (32-bit)",
           :InternalName=>"otherLinuxGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"false",
           :cimOsId=>"36",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"}]},
       {:Name=>"Other",
        :OperatingSystemFamilyId=>"3",
        :OperatingSystem=>
         [{:OperatingSystemId=>"68",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other (64-bit)",
           :InternalName=>"otherGuest64",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"false",
           :PersonalizationAuto=>"false",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"102",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"67",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other (32-bit)",
           :InternalName=>"otherGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"false",
           :PersonalizationAuto=>"false",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"1",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"}]}]}

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_supported_versionsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
# File 'lib/fog/vcloud_director/requests/compute/get_supported_versions.rb', line 24

def get_supported_versions
  body =
    {:xmlns=>"http://www.vmware.com/vcloud/versions",
     :xmlns_xsi=>xmlns_xsi,
     :xsi_schemaLocation=>xsi_schema_location,
     :VersionInfo=>
      [{:Version=>"1.5",
        :LoginUrl=>make_href("sessions"),
        :MediaTypeMapping=>
         [{:MediaType=>
            "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
           :ComplexTypeName=>"InstantiateVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwProviderVdcReferences+xml",
           :ComplexTypeName=>"VMWProviderVdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.customizationSection+xml",
           :ComplexTypeName=>"CustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.prepareHostParams+xml",
           :ComplexTypeName=>"PrepareHostParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.relocateVmParams+xml",
           :ComplexTypeName=>"RelocateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.org+xml",
           :ComplexTypeName=>"OrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwExternalNetworkReferences+xml",
           :ComplexTypeName=>"VMWExternalNetworkReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.networkConnectionSection+xml",
           :ComplexTypeName=>"NetworkConnectionSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.host+xml",
           :ComplexTypeName=>"HostType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalogItem+xml",
           :ComplexTypeName=>"CatalogItemType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.owner+xml",
           :ComplexTypeName=>"OwnerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vdc+xml",
           :ComplexTypeName=>"VdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdc+xml",
           :ComplexTypeName=>"AdminVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.catalog+xml",
           :ComplexTypeName=>"AdminCatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.recomposeVAppParams+xml",
           :ComplexTypeName=>"RecomposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmIntoExistingVAppParams+xml",
           :ComplexTypeName=>"ImportVmIntoExistingVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.taskExtensionRequestUpdateProgressOperationParams+xml",
           :ComplexTypeName=>"TaskExtensionRequestUpdateProgressParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalog+xml",
           :ComplexTypeName=>"CatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml",
           :ComplexTypeName=>"CloneVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.providervdc+xml",
           :ComplexTypeName=>"ProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmsObjectRefsList+xml",
           :ComplexTypeName=>"VmObjectRefsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.undeployVAppParams+xml",
           :ComplexTypeName=>"UndeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdcReferences+xml",
           :ComplexTypeName=>"VdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.systemPasswordPolicySettings+xml",
           :ComplexTypeName=>"SystemPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vApp+xml",
           :ComplexTypeName=>"VAppType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskExtensionRequest+xml",
           :ComplexTypeName=>"TaskExtensionRequestType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vimServerNetworks+xml",
           :ComplexTypeName=>"VimObjectRefListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwprovidervdc+xml",
           :ComplexTypeName=>"VMWProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgSettings+xml",
           :ComplexTypeName=>"OrgSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.captureVAppParams+xml",
           :ComplexTypeName=>"CaptureVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.screenTicket+xml",
           :ComplexTypeName=>"ScreenTicketType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.runtimeInfoSection+xml",
           :ComplexTypeName=>"RuntimeInfoSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.tasksList+xml",
           :ComplexTypeName=>"TasksListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettingsTest+xml",
           :ComplexTypeName=>"AmqpSettingsTestType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.extensionSettings+xml",
           :ComplexTypeName=>"TaskExtensionSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationGeneralSettings+xml",
           :ComplexTypeName=>"OrgGeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.registerVimServerParams+xml",
           :ComplexTypeName=>"RegisterVimServerParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.network+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml",
           :ComplexTypeName=>"UploadVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.datastore+xml",
           :ComplexTypeName=>"DatastoreType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata+xml",
           :ComplexTypeName=>"MetadataType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReportList+xml",
           :ComplexTypeName=>"LicensingReportListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPool+xml",
           :ComplexTypeName=>"VMWNetworkPoolType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.systemSettings+xml",
           :ComplexTypeName=>"SystemSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwHostReferences+xml",
           :ComplexTypeName=>"VMWHostReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.taskExtensionRequestOperationParams+xml",
           :ComplexTypeName=>"TaskExtensionRequestOperationParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata.value+xml",
           :ComplexTypeName=>"MetadataValueType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskOperationList+xml",
           :ComplexTypeName=>"TaskOperationListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.media+xml",
           :ComplexTypeName=>"MediaType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.productSections+xml",
           :ComplexTypeName=>"ProductSectionListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettings+xml",
           :ComplexTypeName=>"AmqpSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppTemplate+xml",
           :ComplexTypeName=>"VAppTemplateType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.deployVAppParams+xml",
           :ComplexTypeName=>"DeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmIntoExistingVAppTemplateParams+xml",
           :ComplexTypeName=>"ImportVmIntoExistingVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourcePoolList+xml",
           :ComplexTypeName=>"ResourcePoolListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkConfigSection+xml",
           :ComplexTypeName=>"NetworkConfigSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.OrganizationVdcResourcePoolSet+xml",
           :ComplexTypeName=>"OrganizationResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationPasswordPolicySettings+xml",
           :ComplexTypeName=>"OrgPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.publishCatalogParams+xml",
           :ComplexTypeName=>"PublishCatalogParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwExtension+xml",
           :ComplexTypeName=>"VMWExtensionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml",
           :ComplexTypeName=>"MediaInsertOrEjectParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingQuestion+xml",
           :ComplexTypeName=>"VmPendingQuestionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.notificationsSettings+xml",
           :ComplexTypeName=>"NotificationsSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapUserSettings+xml",
           :ComplexTypeName=>"LdapUserAttributesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.right+xml",
           :ComplexTypeName=>"RightType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapSettings+xml",
           :ComplexTypeName=>"LdapSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.organization+xml",
           :ComplexTypeName=>"AdminOrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgList+xml",
           :ComplexTypeName=>"OrgListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml",
           :ComplexTypeName=>"OrgVAppTemplateLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwVimServerReferences+xml",
           :ComplexTypeName=>"VMWVimServerReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.entity+xml",
           :ComplexTypeName=>"EntityType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneMediaParams+xml",
           :ComplexTypeName=>"CloneMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReport+xml",
           :ComplexTypeName=>"LicensingReportType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importMediaParams+xml",
           :ComplexTypeName=>"ImportMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.resourcePoolSetUpdateParams+xml",
           :ComplexTypeName=>"UpdateResourcePoolSetParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskExtensionRequestList+xml",
           :ComplexTypeName=>"ReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingAnswer+xml",
           :ComplexTypeName=>"VmQuestionAnswerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
           :ComplexTypeName=>"RasdItemsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.generalSettings+xml",
           :ComplexTypeName=>"GeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPoolReferences+xml",
           :ComplexTypeName=>"VMWNetworkPoolReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.group+xml",
           :ComplexTypeName=>"GroupType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.controlAccess+xml",
           :ComplexTypeName=>"ControlAccessParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapGroupSettings+xml",
           :ComplexTypeName=>"LdapGroupAttributesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.user+xml",
           :ComplexTypeName=>"UserType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vcloud+xml",
           :ComplexTypeName=>"VCloudType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.uberAdminSettings+xml",
           :ComplexTypeName=>"UberAdminSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwvirtualcenter+xml",
           :ComplexTypeName=>"VimServerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.leaseSettingsSection+xml",
           :ComplexTypeName=>"LeaseSettingsSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.composeVAppParams+xml",
           :ComplexTypeName=>"ComposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationEmailSettings+xml",
           :ComplexTypeName=>"OrgEmailSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vm+xml",
           :ComplexTypeName=>"VmType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwProviderVdcResourcePoolSet+xml",
           :ComplexTypeName=>"VMWProviderVdcResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppParams+xml",
           :ComplexTypeName=>"CloneVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.guestCustomizationSection+xml",
           :ComplexTypeName=>"GuestCustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.task+xml",
           :ComplexTypeName=>"TaskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.session+xml",
           :ComplexTypeName=>"SessionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vAppLeaseSettings+xml",
           :ComplexTypeName=>"OrgLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importVmAsVAppParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.role+xml",
           :ComplexTypeName=>"RoleType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItem+xml",
           :ComplexTypeName=>"RASD_Type",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.startupSection+xml",
           :ComplexTypeName=>"StartupSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.virtualHardwareSection+xml",
           :ComplexTypeName=>"VirtualHardwareSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.operatingSystemSection+xml",
           :ComplexTypeName=>"OperatingSystemSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkSection+xml",
           :ComplexTypeName=>"NetworkSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppNetwork+xml",
           :ComplexTypeName=>"VAppNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.network+xml",
           :ComplexTypeName=>"NetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgNetwork+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"}]},
       {:Version=>"5.1",
        :LoginUrl=>make_href("sessions"),
        :MediaTypeMapping=>
         [{:MediaType=>
            "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
           :ComplexTypeName=>"InstantiateVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwprovidervdc+xml",
           :ComplexTypeName=>"MergeParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationFederationSettings+xml",
           :ComplexTypeName=>"OrgFederationSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.emailSettings+xml",
           :ComplexTypeName=>"EmailSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.prepareHostParams+xml",
           :ComplexTypeName=>"PrepareHostParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.org+xml",
           :ComplexTypeName=>"OrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.aclRule+xml",
           :ComplexTypeName=>"AclRuleType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.organizationLdapSettings+xml",
           :ComplexTypeName=>"OrgLdapSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.networkConnectionSection+xml",
           :ComplexTypeName=>"NetworkConnectionSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.owner+xml",
           :ComplexTypeName=>"OwnerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdc+xml",
           :ComplexTypeName=>"AdminVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmIntoExistingVAppParams+xml",
           :ComplexTypeName=>"ImportVmIntoExistingVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalog+xml",
           :ComplexTypeName=>"CatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml",
           :ComplexTypeName=>"CloneVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.createVdcParams+xml",
           :ComplexTypeName=>"CreateVdcParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmsObjectRefsList+xml",
           :ComplexTypeName=>"VmObjectRefsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.undeployVAppParams+xml",
           :ComplexTypeName=>"UndeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.createSnapshotParams+xml",
           :ComplexTypeName=>"CreateSnapshotParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.blockingTask+xml",
           :ComplexTypeName=>"BlockingTaskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwPvdcStorageProfile+xml",
           :ComplexTypeName=>"VMWProviderVdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.allocatedNetworkAddress+xml",
           :ComplexTypeName=>"AllocatedIpAddressesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vimServerNetworks+xml",
           :ComplexTypeName=>"VimObjectRefListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.blockingTaskOperationParams+xml",
           :ComplexTypeName=>"BlockingTaskOperationParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.updateProviderVdcStorageProfiles+xml",
           :ComplexTypeName=>"UpdateProviderVdcStorageProfilesParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.bundleUploadSocket+xml",
           :ComplexTypeName=>"BundleUploadSocketType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.gateway+xml",
           :ComplexTypeName=>"GatewayType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.screenTicket+xml",
           :ComplexTypeName=>"ScreenTicketType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourceClassAction+xml",
           :ComplexTypeName=>"ResourceClassActionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.event+xml",
           :ComplexTypeName=>"EventType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.tasksList+xml",
           :ComplexTypeName=>"TasksListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.migrateVmParams+xml",
           :ComplexTypeName=>"MigrateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.diskCreateParams+xml",
           :ComplexTypeName=>"DiskCreateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.registerVAppParams+xml",
           :ComplexTypeName=>"RegisterVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationGeneralSettings+xml",
           :ComplexTypeName=>"OrgGeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.registerVimServerParams+xml",
           :ComplexTypeName=>"RegisterVimServerParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.datastore+xml",
           :ComplexTypeName=>"DatastoreType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml",
           :ComplexTypeName=>"DiskAttachOrDetachParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.updateRightsParams+xml",
           :ComplexTypeName=>"UpdateRightsParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata+xml",
           :ComplexTypeName=>"MetadataType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdcStorageProfile+xml",
           :ComplexTypeName=>"AdminVdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.systemSettings+xml",
           :ComplexTypeName=>"SystemSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwHostReferences+xml",
           :ComplexTypeName=>"VMWHostReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.userEntityRights+xml",
           :ComplexTypeName=>"UserEntityRightsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata.value+xml",
           :ComplexTypeName=>"MetadataValueType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.media+xml",
           :ComplexTypeName=>"MediaType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.brandingSettings+xml",
           :ComplexTypeName=>"BrandingSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.updateVdcStorageProfiles+xml",
           :ComplexTypeName=>"UpdateVdcStorageProfilesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettings+xml",
           :ComplexTypeName=>"AmqpSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourceClass+xml",
           :ComplexTypeName=>"ResourceClassType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.deployVAppParams+xml",
           :ComplexTypeName=>"DeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourcePoolList+xml",
           :ComplexTypeName=>"ResourcePoolListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vdcStorageProfile+xml",
           :ComplexTypeName=>"VdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkConfigSection+xml",
           :ComplexTypeName=>"NetworkConfigSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.OrganizationVdcResourcePoolSet+xml",
           :ComplexTypeName=>"OrganizationResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.createProviderVdcParams+xml",
           :ComplexTypeName=>"VMWProviderVdcParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.publishCatalogParams+xml",
           :ComplexTypeName=>"PublishCatalogParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwExtension+xml",
           :ComplexTypeName=>"VMWExtensionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.notificationsSettings+xml",
           :ComplexTypeName=>"NotificationsSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.right+xml",
           :ComplexTypeName=>"RightType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",
           :ComplexTypeName=>"SupportedOperatingSystemsInfoType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vm.complianceResult+xml",
           :ComplexTypeName=>"ComplianceResultType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgList+xml",
           :ComplexTypeName=>"OrgListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwVimServerReferences+xml",
           :ComplexTypeName=>"VMWVimServerReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.entity+xml",
           :ComplexTypeName=>"EntityType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneMediaParams+xml",
           :ComplexTypeName=>"CloneMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReport+xml",
           :ComplexTypeName=>"LicensingReportType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.apiDefinition+xml",
           :ComplexTypeName=>"ApiDefinitionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vshieldmanager+xml",
           :ComplexTypeName=>"ShieldManagerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.blockingTaskList+xml",
           :ComplexTypeName=>"ReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingAnswer+xml",
           :ComplexTypeName=>"VmQuestionAnswerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
           :ComplexTypeName=>"RasdItemsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.generalSettings+xml",
           :ComplexTypeName=>"GeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.group+xml",
           :ComplexTypeName=>"GroupType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.controlAccess+xml",
           :ComplexTypeName=>"ControlAccessParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.user+xml",
           :ComplexTypeName=>"UserType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwvirtualcenter+xml",
           :ComplexTypeName=>"VimServerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.strandedItem+xml",
           :ComplexTypeName=>"StrandedItemType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.leaseSettingsSection+xml",
           :ComplexTypeName=>"LeaseSettingsSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationEmailSettings+xml",
           :ComplexTypeName=>"OrgEmailSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppParams+xml",
           :ComplexTypeName=>"CloneVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.task+xml",
           :ComplexTypeName=>"TaskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vAppLeaseSettings+xml",
           :ComplexTypeName=>"OrgLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.role+xml",
           :ComplexTypeName=>"RoleType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwProviderVdcReferences+xml",
           :ComplexTypeName=>"VMWProviderVdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.customizationSection+xml",
           :ComplexTypeName=>"CustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.service+xml",
           :ComplexTypeName=>"ServiceType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.relocateVmParams+xml",
           :ComplexTypeName=>"RelocateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.rights+xml",
           :ComplexTypeName=>"RightRefsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwExternalNetworkReferences+xml",
           :ComplexTypeName=>"VMWExternalNetworkReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.disk+xml",
           :ComplexTypeName=>"DiskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.kerberosSettings+xml",
           :ComplexTypeName=>"KerberosSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.operationLimitsSettings+xml",
           :ComplexTypeName=>"OrgOperationLimitsSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.host+xml",
           :ComplexTypeName=>"HostType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalogItem+xml",
           :ComplexTypeName=>"CatalogItemType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.entityReferences+xml",
           :ComplexTypeName=>"EntityReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vdc+xml",
           :ComplexTypeName=>"VdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.catalog+xml",
           :ComplexTypeName=>"AdminCatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.recomposeVAppParams+xml",
           :ComplexTypeName=>"RecomposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgVdcNetwork+xml",
           :ComplexTypeName=>"OrgVdcNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.providervdc+xml",
           :ComplexTypeName=>"ProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.blockingTaskUpdateProgressOperationParams+xml",
           :ComplexTypeName=>"BlockingTaskUpdateProgressParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdcReferences+xml",
           :ComplexTypeName=>"VdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.systemPasswordPolicySettings+xml",
           :ComplexTypeName=>"SystemPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vApp+xml",
           :ComplexTypeName=>"VAppType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwprovidervdc+xml",
           :ComplexTypeName=>"VMWProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vms+xml",
           :ComplexTypeName=>"VmsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgSettings+xml",
           :ComplexTypeName=>"OrgSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.apiFilter+xml",
           :ComplexTypeName=>"ApiFilterType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.captureVAppParams+xml",
           :ComplexTypeName=>"CaptureVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmCapabilitiesSection+xml",
           :ComplexTypeName=>"VmCapabilitiesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.runtimeInfoSection+xml",
           :ComplexTypeName=>"RuntimeInfoSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettingsTest+xml",
           :ComplexTypeName=>"AmqpSettingsTestType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.guestPersonalizationSettings+xml",
           :ComplexTypeName=>"OrgGuestPersonalizationSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgNetwork+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.fileDescriptor+xml",
           :ComplexTypeName=>"FileDescriptorType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml",
           :ComplexTypeName=>"UploadVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReportList+xml",
           :ComplexTypeName=>"LicensingReportListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPool+xml",
           :ComplexTypeName=>"VMWNetworkPoolType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskOperationList+xml",
           :ComplexTypeName=>"TaskOperationListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vSphereWebClientUrl+xml",
           :ComplexTypeName=>"VSphereWebClientUrlType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.productSections+xml",
           :ComplexTypeName=>"ProductSectionListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.blockingTaskSettings+xml",
           :ComplexTypeName=>"BlockingTaskSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppTemplate+xml",
           :ComplexTypeName=>"VAppTemplateType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationPasswordPolicySettings+xml",
           :ComplexTypeName=>"OrgPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml",
           :ComplexTypeName=>"MediaInsertOrEjectParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingQuestion+xml",
           :ComplexTypeName=>"VmPendingQuestionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.organization+xml",
           :ComplexTypeName=>"AdminOrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapSettings+xml",
           :ComplexTypeName=>"LdapSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.snapshotSection+xml",
           :ComplexTypeName=>"SnapshotSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml",
           :ComplexTypeName=>"OrgVAppTemplateLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importMediaParams+xml",
           :ComplexTypeName=>"ImportMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.resourcePoolSetUpdateParams+xml",
           :ComplexTypeName=>"UpdateResourcePoolSetParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licenseSettings+xml",
           :ComplexTypeName=>"LicenseType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.bundleUploadParams+xml",
           :ComplexTypeName=>"BundleUploadParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPoolReferences+xml",
           :ComplexTypeName=>"VMWNetworkPoolReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vcloud+xml",
           :ComplexTypeName=>"VCloudType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.serviceResource+xml",
           :ComplexTypeName=>"ServiceResourceType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.composeVAppParams+xml",
           :ComplexTypeName=>"ComposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwProviderVdcResourcePool+xml",
           :ComplexTypeName=>"VMWProviderVdcResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vm+xml",
           :ComplexTypeName=>"VmType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.guestCustomizationSection+xml",
           :ComplexTypeName=>"GuestCustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.session+xml",
           :ComplexTypeName=>"SessionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.pvdcStorageProfile+xml",
           :ComplexTypeName=>"ProviderVdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwStorageProfiles+xml",
           :ComplexTypeName=>"VMWStorageProfilesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importVmAsVAppParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.serviceLink+xml",
           :ComplexTypeName=>"ServiceLinkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.enableDownloadParams+xml",
           :ComplexTypeName=>"EnableDownloadParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItem+xml",
           :ComplexTypeName=>"RASD_Type",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.startupSection+xml",
           :ComplexTypeName=>"StartupSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.virtualHardwareSection+xml",
           :ComplexTypeName=>"VirtualHardwareSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.operatingSystemSection+xml",
           :ComplexTypeName=>"OperatingSystemSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkSection+xml",
           :ComplexTypeName=>"NetworkSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppNetwork+xml",
           :ComplexTypeName=>"VAppNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.network+xml",
           :ComplexTypeName=>"NetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgNetwork+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"}]}]}

  Excon::Response.new(
    :body => body,
    :headers => {'Content-Type' => 'text/xml'},
    :status => 200
  )
end

#get_task(id) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/fog/vcloud_director/requests/compute/get_task.rb', line 98

def get_task(id)
  unless data[:tasks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(task_body(id))

  Excon::Response.new(
    :status => 200,
    :headers => {'Type' => "application/#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_task_list(id) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/fog/vcloud_director/requests/compute/get_task_list.rb', line 104

def get_task_list(id)
  unless id == data[:org][:uuid]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"com.vmware.vcloud.entity.org:#{id}\"."
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :href => make_href("tasksList/#{id}"),
    :type => "application/vnd.vmware.vcloud.tasksList+xml",
    :name => "Tasks Lists",
    :Task => data[:tasks].keys.map {|task_id| task_body(task_id)}
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_vapp(id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 28

def get_vapp(id)

  # Retrieve a vApp or VM.
  #

  case id
  when /^vapp-/
    body = get_mock_vapp_body(id)
  when /^vm-/
    body = get_mock_vm_body(id)
  else
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end

#get_vapp_children_vms_body(id) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 115

def get_vapp_children_vms_body(id)
  child_vms = data[:vms].select do |vm_id, vm_details|
    vm_details[:parent_vapp] == id
  end
  child_vms.keys.collect do |vm_id|
    get_mock_vm_body(vm_id)
  end
end

#get_vapp_lease_settings_section_body(id) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb', line 44

def get_vapp_lease_settings_section_body(id)
  {
    :type => "application/vnd.vmware.vcloud.leaseSettingsSection+xml",
    :href => make_href("vApp/#{id}/leaseSettingsSection/"),
    :ovf_required=>"false",
    :"ovf:Info"=>"Lease settings section",
    :DeploymentLeaseInSeconds=>"0",
    :StorageLeaseInSeconds=>"0",
  }
end

#get_vapp_metadata(id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb', line 28

def (id)
  unless vm_or_vapp = data[:vapps][id] || vm_or_vapp = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :xmlns=>xmlns,
    :xmlns_xsi=>xmlns_xsi,
    :type=>"application/vnd.vmware.vcloud.metadata+xml",
    :href=>make_href("vApp/#{id}/metadata"),
    :xsi_schemaLocation=>xsi_schema_location,
    :Link=>
     [{:rel=>"up",
       :type=>"application/vnd.vmware.vcloud.vApp+xml",
       :href=>make_href("/vApp/#{id}")},
      {:rel=>"add",
       :type=>"application/vnd.vmware.vcloud.metadata+xml",
       :href=>make_href("vApp/#{id}/metadata")}],
    :MetadataEntry=>(vm_or_vapp[:metadata], id)
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_vapp_network_config_section_body(id, vapp) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb', line 44

def get_vapp_network_config_section_body(id, vapp)
  # TODO: This is effectively hardcoding a vAppNetwork configuration
  #       into here, but this is sufficient for initial testing.
  #       This network configuration has no networks.

  {
    :type => "application/vnd.vmware.vcloud.networkConfigSection+xml",
    :href => make_href("vApp/#{id}/networkConfigSection/"),
    :ovf_required => "false",
    :"ovf:Info" => "The configuration parameters for logical networks",
    :NetworkConfig => [],
  }
end

#get_vapp_ovf_network_section_body(id, vapp) ⇒ Object



111
112
113
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 111

def get_vapp_ovf_network_section_body(id, vapp)
  {}
end

#get_vapp_ovf_startup_section_body(id, vapp) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/vcloud_director/requests/compute/get_startup_section.rb', line 44

def get_vapp_ovf_startup_section_body(id, vapp)
  {
    :xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
    :ns12_href => make_href("vApp/#{id}"),
    :ns12_type => "application/vnd.vmware.vcloud.startupSection+xml",
    :"ovf:Info" => "VApp startup section",
    :"ovf:Item" => {
      :ovf_stopDelay => "0",
      :ovf_stopAction => "powerOff",
      :ovf_startDelay => "0",
      :ovf_startAction => "powerOn",
      :ovf_order => "0",
      :ovf_id => vapp[:name],
    },
  }
end

#get_vapp_owner(id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb', line 25

def get_vapp_owner(id)

  type = 'application/vnd.vmware.vcloud.owner+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_owner_section_body(id)
  )

end

#get_vapps_in_this_vdc(vdc_id) ⇒ Object



165
166
167
168
169
# File 'lib/fog/vcloud_director/requests/compute/get_vdc.rb', line 165

def get_vapps_in_this_vdc(vdc_id)
  data[:vapps].select do |vapp_id, vapp|
    vapp[:vdc_id] == vdc_id
  end
end

#get_vcloudObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fog/vcloud_director/requests/compute/get_vcloud.rb', line 50

def get_vcloud
  body =
    {:href=>make_href('admin/'),
     :type=>"application/vnd.vmware.admin.vcloud+xml",
     :name=>'VMware vCloud Director',
     :Description=>'5.1.2.1377223 Tue Oct 15 20:56:05 GMT 2013',
     :Tasks=>{:Task=>[]},
     :OrganizationReferences=>
      {:OrganizationReference=>
       [{:type=>"application/vnd.vmware.admin.organization+xml",
         :name=>data[:org][:name],
         :href=>make_href("api/admin/org/#{data[:org][:uuid]}")}]},
     :ProviderVdcReferences=>{:ProviderVdcReference=>[]},
     :RightReferences=>{:RightReference=>[]},
     :RoleReferences=>{:RoleReference=>[]},
     :Networks=>{:Network=>[]}}

  Excon::Response.new(
    :body    => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status  => 200
  )
end

#get_vdc(vdc_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/fog/vcloud_director/requests/compute/get_vdc.rb', line 31

def get_vdc(vdc_id)
  response = Excon::Response.new

  unless vdc = data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"com.vmware.vcloud.entity.vdc:#{vdc_id}\"."
    )
  end

  body =
    {:xmlns=>xmlns,
     :xmlns_xsi=>xmlns_xsi,
     :status=>"1",
     :name=>vdc[:name],
     :id=>"urn:vcloud:vdc:#{vdc_id}",
     :type=>"application/vnd.vmware.vcloud.vdc+xml",
     :href=>make_href("vdc/#{vdc_id}"),
     :xsi_schemaLocation=>xsi_schema_location,
     :Link=>
      [{:rel=>"up",
        :type=>"application/vnd.vmware.vcloud.org+xml",
        :href=>make_href("org/#{data[:org][:uuid]}")},
       {:rel=>"down",
        :type=>"application/vnd.vmware.vcloud.metadata+xml",
        :href=>make_href("vdc/#{vdc_id}/metadata")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml",
        :href=>
         make_href("vdc/#{vdc_id}/action/uploadVAppTemplate")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.media+xml",
        :href=>make_href("vdc/#{vdc_id}/media")},
       {:rel=>"add",
        :type=>
         "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
        :href=>
         make_href("vdc/#{vdc_id}/action/instantiateVAppTemplate")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.cloneVAppParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/cloneVApp")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml",
        :href=>
         make_href("vdc/#{vdc_id}/action/cloneVAppTemplate")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.cloneMediaParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/cloneMedia")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.captureVAppParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/captureVApp")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.composeVAppParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/composeVApp")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.diskCreateParams+xml",
        :href=>make_href("vdc/#{vdc_id}/disk")},
       {:rel=>"edgeGateways",
        :type=>"application/vnd.vmware.vcloud.query.records+xml",
        :href=>make_href("admin/vdc/#{vdc_id}/edgeGateways")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.orgVdcNetwork+xml",
        :href=>make_href("admin/vdc/#{vdc_id}/networks")},
       {:rel=>"orgVdcNetworks",
        :type=>"application/vnd.vmware.vcloud.query.records+xml",
        :href=>make_href("admin/vdc/#{vdc_id}/networks")}],
     :Description=>vdc[:description]||'',
     :AllocationModel=>"AllocationVApp",
     :ComputeCapacity=>
      {:Cpu=>
       {:Units=>"MHz",
        :Allocated=>"0",
        :Limit=>"0",
        :Reserved=>"0",
        :Used=>"0",
        :Overhead=>"0"},
      :Memory=>
       {:Units=>"MB",
        :Allocated=>"0",
        :Limit=>"0",
        :Reserved=>"0",
        :Used=>"0",
        :Overhead=>"0"}},
     :ResourceEntities => {
       :ResourceEntity => []
     },
     :AvailableNetworks => {},
     :Capabilities=>
      {:SupportedHardwareVersions=>
       {:SupportedHardwareVersion=>"vmx-08"}},
     :NicQuota=>"0",
     :NetworkQuota=>"20",
     :UsedNetworkCount=>"0",
     :VmQuota=>"100",
     :IsEnabled=>"true"}

  body[:ResourceEntities][:ResourceEntity] =
    data[:catalog_items].map do |id, item|
      {:type=>"application/vnd.vmware.vcloud.#{item[:type]}+xml",
       :name=>item[:name],
       :href=>make_href("#{item[:type]}/#{item[:type]}-#{id}")}
    end

  body[:ResourceEntities][:ResourceEntity] +=
    get_vapps_in_this_vdc(vdc_id).map do |vapp_id, vapp|
      {:type => "application/vnd.vmware.vcloud.vApp+xml",
       :name => vapp[:name],
       :href => make_href("vApp/#{vapp_id}")}
    end      

  body[:AvailableNetworks][:Network] =
    data[:networks].map do |id, network|
      {:type=>"application/vnd.vmware.vcloud.network+xml",
       :name=>network[:name],
       :href=>make_href("network/#{id}")}
  end

  if api_version.to_f >= 5.1
    body[:VdcStorageProfiles] = {}
    body[:VdcStorageProfiles][:VdcStorageProfile] =
      data[:vdc_storage_classes].select do |id, storage_class|
        storage_class[:vdc] == vdc_id
      end.map do |id, storage_class|
        {:type => 'application/vnd.vmware.vcloud.vdcStorageProfile+xml',
         :name => storage_class[:name],
         :href => make_href("vdcStorageProfile/#{id}")}
      end
  end

  response.status = 200
  response.headers = {'Content-Type' => "#{body[:type]};version=#{api_version}"}
  response.body = body
  response
end

#get_vdc_storage_class(id) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fog/vcloud_director/requests/compute/get_vdc_storage_class.rb', line 47

def get_vdc_storage_class(id)
  unless vdc_storage_class = data[:vdc_storage_classes][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdcstorageProfile:#{id})\"."
    )
  end

  body =
    {:xmlns=>xmlns,
     :xmlns_xsi=>xmlns_xsi,
     :name=>vdc_storage_class[:name],
     :id=>"urn:vcloud:vdcstorageProfile:#{id}",
     :type=>"application/vnd.vmware.vcloud.vdcStorageProfile+xml",
     :href=>make_href("api/vdcStorageProfile/#{id}"),
     :xsi_schemaLocation=>xsi_schema_location,
     :Link=>
      [{:rel=>"up",
        :type=>"application/vnd.vmware.vcloud.vdc+xml",
        :href=>make_href("vdc/#{vdc_storage_class[:vdc]}")},
       {:rel=>"down",
        :type=>"application/vnd.vmware.vcloud.metadata+xml",
        :href=>make_href("vdcStorageProfile/#{id}/metadata")}],
     :Enabled=>vdc_storage_class[:enabled].to_s,
     :Units=>vdc_storage_class[:units],
     :Limit=>vdc_storage_class[:limit].to_s,
     :Default=>vdc_storage_class[:default].to_s}

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_vm(id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/vcloud_director/requests/compute/get_vm.rb', line 27

def get_vm(id)
  vapp = get_vapp(id).body
  vm = parse_vapp_to_vm(vapp)
  body = {:type => vapp[:type], :vm => vm}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_vm_capabilities(id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb', line 31

def get_vm_capabilities(id)

  type = 'application/vnd.vmware.vcloud.vmCapabilitiesSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_capabilities_section_body(id, vm)
  )

end

#get_vm_capabilities_section_body(id, vm) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb', line 49

def get_vm_capabilities_section_body(id, vm)
  {
    :type => "application/vnd.vmware.vcloud.vmCapabilitiesSection+xml",
    :href => make_href("vApp/#{id}/vmCapabilities/"),
    :MemoryHotAddEnabled => "false",
    :CpuHotAddEnabled => "false",
  }
end

#get_vm_disks(id) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/vcloud_director/requests/compute/get_vm_disks.rb', line 30

def get_vm_disks(id)
  disks = data[:disks].values.select {|d| d[:parent_vm] == id}.each_with_index.map do |disk, i|
    {
      :address => i,
      :description => disk[:description],
      :name => disk[:name],
      :id => (i+1)*1000,
      :resource_type => 17,
      :capacity => disk[:capacity],
    }
  end
  body = {:type => 'application/vnd.vmware.vcloud.rasditemslist+xml', :disks => disks}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_vm_guest_customization_section_body(id, vm) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb', line 42

def get_vm_guest_customization_section_body(id, vm)
  {
    :type => "application/vnd.vmware.vcloud.guestCustomizationSection+xml",
    :href => make_href("vApp/#{id}/guestCustomizationSection/"),
    :ovf_required => "false",
    :"ovf:Info" => "Specifies Guest OS Customization Settings",
    :Enabled => "true",
    :ChangeSid => "false",
    :VirtualMachineId => id.split('-').last, # strip the 'vm-' prefix
    :JoinDomainEnabled => "false",
    :UseOrgSettings => "false",
    :AdminPasswordEnabled => "false",
    :AdminPasswordAuto => "true",
    :ResetPasswordRequired => "false",
    :CustomizationScript => vm[:customization_script] || "",
    :ComputerName => vm[:computer_name] || vm[:name],
    :Link => {
      :rel=>"edit",
      :type=>"application/vnd.vmware.vcloud.guestCustomizationSection+xml",
      :href=>make_href("vApp/#{id}"),
    },
  }
end

#get_vm_network(id) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/vcloud_director/requests/compute/get_vm_network.rb', line 30

def get_vm_network(id)
  vapp    = get_vapp(id).body
  network = vapp[:NetworkConnectionSection]
  connection = network[:NetworkConnection]
  body = {
    :type => network[:type],
    :id   => network[:href].split('/')[-2],
    :href => network[:href],
    :info => network[:"ovf:Info"],
    :primary_network_connection_index => network[:PrimaryNetworkConnectionIndex],
    :network => connection[:network],
    :needs_customization => connection[:needsCustomization],
    :network_connection_index => connection[:NetworkConnectionIndex],
    :is_connected => connection[:IsConnected],
    :mac_address => connection[:MACAddress],
    :ip_address_allocation_mode => connection[:IpAddressAllocationMode]
  }
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_vm_network_connection_section_body(id, vm) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb', line 43

def get_vm_network_connection_section_body(id, vm)
  # TODO: Needs work - does not handle multiple NIC case yet, or
  #       DHCP/POOL allocations
  {
    :type => "application/vnd.vmware.vcloud.networkConnectionSection+xml",
    :href => make_href("vApp/#{id}/networkConnectionSection/"),
    :ovf_required => "false",
    :"ovf:Info" => "Specifies the available VM network connections",
    :PrimaryNetworkConnectionIndex => "0",
    :NetworkConnection => {
      :network => vm[:nics][0][:network_name],
      :needsCustomization => "false",
      :NetworkConnectionIndex => "0",
      :IpAddress => vm[:nics][0][:ip_address],
      :IsConnected => "true",
      :MACAddress => vm[:nics][0][:mac_address],
      :IpAddressAllocationMode => "MANUAL"
    }
  }
end

#get_vm_operating_system_section_body(id, vm) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb', line 44

def get_vm_operating_system_section_body(id, vm)
  {
    :xmlns_ns12=>"http://www.vmware.com/vcloud/v1.5",
    :ovf_id => "94", # TODO: What is this?
    :ns12_href => make_href("vApp/#{id}/operatingSystemSection/"),
    :ns12_type => "application/vnd.vmware.vcloud.operatingSystemSection+xml",
    :vmw_osType => vm[:guest_os_type], # eg "ubuntu64Guest"
    :"ovf:Info"=>"Specifies the operating system installed",
    :"ovf:Description"=> vm[:guest_os_description], # eg "Ubuntu Linux (64-bit)",
  }
end

#get_vm_ovf_item_list(id, vm) ⇒ Object



156
157
158
159
160
161
162
163
164
165
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 156

def get_vm_ovf_item_list(id, vm)
  [
    get_network_cards_rasd_items_list_body(id, vm),
    get_disks_rasd_items_list_body(id, vm),
    get_media_rasd_item_cdrom_body(id, vm),
    get_media_rasd_item_floppy_body(id, vm),
    get_cpu_rasd_item_body(id, vm),
    get_memory_rasd_item_body(id, vm),
  ].compact.flatten
end

#get_vm_ovfenv_environment_section_body(id, vm) ⇒ Object



124
125
126
127
128
129
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 124

def get_vm_ovfenv_environment_section_body(id, vm)
  # TODO: I'm pretty sure this is just repeating info in other
  # sections, and the OVF part of VMs is extremely verbose. It's
  # likely to not be needed in Mock mode
  {}
end

#get_vm_runtime_info_section_body(id, vm) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb', line 42

def get_vm_runtime_info_section_body(id, vm)
  {
    :xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
    :ns12_href => make_href("vApp/#{id}/runtimeInfoSection"),
    :ns12_type => "application/vnd.vmware.vcloud.virtualHardwareSection+xml",
    :"ovf:Info" => "Specifies Runtime info",
    :VMWareTools => {
      :version => "9282",
    }
  }
end

#get_vm_storage_profile_section_body(id, vm) ⇒ Object



131
132
133
134
135
136
137
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 131

def get_vm_storage_profile_section_body(id, vm)
  {
    :type => "application/vnd.vmware.vcloud.vdcStorageProfile+xml",
    :name => "Mock Storage Profile",
    :href => make_href("vdcStorageProfile/12345678-1234-1234-1234-1234500e49a8"),
  }
end

#get_vm_virtual_hardware_section_body(id, vm) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 139

def get_vm_virtual_hardware_section_body(id, vm)

  {:xmlns_ns12=>"http://www.vmware.com/vcloud/v1.5",
   :ovf_transport=>"",
   :ns12_href => make_href("vApp/#{id}/virtualHardwareSection/"),
   :ns12_type=>"application/vnd.vmware.vcloud.virtualHardwareSection+xml",
   :"ovf:Info"=>"Virtual hardware requirements",
   :"ovf:System"=>{
     :"vssd:ElementName"=>"Virtual Hardware Family",
     :"vssd:InstanceID"=>"0",
     :"vssd:VirtualSystemIdentifier" => vm[:name],
     :"vssd:VirtualSystemType"=>"vmx-08"
   },
   :"ovf:Item" => get_vm_ovf_item_list(id, vm),
  }
end

#get_vms(id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/vcloud_director/requests/compute/get_vms.rb', line 27

def get_vms(id)
  vapp = get_vapp(id).body
  parser = Fog::Parsers::Compute::VcloudDirector::Vms.new
  vms  = vapp[:Children][:Vm].map {|child| parse_vapp_to_vm(child) }
  body = {:type => vapp[:type], :vms => vms}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#get_vms_disk_attached_to(id) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/fog/vcloud_director/requests/compute/get_vms_disk_attached_to.rb', line 27

def get_vms_disk_attached_to(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.disk:%s".' % id
    )
  end

  Fog::Mock.not_implemented
end

#get_vms_in_lease_from_query(options = {}) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/fog/vcloud_director/requests/compute/get_vms_in_lease_from_query.rb', line 96

def get_vms_in_lease_from_query(options={})

  if options.key?(:filter) && options[:filter] =~ /^href==([^;,]+)$/
    href = $1
    id = href.split('/').last
  else
    Fog::Mock.not_implemented("Filter by href is currently the only option implemented in get_vms_in_lease_from_query Mock")
  end

  vm = data[:vms][id]
  parent_vapp_id = vm[:parent_vapp]
  vdc_id = data[:vapps][parent_vapp_id][:vdc_id]

  body = {
    :xmlns=>xmlns,
    :xmlns_xsi=>xmlns_xsi,
    :href=>make_href('query'),
    :name=>"vm",
    :type=>"application/vnd.vmware.vcloud.query.records+xml",
    :xsi_schemaLocation=>xsi_schema_location,
    :total=>"1",
    :pageSize=>"25",
    :page=>"1",
    :Link=>
      [{:rel=>"alternate",
        :type=>"application/vnd.vmware.vcloud.query.references+xml",
        :href=>make_href('query')},
       {:rel=>"alternate",
        :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
        :href=>make_href('query')}],
    :VMRecord=>
      [{:vdc=>make_href(vdc_id),
        :numberOfCpus=>vm[:cpu_count],
        :name=>vm[:name],
        :containerName=>data[:vapps][parent_vapp_id][:name],
        :memoryMB=>vm[:memory_in_mb],
        :isVAppTemplate=>"false",
        :href=>make_href(id),
        :taskStatus=>"success",
        :task=>make_href("task/#{uuid}"),
        :taskDetails=>" ",
        :taskStatusName=>"vappUpdateVm"}]
  }

  Excon::Response.new(
    :status  => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body    => body
  )
end

#instantiate_vapp_template(vapp_name, template_id, options = {}) ⇒ Object

Assume the template is a single VM with one network interface and one disk.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb', line 104

def instantiate_vapp_template(vapp_name, template_id, options={})
  unless data[:catalog_items].values.find {|i| i[:template_id] == template_id}
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No such template.'
    )
  end
  unless vdc = data[:vdcs][options[:vdc_id]]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No such VDC.'
    )
  end

  vapp_uuid = uuid
  vapp_id   = "vapp-#{vapp_uuid}"
  owner = {
    :href => make_href("vApp/#{vapp_id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Creating Virtual Application #{vapp_name}(#{vapp_uuid})", 'vdcInstantiateVapp', owner,
    :on_success => lambda do
      # Add to the VDC
      data[:vapps][vapp_id] = {
        :name => vapp_name,
        :vdc_id => options[:vdc_id],
        :description => 'From Template',
        :networks => [
          {:parent_id => default_network_uuid }
        ]
      }
      vm_id = "vm-#{uuid}"
      data[:vms][vm_id] = {
        :name => vapp_name,
        :parent_vapp => vapp_id,
        :nics => [
          {
            :network_name => 'Default Network',
            :mac_address  => '7d:68:a2:a0:a4:f8',
            :ip_address   => nil
          }
        ]
      }
      data[:disks][uuid] = {
        :name => 'Hard Disk 1',
        :capacity => 10240,
        :parent_vm => vm_id
      }
    end
  )
  body = {
    :href => make_href("vApp/#{vapp_id}"),
    :Tasks => {
      :Task => {
        :xmlns => xmlns,
        :xmlns_xsi => xmlns_xsi,
        :xsi_schemaLocation => xsi_schema_location,
      }.merge(task_body(task_id))
    }
  }

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#org_nameObject



810
811
812
813
814
815
816
817
818
819
820
821
# File 'lib/fog/vcloud_director/compute.rb', line 810

def org_name
  @org_name ||=
    begin
      username = @vcloud_director_username.split('@')
      if username.size >= 2 # may be 'email_address@org_name'
        username.last
      else
        Fog::Logger.warning('vcloud_director_username should be in the form user@org_name')
        'vcd_org_name'
      end
    end
end

#parse_vapp_to_vm(vapp) ⇒ Object

Mock equivalent of Fog::Parsers::Compute::VcloudDirector::Vm



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/vcloud_director/requests/compute/get_vm.rb', line 39

def parse_vapp_to_vm(vapp)
  parser = Fog::Parsers::Compute::VcloudDirector::Vm.new
  vm = vapp.select {|k| [:href, :name, :status, :type].include? k}
  network = vapp[:NetworkConnectionSection]
  vm.merge({
    :id => vapp[:href].split('/').last,
    :status => parser.human_status(vapp[:status]),
    :ip_address => network[:NetworkConnection][:IpAddress],
    :description => vapp[:Description],
    :cpu => get_hardware(vapp, 3),
    :memory => get_hardware(vapp, 4),
    :disks => get_disks(vapp),
    :links => [vapp[:GuestCustomizationSection][:Link]],
  })
end

#post_cancel_task(id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/vcloud_director/requests/compute/post_cancel_task.rb', line 25

def post_cancel_task(id)
  unless task = data[:tasks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.task:%s"' % id
    )
  end

  # @note Tasks don't actually get cancelled (confirmed VCloud Director
  #   bug) so we'll emulate that. Set the flag and we're done!
  task[:cancel_requested] = true

  Excon::Response.new(
    :status => 204
  )
end

#post_clone_media(vdc_id, source_id, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fog/vcloud_director/requests/compute/post_clone_media.rb', line 53

def post_clone_media(vdc_id, source_id, options={})
  # TODO: check this happens.
  unless source_media = data[:medias][source_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.media:#{source_id})\"."
    )
  end
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  media_id = uuid
  media_name = "#{source_media[:name]}-copy-#{uuid}"

  owner = {
    :href => make_href("media/#{media_id}"),
    :type => 'application/vnd.vmware.vcloud.media+xml'
  }
  task_id = enqueue_task(
    "Copy Media File #{media_name}(#{media_id})", 'vdcCopyMedia', owner,
    :on_success => lambda do
      data[:medias][media_id][:status] = 1
    end
  )

  media = source_media.dup.merge(
    :name => media_name,
    :status => 0,
    :tasks => [task_id]
  )
  data[:medias][media_id] = media

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(media_body(media_id))

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#post_configure_edge_gateway_services(id, configuration) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb', line 37

def post_configure_edge_gateway_services(id, configuration)
  unless data[:edge_gateways][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
              "No access to entity \"(com.vmware.vcloud.entity.edgegateway:#{id})\"."
          )
  end

  owner = {
    :href => make_href("admin/edgeGateway/#{id}"),
    :type => 'application/vnd.vmware.vcloud.gateway+xml'
  }
  task_id = enqueue_task(
      "Configuring edgegateway(#{id})", 'networkConfigureEdgeGatewayServices', owner,
      :on_success => lambda do
        data[:edge_gateways][id][:Configuration][:EdgeGatewayServiceConfiguration] = configuration
      end
  )

  task = task_body(task_id)
  task.delete(:Owner)  # known bug - admin tasks do not return Owner

  body = {
      :xmlns => xmlns,
      :xmlns_xsi => xmlns_xsi,
      :xsi_schemaLocation => xsi_schema_location,
  }.merge(task)

  Excon::Response.new(
      :status => 202,
      :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
      :body => body
  )
end

#post_create_org_vdc_network(vdc_id, name, options = {}) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb', line 68

def post_create_org_vdc_network(vdc_id, name, options={})
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  type = 'network'
  id = uuid

  # Description
  # Configuration
  #   IpScopes
  #     IpScope
  #       IsInherited
  #       Gateway
  #       Netmask
  #       Dns1
  #       Dns2
  #       DnsSuffix
  #       IsEnabled
  #       IpRanges
  #         IpRange
  #           StartAddress
  #           EndAddress
  #   FenceMode
  # EdgeGateway
  # IsShared

  network_body = {
    :name           => name,
    :vdc            => vdc_id,
  }

  [:Description, :IsShared].each do |key|
    network_body[key] = options[key] if options.key?(key)
  end

  if options.key?(:EdgeGateway)
    network_body[:EdgeGateway] =
      options[:EdgeGateway][:href].split('/').last
  end

  if configuration = options[:Configuration]
    if ip_scopes = configuration[:IpScopes]
      if ip_scope = ip_scopes[:IpScope]
        [:IsInherited, :Gateway, :Netmask,
          :Dns1, :Dns2, :DnsSuffix, :IsEnabled].each do |key|
            network_body[key] = ip_scope[key] if ip_scope.key?(key)
        end
        if ip_ranges = ip_scope[:IpRanges]
          network_body[:IpRanges] = []
          ip_ranges.each do |ipr|
            network_body[:IpRanges] << {
              :StartAddress => ipr[:IpRange][:StartAddress],
              :EndAddress   => ipr[:IpRange][:EndAddress]
            }
          end
        end
      end
    end
    network_body[:FenceMode] = configuration[:FenceMode] if ip_scope.key?(:FenceMode)
  end

  owner = {
    :href => make_href("#{type}/#{id}"),
    :type => "application/vnd.vmware.vcloud.#{type}+xml"
  }
  task_id = enqueue_task(
    "Adding #{type} #{name} (#{id})", 'CreateOrgVdcNetwork', owner,
    :on_success => lambda do
      data[:networks][id] = network_body
    end
  )

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :href => make_href("admin/network/#{id}"),
    :name => name,
    :id => "urn:vcloud:network:#{id}",
    :type => "application/vnd.vmware.vcloud.orgVdcNetwork+xml",
    :Link => [
      {:rel=>"up", :type=>"application/vnd.vmware.vcloud.vdc+xml", :href=>make_href("vdc/#{vdc_id}")},
      {:rel=>"down", :type=>"application/vnd.vmware.vcloud.metadata+xml", :href=>make_href("admin/network/#{id}/metadata")},
      {:rel=>"down", :type=>"application/vnd.vmware.vcloud.allocatedNetworkAddress+xml", :href=>make_href("admin/network/#{id}/allocatedAddresses/")},
    ],
  }.merge(options)

  body[:Tasks] = {
    :Task => task_body(task_id)
  }

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#post_instantiate_vapp_template(vdc_id, vapp_template_id, name, options = {}) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb', line 134

def post_instantiate_vapp_template(vdc_id, vapp_template_id, name, options={})
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  type = 'vApp'
  vapp_id = "vapp-#{uuid}"
  vm_id = "vm-#{uuid}"

  data[:vapps][vapp_id] = {
    :name => name,
    :vdc_id => vdc_id,
    :description => options.fetch(:description, "vApp created from #{vapp_template_id}"),
    :networks => [],
    :metadata => {:'vapp_key' => 'vapp_value'},
    :status => "0",
  }

  data[:vms][vm_id] = {
    :name => 'vm-template-name',
    :parent_vapp => vapp_id,
    :memory_in_mb => "1024",
    :cpu_count => "2",
    :metadata => {:'vm_key' => 'vm_value'},
    :nics => [
      {
      :network_name => 'Default Network',
      :mac_address => "00:50:56:00:00:00",
      :ip_address => "192.168.0.1",
      }
    ],
  }

  owner = {
    :href => make_href("#{type}/#{vapp_id}"),
    :type => "application/vnd.vmware.vcloud.#{type}+xml"
  }
  task_id = enqueue_task(
    "Creating Virtual Application #{name}(#{vapp_id})", 'vdcInstantiateVapp', owner,
    :on_success => lambda do
      data[:vapps][vapp_id][:status] = "8"
    end
  )

  body = get_vapp(vapp_id).body

  body[:Tasks] = {
    :Task => task_body(task_id)
  }

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#post_power_on_vapp(id) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb', line 35

def post_power_on_vapp(id)
  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Starting Virtual Application #{data[:vapps][id]} vapp(#{id})", 'vappDeploy', owner,
    :on_success => lambda do
      data[:vms].values.each do |vm|
        if vm[:parent_vapp] == id
          vm[:status] = '4' # on
        end
      end
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#post_reconfigure_vm(id, options = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/fog/vcloud_director/requests/compute/post_reconfigure_vm.rb', line 83

def post_reconfigure_vm(id, options={})
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:name] = options[:name]
      data[:vms][id][:description] = options[:description] if options[:description]
      data[:vms][id][:cpu_count] = options[:cpu] if options[:cpu]
      data[:vms][id][:memory_in_mb] = options[:memory] if options[:memory]
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#post_update_vapp_metadata(id, metadata = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb', line 51

def (id, ={})
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      .each do |k,v|
        data[:tags][id] ||= {}
        data[:tags][id][k] = v
      end
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#post_upload_disk(id, name, size, options = {}) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/fog/vcloud_director/requests/compute/post_upload_disk.rb', line 82

def post_upload_disk(id, name, size, options={})
  unless size.to_s =~ /^\d+$/
    raise Fog::Compute::VcloudDirector::BadRequest.new(
      "validation error on field 'diskSpec.sizeBytes': must be greater than or equal to 0"
    )
  end
  unless data[:vdcs][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "(com.vmware.vcloud.entity.vdc:%s)".' % id
    )
  end

  disk_id = uuid

  owner = {
    :href => make_href("disk/#{disk_id}"),
    :type => 'application/vnd.vmware.vcloud.disk+xml'
  }
  task_id = enqueue_task(
    "Creating Disk #{name}(#{disk_id})", 'vdcCreateDisk', owner,
    :on_success => lambda do
      data[:disks][disk_id][:status] = 1
    end
  )

  disk = {
    :description => options[:Description],
    :name => name,
    :size => size.to_i,
    :status => 0,
    :tasks => [task_id],
    :vdc_id => id,
    :vdc_storage_class => data[:vdc_storage_classes].find {|k,v| v[:default]}.first
  }
  data[:disks][disk_id] = disk

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(disk_body(disk_id))

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#post_upload_media(vdc_id, name, image_type, size, options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/fog/vcloud_director/requests/compute/post_upload_media.rb', line 56

def post_upload_media(vdc_id, name, image_type, size, options={})
  unless ['iso','floppy'].include?(image_type)
    raise Fog::Compute::VcloudDirector::BadRequest.new(
      'The value of parameter imageType is incorrect.'
    )
  end
  unless size.to_s =~ /^\d+$/
    raise Fog::Compute::VcloudDirector::BadRequest.new(
      'validation error on field \'size\': must be greater than or equal to 0'
    )
  end
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  media_id = uuid
  file_id = uuid

  owner = {
    :href => make_href("media/#{media_id}"),
    :type => 'application/vnd.vmware.vcloud.media+xml'
  }
  task_id = enqueue_task(
    "Importing Media File #{name}(#{file_id})", 'vdcUploadMedia', owner,
    :on_success => lambda do
      media = data[:medias][media_id]
      media[:file][:bytes_transferred] = media[:size]
      media[:status] = 1
    end
  )

  media = {
    :description => options[:Description],
    :file => {
      :bytes_transferred => 0,
      :uuid => file_id
    },
    :image_type => image_type,
    :name => name,
    :size => size.to_i,
    :status => 0,
    :tasks => [task_id],
    :vdc_id => vdc_id,
    :vdc_storage_class => data[:vdc_storage_classes].find {|k,v| v[:default]}.first
  }
  data[:medias][media_id] = media

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(media_body(media_id))

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#process_task(response_body) ⇒ Boolean

Note:

As far as this method is concerned, the only possible task states are ‘running’ and ‘success’.

Parameters:

  • response_body (Hash)

Returns:

  • (Boolean)


874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
# File 'lib/fog/vcloud_director/compute.rb', line 874

def process_task(response_body)
  task_id = response_body[:href].split('/').last
  task = data[:tasks][task_id]

  if task[:status] == 'running'
    task[:end_time] = DateTime.now
    task[:progress] = 100
    task[:status] = 'success'

    if task[:on_success]
      task[:on_success].call
      task.delete(:on_success)
    end
  end

  return true if task[:status] == 'success'
  raise TaskError.new "status: #{task[:status]}, error: #{task[:Error]}"
end

#put_cpu(id, num_cpus) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/fog/vcloud_director/requests/compute/put_cpu.rb', line 55

def put_cpu(id, num_cpus)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:cpu_count] = num_cpus
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#put_memory(id, memory) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fog/vcloud_director/requests/compute/put_memory.rb', line 55

def put_memory(id, memory)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:memory_in_mb] = memory
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end

#put_network(id, name, options = {}) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/fog/vcloud_director/requests/compute/put_network.rb', line 68

def put_network(id, name, options={})
  original_network = data[:networks][id]
  unless original_network
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.orgVdcNetwork:#{id})\"."
    )
  end

  type = 'network'

  # Description
  # Configuration
  #   IpScopes
  #     IpScope
  #       IsInherited
  #       Gateway
  #       Netmask
  #       Dns1
  #       Dns2
  #       DnsSuffix
  #       IsEnabled
  #       IpRanges
  #         IpRange
  #           StartAddress
  #           EndAddress
  #   FenceMode
  # EdgeGateway
  # IsShared
  #
  vdc_id = original_network[:vdc],

  network_body = {
    :name => name,
    :vdc  => vdc_id,
  }

  [:Description, :IsShared].each do |key|
    network_body[key] = options[key] if options.key?(key)
  end

  if options.key?(:EdgeGateway)
    network_body[:EdgeGateway] =
      options[:EdgeGateway][:href].split('/').last
  end

  if configuration = options[:Configuration]
    if ip_scopes = configuration[:IpScopes]
      if ip_scope = ip_scopes[:IpScope]
        [:IsInherited, :Gateway, :Netmask,
          :Dns1, :Dns2, :DnsSuffix, :IsEnabled].each do |key|
            network_body[key] = ip_scope[key] if ip_scope.key?(key)
        end
        if ip_ranges = ip_scope[:IpRanges]
          network_body[:IpRanges] = []
          ip_ranges.each do |ipr|
            network_body[:IpRanges] << {
              :StartAddress => ipr[:IpRange][:StartAddress],
              :EndAddress   => ipr[:IpRange][:EndAddress]
            }
          end
        end
      end
    end
    network_body[:FenceMode] = configuration[:FenceMode] if ip_scope.key?(:FenceMode)
  end

  owner = {
    :href => make_href("#{type}/#{id}"),
    :type => "application/vnd.vmware.vcloud.#{type}+xml"
  }
  task_id = enqueue_task(
    "Updating #{type} #{name} (#{id})", 'networkUpdateNetwork', owner,
    :on_success => lambda do
      data[:networks][id] = network_body
    end
  )
  task = task_body(task_id)
  task.delete(:Owner) #known-bug: admin-api does not return owner.
  body = {
      :xmlns => xmlns,
      :xmlns_xsi => xmlns_xsi,
      :xsi_schemaLocation => xsi_schema_location,
  }.merge(task)

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end

#put_network_connection_system_section_vapp(id, options = {}) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb', line 120

def put_network_connection_system_section_vapp(id, options={})
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:nics].first[:network_name] = options[:network]
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#put_vapp_metadata_item_metadata(id, key, value) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fog/vcloud_director/requests/compute/put_vapp_metadata_item_metadata.rb', line 51

def (id, key, value)
  unless vm_or_vapp = data[:vapps][id] || vm_or_vapp = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{vm_or_vapp[:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      vm_or_vapp[:metadata][key] = value
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end

#put_vm(id, name, options) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/vcloud_director/requests/compute/put_vm.rb', line 39

def put_vm(id, name, options)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
      :on_success => lambda do
        data[:vms][id][:name] = name
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end

#user_nameObject



823
824
825
# File 'lib/fog/vcloud_director/compute.rb', line 823

def user_name
  @user_name ||= @vcloud_director_username.split('@').first
end

#user_uuidObject



827
828
829
# File 'lib/fog/vcloud_director/compute.rb', line 827

def user_uuid
  @user_uuid ||= uuid
end

#uuidObject



831
832
833
# File 'lib/fog/vcloud_director/compute.rb', line 831

def uuid
  [8,4,4,4,12].map {|i| Fog::Mock.random_hex(i)}.join('-')
end

#vcloud_tokenObject



806
807
808
# File 'lib/fog/vcloud_director/compute.rb', line 806

def vcloud_token
  @vcloud_token || Fog::Mock.random_base64(32)
end