vmonkey 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 074a3abf7dd0bd69dc81a239cce45d38897e2678
4
- data.tar.gz: a02e1b242f6e29d90f56803b3de675500ab06e86
3
+ metadata.gz: a0ff9f61554b7d4d9b77eb7db920190d126c0dc7
4
+ data.tar.gz: edd8cf44704212d256c7abb8e00f5bd83ff4ee1d
5
5
  SHA512:
6
- metadata.gz: 226b996416590abfc6fa200a3637236ef33e31f09f760a7653d52cf7754903fd19b258af1430c7b4ee341a4a1a82f647aaca388a9ee569b10c5212e56ff04ae7
7
- data.tar.gz: adea1d500fb7f725b249d541e07cb28969878ddf267f47eed361bc18e1012d0a484c2c39fe27e51421796d94743fd1021bfd2bb69537572a2fa4433ab7324890
6
+ metadata.gz: 34f00cb986328f92dbbe713edd3342c6674a25f18332f089ca6b789a9f2c4abbefc47705e3fd781567504b82770d4040942aa1dcd9ed2be4c4e2ec91ac89ee6f
7
+ data.tar.gz: 81d1b577c3f4de6a43c4ce2789726cdf1672a2388096ca913bac1dbc8ff278a7e17f5cf2303cad323fcf7ce941d761e35d4d69be2796bd227396046bae0368c1
@@ -1,3 +1,3 @@
1
1
  module Vmonkey
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -6,4 +6,15 @@ class RbVmomi::VIM::Folder
6
6
  def vm_folder
7
7
  self
8
8
  end
9
+
10
+ def findByInstanceUuid uuid, type=RbVmomi::VIM::VirtualMachine, dc=nil
11
+ propSpecs = {
12
+ :entity => self, :uuid => uuid, :instanceUuid => true,
13
+ :vmSearch => type == RbVmomi::VIM::VirtualMachine
14
+ }
15
+ propSpecs[:datacenter] = dc if dc
16
+ x = _connection.searchIndex.FindByUuid(propSpecs)
17
+ x if x.is_a? type
18
+ end
19
+
9
20
  end
@@ -33,6 +33,22 @@ module RbVmomi
33
33
  vm(path) || raise("VirtualMachine not found. [#{path}]")
34
34
  end
35
35
 
36
+ def vm_by_uuid(uuid)
37
+ dc.vmFolder.findByUuid uuid, RbVmomi::VIM::VirtualMachine, dc
38
+ end
39
+
40
+ def vm_by_uuid!(uuid)
41
+ vm_by_uuid(uuid) || raise("VirtualMachine not found. [#{uuid}]")
42
+ end
43
+
44
+ def vm_by_instance_uuid(uuid)
45
+ dc.vmFolder.findByInstanceUuid uuid
46
+ end
47
+
48
+ def vm_by_instance_uuid!(uuid)
49
+ vm_by_instance_uuid(uuid) || raise("VirtualMachine not found. [#{uuid}]")
50
+ end
51
+
36
52
  def vapp(path)
37
53
  dc.vmFolder.traverse path, RbVmomi::VIM::VirtualApp
38
54
  end
data/spec/vim_spec.rb CHANGED
@@ -3,6 +3,7 @@ require_relative 'spec_helper'
3
3
  describe RbVmomi::VIM do
4
4
  before :all do
5
5
  @monkey ||= VMonkey.connect
6
+ @template ||= @monkey.vm! VM_SPEC_OPTS[:template_path]
6
7
  end
7
8
 
8
9
  describe '#folder' do
@@ -31,6 +32,42 @@ describe RbVmomi::VIM do
31
32
  end
32
33
  end
33
34
 
35
+ context 'with a cloned VM' do
36
+ before(:all) do
37
+ @vm_path = "#{VM_SPEC_OPTS[:working_folder]}/vmonkey_vim_spec"
38
+ @spec_vm = @template.clone_to @vm_path
39
+ end
40
+ after(:all) { @spec_vm.destroy }
41
+
42
+ describe '#vm_by_uuid' do
43
+ before(:all) { @uuid ||= @spec_vm.config.uuid }
44
+ subject { @vm ||= @monkey.vm_by_uuid @uuid }
45
+
46
+ it { should_not be_nil }
47
+ its(:name) { should == @spec_vm.name }
48
+ end
49
+
50
+ describe '#vm_by_uuid!' do
51
+ it 'should raise a RuntimeError given a UUID of a non-existent vm' do
52
+ expect { @monkey.vm_by_uuid! 'xyzzy' }.to raise_error RuntimeError
53
+ end
54
+ end
55
+
56
+ describe '#vm_by_instance_uuid' do
57
+ before(:all) { @instance_uuid ||= @spec_vm.config.instanceUuid }
58
+ subject { @vm ||= @monkey.vm_by_instance_uuid @instance_uuid }
59
+
60
+ it { should_not be_nil }
61
+ its(:name) { should == @spec_vm.name }
62
+ end
63
+
64
+ describe '#vm_by_instance_uuid!' do
65
+ it 'should raise a RuntimeError given a UUID of a non-existent vm' do
66
+ expect { @monkey.vm_by_instance_uuid! 'xyzzy' }.to raise_error RuntimeError
67
+ end
68
+ end
69
+ end
70
+
34
71
  describe '#vapp' do
35
72
  subject { @vapp ||= @monkey.vapp VM_SPEC_OPTS[:vapp_path] }
36
73
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmonkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dupras
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-12 00:00:00.000000000 Z
12
+ date: 2014-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.0.14
133
+ rubygems_version: 2.1.11
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: simple to use vsphere methods