fog-vsphere 1.7.0.1 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -2
  3. data/.travis.yml +7 -6
  4. data/CHANGELOG.md +13 -2
  5. data/CONTRIBUTORS.md +0 -8
  6. data/Rakefile +1 -10
  7. data/gemfiles/Gemfile.1.9.2+ +9 -0
  8. data/lib/fog/vsphere/compute.rb +2 -0
  9. data/lib/fog/vsphere/models/compute/scsicontroller.rb +6 -1
  10. data/lib/fog/vsphere/models/compute/server.rb +37 -8
  11. data/lib/fog/vsphere/models/compute/volume.rb +62 -28
  12. data/lib/fog/vsphere/models/compute/volumes.rb +1 -1
  13. data/lib/fog/vsphere/requests/compute/create_vm.rb +32 -44
  14. data/lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb +4 -11
  15. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +2 -1
  16. data/lib/fog/vsphere/requests/compute/modify_vm_controller.rb +2 -14
  17. data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +3 -3
  18. data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -2
  19. data/lib/fog/vsphere/requests/compute/vm_migrate.rb +1 -0
  20. data/lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb +26 -15
  21. data/lib/fog/vsphere/version.rb +1 -1
  22. data/tests/class_from_string_tests.rb +3 -3
  23. data/tests/compute_tests.rb +17 -16
  24. data/tests/helpers/mock_helper.rb +3 -3
  25. data/tests/models/compute/cluster_tests.rb +5 -4
  26. data/tests/models/compute/hosts_tests.rb +4 -2
  27. data/tests/models/compute/rules_tests.rb +16 -10
  28. data/tests/models/compute/server_tests.rb +29 -33
  29. data/tests/models/compute/servers_tests.rb +4 -2
  30. data/tests/requests/compute/current_time_tests.rb +4 -2
  31. data/tests/requests/compute/folder_destroy_tests.rb +7 -5
  32. data/tests/requests/compute/get_network_tests.rb +22 -18
  33. data/tests/requests/compute/list_child_snapshots_tests.rb +2 -1
  34. data/tests/requests/compute/list_clusters_tests.rb +6 -5
  35. data/tests/requests/compute/list_datastores_tests.rb +7 -6
  36. data/tests/requests/compute/list_hosts_tests.rb +4 -3
  37. data/tests/requests/compute/list_networks_tests.rb +7 -6
  38. data/tests/requests/compute/list_storage_pods_test.rb +4 -3
  39. data/tests/requests/compute/list_virtual_machines_tests.rb +20 -16
  40. data/tests/requests/compute/list_vm_cdroms_tests.rb +2 -1
  41. data/tests/requests/compute/list_vm_snapshots_tests.rb +2 -1
  42. data/tests/requests/compute/modify_vm_cdrom_tests.rb +4 -3
  43. data/tests/requests/compute/revert_to_snapshot_tests.rb +4 -2
  44. data/tests/requests/compute/set_vm_customvalue_tests.rb +2 -0
  45. data/tests/requests/compute/vm_clone_tests.rb +20 -20
  46. data/tests/requests/compute/vm_config_vnc_tests.rb +4 -3
  47. data/tests/requests/compute/vm_destroy_tests.rb +4 -1
  48. data/tests/requests/compute/vm_migrate_tests.rb +2 -1
  49. data/tests/requests/compute/vm_power_off_tests.rb +4 -2
  50. data/tests/requests/compute/vm_power_on_tests.rb +3 -1
  51. data/tests/requests/compute/vm_reboot_tests.rb +4 -2
  52. data/tests/requests/compute/vm_reconfig_cdrom_tests.rb +3 -2
  53. data/tests/requests/compute/vm_reconfig_cpus_tests.rb +3 -1
  54. data/tests/requests/compute/vm_reconfig_hardware_tests.rb +4 -2
  55. data/tests/requests/compute/vm_reconfig_memory_tests.rb +3 -1
  56. data/tests/requests/compute/vm_take_snapshot_tests.rb +3 -1
  57. metadata +4 -22
  58. data/.rubocop.yml +0 -8
  59. data/.rubocop_todo.yml +0 -217
  60. data/lib/fog/vsphere/models/compute/ticket.rb +0 -16
  61. data/lib/fog/vsphere/models/compute/tickets.rb +0 -25
  62. data/lib/fog/vsphere/requests/compute/host_finish_maintenance.rb +0 -14
  63. data/lib/fog/vsphere/requests/compute/host_shutdown.rb +0 -14
  64. data/lib/fog/vsphere/requests/compute/host_start_maintenance.rb +0 -14
  65. data/lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb +0 -34
  66. data/lib/fog/vsphere/requests/compute/vm_relocate.rb +0 -54
  67. data/lib/fog/vsphere/requests/compute/vm_remove_snapshot.rb +0 -29
  68. data/lib/fog/vsphere/requests/compute/vm_rename.rb +0 -24
  69. data/lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb +0 -29
  70. data/lib/fog/vsphere/requests/compute/vm_suspend.rb +0 -54
  71. data/tests/models/compute/ticket_tests.rb +0 -12
  72. data/tests/models/compute/tickets_tests.rb +0 -8
  73. data/tests/requests/compute/vm_suspend_tests.rb +0 -23
