fog-vsphere 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.rubocop_todo.yml +217 -0
  4. data/.travis.yml +1 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Rakefile +10 -1
  7. data/fog-vsphere.gemspec +2 -2
  8. data/lib/fog/bin/vsphere.rb +1 -1
  9. data/lib/fog/vsphere/compute.rb +320 -301
  10. data/lib/fog/vsphere/models/compute/cdrom.rb +10 -10
  11. data/lib/fog/vsphere/models/compute/cdroms.rb +2 -2
  12. data/lib/fog/vsphere/models/compute/cluster.rb +20 -20
  13. data/lib/fog/vsphere/models/compute/clusters.rb +1 -1
  14. data/lib/fog/vsphere/models/compute/customfields.rb +4 -4
  15. data/lib/fog/vsphere/models/compute/customvalues.rb +8 -8
  16. data/lib/fog/vsphere/models/compute/datacenter.rb +16 -16
  17. data/lib/fog/vsphere/models/compute/datastores.rb +1 -1
  18. data/lib/fog/vsphere/models/compute/folder.rb +2 -2
  19. data/lib/fog/vsphere/models/compute/folders.rb +2 -2
  20. data/lib/fog/vsphere/models/compute/hosts.rb +4 -4
  21. data/lib/fog/vsphere/models/compute/interface.rb +12 -12
  22. data/lib/fog/vsphere/models/compute/interfaces.rb +14 -16
  23. data/lib/fog/vsphere/models/compute/interfacetype.rb +2 -2
  24. data/lib/fog/vsphere/models/compute/interfacetypes.rb +6 -8
  25. data/lib/fog/vsphere/models/compute/networks.rb +1 -1
  26. data/lib/fog/vsphere/models/compute/resource_pools.rb +1 -1
  27. data/lib/fog/vsphere/models/compute/rule.rb +8 -9
  28. data/lib/fog/vsphere/models/compute/rules.rb +9 -10
  29. data/lib/fog/vsphere/models/compute/scsicontroller.rb +1 -1
  30. data/lib/fog/vsphere/models/compute/server.rb +68 -80
  31. data/lib/fog/vsphere/models/compute/servers.rb +12 -13
  32. data/lib/fog/vsphere/models/compute/servertype.rb +6 -6
  33. data/lib/fog/vsphere/models/compute/servertypes.rb +2 -2
  34. data/lib/fog/vsphere/models/compute/snapshot.rb +5 -6
  35. data/lib/fog/vsphere/models/compute/snapshots.rb +1 -1
  36. data/lib/fog/vsphere/models/compute/ticket.rb +0 -1
  37. data/lib/fog/vsphere/models/compute/volume.rb +12 -14
  38. data/lib/fog/vsphere/models/compute/volumes.rb +10 -10
  39. data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +8 -8
  40. data/lib/fog/vsphere/requests/compute/create_folder.rb +5 -5
  41. data/lib/fog/vsphere/requests/compute/create_group.rb +16 -16
  42. data/lib/fog/vsphere/requests/compute/create_rule.rb +13 -13
  43. data/lib/fog/vsphere/requests/compute/create_vm.rb +117 -119
  44. data/lib/fog/vsphere/requests/compute/destroy_group.rb +8 -8
  45. data/lib/fog/vsphere/requests/compute/destroy_rule.rb +8 -8
  46. data/lib/fog/vsphere/requests/compute/folder_destroy.rb +3 -3
  47. data/lib/fog/vsphere/requests/compute/get_cluster.rb +2 -2
  48. data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +16 -16
  49. data/lib/fog/vsphere/requests/compute/get_datacenter.rb +7 -7
  50. data/lib/fog/vsphere/requests/compute/get_datastore.rb +1 -2
  51. data/lib/fog/vsphere/requests/compute/get_folder.rb +24 -24
  52. data/lib/fog/vsphere/requests/compute/get_host.rb +2 -3
  53. data/lib/fog/vsphere/requests/compute/get_interface_type.rb +6 -6
  54. data/lib/fog/vsphere/requests/compute/get_network.rb +7 -10
  55. data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -2
  56. data/lib/fog/vsphere/requests/compute/get_server_type.rb +14 -14
  57. data/lib/fog/vsphere/requests/compute/get_storage_pod.rb +2 -2
  58. data/lib/fog/vsphere/requests/compute/get_template.rb +1 -2
  59. data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +26 -26
  60. data/lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb +6 -7
  61. data/lib/fog/vsphere/requests/compute/host_finish_maintenance.rb +1 -1
  62. data/lib/fog/vsphere/requests/compute/host_shutdown.rb +1 -1
  63. data/lib/fog/vsphere/requests/compute/host_start_maintenance.rb +1 -1
  64. data/lib/fog/vsphere/requests/compute/list_child_snapshots.rb +37 -39
  65. data/lib/fog/vsphere/requests/compute/list_clusters.rb +8 -9
  66. data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +57 -59
  67. data/lib/fog/vsphere/requests/compute/list_customfields.rb +5 -6
  68. data/lib/fog/vsphere/requests/compute/list_datacenters.rb +17 -17
  69. data/lib/fog/vsphere/requests/compute/list_datastores.rb +16 -15
  70. data/lib/fog/vsphere/requests/compute/list_folders.rb +4 -4
  71. data/lib/fog/vsphere/requests/compute/list_groups.rb +5 -5
  72. data/lib/fog/vsphere/requests/compute/list_hosts.rb +30 -14
  73. data/lib/fog/vsphere/requests/compute/list_interface_types.rb +7 -7
  74. data/lib/fog/vsphere/requests/compute/list_networks.rb +12 -16
  75. data/lib/fog/vsphere/requests/compute/list_processes.rb +14 -14
  76. data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +13 -14
  77. data/lib/fog/vsphere/requests/compute/list_rules.rb +4 -4
  78. data/lib/fog/vsphere/requests/compute/list_server_types.rb +24 -26
  79. data/lib/fog/vsphere/requests/compute/list_storage_pods.rb +8 -8
  80. data/lib/fog/vsphere/requests/compute/list_templates.rb +4 -5
  81. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +15 -15
  82. data/lib/fog/vsphere/requests/compute/list_vm_cdroms.rb +16 -12
  83. data/lib/fog/vsphere/requests/compute/list_vm_customvalues.rb +3 -4
  84. data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +54 -56
  85. data/lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb +7 -7
  86. data/lib/fog/vsphere/requests/compute/list_vm_snapshots.rb +36 -36
  87. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +43 -36
  88. data/lib/fog/vsphere/requests/compute/modify_vm_cdrom.rb +4 -4
  89. data/lib/fog/vsphere/requests/compute/modify_vm_controller.rb +2 -2
  90. data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +26 -19
  91. data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +7 -7
  92. data/lib/fog/vsphere/requests/compute/revert_to_snapshot.rb +2 -2
  93. data/lib/fog/vsphere/requests/compute/set_vm_customvalue.rb +2 -2
  94. data/lib/fog/vsphere/requests/compute/update_vm.rb +111 -0
  95. data/lib/fog/vsphere/requests/compute/upload_iso.rb +10 -10
  96. data/lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb +3 -3
  97. data/lib/fog/vsphere/requests/compute/vm_clone.rb +245 -247
  98. data/lib/fog/vsphere/requests/compute/vm_config_vnc.rb +15 -15
  99. data/lib/fog/vsphere/requests/compute/vm_destroy.rb +2 -2
  100. data/lib/fog/vsphere/requests/compute/vm_execute.rb +16 -16
  101. data/lib/fog/vsphere/requests/compute/vm_migrate.rb +11 -11
  102. data/lib/fog/vsphere/requests/compute/vm_power_off.rb +8 -8
  103. data/lib/fog/vsphere/requests/compute/vm_power_on.rb +2 -2
  104. data/lib/fog/vsphere/requests/compute/vm_reboot.rb +5 -5
  105. data/lib/fog/vsphere/requests/compute/vm_reconfig_cdrom.rb +11 -11
  106. data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +8 -8
  107. data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +6 -6
  108. data/lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb +8 -8
  109. data/lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb +14 -16
  110. data/lib/fog/vsphere/requests/compute/vm_relocate.rb +8 -8
  111. data/lib/fog/vsphere/requests/compute/vm_remove_snapshot.rb +2 -2
  112. data/lib/fog/vsphere/requests/compute/vm_rename.rb +5 -5
  113. data/lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb +1 -1
  114. data/lib/fog/vsphere/requests/compute/vm_take_snapshot.rb +8 -8
  115. data/lib/fog/vsphere/version.rb +1 -1
  116. data/tests/compute_tests.rb +16 -17
  117. data/tests/helpers/mock_helper.rb +3 -3
  118. data/tests/models/compute/cluster_tests.rb +4 -5
  119. data/tests/models/compute/hosts_tests.rb +2 -4
  120. data/tests/models/compute/rules_tests.rb +10 -16
  121. data/tests/models/compute/server_tests.rb +30 -31
  122. data/tests/models/compute/servers_tests.rb +2 -4
  123. data/tests/models/compute/ticket_tests.rb +4 -6
  124. data/tests/models/compute/tickets_tests.rb +1 -3
  125. data/tests/requests/compute/current_time_tests.rb +2 -4
  126. data/tests/requests/compute/folder_destroy_tests.rb +5 -7
  127. data/tests/requests/compute/get_network_tests.rb +20 -23
  128. data/tests/requests/compute/list_child_snapshots_tests.rb +1 -2
  129. data/tests/requests/compute/list_clusters_tests.rb +5 -6
  130. data/tests/requests/compute/list_datastores_tests.rb +6 -7
  131. data/tests/requests/compute/list_hosts_tests.rb +3 -4
  132. data/tests/requests/compute/list_networks_tests.rb +6 -7
  133. data/tests/requests/compute/list_storage_pods_test.rb +3 -4
  134. data/tests/requests/compute/list_virtual_machines_tests.rb +16 -20
  135. data/tests/requests/compute/list_vm_cdroms_tests.rb +1 -2
  136. data/tests/requests/compute/list_vm_snapshots_tests.rb +1 -2
  137. data/tests/requests/compute/modify_vm_cdrom_tests.rb +3 -4
  138. data/tests/requests/compute/revert_to_snapshot_tests.rb +2 -4
  139. data/tests/requests/compute/set_vm_customvalue_tests.rb +0 -2
  140. data/tests/requests/compute/update_vm_tests.rb +13 -0
  141. data/tests/requests/compute/vm_clone_tests.rb +20 -20
  142. data/tests/requests/compute/vm_config_vnc_tests.rb +3 -4
  143. data/tests/requests/compute/vm_destroy_tests.rb +1 -4
  144. data/tests/requests/compute/vm_migrate_tests.rb +1 -2
  145. data/tests/requests/compute/vm_power_off_tests.rb +2 -4
  146. data/tests/requests/compute/vm_power_on_tests.rb +1 -3
  147. data/tests/requests/compute/vm_reboot_tests.rb +2 -4
  148. data/tests/requests/compute/vm_reconfig_cdrom_tests.rb +2 -3
  149. data/tests/requests/compute/vm_reconfig_cpus_tests.rb +1 -3
  150. data/tests/requests/compute/vm_reconfig_hardware_tests.rb +2 -4
  151. data/tests/requests/compute/vm_reconfig_memory_tests.rb +1 -3
  152. data/tests/requests/compute/vm_take_snapshot_tests.rb +1 -3
  153. metadata +9 -4
