fog-vsphere 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +4 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +9 -0
- data/README.md +7 -1
- data/fog-vsphere.gemspec +2 -1
- data/lib/fog-vsphere.rb +1 -0
- data/lib/fog/bin/vsphere.rb +1 -1
- data/lib/fog/vsphere.rb +2 -4
- data/lib/fog/vsphere/compute.rb +23 -6
- data/lib/fog/vsphere/models/compute/cdrom.rb +2 -2
- data/lib/fog/vsphere/models/compute/cdroms.rb +3 -3
- data/lib/fog/vsphere/models/compute/cluster.rb +2 -2
- data/lib/fog/vsphere/models/compute/clusters.rb +3 -3
- data/lib/fog/vsphere/models/compute/customfield.rb +2 -2
- data/lib/fog/vsphere/models/compute/customfields.rb +3 -3
- data/lib/fog/vsphere/models/compute/customvalue.rb +2 -2
- data/lib/fog/vsphere/models/compute/customvalues.rb +5 -5
- data/lib/fog/vsphere/models/compute/datacenter.rb +2 -2
- data/lib/fog/vsphere/models/compute/datacenters.rb +3 -3
- data/lib/fog/vsphere/models/compute/datastore.rb +2 -2
- data/lib/fog/vsphere/models/compute/datastores.rb +3 -3
- data/lib/fog/vsphere/models/compute/folder.rb +2 -2
- data/lib/fog/vsphere/models/compute/folders.rb +3 -3
- data/lib/fog/vsphere/models/compute/host.rb +2 -2
- data/lib/fog/vsphere/models/compute/hosts.rb +4 -4
- data/lib/fog/vsphere/models/compute/interface.rb +2 -2
- data/lib/fog/vsphere/models/compute/interfaces.rb +8 -8
- data/lib/fog/vsphere/models/compute/interfacetype.rb +2 -2
- data/lib/fog/vsphere/models/compute/interfacetypes.rb +5 -5
- data/lib/fog/vsphere/models/compute/network.rb +2 -2
- data/lib/fog/vsphere/models/compute/networks.rb +3 -3
- data/lib/fog/vsphere/models/compute/process.rb +2 -2
- data/lib/fog/vsphere/models/compute/resource_pool.rb +2 -2
- data/lib/fog/vsphere/models/compute/resource_pools.rb +3 -3
- data/lib/fog/vsphere/models/compute/rule.rb +2 -2
- data/lib/fog/vsphere/models/compute/rules.rb +4 -4
- data/lib/fog/vsphere/models/compute/scsicontroller.rb +2 -2
- data/lib/fog/vsphere/models/compute/server.rb +6 -6
- data/lib/fog/vsphere/models/compute/servers.rb +4 -4
- data/lib/fog/vsphere/models/compute/servertype.rb +2 -2
- data/lib/fog/vsphere/models/compute/servertypes.rb +4 -4
- data/lib/fog/vsphere/models/compute/snapshot.rb +2 -2
- data/lib/fog/vsphere/models/compute/snapshots.rb +3 -3
- data/lib/fog/vsphere/models/compute/storage_pod.rb +2 -2
- data/lib/fog/vsphere/models/compute/storage_pods.rb +3 -3
- data/lib/fog/vsphere/models/compute/template.rb +2 -2
- data/lib/fog/vsphere/models/compute/templates.rb +3 -3
- data/lib/fog/vsphere/models/compute/ticket.rb +2 -2
- data/lib/fog/vsphere/models/compute/tickets.rb +4 -4
- data/lib/fog/vsphere/models/compute/volume.rb +3 -3
- data/lib/fog/vsphere/models/compute/volumes.rb +5 -5
- data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +2 -2
- data/lib/fog/vsphere/requests/compute/create_folder.rb +2 -2
- data/lib/fog/vsphere/requests/compute/create_group.rb +2 -2
- data/lib/fog/vsphere/requests/compute/create_rule.rb +2 -2
- data/lib/fog/vsphere/requests/compute/create_vm.rb +2 -2
- data/lib/fog/vsphere/requests/compute/current_time.rb +2 -2
- data/lib/fog/vsphere/requests/compute/destroy_group.rb +2 -2
- data/lib/fog/vsphere/requests/compute/destroy_rule.rb +2 -2
- data/lib/fog/vsphere/requests/compute/folder_destroy.rb +2 -2
- data/lib/fog/vsphere/requests/compute/get_cluster.rb +5 -4
- data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_datacenter.rb +4 -4
- data/lib/fog/vsphere/requests/compute/get_datastore.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_folder.rb +6 -6
- data/lib/fog/vsphere/requests/compute/get_host.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_interface_type.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_network.rb +4 -4
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_server_type.rb +5 -5
- data/lib/fog/vsphere/requests/compute/get_storage_pod.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_template.rb +2 -2
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +4 -4
- data/lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb +3 -3
- data/lib/fog/vsphere/requests/compute/host_finish_maintenance.rb +2 -2
- data/lib/fog/vsphere/requests/compute/host_shutdown.rb +2 -2
- data/lib/fog/vsphere/requests/compute/host_start_maintenance.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_child_snapshots.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_clusters.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_customfields.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_datacenters.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_datastores.rb +4 -4
- data/lib/fog/vsphere/requests/compute/list_folders.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_groups.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_hosts.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_interface_types.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_networks.rb +4 -4
- data/lib/fog/vsphere/requests/compute/list_processes.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_rules.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_server_types.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_storage_pods.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_templates.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_vm_cdroms.rb +3 -3
- data/lib/fog/vsphere/requests/compute/list_vm_customvalues.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +3 -3
- data/lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb +4 -4
- data/lib/fog/vsphere/requests/compute/list_vm_snapshots.rb +2 -2
- data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +2 -2
- data/lib/fog/vsphere/requests/compute/modify_vm_cdrom.rb +2 -2
- data/lib/fog/vsphere/requests/compute/modify_vm_controller.rb +2 -2
- data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +4 -4
- data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +2 -2
- data/lib/fog/vsphere/requests/compute/revert_to_snapshot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/set_vm_customvalue.rb +2 -2
- data/lib/fog/vsphere/requests/compute/update_vm.rb +2 -2
- data/lib/fog/vsphere/requests/compute/upload_iso.rb +4 -4
- data/lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +11 -8
- data/lib/fog/vsphere/requests/compute/vm_config_vnc.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_destroy.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_execute.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_migrate.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_power_off.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_power_on.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reboot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reconfig_cdrom.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_relocate.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_remove_snapshot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_rename.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_suspend.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_take_snapshot.rb +2 -2
- data/lib/fog/vsphere/version.rb +1 -1
- data/tests/helper.rb +3 -0
- data/tests/models/compute/cluster_tests.rb +3 -3
- data/tests/models/compute/hosts_tests.rb +1 -1
- data/tests/models/compute/rules_tests.rb +1 -1
- data/tests/models/compute/server_tests.rb +4 -4
- data/tests/models/compute/server_unit_tests.rb +1 -1
- data/tests/models/compute/servers_tests.rb +1 -1
- data/tests/models/compute/tickets_tests.rb +1 -1
- data/tests/requests/compute/get_network_tests.rb +23 -15
- data/tests/requests/compute/revert_to_snapshot_tests.rb +1 -1
- data/tests/requests/compute/update_vm_tests.rb +1 -1
- data/tests/requests/compute/vm_clone_tests.rb +10 -5
- metadata +26 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Vsphere
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def list_networks(filters = {})
|
6
6
|
datacenter_name = filters[:datacenter]
|
@@ -107,10 +107,10 @@ module Fog
|
|
107
107
|
cluster_name = filters.fetch(:cluster, nil)
|
108
108
|
if cluster_name.nil?
|
109
109
|
data[:networks].values.select { |d| d['datacenter'] == datacenter_name } ||
|
110
|
-
raise(Fog::Compute::
|
110
|
+
raise(Fog::Vsphere::Compute::NotFound)
|
111
111
|
else
|
112
112
|
data[:networks].values.select { |d| d['datacenter'] == datacenter_name && d['cluster'].include?(cluster_name) } ||
|
113
|
-
raise(Fog::Compute::
|
113
|
+
raise(Fog::Vsphere::Compute::NotFound)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# rubocop:disable Lint/RescueWithoutErrorClass
|
2
2
|
module Fog
|
3
|
-
module
|
4
|
-
class
|
3
|
+
module Vsphere
|
4
|
+
class Compute
|
5
5
|
class Real
|
6
6
|
def list_vm_cdroms(vm_id)
|
7
7
|
get_vm_ref(vm_id).config.hardware.device.select { |hw| hw.class == RbVmomi::VIM::VirtualCdrom }.map do |cdrom|
|
@@ -25,7 +25,7 @@ module Fog
|
|
25
25
|
end
|
26
26
|
class Mock
|
27
27
|
def list_vm_cdroms(vm_id)
|
28
|
-
raise Fog::Compute::
|
28
|
+
raise Fog::Vsphere::Compute::NotFound, 'VM not Found' unless data[:servers].key?(vm_id)
|
29
29
|
return [] unless data[:servers][vm_id].key?('cdroms')
|
30
30
|
data[:servers][vm_id]['cdroms'].map { |h| h.merge(instance_uuid: vm_id) }
|
31
31
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Vsphere
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
# => VirtualE1000(
|
6
6
|
# addressType: "assigned",
|
@@ -44,7 +44,7 @@ module Fog
|
|
44
44
|
def get_raw_interface(vm_id, options = {})
|
45
45
|
raise ArgumentError, 'instance id is a required parameter' unless vm_id
|
46
46
|
|
47
|
-
if options.is_a? Fog::Compute::
|
47
|
+
if options.is_a? Fog::Vsphere::Compute::Interface
|
48
48
|
options
|
49
49
|
|
50
50
|
else
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Vsphere
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def list_vm_scsi_controllers(vm_id)
|
6
6
|
list_vm_scsi_controllers_raw(vm_id).map do |raw_controller|
|
7
|
-
Fog::Compute::
|
7
|
+
Fog::Vsphere::Compute::SCSIController.new(raw_controller)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -21,7 +21,7 @@ module Fog
|
|
21
21
|
end
|
22
22
|
class Mock
|
23
23
|
def list_vm_scsi_controllers(vm_id)
|
24
|
-
raise Fog::Compute::
|
24
|
+
raise Fog::Vsphere::Compute::NotFound, 'VM not Found' unless data[:servers].key?(vm_id)
|
25
25
|
return [] unless data[:servers][vm_id].key?('scsi_controllers')
|
26
26
|
data[:servers][vm_id]['scsi_controllers'].map { |h| h.merge(server_id: vm_id) }
|
27
27
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Vsphere
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def add_vm_cdrom(cdrom)
|
6
6
|
vm_reconfig_hardware('instance_uuid' => cdrom.server.instance_uuid, 'hardware_spec' => { 'deviceChange' => [create_cdrom(cdrom, cdrom.unit_number, :add)] })
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Vsphere
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def add_vm_interface(vmid, options = {})
|
6
6
|
raise ArgumentError, 'instance id is a required parameter' unless vmid
|
@@ -49,10 +49,10 @@ module Fog
|
|
49
49
|
|
50
50
|
elsif options[:key] && (options[:key] > 0)
|
51
51
|
oldattributes = get_vm_interface(vmid, options)
|
52
|
-
Fog::Compute::
|
52
|
+
Fog::Vsphere::Compute::Interface.new(oldattributes.merge(options))
|
53
53
|
|
54
54
|
elsif options[:type] && options[:network]
|
55
|
-
Fog::Compute::
|
55
|
+
Fog::Vsphere::Compute::Interface.new options
|
56
56
|
|
57
57
|
else
|
58
58
|
raise ArgumentError, 'interface is a required parameter or pass options with type and network'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Vsphere
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def upload_iso_check_options(options)
|
6
6
|
default_options = {
|
@@ -11,8 +11,8 @@ module Fog
|
|
11
11
|
required_options.each do |param|
|
12
12
|
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.key? param
|
13
13
|
end
|
14
|
-
raise Fog::Compute::
|
15
|
-
raise Fog::Compute::
|
14
|
+
raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['datacenter']} Doesn't Exist!" unless get_datacenter(options['datacenter'])
|
15
|
+
raise Fog::Vsphere::Compute::NotFound, "Datastore #{options['datastore']} Doesn't Exist!" unless get_raw_datastore(options['datastore'], options['datacenter'])
|
16
16
|
options
|
17
17
|
end
|
18
18
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Vsphere
|
3
|
+
class Compute
|
4
4
|
module Shared
|
5
5
|
private
|
6
6
|
|
@@ -19,10 +19,13 @@ module Fog
|
|
19
19
|
required_options.each do |param|
|
20
20
|
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.key? param
|
21
21
|
end
|
22
|
-
raise
|
23
|
-
raise Fog::Compute::
|
22
|
+
raise ArgumentError, 'cluster option is required' unless options['resource_pool'][0]
|
23
|
+
raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['datacenter']} Doesn't Exist!" unless get_datacenter(options['datacenter'])
|
24
|
+
raise Fog::Vsphere::Compute::NotFound, "Template #{options['template_path']} Doesn't Exist!" unless get_virtual_machine(options['template_path'], options['datacenter'])
|
25
|
+
raise Fog::Vsphere::Compute::NotFound, "Cluster #{options['resource_pool'][0]} Doesn't Exist in the DC!" unless get_raw_cluster(options["resource_pool"][0], options['datacenter'])
|
26
|
+
raise ArgumentError, 'path option is required' unless options.fetch('dest_folder', '/')
|
24
27
|
if options.key?('storage_pod') && !options['storage_pod'].nil? && !get_raw_storage_pod(options['storage_pod'], options['datacenter'])
|
25
|
-
raise Fog::Compute::
|
28
|
+
raise Fog::Vsphere::Compute::NotFound, "Storage Pod #{options['storage_pod']} Doesn't Exist!"
|
26
29
|
end
|
27
30
|
options
|
28
31
|
end
|
@@ -641,7 +644,7 @@ module Fog
|
|
641
644
|
config: virtual_machine_config_spec,
|
642
645
|
customization: customization_spec,
|
643
646
|
powerOn: options.key?('power_on') ? options['power_on'] : true,
|
644
|
-
template: false)
|
647
|
+
template: options.key?('template') ? options['template'] : false)
|
645
648
|
|
646
649
|
# Perform the actual Clone Task
|
647
650
|
# Clone VM on a storage pod
|
@@ -774,7 +777,7 @@ module Fog
|
|
774
777
|
device: template_nic
|
775
778
|
}
|
776
779
|
else
|
777
|
-
interface = Fog::Compute::
|
780
|
+
interface = Fog::Vsphere::Compute::Interface.new(raw_to_hash(template_nic))
|
778
781
|
specs << create_interface(interface, interface.key, :remove, datacenter: datacenter)
|
779
782
|
end
|
780
783
|
end
|
@@ -833,7 +836,7 @@ module Fog
|
|
833
836
|
def vm_clone(options = {})
|
834
837
|
# Option handling TODO Needs better method of checking
|
835
838
|
options = vm_clone_check_options(options)
|
836
|
-
notfound = -> { raise Fog::Compute::
|
839
|
+
notfound = -> { raise Fog::Vsphere::Compute::NotFound, 'Could not find VM template' }
|
837
840
|
template = list_virtual_machines.find(notfound) do |vm|
|
838
841
|
vm['name'] == options['template_path'].split('/')[-1]
|
839
842
|
end
|