data/.rubocop.yml DELETED
@@ -1,8 +0,0 @@
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 DELETED
@@ -1,217 +0,0 @@
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'
@@ -1,16 +0,0 @@
1
- require 'fog/compute/models/server'
2
-
3
- module Fog
4
- module Compute
5
- class Vsphere
6
- class Ticket < Fog::Model
7
- attribute :server_id
8
-
9
- attribute :ticket
10
- attribute :host
11
- attribute :port
12
- attribute :ssl_thumbprint
13
- end
14
- end
15
- end
16
- end
@@ -1,25 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Tickets < Fog::Collection
5
- autoload :Ticket, File.expand_path('../ticket', __FILE__)
6
-
7
- model Fog::Compute::Vsphere::Ticket
8
-
9
- attr_accessor :server
10
-
11
- def create(opts = {})
12
- requires :server
13
- raise 'server must be a Fog::Compute::Vsphere::Server' unless server.is_a?(Fog::Compute::Vsphere::Server)
14
- new(
15
- service.vm_acquire_ticket(
16
- opts.merge(
17
- 'instance_uuid' => server.instance_uuid
18
- )
19
- )
20
- )
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,14 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Real
5
- def host_finish_maintenance(name, cluster_name, datacenter_name, timeout = 0)
6
- host_ref = get_host(name, cluster_name, datacenter_name)
7
- task = host_ref.ExitMaintenanceMode_Task(timeout: timeout)
8
- task.wait_for_completion
9
- { 'task_state' => task.info.state }
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Real
5
- def host_shutdown(name, cluster_name, datacenter_name, force = false)
6
- host_ref = get_host(name, cluster_name, datacenter_name)
7
- task = host_ref.ShutdownHost_Task(force: force)
8
- task.wait_for_completion
9
- { 'task_state' => task.info.state }
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Real
5
- def host_start_maintenance(name, cluster_name, datacenter_name, timeout = 0, evacuate_powered_off_vms = false)
6
- host_ref = get_host(name, cluster_name, datacenter_name)
7
- task = host_ref.EnterMaintenanceMode_Task(timeout: timeout, evacuatePoweredOffVms: evacuate_powered_off_vms)
8
- task.wait_for_completion
9
- { 'task_state' => task.info.state }
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,34 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Real
5
- def vm_acquire_ticket(options = {})
6
- raise ArgumentError, 'instance_uuid is a required parameter' unless options.key?('instance_uuid')
7
- ticket_type = options['ticket_type'] || 'webmks'
8
-
9
- vm_mob_ref = get_vm_ref(options['instance_uuid'])
10
-
11
- ticket = vm_mob_ref.AcquireTicket(ticketType: ticket_type)
12
- {
13
- 'ticket' => ticket.ticket,
14
- 'host' => ticket.host,
15
- 'port' => ticket.port,
16
- 'ssl_thumbprint' => ticket.sslThumbprint
17
- }
18
- end
19
- end
20
-
21
- class Mock
22
- def vm_acquire_ticket(options = {})
23
- raise ArgumentError, 'instance_uuid is a required parameter' unless options.key?('instance_uuid')
24
- {
25
- 'ticket' => 'fdsfdsf',
26
- 'host' => 'esxi.example.com',
27
- 'port' => 443,
28
- 'ssl_thumbprint' => '1C:63:E1:BD:56:03:EB:44:85:12:12:FC:DA:40:11:65:0E:30:A1:B8'
29
- }
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,54 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Real
5
- # Clones a VM from a template or existing machine on your vSphere
6
- # Server.
7
- #
8
- # ==== Parameters
9
- # * options<~Hash>:
10
- # * 'instance_uuid'<~String> - *REQUIRED* VM to relocate
11
- # * 'host'<~String> - name of host which will run the VM.
12
- # * 'pool'<~String> - name of pool which the VM should be
13
- # attached.
14
- # * 'disks'<~Array> - disks to relocate. Each disk is a
15
- # hash with diskId wich is key attribute of volume,
16
- # and datastore to relocate to.
17
- def vm_relocate(options = {})
18
- raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
19
-
20
- # Find the VM Object
21
- search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
22
- vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
23
-
24
- unless vm_mob_ref.is_a? RbVmomi::VIM::VirtualMachine
25
- raise Fog::Vsphere::Errors::NotFound,
26
- "Could not find VirtualMachine with instance uuid #{options['instance_uuid']}"
27
- end
28
- options['host'] = get_raw_host(options['host'], options['cluster'], options['datacenter']) if options['host']
29
- if options['disks']
30
- options['disks'] = options['disks'].map do |disk|
31
- disk['datastore'] = get_raw_datastore(disk['datastore'], nil)
32
- RbVmomi::VIM::VirtualMachineRelocateSpecDiskLocator(disk)
33
- end
34
- end
35
- spec = RbVmomi::VIM::VirtualMachineRelocateSpec(
36
- pool: options['pool'],
37
- host: options['host'],
38
- disk: options['disks']
39
- )
40
- task = vm_mob_ref.RelocateVM_Task(spec: spec, priority: options['priority'])
41
- task.wait_for_completion
42
- { 'task_state' => task.info.state }
43
- end
44
- end
45
-
46
- class Mock
47
- def vm_relocate(options = {})
48
- raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
49
- { 'task_state' => 'success' }
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,29 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Real
5
- def vm_remove_snapshot(vm_id, snapshot_id, remove_children = false)
6
- vm = servers.get(vm_id)
7
- snapshot = vm.snapshots.get(snapshot_id).mo_ref
8
- task = snapshot.RemoveSnapshot_Task(removeChildren: remove_children)
9
-
10
- task.wait_for_completion
11
-
12
- {
13
- 'task_state' => task.info.state,
14
- 'was_cancelled' => task.info.cancelled
15
- }
16
- end
17
- end
18
-
19
- class Mock
20
- def vm_remove_snapshot(_vm_id, _snapshot_id)
21
- {
22
- 'task_state' => 'success',
23
- 'was_cancelled' => false
24
- }
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,24 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Vsphere
4
- class Real
5
- def vm_rename(options = {})
6
- raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
7
- raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
8
- vm_mob_ref = get_vm_ref(options['instance_uuid'])
9
- task = vm_mob_ref.Rename_Task(newName: options['name'])
10
- task.wait_for_completion
11
- { 'task_state' => task.info.state }
12
- end
13
- end
14
-
15
- class Mock
16
- def vm_rename(options = {})
17
- raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
18
- raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
19
- { 'task_state' => 'success' }
20
- end
21
- end
22
- end
23
- end
24
- end