@@ -5,14 +5,14 @@ module Fog
5
5
  identity :key
6
6
 
7
7
  attribute :filename
8
- attribute :name, :default => "CD-/DVD-ROM Drive"
8
+ attribute :name, default: 'CD-/DVD-ROM Drive'
9
9
  attribute :controller_key
10
10
  attribute :unit_number
11
11
  attribute :start_connected
12
12
  attribute :allow_guest_control
13
13
  attribute :connected
14
14
 
15
- has_one_identity :server, :servers, :aliases => :instance_uuid
15
+ has_one_identity :server, :servers, aliases: :instance_uuid
16
16
 
17
17
  def to_s
18
18
  name
@@ -29,17 +29,17 @@ module Fog
29
29
  requires :instance_uuid
30
30
 
31
31
  if unit_number.nil?
32
- used_unit_numbers = server.cdroms.map { |cdrom| cdrom.unit_number }
32
+ used_unit_numbers = server.cdroms.map(&:unit_number)
33
33
  max_unit_number = used_unit_numbers.max
34
34
 
35
- if max_unit_number > server.cdroms.size
36
- # If the max ID exceeds the number of cdroms, there must be a hole in the range. Find a hole and use it.
37
- self.unit_number = max_unit_number.times.to_a.find { |i| used_unit_numbers.exclude?(i) }
38
- else
39
- self.unit_number = max_unit_number + 1
40
- end
35
+ self.unit_number = if max_unit_number > server.cdroms.size
36
+ # If the max ID exceeds the number of cdroms, there must be a hole in the range. Find a hole and use it.
37
+ max_unit_number.times.to_a.find { |i| used_unit_numbers.exclude?(i) }
38
+ else
39
+ max_unit_number + 1
40
+ end
41
41
  else
