vmonkey 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vmonkey/version.rb +1 -1
- data/lib/vmonkey/vim/Folder.rb +16 -0
- data/spec/folder_spec.rb +45 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73473f9859e69b977f39d70718c324209348f108
|
4
|
+
data.tar.gz: 918674b456eab8cd11cdfef9cb6a46b8b2d4e3dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41cd3ffe4dd03e1212eb4dac8f2b02db048f585528137f24869eb90656cdf113510656dc18455177013a75ae2ac139dbeb9257e0ff2a35d1195c7b2fdc25ced9
|
7
|
+
data.tar.gz: a7d9dd69f806cab2edb56ed01b4e8ce74587c33478ed902d40cbec8f7f1a6ac7f4f61b7b7c5fd943482a87fe8e7c23cab2ec92cefe7978d86622bd8f31368be9
|
data/lib/vmonkey/version.rb
CHANGED
data/lib/vmonkey/vim/Folder.rb
CHANGED
@@ -25,4 +25,20 @@ class RbVmomi::VIM::Folder
|
|
25
25
|
self.childEntity.grep(RbVmomi::VIM::VirtualMachine).select { |v| v.config.nil? || (v.config && !v.config.template) }
|
26
26
|
end
|
27
27
|
|
28
|
+
def folder(path)
|
29
|
+
self.traverse path, RbVmomi::VIM::Folder
|
30
|
+
end
|
31
|
+
|
32
|
+
def folder!(path)
|
33
|
+
folder(path) || raise("Folder not found. [#{path}]")
|
34
|
+
end
|
35
|
+
|
36
|
+
def mk_folder(path)
|
37
|
+
self.traverse path, RbVmomi::VIM::Folder, true
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
self.Destroy_Task.wait_for_completion
|
42
|
+
end
|
43
|
+
|
28
44
|
end
|
data/spec/folder_spec.rb
CHANGED
@@ -6,8 +6,50 @@ describe RbVmomi::VIM::Folder do
|
|
6
6
|
@folder ||= @monkey.folder VM_SPEC_OPTS[:working_folder]
|
7
7
|
end
|
8
8
|
|
9
|
-
describe '#vm_pool' do
|
10
|
-
|
11
|
-
|
9
|
+
# describe '#vm_pool' do
|
10
|
+
# subject { @folder.vm_pool }
|
11
|
+
# it { should_not be_nil }
|
12
|
+
# end
|
13
|
+
|
14
|
+
describe '#folder!' do
|
15
|
+
it 'should raise an error when the folder doesn\'t exist' do
|
16
|
+
expect { @folder.folder! 'not_here' }.to raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#folder' do
|
21
|
+
before :all do
|
22
|
+
@folder.mk_folder 'vmonkeytmp/tmp2'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should find a folder by a single path element' do
|
26
|
+
expect(@folder.folder('vmonkeytmp')).to_not be_nil
|
27
|
+
expect(@folder.folder('vmonkeytmp').name).to eq('vmonkeytmp')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should find a folder by a nested path' do
|
31
|
+
expect(@folder.folder('vmonkeytmp/tmp2')).to_not be_nil
|
32
|
+
expect(@folder.folder('vmonkeytmp/tmp2').name).to eq('tmp2')
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
@folder.folder('vmonkeytmp').destroy
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#mk_folder' do
|
41
|
+
before :all do
|
42
|
+
@sub = @folder.mk_folder 'vmonkeytmp/tmp3'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should create nested folders' do
|
46
|
+
expect(@folder.folder!('vmonkeytmp/tmp3').name).to eq('tmp3')
|
47
|
+
expect(@folder.folder!('vmonkeytmp/tmp3').parent.parent.name).to eq(@folder.name)
|
48
|
+
expect(@sub.name).to eq('tmp3')
|
49
|
+
end
|
50
|
+
|
51
|
+
after :all do
|
52
|
+
@folder.folder!('vmonkeytmp').destroy
|
53
|
+
end
|
12
54
|
end
|
13
55
|
end
|