fog-vsphere 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.travis.yml +32 -0
  4. data/CONTRIBUTING.md +18 -0
  5. data/CONTRIBUTORS.md +59 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE.md +20 -0
  8. data/README.md +31 -0
  9. data/Rakefile +8 -0
  10. data/fog-vsphere.gemspec +32 -0
  11. data/gemfiles/Gemfile.1.9.2+ +8 -0
  12. data/gemfiles/Gemfile.1.9.2- +11 -0
  13. data/lib/fog/vsphere.rb +41 -0
  14. data/lib/fog/vsphere/compute.rb +473 -0
  15. data/lib/fog/vsphere/models/compute/cluster.rb +28 -0
  16. data/lib/fog/vsphere/models/compute/clusters.rb +22 -0
  17. data/lib/fog/vsphere/models/compute/customfield.rb +16 -0
  18. data/lib/fog/vsphere/models/compute/customfields.rb +23 -0
  19. data/lib/fog/vsphere/models/compute/customvalue.rb +14 -0
  20. data/lib/fog/vsphere/models/compute/customvalues.rb +33 -0
  21. data/lib/fog/vsphere/models/compute/datacenter.rb +44 -0
  22. data/lib/fog/vsphere/models/compute/datacenters.rb +19 -0
  23. data/lib/fog/vsphere/models/compute/datastore.rb +21 -0
  24. data/lib/fog/vsphere/models/compute/datastores.rb +21 -0
  25. data/lib/fog/vsphere/models/compute/folder.rb +24 -0
  26. data/lib/fog/vsphere/models/compute/folders.rb +23 -0
  27. data/lib/fog/vsphere/models/compute/interface.rb +91 -0
  28. data/lib/fog/vsphere/models/compute/interfaces.rb +66 -0
  29. data/lib/fog/vsphere/models/compute/interfacetype.rb +22 -0
  30. data/lib/fog/vsphere/models/compute/interfacetypes.rb +34 -0
  31. data/lib/fog/vsphere/models/compute/network.rb +18 -0
  32. data/lib/fog/vsphere/models/compute/networks.rb +22 -0
  33. data/lib/fog/vsphere/models/compute/process.rb +17 -0
  34. data/lib/fog/vsphere/models/compute/resource_pool.rb +19 -0
  35. data/lib/fog/vsphere/models/compute/resource_pools.rb +22 -0
  36. data/lib/fog/vsphere/models/compute/scsicontroller.rb +16 -0
  37. data/lib/fog/vsphere/models/compute/server.rb +325 -0
  38. data/lib/fog/vsphere/models/compute/servers.rb +36 -0
  39. data/lib/fog/vsphere/models/compute/servertype.rb +36 -0
  40. data/lib/fog/vsphere/models/compute/servertypes.rb +23 -0
  41. data/lib/fog/vsphere/models/compute/snapshot.rb +35 -0
  42. data/lib/fog/vsphere/models/compute/snapshots.rb +27 -0
  43. data/lib/fog/vsphere/models/compute/template.rb +11 -0
  44. data/lib/fog/vsphere/models/compute/templates.rb +19 -0
  45. data/lib/fog/vsphere/models/compute/volume.rb +99 -0
  46. data/lib/fog/vsphere/models/compute/volumes.rb +53 -0
  47. data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +65 -0
  48. data/lib/fog/vsphere/requests/compute/create_folder.rb +22 -0
  49. data/lib/fog/vsphere/requests/compute/create_vm.rb +169 -0
  50. data/lib/fog/vsphere/requests/compute/current_time.rb +18 -0
  51. data/lib/fog/vsphere/requests/compute/get_cluster.rb +25 -0
  52. data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +41 -0
  53. data/lib/fog/vsphere/requests/compute/get_datacenter.rb +31 -0
  54. data/lib/fog/vsphere/requests/compute/get_datastore.rb +30 -0
  55. data/lib/fog/vsphere/requests/compute/get_folder.rb +74 -0
  56. data/lib/fog/vsphere/requests/compute/get_interface_type.rb +15 -0
  57. data/lib/fog/vsphere/requests/compute/get_network.rb +59 -0
  58. data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +26 -0
  59. data/lib/fog/vsphere/requests/compute/get_server_type.rb +32 -0
  60. data/lib/fog/vsphere/requests/compute/get_template.rb +16 -0
  61. data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +57 -0
  62. data/lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb +26 -0
  63. data/lib/fog/vsphere/requests/compute/list_child_snapshots.rb +71 -0
  64. data/lib/fog/vsphere/requests/compute/list_clusters.rb +72 -0
  65. data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +92 -0
  66. data/lib/fog/vsphere/requests/compute/list_customfields.rb +21 -0
  67. data/lib/fog/vsphere/requests/compute/list_datacenters.rb +53 -0
  68. data/lib/fog/vsphere/requests/compute/list_datastores.rb +40 -0
  69. data/lib/fog/vsphere/requests/compute/list_folders.rb +44 -0
  70. data/lib/fog/vsphere/requests/compute/list_interface_types.rb +25 -0
  71. data/lib/fog/vsphere/requests/compute/list_networks.rb +38 -0
  72. data/lib/fog/vsphere/requests/compute/list_processes.rb +40 -0
  73. data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +38 -0
  74. data/lib/fog/vsphere/requests/compute/list_server_types.rb +54 -0
  75. data/lib/fog/vsphere/requests/compute/list_templates.rb +48 -0
  76. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +80 -0
  77. data/lib/fog/vsphere/requests/compute/list_vm_customvalues.rb +20 -0
  78. data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +63 -0
  79. data/lib/fog/vsphere/requests/compute/list_vm_snapshots.rb +66 -0
  80. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +52 -0
  81. data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +59 -0
  82. data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +25 -0
  83. data/lib/fog/vsphere/requests/compute/revert_to_snapshot.rb +30 -0
  84. data/lib/fog/vsphere/requests/compute/set_vm_customvalue.rb +17 -0
  85. data/lib/fog/vsphere/requests/compute/vm_clone.rb +727 -0
  86. data/lib/fog/vsphere/requests/compute/vm_config_vnc.rb +45 -0
  87. data/lib/fog/vsphere/requests/compute/vm_destroy.rb +23 -0
  88. data/lib/fog/vsphere/requests/compute/vm_execute.rb +47 -0
  89. data/lib/fog/vsphere/requests/compute/vm_migrate.rb +33 -0
  90. data/lib/fog/vsphere/requests/compute/vm_power_off.rb +39 -0
  91. data/lib/fog/vsphere/requests/compute/vm_power_on.rb +26 -0
  92. data/lib/fog/vsphere/requests/compute/vm_reboot.rb +31 -0
  93. data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +23 -0
  94. data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +24 -0
  95. data/lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb +23 -0
  96. data/lib/fog/vsphere/requests/compute/vm_take_snapshot.rb +37 -0
  97. data/lib/fog/vsphere/version.rb +5 -0
  98. data/tests/compute_tests.rb +53 -0
  99. data/tests/helper.rb +8 -0
  100. data/tests/helpers/mock_helper.rb +9 -0
  101. data/tests/helpers/succeeds_helper.rb +9 -0
  102. data/tests/models/compute/server_tests.rb +70 -0
  103. data/tests/models/compute/servers_tests.rb +15 -0
  104. data/tests/requests/compute/current_time_tests.rb +12 -0
  105. data/tests/requests/compute/get_network_tests.rb +50 -0
  106. data/tests/requests/compute/list_child_snapshots_tests.rb +10 -0
  107. data/tests/requests/compute/list_clusters_tests.rb +11 -0
  108. data/tests/requests/compute/list_virtual_machines_tests.rb +38 -0
  109. data/tests/requests/compute/list_vm_snapshots_tests.rb +10 -0
  110. data/tests/requests/compute/revert_to_snapshot_tests.rb +15 -0
  111. data/tests/requests/compute/set_vm_customvalue_tests.rb +20 -0
  112. data/tests/requests/compute/vm_clone_tests.rb +50 -0
  113. data/tests/requests/compute/vm_config_vnc_tests.rb +19 -0
  114. data/tests/requests/compute/vm_destroy_tests.rb +17 -0
  115. data/tests/requests/compute/vm_migrate_tests.rb +16 -0
  116. data/tests/requests/compute/vm_power_off_tests.rb +26 -0
  117. data/tests/requests/compute/vm_power_on_tests.rb +17 -0
  118. data/tests/requests/compute/vm_reboot_tests.rb +26 -0
  119. data/tests/requests/compute/vm_reconfig_cpus_tests.rb +19 -0
  120. data/tests/requests/compute/vm_reconfig_hardware_tests.rb +19 -0
  121. data/tests/requests/compute/vm_reconfig_memory_tests.rb +19 -0
  122. data/tests/requests/compute/vm_take_snapshot_tests.rb +19 -0
  123. metadata +289 -0
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def current_time
6
+ current_time = @connection.serviceInstance.CurrentTime
7
+ { 'current_time' => current_time }
8
+ end
9
+ end
10
+
11
+ class Mock
12
+ def current_time
13
+ { 'current_time' => Time.now.utc }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_cluster(name, datacenter_name)
6
+ cluster = get_raw_cluster(name, datacenter_name)
7
+ raise(Fog::Compute::Vsphere::NotFound) unless cluster
8
+ cluster_attributes(cluster, datacenter_name)
9
+ end
10
+
11
+ protected
12
+
13
+ def get_raw_cluster(name, datacenter_name)
14
+ dc = find_raw_datacenter(datacenter_name)
15
+ dc.find_compute_resource(name)
16
+ end
17
+ end
18
+
19
+ class Mock
20
+ def get_cluster(id)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,41 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_compute_resource(name, datacenter_name)
6
+ compute_resource = get_raw_compute_resource(name, datacenter_name)
7
+ raise(Fog::Compute::Vsphere::NotFound) unless compute_resource
8
+ compute_resource_attributes(compute_resource, datacenter_name)
9
+ end
10
+
11
+ protected
12
+
13
+ def get_raw_compute_resource(name, datacenter_name)
14
+ find_raw_datacenter(datacenter_name).find_compute_resource(name)
15
+ end
16
+ end
17
+
18
+ class Mock
19
+ def get_compute_resource(name, datacenter_name)
20
+ {
21
+ :id=>"domain-s7",
22
+ :name=>"fake-host",
23
+ :totalCpu=>33504,
24
+ :totalMemory=>154604142592,
25
+ :numCpuCores=>12,
26
+ :numCpuThreads=>24,
27
+ :effectiveCpu=>32247,
28
+ :effectiveMemory=>135733,
29
+ :numHosts=>1,
30
+ :numEffectiveHosts=>1,
31
+ :overallStatus=>"gray",
32
+ :overallCpuUsage=>15682,
33
+ :overallMemoryUsage=>132755,
34
+ :effective=>true,
35
+ :isSingleHost=>true
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_datacenter name
6
+ dc = find_raw_datacenter(name)
7
+ raise(Fog::Compute::Vsphere::NotFound) unless dc
8
+ {:name => dc.name, :status => dc.overallStatus, :path => raw_getpathmo(dc) }
9
+ end
10
+
11
+ protected
12
+
13
+ def find_raw_datacenter name
14
+ raw_datacenters.find {|d| d.name == name} || get_raw_datacenter(name)
15
+ end
16
+
17
+ def get_raw_datacenter name
18
+ @connection.serviceInstance.find_datacenter(name)
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def get_datacenter name
24
+ dc = self.data[:datacenters][name]
25
+ raise(Fog::Compute::Vsphere::NotFound) unless dc
26
+ dc
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_datastore(name, datacenter_name)
6
+ datastore = get_raw_datastore(name, datacenter_name)
7
+ raise(Fog::Compute::Vsphere::NotFound) unless datastore
8
+ datastore_attributes(datastore, datacenter_name)
9
+ end
10
+
11
+ protected
12
+
13
+ def get_raw_datastore(name, datacenter_name)
14
+ dc = find_raw_datacenter(datacenter_name)
15
+
16
+ @connection.serviceContent.viewManager.CreateContainerView({
17
+ :container => dc.datastoreFolder,
18
+ :type => ["Datastore"],
19
+ :recursive => true
20
+ }).view.select{|ds| ds.name == name}.first
21
+ end
22
+ end
23
+
24
+ class Mock
25
+ def get_datastore(name, datacenter_name)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,74 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_folder(path, datacenter_name, type = nil)
6
+ type ||= 'vm'
7
+
8
+ # Cycle through all types of folders.
9
+ case type
10
+ when 'vm', :vm
11
+ # if you're a vm then grab the VM.
12
+ folder = get_raw_vmfolder(path, datacenter_name)
13
+ raise(Fog::Compute::Vsphere::NotFound) unless folder
14
+ folder_attributes(folder, datacenter_name)
15
+ when 'network', :network
16
+ raise "not implemented"
17
+ when 'datastore', :datastore
18
+ raise "not implemented"
19
+ else
20
+ raise ArgumentError, "#{type} is unknown"
21
+ end
22
+ end
23
+
24
+ protected
25
+
26
+ def get_raw_vmfolder(path, datacenter_name)
27
+ # The required path syntax - 'topfolder/subfolder
28
+
29
+ # Clean up path to be relative since we're providing datacenter name
30
+ dc = find_raw_datacenter(datacenter_name)
31
+ dc_root_folder = dc.vmFolder
32
+ # Filter the root path for this datacenter not to be used."
33
+ dc_root_folder_path=dc_root_folder.path.map { | id, name | name }.join("/")
34
+ paths = path.sub(/^\/?#{Regexp.quote(dc_root_folder_path)}\/?/, '').split('/')
35
+
36
+ return dc_root_folder if paths.empty?
37
+ # Walk the tree resetting the folder pointer as we go
38
+ paths.reduce(dc_root_folder) do |last_returned_folder, sub_folder|
39
+ # JJM VIM::Folder#find appears to be quite efficient as it uses the
40
+ # searchIndex It certainly appears to be faster than
41
+ # VIM::Folder#inventory since that returns _all_ managed objects of
42
+ # a certain type _and_ their properties.
43
+ sub = last_returned_folder.find(sub_folder, RbVmomi::VIM::Folder)
44
+ raise ArgumentError, "Could not descend into #{sub_folder}. Please check your path. #{path}" unless sub
45
+ sub
46
+ end
47
+ end
48
+
49
+ def folder_attributes(folder, datacenter_name)
50
+ {
51
+ :id => managed_obj_id(folder),
52
+ :name => folder.name,
53
+ :parent => folder.parent.name,
54
+ :datacenter => datacenter_name,
55
+ :type => folder_type(folder),
56
+ :path => "/"+folder.path.map(&:last).join('/'),
57
+ }
58
+ end
59
+
60
+ def folder_type(folder)
61
+ types = folder.childType
62
+ return :vm if types.include?('VirtualMachine')
63
+ return :network if types.include?('Network')
64
+ return :datastore if types.include?('Datastore')
65
+ end
66
+ end
67
+
68
+ class Mock
69
+ def get_folder(path, filters = { })
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_interface_type(id, servertype, datacenter, filter={})
6
+ interfacetype=list_interface_types(filters={:id => id,
7
+ :datacenter => datacenter,
8
+ :servertype => servertype.id }).first
9
+ raise(Fog::Compute::Vsphere::NotFound) unless interfacetype
10
+ interfacetype
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,59 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_network(name, datacenter_name)
6
+ network = get_raw_network(name, datacenter_name)
7
+ raise(Fog::Compute::Vsphere::NotFound) unless network
8
+ network_attributes(network, datacenter_name)
9
+ end
10
+
11
+ protected
12
+
13
+ def get_raw_network(name, datacenter_name, distributedswitch=nil)
14
+ finder = choose_finder(name, distributedswitch)
15
+ networks = get_all_raw_networks(datacenter_name)
16
+ networks.find { |n| finder.call(n) }
17
+ end
18
+ end
19
+
20
+ module Shared
21
+
22
+ protected
23
+
24
+ def get_all_raw_networks(datacenter_name)
25
+ dc = find_raw_datacenter(datacenter_name)
26
+ @connection.serviceContent.viewManager.
27
+ CreateContainerView({
28
+ :container => dc.networkFolder,
29
+ :type => ["Network"],
30
+ :recursive => true
31
+ }).view
32
+ end
33
+
34
+ def choose_finder(name, distributedswitch)
35
+ case distributedswitch
36
+ when String
37
+ # only the one will do
38
+ Proc.new { |n| (n.name == name) &&
39
+ (n.class.to_s == "DistributedVirtualPortgroup") &&
40
+ (n.config.distributedVirtualSwitch.name == distributedswitch)
41
+ }
42
+ when :dvs
43
+ # the first distributed virtual switch will do - selected by network - gives control to vsphere
44
+ Proc.new { |n| (n.name == name) && (n.class.to_s == "DistributedVirtualPortgroup") }
45
+ else
46
+ # the first matching network will do, seems like the non-distributed networks come first
47
+ Proc.new { |n| (n.name == name) }
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ class Mock
54
+ def get_network(id)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_resource_pool(name, cluster_name, datacenter_name)
6
+ resource_pool = get_raw_resource_pool(name, cluster_name, datacenter_name)
7
+ raise(Fog::Compute::Vsphere::NotFound) unless resource_pool
8
+ resource_pool_attributes(resource_pool, cluster_name, datacenter_name)
9
+ end
10
+
11
+ protected
12
+
13
+ def get_raw_resource_pool(name, cluster_name, datacenter_name)
14
+ dc = find_raw_datacenter(datacenter_name)
15
+ cluster = dc.find_compute_resource(cluster_name)
16
+ name.nil? ? cluster.resourcePool : cluster.resourcePool.traverse(name)
17
+ end
18
+ end
19
+
20
+ class Mock
21
+ def get_resource_pool(name, cluster_name, datacenter_name)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_server_type(id, datacenter, filter={})
6
+ server_type=get_raw_server_type(id, datacenter)
7
+ raise(Fog::Compute::Vsphere::NotFound) unless server_type
8
+ server_type_attributes(server_type, datacenter)
9
+ end
10
+
11
+ protected
12
+
13
+ def get_raw_server_type(id, datacenter, filter={})
14
+ types=raw_server_types(datacenter)
15
+ raise(Fog::Compute::Vsphere::NotFound) unless types
16
+ types=types.select{ | servertype | servertype.id == id }.first
17
+ raise(Fog::Compute::Vsphere::NotFound) unless types
18
+ types
19
+ end
20
+ end
21
+ class Mock
22
+ def get_server_type(id)
23
+ {:id=>"rhel6Guest",
24
+ :name=>"rhel6Guest",
25
+ :family=>"linuxGuest",
26
+ :fullname=>"Red Hat Enterprise Linux 6 (32-Bit)",
27
+ :datacenter=>"Solutions"}
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_template(id, datacenter_name = nil)
6
+ convert_vm_mob_ref_to_attr_hash(get_vm_ref(id, datacenter_name))
7
+ end
8
+ end
9
+
10
+ class Mock
11
+ def get_template(id, datacenter_name = nil)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,57 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def get_virtual_machine(id, datacenter_name = nil)
6
+ # The larger the VM list the longer it will take if not searching based on UUID.
7
+ convert_vm_mob_ref_to_attr_hash(get_vm_ref(id, datacenter_name))
8
+ end
9
+
10
+ protected
11
+
12
+ def get_vm_ref(id, dc = nil)
13
+ raw_datacenter = find_raw_datacenter(dc) if dc
14
+ vm = case is_uuid?(id)
15
+ # UUID based
16
+ when true
17
+ params = {:uuid => id, :vmSearch => true, :instanceUuid => true}
18
+ params[:datacenter] = raw_datacenter if dc
19
+ @connection.searchIndex.FindByUuid(params)
20
+ else
21
+ # try to find based on VM name
22
+ if dc
23
+ get_vm_by_name(id, dc)
24
+ else
25
+ raw_datacenters.map { |d| get_vm_by_name(id, d["name"])}.compact.first
26
+ end
27
+ end
28
+ vm ? vm : raise(Fog::Compute::Vsphere::NotFound, "#{id} was not found")
29
+ end
30
+
31
+ def get_vm_by_name(name, dc)
32
+ vms = raw_list_all_virtual_machines(dc)
33
+
34
+ if name.include?('/')
35
+ folder = File.dirname(name)
36
+ basename = File.basename(name)
37
+ vms.keep_if { |v| v["name"] == basename && v.parent.pretty_path.include?(folder) }.first
38
+ else
39
+ vms.keep_if { |v| v["name"] == name }.first
40
+ end
41
+ end
42
+ end
43
+
44
+ class Mock
45
+ def get_virtual_machine(id, datacenter_name = nil)
46
+ if is_uuid?(id)
47
+ vm = list_virtual_machines({ 'instance_uuid' => id, 'datacenter' => datacenter_name }).first
48
+ else
49
+ # try to find based on VM name. May need to handle the path of the VM
50
+ vm = list_virtual_machines({ 'name' => id, 'datacenter' => datacenter_name }).first
51
+ end
52
+ vm ? vm : raise(Fog::Compute::Vsphere::NotFound, "#{id} was not found")
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,26 @@
1
+
2
+ module Fog
3
+ module Compute
4
+ class Vsphere
5
+ class Real
6
+ def get_vm_first_scsi_controller(vm_id)
7
+ Fog::Compute::Vsphere::SCSIController.new(get_vm_first_scsi_controller_raw(vm_id))
8
+ end
9
+
10
+ def get_vm_first_scsi_controller_raw(vm_id)
11
+ ctrl=get_vm_ref(vm_id).config.hardware.device.grep(RbVmomi::VIM::VirtualSCSIController).select{ | ctrl | ctrl.key == 1000 }.first
12
+ {
13
+ :type => ctrl.class.to_s,
14
+ :shared_bus => ctrl.sharedBus.to_s,
15
+ :unit_number => ctrl.scsiCtlrUnitNumber,
16
+ :key => ctrl.key,
17
+ }
18
+ end
19
+ end
20
+ class Mock
21
+ def get_vm_first_scsi_controller(vm_id)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end