42
- if server.cdroms.any? { |cdrom| cdrom.unit_number == self.unit_number && cdrom.id != self.id }
42
+ if server.cdroms.any? { |cdrom| cdrom.unit_number == unit_number && cdrom.id != id }
43
43
  raise "A cdrom already exists with that unit_number, so we can't save the new cdrom"
44
44
  end
45
45
  end
@@ -2,10 +2,10 @@ module Fog
2
2
  module Compute
3
3
  class Vsphere
4
4
  class Cdroms < Fog::Collection
5
- attribute :instance_uuid, :alias => :server_id
5
+ attribute :instance_uuid, alias: :server_id
6
6
  model Fog::Compute::Vsphere::Cdrom
7
7
 
8
- def all(filters = {})
8
+ def all(_filters = {})
9
9
  load service.list_vm_cdroms(instance_uuid)
10
10
  end
11
11
 
@@ -11,36 +11,36 @@ module Fog
11
11
  attribute :overall_status
12
12
  attribute :full_path
13
13
 
14
- def resource_pools(filters = { })
15
- self.attributes[:resource_pools] ||= id.nil? ? [] : service.resource_pools({
16
- :service => service,
17
- :cluster => full_path,
18
- :datacenter => datacenter
19
- }.merge(filters))
14
+ def resource_pools(filters = {})
15
+ attributes[:resource_pools] ||= id.nil? ? [] : service.resource_pools({
16
+ service: service,
17
+ cluster: full_path,
18
+ datacenter: datacenter
19
+ }.merge(filters))
20
20
  end
