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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87c94e63f2cec168825d797d960e7e0ef3adefb02687c4007b56451ae07666e7
4
- data.tar.gz: 2ea05f4bf6f0fc3043d7d2f9d6323edbf82a5727c07de80ceefb7177157cf6e8
3
+ metadata.gz: 50674c6fa7d5ee252ada84a587b3321aa1eea6fcfdc39b6a7d4024f6aca1ff2b
4
+ data.tar.gz: 8ff973afd99e08033368d76e7907d5944c5cecaa5c221dcb6d967616ea30e5af
5
5
  SHA512:
6
- metadata.gz: ec3396a601b88ac91360e8afd0abfee1396f2c20ce99c78eb26ad8689da89f408f74cd4333d9c1c29642189319eebd4175cfd47a376bac3bd93aafae718ec82e
7
- data.tar.gz: 4ceb831473e95b93a2fc8e837e87403b717c4cc91be0d80eed77ab479e37703c2a1a2024ba685744a03014df2cd89b6f9a66eeaf9eead273b47e4e2eedc5754f
6
+ metadata.gz: a463bfaf886fadb3e0944aefdc7b5a93e2345d7183ccd0862a52ff735be9251e29d323d9baab700f86c9815452d66e8052149f577177d4bd6b253871480e746c
7
+ data.tar.gz: bb5a1ec93db10d8f59424cf0deb625a3add86471a5eecec6b81be885d738003617fd54386c5dd423c876b2afaae7f30fdb48fe11e7096fad8f47c2f2dc265aa8
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.0
6
+
7
+ Style/Documentation:
8
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,217 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-04-18 16:02:28 +0200 using RuboCop version 0.50.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 4
10
+ # Configuration parameters: AllowSafeAssignment.
11
+ Lint/AssignmentInCondition:
12
+ Exclude:
13
+ - 'lib/fog/vsphere/requests/compute/create_vm.rb'
14
+ - 'lib/fog/vsphere/requests/compute/vm_clone.rb'
15
+
16
+ # Offense count: 7
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
19
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
20
+ Lint/EndAlignment:
21
+ Exclude:
22
+ - 'lib/fog/vsphere/models/compute/customfields.rb'
23
+ - 'lib/fog/vsphere/models/compute/customvalues.rb'
24
+ - 'lib/fog/vsphere/models/compute/tickets.rb'
25
+ - 'lib/fog/vsphere/models/compute/volumes.rb'
26
+ - 'lib/fog/vsphere/requests/compute/create_vm.rb'
27
+ - 'lib/fog/vsphere/requests/compute/host_start_maintenance.rb'
28
+
29
+ # Offense count: 2
30
+ Lint/InterpolationCheck:
31
+ Exclude:
32
+ - 'tests/requests/compute/vm_power_off_tests.rb'
33
+ - 'tests/requests/compute/vm_suspend_tests.rb'
34
+
35
+ # Offense count: 13
36
+ Lint/RescueWithoutErrorClass:
37
+ Exclude:
38
+ - 'lib/fog/vsphere/compute.rb'
39
+ - 'lib/fog/vsphere/requests/compute/list_hosts.rb'
40
+ - 'lib/fog/vsphere/requests/compute/list_vm_cdroms.rb'
41
+ - 'lib/fog/vsphere/requests/compute/list_vm_volumes.rb'
42
+
43
+ # Offense count: 3
44
+ Lint/ShadowingOuterLocalVariable:
45
+ Exclude:
46
+ - 'lib/fog/vsphere/requests/compute/create_vm.rb'
47
+ - 'lib/fog/vsphere/requests/compute/destroy_rule.rb'
48
+ - 'lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb'
49
+
50
+ # Offense count: 9
51
+ Lint/UselessAssignment:
52
+ Exclude:
53
+ - 'lib/fog/vsphere/compute.rb'
54
+ - 'lib/fog/vsphere/models/compute/interfaces.rb'
55
+ - 'lib/fog/vsphere/models/compute/volumes.rb'
56
+ - 'lib/fog/vsphere/requests/compute/create_rule.rb'
57
+ - 'lib/fog/vsphere/requests/compute/create_vm.rb'
58
+ - 'lib/fog/vsphere/requests/compute/get_interface_type.rb'
59
+ - 'lib/fog/vsphere/requests/compute/vm_clone.rb'
60
+ - 'lib/fog/vsphere/requests/compute/vm_migrate.rb'
61
+ - 'tests/requests/compute/vm_clone_tests.rb'
62
+
63
+ # Offense count: 57
64
+ Metrics/AbcSize:
65
+ Max: 633
66
+
67
+ # Offense count: 12
68
+ # Configuration parameters: CountComments, ExcludedMethods.
69
+ Metrics/BlockLength:
70
+ Max: 263
71
+
72
+ # Offense count: 21
73
+ # Configuration parameters: CountBlocks.
74
+ Metrics/BlockNesting:
75
+ Max: 5
76
+
77
+ # Offense count: 6
78
+ # Configuration parameters: CountComments.
79
+ Metrics/ClassLength:
80
+ Max: 452
81
+
82
+ # Offense count: 15
83
+ Metrics/CyclomaticComplexity:
84
+ Max: 150
85
+
86
+ # Offense count: 16
87
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
88
+ # URISchemes: http, https
89
+ Metrics/LineLength:
90
+ Max: 317
91
+
92
+ # Offense count: 72
93
+ # Configuration parameters: CountComments.
94
+ Metrics/MethodLength:
95
+ Max: 356
96
+
97
+ # Offense count: 1
98
+ # Configuration parameters: CountComments.
99
+ Metrics/ModuleLength:
100
+ Max: 109
101
+
102
+ # Offense count: 2
103
+ # Configuration parameters: CountKeywordArgs.
104
+ Metrics/ParameterLists:
105
+ Max: 6
106
+
107
+ # Offense count: 16
108
+ Metrics/PerceivedComplexity:
109
+ Max: 158
110
+
111
+ # Offense count: 1
112
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
113
+ # NamePrefix: is_, has_, have_
114
+ # NamePrefixBlacklist: is_, has_, have_
115
+ # NameWhitelist: is_a?
116
+ Naming/PredicateName:
117
+ Exclude:
118
+ - 'spec/**/*'
119
+ - 'lib/fog/vsphere/compute.rb'
120
+
121
+ # Offense count: 15
122
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
123
+ # SupportedStyles: snake_case, camelCase
124
+ Naming/VariableName:
125
+ Exclude:
126
+ - 'lib/fog/vsphere/requests/compute/create_vm.rb'
127
+ - 'lib/fog/vsphere/requests/compute/list_datacenters.rb'
128
+ - 'lib/fog/vsphere/requests/compute/list_resource_pools.rb'
129
+ - 'lib/fog/vsphere/requests/compute/list_server_types.rb'
130
+ - 'lib/fog/vsphere/requests/compute/vm_clone.rb'
131
+ - 'tests/compute_tests.rb'
132
+
133
+ # Offense count: 10
134
+ Style/CaseEquality:
135
+ Exclude:
136
+ - 'lib/fog/vsphere/requests/compute/list_child_snapshots.rb'
137
+ - 'lib/fog/vsphere/requests/compute/revert_to_snapshot.rb'
138
+ - 'tests/requests/compute/list_child_snapshots_tests.rb'
139
+ - 'tests/requests/compute/list_datastores_tests.rb'
140
+ - 'tests/requests/compute/list_hosts_tests.rb'
141
+ - 'tests/requests/compute/list_networks_tests.rb'
142
+ - 'tests/requests/compute/list_vm_cdroms_tests.rb'
143
+ - 'tests/requests/compute/list_vm_snapshots_tests.rb'
144
+
145
+ # Offense count: 1
146
+ Style/ClassVars:
147
+ Exclude:
148
+ - 'lib/fog/bin/vsphere.rb'
149
+
150
+ # Offense count: 1
151
+ Style/DoubleNegation:
152
+ Exclude:
153
+ - 'tests/helpers/succeeds_helper.rb'
154
+
155
+ # Offense count: 12
156
+ # Configuration parameters: MinBodyLength.
157
+ Style/GuardClause:
158
+ Exclude:
159
+ - 'lib/fog/vsphere/compute.rb'
160
+ - 'lib/fog/vsphere/models/compute/interfaces.rb'
161
+ - 'lib/fog/vsphere/models/compute/rule.rb'
162
+ - 'lib/fog/vsphere/models/compute/server.rb'
163
+ - 'lib/fog/vsphere/requests/compute/create_group.rb'
164
+ - 'lib/fog/vsphere/requests/compute/create_rule.rb'
165
+ - 'lib/fog/vsphere/requests/compute/create_vm.rb'
166
+ - 'lib/fog/vsphere/requests/compute/list_resource_pools.rb'
167
+ - 'lib/fog/vsphere/requests/compute/list_server_types.rb'
168
+
169
+ # Offense count: 2
170
+ Style/IfInsideElse:
171
+ Exclude:
172
+ - 'lib/fog/vsphere/models/compute/cdrom.rb'
173
+ - 'lib/fog/vsphere/models/compute/volume.rb'
174
+
175
+ # Offense count: 2
176
+ Style/MultilineBlockChain:
177
+ Exclude:
178
+ - 'lib/fog/vsphere/requests/compute/vm_clone.rb'
179
+
180
+ # Offense count: 4
181
+ Style/MultilineTernaryOperator:
182
+ Exclude:
183
+ - 'lib/fog/vsphere/models/compute/cluster.rb'
184
+ - 'lib/fog/vsphere/requests/compute/list_child_snapshots.rb'
185
+
186
+ # Offense count: 1
187
+ # Cop supports --auto-correct.
188
+ # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
189
+ # SupportedStyles: predicate, comparison
190
+ Style/NumericPredicate:
191
+ Exclude:
192
+ - 'spec/**/*'
193
+ - 'lib/fog/vsphere/requests/compute/list_compute_resources.rb'
194
+
195
+ # Offense count: 1
196
+ # Cop supports --auto-correct.
197
+ # Configuration parameters: PreferredDelimiters.
198
+ Style/PercentLiteralDelimiters:
199
+ Exclude:
200
+ - 'Rakefile'
201
+
202
+ # Offense count: 3
203
+ # Cop supports --auto-correct.
204
+ # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
205
+ # SupportedStyles: slashes, percent_r, mixed
206
+ Style/RegexpLiteral:
207
+ Exclude:
208
+ - 'lib/fog/vsphere/requests/compute/create_folder.rb'
209
+ - 'lib/fog/vsphere/requests/compute/get_folder.rb'
210
+ - 'lib/fog/vsphere/requests/compute/list_resource_pools.rb'
211
+
212
+ # Offense count: 1
213
+ # Cop supports --auto-correct.
214
+ # Configuration parameters: AllowAsExpressionSeparator.
215
+ Style/Semicolon:
216
+ Exclude:
217
+ - 'tests/models/compute/rules_tests.rb'
data/.travis.yml CHANGED
@@ -18,6 +18,7 @@ matrix:
18
18
  gemfile: Gemfile
