vm_shepherd 1.8.4 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88deef3c10c81db0c5ea70d8cfd04e85999424ba
4
- data.tar.gz: 4d4a8c296e95d0c574d76f67a5f92ee21c2edf66
3
+ metadata.gz: 9005c41f3252dada8327d25150585f18eab17a14
4
+ data.tar.gz: c1b4637cbe43854e4a1a3e1569beffa64c333adf
5
5
  SHA512:
6
- metadata.gz: 1c71799a37d10d37049f2bce2410d34d3b8c0c6ca16ff242312786d76c486f98032216e7c25ad7d867c522fc810828ec69b73dcadda3a5f31e9bb0ad835eec66
7
- data.tar.gz: 6332671a327756f8b1893082b4f67580f07cf52dc00c57d364802570d5457c5d5992b08129845239a9643ce5c716303bbc6aeb9ff7782a988b175db17882ff00
6
+ metadata.gz: 3545eaa72f1f99a5896eb1a2660ea995bc08ffe810a45f5368111e05ef9500eb222326d1000b6257d2bfdeda899bfa63b6f3ef4b67ca470dc30e3515a9def169
7
+ data.tar.gz: bf1964936e38d28329afa32d70c83e506f129ec8b879bd65fdd0367790c536af3113213c2a54b5e609b31c541bc35aec8faef79984b4dc4b003847395f5e3f80
@@ -1,3 +1,3 @@
1
1
  module VmShepherd
2
- VERSION = '1.8.4'.freeze
2
+ VERSION = '1.9.0'.freeze
3
3
  end
@@ -41,7 +41,7 @@ module VmShepherd
41
41
  begin
42
42
  logger.info("BEGIN datastore_folder.destroy_task folder=#{folder_name}")
43
43
 
44
- connection.serviceContent.fileManager.DeleteDatastoreFile_Task(
44
+ file_manager.DeleteDatastoreFile_Task(
45
45
  datacenter: datacenter,
46
46
  name: "[#{datastore}] #{folder_name}"
47
47
  ).wait_for_completion
@@ -124,7 +124,10 @@ module VmShepherd
124
124
  3.times do |attempt|
125
125
  break unless (folder = datacenter.vmFolder.traverse(folder_name))
126
126
 
127
- find_vms(folder).each { |vm| power_off_vm(vm) }
127
+ find_vms(folder).each do |vm|
128
+ power_off_vm(vm)
129
+ destroy_vm_datastore_folder(vm)
130
+ end
128
131
 
129
132
  begin
130
133
  logger.info("BEGIN folder.destroy_task folder=#{folder_name} attempt ##{attempt}")
@@ -162,6 +165,18 @@ module VmShepherd
162
165
  end
163
166
  end
164
167
 
168
+
169
+ def destroy_vm_datastore_folder(vm)
170
+ begin
171
+ vm_datastore_folder = vm.config.files.snapshotDirectory
172
+ logger.info("BEGIN vm_datastore_folder.delete_datastore_file_task folder=#{vm_datastore_folder}")
173
+ file_manager.DeleteDatastoreFile_Task(name: vm_datastore_folder, datacenter: datacenter).wait_for_completion
174
+ logger.info("END vm_datastore_folder.delete_datastore_file_task folder=#{vm_datastore_folder}")
175
+ rescue RbVmomi::Fault => e
176
+ logger.info("ERROR vm_datastore_folder.delete_datastore_file_task. Skipping ... folder=#{vm_datastore_folder} #{e.inspect}")
177
+ end
178
+ end
179
+
165
180
  def deploy_ovf_template(ovf_file_path, vsphere_config)
166
181
  template_name = [TEMPLATE_PREFIX, Time.new.strftime('%F-%H-%M'), cluster(vsphere_config).name].join('-')
167
182
  logger.info("BEGIN deploy_ovf ovf_file=#{ovf_file_path} template_name=#{template_name}")
@@ -312,6 +327,12 @@ module VmShepherd
312
327
  end
313
328
  end
314
329
 
330
+ def file_manager
331
+ connection.serviceContent.fileManager.tap do |fm|
332
+ fail("ERROR finding filemanager") unless fm.is_a?(RbVmomi::VIM::FileManager)
333
+ end
334
+ end
335
+
315
336
  def target_folder(vsphere_config)
316
337
  datacenter.vmFolder.traverse(vsphere_config[:folder], RbVmomi::VIM::Folder, true)
317
338
  end
@@ -36,9 +36,9 @@ module VmShepherd
36
36
  allow(datacenter).to receive(:vmFolder).and_return(folder)
37
37
  allow(folder).to receive(:traverse).with('FAKE_DATACENTER_FOLDERS').and_return(folder)
38
38
  allow(service_content).to receive(:fileManager).and_return(filemanager)
39
+ allow(filemanager).to receive(:is_a?).with(RbVmomi::VIM::FileManager).and_return(true)
39
40
  # stubbed private methods:
40
41
  allow(subject).to receive(:find_vms).and_return(vms)
41
- allow(subject).to receive(:power_off_vm)
42
42
  allow(subject).to receive(:delete_folder_and_vms)
43
43
  end
44
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vm_shepherd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.4
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ops Manager Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-29 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-v1