21
21
 
22
- def datastores(filters = { })
23
- self.attributes[:datastores] ||= id.nil? ? [] : service.datastores({
24
- :service => service,
25
- :cluster => full_path,
26
- :datacenter => datacenter
27
- }.merge(filters))
22
+ def datastores(filters = {})
23
+ attributes[:datastores] ||= id.nil? ? [] : service.datastores({
24
+ service: service,
25
+ cluster: full_path,
26
+ datacenter: datacenter
27
+ }.merge(filters))
28
28
  end
29
29
 
30
- def networks(filters = { })
31
- self.attributes[:networks] ||= id.nil? ? [] : service.networks({
32
- :service => service,
33
- :cluster => full_path,
34
- :datacenter => datacenter
35
- }.merge(filters))
30
+ def networks(filters = {})
31
+ attributes[:networks] ||= id.nil? ? [] : service.networks({
32
+ service: service,
33
+ cluster: full_path,
34
+ datacenter: datacenter
35
+ }.merge(filters))
36
36
  end
37
37
 
38
38
  def rules
39
- service.rules(:datacenter => datacenter, :cluster => full_path)
39
+ service.rules(datacenter: datacenter, cluster: full_path)
40
40
  end
41
41
 
42
42
  def hosts
43
- service.hosts(:datacenter => datacenter, :cluster => full_path)
43
+ service.hosts(datacenter: datacenter, cluster: full_path)
44
44
  end
45
45
 
46
46
  def to_s
@@ -9,7 +9,7 @@ module Fog
9
9
 
10
10
  def all(filters = {})
11
11
  requires :datacenter
12
- load service.list_clusters(filters.merge(:datacenter => datacenter))
12
+ load service.list_clusters(filters.merge(datacenter: datacenter))
13
13
  end
14
14
 
15
15
  def get(id)