19
19
  - rvm: jruby-head
20
20
  gemfile: Gemfile
21
+ script: bundle exec rake travis:ci
21
22
  notifications:
22
23
  email: false
23
24
  addons:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v2.2.0
2
+ * vm interface updating needs a datacenter as option (#140)
3
+ * improve vm saving to use a single api call and support network changes (#142)
4
+
1
5
  ## v2.1.1
2
6
  * fixes an issue where networks of type DVPort cannot be listed (#137)
3
7
 
data/Rakefile CHANGED
@@ -1,8 +1,17 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rubocop/rake_task'
3
+
4
+ desc 'Run Ruby style checks'
5
+ RuboCop::RakeTask.new(:style)
6
+
7
+ namespace :travis do
8
+ desc 'Run tests on Travis'
9
+ task ci: %w(style test)
10
+ end
2
11
 
3
12
  mock = ENV['FOG_MOCK'] || 'true'
4
13
  task :test do
5
14
  sh("export FOG_MOCK=#{mock} && bundle exec shindont")
6
15
  end
7
16
 
8
- task(:default => [:test])
17
+ task(default: [:test])
data/fog-vsphere.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'fog/vsphere/version'
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'pry', '~> 0.10'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'minitest', '~> 5.8'
31
- spec.add_development_dependency 'rubocop', '~> 0.34'
31
+ spec.add_development_dependency 'rubocop', '~> 0.50.0'
32
32
  spec.add_development_dependency 'shindo', '~> 0.3'
33
33
  end
@@ -13,7 +13,7 @@ class Vsphere < Fog::Bin
13
13
  @@connections ||= Hash.new do |hash, key|
14
14
  hash[key] = case key
15
15
  when :compute
16
- Fog::Compute.new(:provider => 'Vsphere')
16
+ Fog::Compute.new(provider: 'Vsphere')
17
17
  else
18
18
  raise ArgumentError, "Unrecognized service: #{key.inspect}"
19
19
  end
@@ -83,6 +83,7 @@ module Fog
83
83
  request :get_folder
84
84
  request :list_folders
85
85
  request :create_vm
86
+ request :update_vm
86
87
  request :list_vm_interfaces
87
88
  request :modify_vm_interface
88
89
  request :modify_vm_volume
@@ -140,33 +141,33 @@ module Fog
140
141
  protected
141
142
 
142
143
  ATTR_TO_PROP = {
143
- :id => 'config.instanceUuid',
144
- :name => 'name',
145
- :uuid => 'config.uuid',
146
- :template => 'config.template',
147
- :parent => 'parent',
148
- :hostname => 'summary.guest.hostName',
149
- :operatingsystem => 'summary.guest.guestFullName',
150
- :ipaddress => 'guest.ipAddress',
151
- :power_state => 'runtime.powerState',
152
- :connection_state => 'runtime.connectionState',
153
- :hypervisor => 'runtime.host',
154
- :tools_state => 'guest.toolsStatus',
155
- :tools_version => 'guest.toolsVersionStatus',
156
- :memory_mb => 'config.hardware.memoryMB',
157
- :cpus => 'config.hardware.numCPU',
158
- :corespersocket => 'config.hardware.numCoresPerSocket',
159
- :overall_status => 'overallStatus',
160
- :guest_id => 'config.guestId',
161
- :hardware_version => 'config.version',
162
- :cpuHotAddEnabled => 'config.cpuHotAddEnabled',
163
- :memoryHotAddEnabled => 'config.memoryHotAddEnabled',
164
- :firmware => 'config.firmware',
165
- :annotation => 'config.annotation',
166
- }
144
+ id: 'config.instanceUuid',
145
+ name: 'name',
146
+ uuid: 'config.uuid',
147
+ template: 'config.template',
148
+ parent: 'parent',
149
+ hostname: 'summary.guest.hostName',
150
+ operatingsystem: 'summary.guest.guestFullName',
151
+ ipaddress: 'guest.ipAddress',
152
+ power_state: 'runtime.powerState',
153
+ connection_state: 'runtime.connectionState',
154
+ hypervisor: 'runtime.host',
155
+ tools_state: 'guest.toolsStatus',
156
+ tools_version: 'guest.toolsVersionStatus',
157
+ memory_mb: 'config.hardware.memoryMB',
158
+ cpus: 'config.hardware.numCPU',
159
+ corespersocket: 'config.hardware.numCoresPerSocket',
160
+ overall_status: 'overallStatus',
161
+ guest_id: 'config.guestId',
162
+ hardware_version: 'config.version',
163
+ cpuHotAddEnabled: 'config.cpuHotAddEnabled',
164
+ memoryHotAddEnabled: 'config.memoryHotAddEnabled',
165
+ firmware: 'config.firmware',
166
+ annotation: 'config.annotation'
167
+ }.freeze
167
168
 
168
169
  def convert_vm_view_to_attr_hash(vms)
169
- vms = connection.serviceContent.propertyCollector.collectMultiple(vms,*ATTR_TO_PROP.values.uniq)
170
+ vms = connection.serviceContent.propertyCollector.collectMultiple(vms, *ATTR_TO_PROP.values.uniq)
170
171
  vms.map { |vm| props_to_attr_hash(*vm) }
171
172
  end
172
173
 
@@ -181,7 +182,7 @@ module Fog
181
182
  props_to_attr_hash vm_mob_ref, props
182
183
  end
183
184
 
184
- def props_to_attr_hash vm_mob_ref, props
185
+ def props_to_attr_hash(vm_mob_ref, props)
185
186
  # NOTE: Object.tap is in 1.8.7 and later.
186
187
  # Here we create the hash object that this method returns, but first we need
187
188
  # to add a few more attributes that require additional calls to the vSphere
@@ -190,47 +191,82 @@ module Fog
190
191
  #
191
192
  # The use of the "tap" method here is a convenience, it allows us to update the
192
193
  # hash object without explicitly returning the hash at the end of the method.
193
- Hash[ATTR_TO_PROP.map { |k,v| [k.to_s, props[v]] }].tap do |attrs|
194
+ Hash[ATTR_TO_PROP.map { |k, v| [k.to_s, props[v]] }].tap do |attrs|
194
195
  attrs['id'] ||= vm_mob_ref._ref
195
196
  attrs['mo_ref'] = vm_mob_ref._ref
196
197
  # The name method "magically" appears after a VM is ready and
197
198
  # finished cloning.
198
- if attrs['hypervisor'].kind_of?(RbVmomi::VIM::HostSystem)
199
+ if attrs['hypervisor'].is_a?(RbVmomi::VIM::HostSystem)
199
200
  host = attrs['hypervisor']
200
- attrs['datacenter'] = Proc.new { parent_attribute(host.path, :datacenter)[1] rescue nil }
201
- attrs['cluster'] = Proc.new { parent_attribute(host.path, :cluster)[1] rescue nil }
202
- attrs['hypervisor'] = Proc.new { host.name rescue nil }
203
- attrs['resource_pool'] = Proc.new {(vm_mob_ref.resourcePool || host.resourcePool).name rescue nil}
201
+ attrs['datacenter'] = proc {
202
+ begin
203
+ parent_attribute(host.path, :datacenter)[1]
204
+ rescue
205
+ nil
206
+ end
207
+ }
208
+ attrs['cluster'] = proc {
209
+ begin
210
+ parent_attribute(host.path, :cluster)[1]
211
+ rescue
212
+ nil
213
+ end
214
+ }
215
+ attrs['hypervisor'] = proc {
216
+ begin
217
+ host.name
218
+ rescue
219
+ nil
220
+ end
221
+ }
222
+ attrs['resource_pool'] = proc {
223
+ begin
224
+ (vm_mob_ref.resourcePool || host.resourcePool).name
225
+ rescue
226
+ nil
227
+ end
228
+ }
204
229
  end
205
230
  # This inline rescue catches any standard error. While a VM is
206
231
  # cloning, a call to the macs method will throw and NoMethodError
207
- attrs['mac_addresses'] = Proc.new {vm_mob_ref.macs rescue nil}
232
+ attrs['mac_addresses'] = proc {
233
+ begin
234
+ vm_mob_ref.macs
235
+ rescue
236
+ nil
237
+ end
238
+ }
208
239
  # Rescue nil to catch testing while vm_mob_ref isn't reaL??
209
- attrs['path'] = "/"+attrs['parent'].path.map(&:last).join('/') rescue nil
240
+ attrs['path'] = begin
241
+ '/' + attrs['parent'].path.map(&:last).join('/')
242
+ rescue
243
+ nil
244
+ end
210
245
  end
211
246
  end
247
+
212
248
  # returns the parent object based on a type
213
249
  # provides both real RbVmomi object and its name.
214
250
  # e.g.
215
- #[Datacenter("datacenter-2"), "dc-name"]
216
- def parent_attribute path, type
251
+ # [Datacenter("datacenter-2"), "dc-name"]
252
+ def parent_attribute(path, type)
217
253
  element = case type
218
- when :datacenter
219
- RbVmomi::VIM::Datacenter
220
- when :cluster
221
- RbVmomi::VIM::ClusterComputeResource
222
- when :host
223
- RbVmomi::VIM::HostSystem
224
- else
225
- raise "Unknown type"
254
+ when :datacenter
255
+ RbVmomi::VIM::Datacenter
256
+ when :cluster
257
+ RbVmomi::VIM::ClusterComputeResource
258
+ when :host
259
+ RbVmomi::VIM::HostSystem
260
+ else
261
+ raise 'Unknown type'
226
262
  end
227
- path.select {|x| x[0].is_a? element}.flatten
263
+ path.select { |x| x[0].is_a? element }.flatten
228
264
  rescue
229
265
  nil
230
266
  end
231
267
 
232
268
  # returns vmware managed obj id string
233
- def managed_obj_id obj
269
+ def managed_obj_id(obj)
234
270
  obj.to_s.match(/\("([^"]+)"\)/)[1]
235
271
  end
236
272
 
@@ -245,174 +281,171 @@ module Fog
245
281
  def self.data
246
282
  @data ||= Hash.new do |hash, key|
247
283
  hash[key] = {
248
- :servers => {
249
- "5032c8a5-9c5e-ba7a-3804-832a03e16381" => {
250
- "resource_pool" => "Resources",
251
- "memory_mb" => 2196,
252
- "mac_addresses" => { "Network adapter 1" => "00:50:56:a9:00:28" },
253
- "power_state" => "poweredOn",
254
- "cpus" => 1,
255
- "hostname" => "dhcp75-197.virt.bos.redhat.com",
256
- "mo_ref" => "vm-562",
257
- "connection_state" => "connected",
258
- "overall_status" => "green",
259
- "datacenter" => "Solutions",
260
- "volumes" =>
284
+ servers: {
285
+ '5032c8a5-9c5e-ba7a-3804-832a03e16381' => {
286
+ 'resource_pool' => 'Resources',
287
+ 'memory_mb' => 2196,
288
+ 'mac_addresses' => { 'Network adapter 1' => '00:50:56:a9:00:28' },
289
+ 'power_state' => 'poweredOn',
290
+ 'cpus' => 1,
291
+ 'hostname' => 'dhcp75-197.virt.bos.redhat.com',
292
+ 'mo_ref' => 'vm-562',
293
+ 'connection_state' => 'connected',
294
+ 'overall_status' => 'green',
295
+ 'datacenter' => 'Solutions',
296
+ 'volumes' =>
261
297
  [{
262
- "id" => "6000C29c-a47d-4cd9-5249-c371de775f06",
263
- "datastore" => "Storage1",
264
- "mode" => "persistent",
265
- "size" => 8388608,
266
- "thin" => true,
267
- "name" => "Hard disk 1",
268
- "filename" => "[Storage1] rhel6-mfojtik/rhel6-mfojtik.vmdk",
269
- "size_gb" => 8
270
- }],
271
- "scsi_controllers" =>
272
- [{"shared_bus" => "noSharing",
273
- "type" => "VirtualLsiLogicController",
274
- "unit_number" => 7,
275
- "key" => 1000
298
+ 'id' => '6000C29c-a47d-4cd9-5249-c371de775f06',
299
+ 'datastore' => 'Storage1',
300
+ 'mode' => 'persistent',
301
+ 'size' => 8_388_608,
302
+ 'thin' => true,
303
+ 'name' => 'Hard disk 1',
304
+ 'filename' => '[Storage1] rhel6-mfojtik/rhel6-mfojtik.vmdk',
305
+ 'size_gb' => 8
276
306
  }],
277
- "interfaces" =>
278
- [{"mac" => "00:50:56:a9:00:28",
279
- "network" => "dvportgroup-123456",
280
- "name" => "Network adapter 1",
281
- "status" => "ok",
282
- "summary" => "VM Network",
283
- }],
284
- "cdroms" =>
307
+ 'scsi_controllers' =>
308
+ [{ 'shared_bus' => 'noSharing',
309
+ 'type' => 'VirtualLsiLogicController',
310
+ 'unit_number' => 7,
311
+ 'key' => 1000 }],
312
+ 'interfaces' =>
313
+ [{ 'mac' => '00:50:56:a9:00:28',
314
+ 'network' => 'dvportgroup-123456',
315
+ 'name' => 'Network adapter 1',
316
+ 'status' => 'ok',
317
+ 'summary' => 'VM Network' }],
318
+ 'cdroms' =>
285
319
  [{
286
- "name" => "CD-/DVD-Drive 1",
287
- "filename" => nil,
288
- "key" => 3000,
289
- "controller_key" => 200,
290
- "unit_number" => 0,
291
- "start_connected" => false,
292
- "allow_guest_control" => true,
293
- "connected" => false,
294
- }],
295
- "hypervisor" => "gunab.puppetlabs.lan",
296
- "guest_id" => "rhel6_64Guest",
297
- "tools_state" => "toolsOk",
298
- "cluster" => "Solutionscluster",
299
- "name" => "rhel64",
300
- "operatingsystem" => "Red Hat Enterprise Linux 6 (64-bit)",
301
- "path" => "/Datacenters/Solutions/vm",
302
- "uuid" => "4229f0e9-bfdc-d9a7-7bac-12070772e6dc",
303
- "instance_uuid" => "5032c8a5-9c5e-ba7a-3804-832a03e16381",
304
- "id" => "5032c8a5-9c5e-ba7a-3804-832a03e16381",
305
- "tools_version" => "guestToolsUnmanaged",
306
- "ipaddress" => "192.168.100.184",
307
- "template" => false
308
- },
309
- "502916a3-b42e-17c7-43ce-b3206e9524dc" => {
310
- "resource_pool" => "Resources",
311
- "memory_mb" => 512,
312
- "power_state" => "poweredOn",
313
- "mac_addresses" => { "Network adapter 1" => "00:50:56:a9:00:00" },
314
- "hostname" => nil,
315
- "cpus" => 1,
316
- "connection_state" => "connected",
317
- "mo_ref" => "vm-621",
318
- "overall_status" => "green",
319
- "datacenter" => "Solutions",
320
- "volumes" =>
321
- [{"thin" => false,
322
- "size_gb" => 10,
323
- "datastore" => "datastore1",
324
- "filename" => "[datastore1] i-1342439683/i-1342439683.vmdk",
325
- "size" => 10485762,
326
- "name" => "Hard disk 1",
327
- "mode" => "persistent",
328
- "id" => "6000C29b-f364-d073-8316-8e98ac0a0eae" }],
329
- "scsi_controllers" =>
330
- [{"shared_bus" => "noSharing",
331
- "type" => "VirtualLsiLogicController",
332
- "unit_number" => 7,
333
- "key" => 1000
320
+ 'name' => 'CD-/DVD-Drive 1',
321
+ 'filename' => nil,
322
+ 'key' => 3000,
323
+ 'controller_key' => 200,
324
+ 'unit_number' => 0,
325
+ 'start_connected' => false,
326
+ 'allow_guest_control' => true,
327
+ 'connected' => false
334
328
  }],
335
- "interfaces" =>
336
- [{ "summary" => "VM Network",
337
- "mac" => "00:50:56:a9:00:00",
338
- "status" => "ok",
339
- "network" => "dvportgroup-123456",
340
- "name" => "Network adapter 1" }],
341
- "hypervisor" => "gunab.puppetlabs.lan",
342
- "guest_id" => nil,
343
- "cluster" => "Solutionscluster",
344
- "tools_state" => "toolsNotInstalled",
345
- "name" => "i-1342439683",
346
- "operatingsystem" => nil,
347
- "path" => "/",
348
- "tools_version" => "guestToolsNotInstalled",
349
- "uuid" => "4229e0de-30cb-ceb2-21f9-4d8d8beabb52",
350
- "instance_uuid" => "502916a3-b42e-17c7-43ce-b3206e9524dc",
351
- "id" => "502916a3-b42e-17c7-43ce-b3206e9524dc",
352
- "ipaddress" => nil,
353
- "template" => false
329
+ 'hypervisor' => 'gunab.puppetlabs.lan',
330
+ 'guest_id' => 'rhel6_64Guest',
331
+ 'tools_state' => 'toolsOk',
332
+ 'cluster' => 'Solutionscluster',
333
+ 'name' => 'rhel64',
334
+ 'operatingsystem' => 'Red Hat Enterprise Linux 6 (64-bit)',
335
+ 'path' => '/Datacenters/Solutions/vm',
336
+ 'uuid' => '4229f0e9-bfdc-d9a7-7bac-12070772e6dc',
337
+ 'instance_uuid' => '5032c8a5-9c5e-ba7a-3804-832a03e16381',
338
+ 'id' => '5032c8a5-9c5e-ba7a-3804-832a03e16381',
339
+ 'tools_version' => 'guestToolsUnmanaged',
340
+ 'ipaddress' => '192.168.100.184',
341
+ 'template' => false
354
342
  },
355
- "5029c440-85ee-c2a1-e9dd-b63e39364603" => {
356
- "resource_pool" => "Resources",
357
- "memory_mb" => 2196,
358
- "power_state" => "poweredOn",
359
- "mac_addresses" => { "Network adapter 1" => "00:50:56:b2:00:af" },
360
- "hostname" => "centos56gm.localdomain",
361
- "cpus" => 1,
362
- "connection_state" => "connected",
363
- "mo_ref" => "vm-715",
364
- "overall_status" => "green",
365
- "datacenter" => "Solutions",
366
- "hypervisor" => "gunab.puppetlabs.lan",
367
- "guest_id" => "rhel6_64Guest",
368
- "cluster" => "Solutionscluster",
369
- "tools_state" => "toolsOk",
370
- "name" => "jefftest",
371
- "operatingsystem" => "Red Hat Enterprise Linux 6 (64-bit)",
372
- "path" => "/Solutions/wibble",
373
- "tools_version" => "guestToolsUnmanaged",
374
- "ipaddress" => "192.168.100.187",
375
- "uuid" => "42329da7-e8ab-29ec-1892-d6a4a964912a",
376
- "instance_uuid" => "5029c440-85ee-c2a1-e9dd-b63e39364603",
377
- "id" => "5029c440-85ee-c2a1-e9dd-b63e39364603",
378
- "template" => false
343
+ '502916a3-b42e-17c7-43ce-b3206e9524dc' => {
344
+ 'resource_pool' => 'Resources',
345
+ 'memory_mb' => 512,
346
+ 'power_state' => 'poweredOn',
347
+ 'mac_addresses' => { 'Network adapter 1' => '00:50:56:a9:00:00' },
348
+ 'hostname' => nil,
349
+ 'cpus' => 1,
350
+ 'connection_state' => 'connected',
351
+ 'mo_ref' => 'vm-621',
352
+ 'overall_status' => 'green',
353
+ 'datacenter' => 'Solutions',
354
+ 'volumes' =>
355
+ [{ 'thin' => false,
356
+ 'size_gb' => 10,
357
+ 'datastore' => 'datastore1',
358
+ 'filename' => '[datastore1] i-1342439683/i-1342439683.vmdk',
359
+ 'size' => 10_485_762,
360
+ 'name' => 'Hard disk 1',
361
+ 'mode' => 'persistent',
362
+ 'id' => '6000C29b-f364-d073-8316-8e98ac0a0eae' }],
363
+ 'scsi_controllers' =>
364
+ [{ 'shared_bus' => 'noSharing',
365
+ 'type' => 'VirtualLsiLogicController',
366
+ 'unit_number' => 7,
367
+ 'key' => 1000 }],
368
+ 'interfaces' =>
369
+ [{ 'summary' => 'VM Network',
370
+ 'mac' => '00:50:56:a9:00:00',
371
+ 'status' => 'ok',
372
+ 'network' => 'dvportgroup-123456',
373
+ 'name' => 'Network adapter 1' }],
374
+ 'hypervisor' => 'gunab.puppetlabs.lan',
375
+ 'guest_id' => nil,
376
+ 'cluster' => 'Solutionscluster',
377
+ 'tools_state' => 'toolsNotInstalled',
378
+ 'name' => 'i-1342439683',
379
+ 'operatingsystem' => nil,
380
+ 'path' => '/',
381
+ 'tools_version' => 'guestToolsNotInstalled',
382
+ 'uuid' => '4229e0de-30cb-ceb2-21f9-4d8d8beabb52',
383
+ 'instance_uuid' => '502916a3-b42e-17c7-43ce-b3206e9524dc',
384
+ 'id' => '502916a3-b42e-17c7-43ce-b3206e9524dc',
385
+ 'ipaddress' => nil,
386
+ 'template' => false
387
+ },
388
+ '5029c440-85ee-c2a1-e9dd-b63e39364603' => {
389
+ 'resource_pool' => 'Resources',
390
+ 'memory_mb' => 2196,
391
+ 'power_state' => 'poweredOn',
392
+ 'mac_addresses' => { 'Network adapter 1' => '00:50:56:b2:00:af' },
393
+ 'hostname' => 'centos56gm.localdomain',
394
+ 'cpus' => 1,
395
+ 'connection_state' => 'connected',
396
+ 'mo_ref' => 'vm-715',
397
+ 'overall_status' => 'green',
398
+ 'datacenter' => 'Solutions',
399
+ 'hypervisor' => 'gunab.puppetlabs.lan',
400
+ 'guest_id' => 'rhel6_64Guest',
401
+ 'cluster' => 'Solutionscluster',
402
+ 'tools_state' => 'toolsOk',
403
+ 'name' => 'jefftest',
404
+ 'operatingsystem' => 'Red Hat Enterprise Linux 6 (64-bit)',
405
+ 'path' => '/Solutions/wibble',
406
+ 'tools_version' => 'guestToolsUnmanaged',
407
+ 'ipaddress' => '192.168.100.187',
408
+ 'uuid' => '42329da7-e8ab-29ec-1892-d6a4a964912a',
409
+ 'instance_uuid' => '5029c440-85ee-c2a1-e9dd-b63e39364603',
410
+ 'id' => '5029c440-85ee-c2a1-e9dd-b63e39364603',
411
+ 'template' => false
379
412
  }
380
413
  },
381
- :datacenters => {
382
- "Solutions" => {:name => "Solutions", :status => "grey", :path => ['Solutions']}
414
+ datacenters: {
415
+ 'Solutions' => { name: 'Solutions', status: 'grey', path: ['Solutions'] }
383
416
  },
384
- :datastores => {
417
+ datastores: {
385
418
  'Storage1' => {
386
419
  'id' => 'datastore-123456',
387
420
  'name' => 'Storage1',
388
421
  'datacenter' => 'Solutions',
389
422
  'type' => 'VMFS',
390
- 'freespace' => 697471860736,
423
+ 'freespace' => 697_471_860_736,
391
424
  'accessible' => true,
392
- 'capacity' => 1099243192320,
393
- 'uncommitted' => 977158537741,
394
- 'cluster' => [],
425
+ 'capacity' => 1_099_243_192_320,
426
+ 'uncommitted' => 977_158_537_741,
427
+ 'cluster' => []
395
428
  },
396
429
  'datastore1' => {
397
430
  'id' => 'datastore-789123',
398
431
  'name' => 'datastore1',
399
432
  'datacenter' => 'Solutions',
400
433
  'type' => 'VMFS',
401
- 'freespace' => 697471860736,
434
+ 'freespace' => 697_471_860_736,
402
435
  'accessible' => true,
403
- 'capacity' => 1099243192320,
404
- 'uncommitted' => 977158537741,
405
- 'cluster' => ['Solutionscluster'],
406
- },
436
+ 'capacity' => 1_099_243_192_320,
437
+ 'uncommitted' => 977_158_537_741,
438
+ 'cluster' => ['Solutionscluster']
439
+ }
407
440
  },
408
- :networks => {
441
+ networks: {
409
442
  'network1' => {
410
443
  'id' => 'dvportgroup-123456',
411
444
  'name' => 'network1',
412
445
  'datacenter' => 'Solutions',
413
446
  'accessible' => true,
414
447
  'virtualswitch' => nil,
415
- 'cluster' => ['Solutionscluster'],
448
+ 'cluster' => ['Solutionscluster']
416
449
  },
417
450
  'network2' => {
418
451
  'id' => 'dvportgroup-789123',
@@ -420,10 +453,10 @@ module Fog
420
453
  'datacenter' => 'Solutions',
421
454
  'accessible' => true,
422
455
  'virtualswitch' => nil,
423
- 'cluster' => [],
424
- },
456
+ 'cluster' => []
457
+ }
425
458
  },
426
- :folders => {
459
+ folders: {
427
460
  'wibble' => {
428
461
  'name' => 'wibble',
429
462
  'datacenter' => 'Solutions',
@@ -437,92 +470,83 @@ module Fog
437
470
  'type' => 'vm'
438
471
  }
439
472
  },
440
- :storage_pods =>
441
- [{:id => "group-p123456",
442
- :name => "Datastore Cluster 1",
443
- :freespace => "4856891834368",
444
- :capacity => "7132061630464",
445
- :datacenter => "Solutions",
446
- },
447
- ],
448
- :clusters =>
449
- [{:id => "1d4d9a3f-e4e8-4c40-b7fc-263850068fa4",
450
- :name => "Solutionscluster",
451
- :num_host => "4",
452
- :num_cpu_cores => "16",
453
- :overall_status => "green",
454
- :datacenter => "Solutions",
455
- :full_path => 'Solutionscluster',
456
- :klass => "RbVmomi::VIM::ComputeResource"
457
- },
458
- {:id => "e4195973-102b-4096-bbd6-5429ff0b35c9",
459
- :name => "Problemscluster",
460
- :num_host => "4",
461
- :num_cpu_cores => "32",
462
- :overall_status => "green",
463
- :datacenter => "Solutions",
464
- :full_path => 'Problemscluster',
465
- :klass => "RbVmomi::VIM::ComputeResource"
466
- },
467
- {
468
- :klass => "RbVmomi::VIM::Folder",
469
- :clusters => [{:id => "03616b8d-b707-41fd-b3b5-The first",
470
- :name => "Problemscluster",
471
- :num_host => "4",
472
- :num_cpu_cores => "32",
473
- :overall_status => "green",
474
- :datacenter => "Solutions",
475
- :full_path => 'Nested/Problemscluster',
476
- :klass => "RbVmomi::VIM::ComputeResource"
477
- },
478
- {:id => "03616b8d-b707-41fd-b3b5-the Second",
479
- :name => "Lastcluster",
480
- :num_host => "8",
481
- :num_cpu_cores => "32",
482
- :overall_status => "green",
483
- :datacenter => "Solutions",
484
- :full_path => 'Nested/Lastcluster',
485
- :klass => "RbVmomi::VIM::ComputeResource"}
486
- ]
487
- }
488
- ],
489
- :rules => {
490
- 'anti-affinity-foo' => {
491
- :datacenter => 'Solutions',
492
- :cluster => 'Solutionscluster',
493
- :key => 4242,
494
- :name => 'anti-affinity-foo',
495
- :enabled => true,
496
- :type => RbVmomi::VIM::ClusterAntiAffinityRuleSpec,
497
- :vm_ids => ['5032c8a5-9c5e-ba7a-3804-832a03e16381', '502916a3-b42e-17c7-43ce-b3206e9524dc']
498
- }
499
- },
500
- :hosts => {
501
- 'Host1' => {
502
- :datacenter => 'Solutions',
503
- :cluster => 'Solutionscluster',
504
- :name => 'host1.example.com',
505
- :model => 'PowerEdge R730',
506
- :vendor => 'Dell Inc.',
507
- :ipaddress => '1.2.3.4',
508
- :ipaddress6 => nil,
509
- :hostname => 'host1',
510
- :domainname => 'example.com',
511
- :product_name => 'VMware ESXi',
512
- :uuid => '4c4c4544-0051-3610-8046-c4c44f584a32',
513
- :cpu_cores => 20,
514
- :cpu_sockets => 2,
515
- :cpu_threads => 40,
516
- :memory => 824597241856,
517
- :product_version => '6.0.0',
518
- :vm_ids => ['5032c8a5-9c5e-ba7a-3804-832a03e16381', '502916a3-b42e-17c7-43ce-b3206e9524dc']
519
- }
520
- }
473
+ storage_pods: [{ id: 'group-p123456',
474
+ name: 'Datastore Cluster 1',
475
+ freespace: '4856891834368',
476
+ capacity: '7132061630464',
477
+ datacenter: 'Solutions' }],
478
+ clusters: [{ id: '1d4d9a3f-e4e8-4c40-b7fc-263850068fa4',
479
+ name: 'Solutionscluster',
480
+ num_host: '4',
481
+ num_cpu_cores: '16',
482
+ overall_status: 'green',
483
+ datacenter: 'Solutions',
484
+ full_path: 'Solutionscluster',
485
+ klass: 'RbVmomi::VIM::ComputeResource' },
486
+ { id: 'e4195973-102b-4096-bbd6-5429ff0b35c9',
487
+ name: 'Problemscluster',
488
+ num_host: '4',
489
+ num_cpu_cores: '32',
490
+ overall_status: 'green',
491
+ datacenter: 'Solutions',
492
+ full_path: 'Problemscluster',
493
+ klass: 'RbVmomi::VIM::ComputeResource' },
494
+ {
495
+ klass: 'RbVmomi::VIM::Folder',
496
+ clusters: [{ id: '03616b8d-b707-41fd-b3b5-The first',
497
+ name: 'Problemscluster',
498
+ num_host: '4',
499
+ num_cpu_cores: '32',
500
+ overall_status: 'green',
501
+ datacenter: 'Solutions',
502
+ full_path: 'Nested/Problemscluster',
503
+ klass: 'RbVmomi::VIM::ComputeResource' },
504
+ { id: '03616b8d-b707-41fd-b3b5-the Second',
505
+ name: 'Lastcluster',
506
+ num_host: '8',
507
+ num_cpu_cores: '32',
508
+ overall_status: 'green',
509
+ datacenter: 'Solutions',
510
+ full_path: 'Nested/Lastcluster',
511
+ klass: 'RbVmomi::VIM::ComputeResource' }]
512
+ }],
513
+ rules: {
514
+ 'anti-affinity-foo' => {
515
+ datacenter: 'Solutions',
516
+ cluster: 'Solutionscluster',
517
+ key: 4242,
518
+ name: 'anti-affinity-foo',
519
+ enabled: true,
520
+ type: RbVmomi::VIM::ClusterAntiAffinityRuleSpec,
521
+ vm_ids: ['5032c8a5-9c5e-ba7a-3804-832a03e16381', '502916a3-b42e-17c7-43ce-b3206e9524dc']
522
+ }
523
+ },
524
+ hosts: {
525
+ 'Host1' => {
526
+ datacenter: 'Solutions',
527
+ cluster: 'Solutionscluster',
528
+ name: 'host1.example.com',
529
+ model: 'PowerEdge R730',
530
+ vendor: 'Dell Inc.',
531
+ ipaddress: '1.2.3.4',
532
+ ipaddress6: nil,
533
+ hostname: 'host1',
534
+ domainname: 'example.com',
535
+ product_name: 'VMware ESXi',
536
+ uuid: '4c4c4544-0051-3610-8046-c4c44f584a32',
537
+ cpu_cores: 20,
538
+ cpu_sockets: 2,
539
+ cpu_threads: 40,
540
+ memory: 824_597_241_856,
541
+ product_version: '6.0.0',
542
+ vm_ids: ['5032c8a5-9c5e-ba7a-3804-832a03e16381', '502916a3-b42e-17c7-43ce-b3206e9524dc']
543
+ }
544
+ }
521
545
  }
522
546
  end
523
547
  end
524
548
 
525
- def initialize(options={})
549
+ def initialize(options = {})
526
550
  require 'rbvmomi'
527
551
  @vsphere_username = options[:vsphere_username]
528
552
  @vsphere_password = 'REDACTED'
@@ -544,7 +568,7 @@ module Fog
544
568
  class Real
545
569
  include Shared
546
570
 
547
- def initialize(options={})
571
+ def initialize(options = {})
548
572
  require 'rbvmomi'
549
573
  @vsphere_username = options[:vsphere_username]
550
574
  @vsphere_password = options[:vsphere_password]
@@ -576,21 +600,20 @@ module Fog
576
600
  def reload
577
601
  connect
578
602
  # Check if the negotiation was ever run
579
- if @vsphere_is_vcenter.nil?
580
- negotiate
581
- end
603
+ negotiate if @vsphere_is_vcenter.nil?
582
604
  authenticate
583
605
  end
584
606
 
585
607
  private
608
+
586
609
  def negotiate_revision(revision = nil)
587
610
  # Negotiate the API revision
588
- if not revision
611
+ unless revision
589
612
  rev = @connection.serviceContent.about.apiVersion
590
- @connection.rev = [ rev, ENV['FOG_VSPHERE_REV'] || '4.1' ].max
613
+ @connection.rev = [rev, ENV['FOG_VSPHERE_REV'] || '4.1'].max
591
614
  end
592
615
 
593
- @vsphere_is_vcenter = @connection.serviceContent.about.apiType == "VirtualCenter"
616
+ @vsphere_is_vcenter = @connection.serviceContent.about.apiType == 'VirtualCenter'
594
617
  @vsphere_rev = @connection.rev
595
618
  end
596
619
 
@@ -599,14 +622,14 @@ module Fog
599
622
  bad_cert = false
600
623
  loop do
601
624
  begin
602
- @connection = RbVmomi::VIM.new :host => @vsphere_server,
603
- :port => @vsphere_port,
604
- :path => @vsphere_path,
605
- :ns => @vsphere_ns,
606
- :rev => @vsphere_rev,
607
- :ssl => @vsphere_ssl,
608
- :insecure => bad_cert,
609
- :debug => @vsphere_debug
625
+ @connection = RbVmomi::VIM.new host: @vsphere_server,
626
+ port: @vsphere_port,
627
+ path: @vsphere_path,
628
+ ns: @vsphere_ns,
629
+ rev: @vsphere_rev,
630
+ ssl: @vsphere_ssl,
631
+ insecure: bad_cert,
632
+ debug: @vsphere_debug
610
633
 
611
634
  # Create a shadow class to change the behaviour of @connection.obj2xml
612
635
  # so that xsd:any types are converted to xsd:int (and not xsd:long).
@@ -618,7 +641,7 @@ module Fog
618
641
  # pull request that fixes it in RbVmomi.
619
642
  #
620
643
  class <<@connection
621
- def obj2xml xml, name, type, is_array, o, attrs={}
644
+ def obj2xml(xml, name, type, is_array, o, attrs = {})
622
645
  case o
623
646
  when Integer
624
647
  attrs['xsi:type'] = 'xsd:int' if type(type) == RbVmomi::BasicTypes::AnyType
@@ -637,18 +660,14 @@ module Fog
637
660
  end
638
661
  end
639
662
 
640
- if bad_cert then
641
- validate_ssl_connection
642
- end
663
+ validate_ssl_connection if bad_cert
643
664
  end
644
665
 
645
666
  def authenticate
646
- begin
647
- @connection.serviceContent.sessionManager.Login :userName => @vsphere_username,
648
- :password => @vsphere_password
649
- rescue RbVmomi::VIM::InvalidLogin => e
650
- raise Fog::Vsphere::Errors::ServiceError, e.message
651
- end
667
+ @connection.serviceContent.sessionManager.Login userName: @vsphere_username,
668
+ password: @vsphere_password
669
+ rescue RbVmomi::VIM::InvalidLogin => e
670
+ raise Fog::Vsphere::Errors::ServiceError, e.message
652
671
  end
653
672
 
654
673
  # Verify a SSL certificate based on the hashed public key
@@ -656,13 +675,13 @@ module Fog
656
675
  pubkey = @connection.http.peer_cert.public_key
657
676
  pubkey_hash = Digest::SHA2.hexdigest(pubkey.to_s)
658
677
  expected_pubkey_hash = @vsphere_expected_pubkey_hash
659
- if pubkey_hash != expected_pubkey_hash then
678
+ if pubkey_hash != expected_pubkey_hash
660
679
  raise Fog::Vsphere::Errors::SecurityError, "The remote system presented a public key with hash #{pubkey_hash} but we're expecting a hash of #{expected_pubkey_hash || '<unset>'}. If you are sure the remote system is authentic set vsphere_expected_pubkey_hash: <the hash printed in this message> in ~/.fog"
661
680
  end
662
681
  end
663
682
 
664
683
  def list_container_view(datacenter_obj_or_name, type, container_object = nil)
665
- dc = if datacenter_obj_or_name.kind_of?(String)
684
+ dc = if datacenter_obj_or_name.is_a?(String)
666
685
  find_raw_datacenter(datacenter_obj_or_name)
667
686
  else
668
687
  datacenter_obj_or_name
@@ -675,9 +694,9 @@ module Fog
675
694
  end
676
695
 
677
696
  container_view = connection.serviceContent.viewManager.CreateContainerView(
678
- :container => dc,
679
- :type => [type],
680
- :recursive => true
697
+ container: dc,
698
+ type: [type],
699
+ recursive: true
681
700
  )
682
701
 
683
702
  result = container_view.view