@@ -8,13 +8,13 @@ module Fog
8
8
 
9
9
  attr_accessor :vm
10
10
 
11
- def all(filters = {})
12
- load service.list_customfields()
11
+ def all(_filters = {})
12
+ load service.list_customfields
13
13
  end
14
14
 
15
15
  def get(key)
16
- load(service.list_customfields()).find do | cv |
17
- cv.key == ((key.is_a? String) ? key.to_i : key)
16
+ load(service.list_customfields).find do |cv|
17
+ cv.key == (key.is_a? String ? key.to_i : key)
18
18
  end
19
19
  end
20
20
  end
@@ -8,12 +8,12 @@ module Fog
8
8
 
9
9
  attr_accessor :vm
10
10
 
11
- def all(filters = {})
11
+ def all(_filters = {})
12
12
  requires :vm
13
13
  case vm
14
- when Fog::Compute::Vsphere::Server
15
- load service.list_vm_customvalues(vm.id)
16
- else
14
+ when Fog::Compute::Vsphere::Server
15
+ load service.list_vm_customvalues(vm.id)
16
+ else
17
17
  raise 'customvalues should have vm'
18
18
  end
19
19
  end
@@ -21,11 +21,11 @@ module Fog
21
21
  def get(key)
22
22
  requires :vm
23
23
  case vm
24
- when Fog::Compute::Vsphere::Server
25
- load service.list_vm_customvalues(vm.id)
26
- else
24
+ when Fog::Compute::Vsphere::Server
25
+ load service.list_vm_customvalues(vm.id)
26
+ else
27
27
  raise 'customvalues should have vm'
28
- end.find { | cv | cv.key == key }
28
+ end.find { |cv| cv.key == key }
29
29
  end
30
30
  end
31
31
  end
@@ -7,36 +7,36 @@ module Fog
7
7
  attribute :path
8
8
  attribute :status
9
9
 
10
- def clusters filters = { }
11
- service.clusters({ :datacenter => path.join("/") }.merge(filters))
10
+ def clusters(filters = {})
11
+ service.clusters({ datacenter: path.join('/') }.merge(filters))
12
12
  end
13
13
 
14
- def networks filters = { }
15
- service.networks({ :datacenter => path.join("/") }.merge(filters))
14
+ def networks(filters = {})
15
+ service.networks({ datacenter: path.join('/') }.merge(filters))
16
16
  end
17
17
 
18
- def datastores filters = { }
19
- service.datastores({ :datacenter => path.join("/") }.merge(filters))
18
+ def datastores(filters = {})
19
+ service.datastores({ datacenter: path.join('/') }.merge(filters))
20
20
  end
21
21
 
22
- def storage_pods filters = { }
23
- service.storage_pods({ :datacenter => path.join("/") }.merge(filters))
22
+ def storage_pods(filters = {})
23
+ service.storage_pods({ datacenter: path.join('/') }.merge(filters))
24
24
  end
25
25
 
26
- def vm_folders filters = { }
27
- service.folders({ :datacenter => path.join("/"), :type => :vm }.merge(filters))
26
+ def vm_folders(filters = {})
27
+ service.folders({ datacenter: path.join('/'), type: :vm }.merge(filters))
28
28
  end
29
29
 
30
- def virtual_machines filters = {}
31
- service.servers({ :datacenter => path.join("/") }.merge(filters))
30
+ def virtual_machines(filters = {})
31
+ service.servers({ datacenter: path.join('/') }.merge(filters))
32
32
  end
33
33
 
34
- def servertypes filters={}
35
- service.servertypes({:datacenter => name }.merge(filters))
34
+ def servertypes(filters = {})
35
+ service.servertypes({ datacenter: name }.merge(filters))
36
36
  end
37
37
 
38
- def customfields filters = {}
39
- service.customfields({ :datacenter => path.join("/")}.merge(filters))
38
+ def customfields(filters = {})
39
+ service.customfields({ datacenter: path.join('/') }.merge(filters))
40
40
  end
41
41
 
42
42
  def to_s
@@ -8,7 +8,7 @@ module Fog
8
8
  attr_accessor :datacenter, :cluster
9
9
 
10
10
  def all(filters = {})
11
- load service.list_datastores(filters.merge(:datacenter => datacenter, :cluster => cluster))
11
+ load service.list_datastores(filters.merge(datacenter: datacenter, cluster: cluster))
12
12
  end
13
13
 
14
14
  def get(id)
@@ -13,13 +13,13 @@ module Fog
13
13
  # Pass :recursive => true to get a Servers object that searches for VM names recursively
14
14
  def vms(options = {})
15
15
  return [] if type.to_s != 'vm'
16
- service.servers(:folder => path, :datacenter => datacenter, :recursive => options[:recursive])
16
+ service.servers(folder: path, datacenter: datacenter, recursive: options[:recursive])
17
17
  end
18
18
 
19
19
  def to_s
20
20
  name
21
21
  end
22
-
22
+
23
23
  def destroy
24
24
  service.folder_destroy(path, datacenter)
25
25
  end
@@ -7,10 +7,10 @@ module Fog
7
7
  model Fog::Compute::Vsphere::Folder
8
8
  attr_accessor :datacenter, :type, :path
9
9
 
10
- def all(filters = { })
10
+ def all(filters = {})
11
11
  requires :datacenter
12
12
  requires :type
13
- load service.list_folders(filters.merge(:datacenter => datacenter, :type => type, :path => path))
13
+ load service.list_folders(filters.merge(datacenter: datacenter, type: type, path: path))
14
14
  end
15
15
 
16
16
  def get(id)
@@ -7,14 +7,14 @@ module Fog
7
7
 
8
8
  model Fog::Compute::Vsphere::Host
9
9
 
10
- def all(filters = {})
10
+ def all(_filters = {})
11
11
  requires :datacenter, :cluster
12
- load service.list_hosts(:datacenter => datacenter, :cluster => cluster)
12
+ load service.list_hosts(datacenter: datacenter, cluster: cluster)
13
13
  end
14
14
 
15
15
  def get(name)
16
- all.find { |host| host.name == name } or
17
- raise Fog::Compute::Vsphere::NotFound, "no such host #{name}"
16
+ all.find { |host| host.name == name } ||
17
+ raise(Fog::Compute::Vsphere::NotFound, "no such host #{name}")
18
18
  end
19
19
  end
20
20
  end
@@ -5,7 +5,7 @@ module Fog
5
5
  SAVE_MUTEX = Mutex.new
6
6
 
7
7
  identity :mac
8
- alias_method :id, :mac
8
+ alias id mac
9
9
 
10
10
  attribute :network
11
11
  attribute :name
@@ -21,12 +21,12 @@ module Fog
21
21
  # Assign server first to prevent race condition with persisted?
22
22
  self.server_id = attributes.delete(:server_id)
23
23
 
24
- if attributes.key? :type then
25
- if attributes[:type].is_a? String then
26
- attributes[:type] = Fog::Vsphere.class_from_string(attributes[:type], "RbVmomi::VIM")
24
+ if attributes.key? :type
25
+ if attributes[:type].is_a? String
26
+ attributes[:type] = Fog::Vsphere.class_from_string(attributes[:type], 'RbVmomi::VIM')
27
27
  end
28
28
  else
29
- attributes[:type] = Fog::Vsphere.class_from_string("VirtualE1000", "RbVmomi::VIM")
29
+ attributes[:type] = Fog::Vsphere.class_from_string('VirtualE1000', 'RbVmomi::VIM')
30
30
  end
31
31
 
32
32
  super defaults.merge(attributes)
@@ -44,11 +44,11 @@ module Fog
44
44
  def destroy
45
45
  requires :server_id, :key, :type
46
46
 
47
- service.destroy_vm_interface(server_id, :key => key, :type => type)
47
+ service.destroy_vm_interface(server_id, key: key, type: type)
48
48
  end
49
49
 
50
50
  def save
51
- raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
51
+ raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
52
52
  requires :server_id, :type, :network
53
53
 
54
54
  # Our approach of finding the newly created interface is rough. We assume that the :key value always increments
@@ -78,12 +78,12 @@ module Fog
78
78
  private
79
79
 
80
80
  def defaults
81
- default_type=Fog.credentials[:default_nic_type] || RbVmomi::VIM::VirtualE1000
81
+ default_type = Fog.credentials[:default_nic_type] || RbVmomi::VIM::VirtualE1000
82
82
  {
83
- :name=>"Network adapter",
84
- :network=>"VM Network",
85
- :summary=>"VM Network",
86
- :type=> Fog::Vsphere.class_from_string(default_type, "RbVmomi::VIM"),
83
+ name: 'Network adapter',
84
+ network: 'VM Network',
85
+ summary: 'VM Network',
86
+ type: Fog::Vsphere.class_from_string(default_type, 'RbVmomi::VIM')
87
87
  }
88
88
  end
89
89
  end
@@ -8,19 +8,19 @@ module Fog
8
8
 
9
9
  attribute :server_id
10
10
 
11
- def all(filters = {})
11
+ def all(_filters = {})
12
12
  requires :server_id
13
13
 
14
14
  case server
15
- when Fog::Compute::Vsphere::Server
16
- load service.list_vm_interfaces(server.id)
17
- when Fog::Compute::Vsphere::Template
18
- load service.list_template_interfaces(server.id)
19
- else
15
+ when Fog::Compute::Vsphere::Server
16
+ load service.list_vm_interfaces(server.id)
17
+ when Fog::Compute::Vsphere::Template
18
+ load service.list_template_interfaces(server.id)
19
+ else
20
20
  raise 'interfaces should have vm or template'
21
21
  end
22
22
 
23
- self.each { |interface| interface.server_id = server.id }
23
+ each { |interface| interface.server_id = server.id }
24
24
  self
25
25
  end
26
26
 
@@ -28,25 +28,23 @@ module Fog
28
28
  requires :server_id
29
29
 
30
30
  case server
31
- when Fog::Compute::Vsphere::Server
32
- interface = service.get_vm_interface(server.id, :key => id, :mac=> id, :name => id)
33
- when Fog::Compute::Vsphere::Template
34
- interface = service.get_template_interfaces(server.id, :key => id, :mac=> id, :name => id)
35
- else
31
+ when Fog::Compute::Vsphere::Server
32
+ interface = service.get_vm_interface(server.id, key: id, mac: id, name: id)
33
+ when Fog::Compute::Vsphere::Template
34
+ interface = service.get_template_interfaces(server.id, key: id, mac: id, name: id)
35
+ else
36
36
 
37
37
  raise 'interfaces should have vm or template'
38
38
  end
39
39
 
40
40
  if interface
41
- Fog::Compute::Vsphere::Interface.new(interface.merge(:server_id => server.id, :service => service))
42
- else
43
- nil
41
+ Fog::Compute::Vsphere::Interface.new(interface.merge(server_id: server.id, service: service))
44
42
  end
45
43
  end
46
44
 
47
45
  def new(attributes = {})
48
46
  if server_id
49
- super({ :server_id => server_id }.merge(attributes))
47
+ super({ server_id: server_id }.merge(attributes))
50
48
  else
51
49
  super
52
50
  end
@@ -4,12 +4,12 @@ module Fog
4
4
  class Interfacetype < Fog::Model
5
5
  identity :id
6
6
 
7
- # attribute :class
7
+ # attribute :class
8
8
  attribute :name
9
9
  attribute :datacenter
10
10
  attribute :servertype
11
11
 
12
- def initialize(attributes={} )
12
+ def initialize(attributes = {})
13
13
  super attributes
14
14
  end
15
15
 
@@ -8,16 +8,14 @@ module Fog
8
8
  attr_accessor :datacenter
9
9
  attr_accessor :servertype
10
10
 
11
- def all(filters = { })
11
+ def all(filters = {})
12
12
  requires :servertype
13
13
  case servertype
14
- when Fog::Compute::Vsphere::Servertype
15
- load service.list_interface_types(filters.merge({
16
- :datacenter => datacenter,
17
- :servertype => servertype.id
18
- }))
19
- else
20
- raise 'interfacetypes should have a servertype'
14
+ when Fog::Compute::Vsphere::Servertype
15
+ load service.list_interface_types(filters.merge(datacenter: datacenter,
16
+ servertype: servertype.id))
17
+ else
18
+ raise 'interfacetypes should have a servertype'
21
19
  end
22
20
  end
23
21