vmonkey 0.8.0 → 0.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: 5b5abf9886b87a12c8c10b8325e21b066efbde2e
4
- data.tar.gz: e5dbdfb1e613e7bb2bddfc548daac3a2fb2f006b
3
+ metadata.gz: 8e56d35ace21b66bf6da740b610ce5b92f98caff
4
+ data.tar.gz: 34ce83f0af713c575ea2cf000ada45a9168f4ec1
5
5
  SHA512:
6
- metadata.gz: 179e134d60a7800751beee309ef87abed62b5d06032eb0ef3f37af53e3da762631c02662a2382205c6388ca7456192c2bd94fc11b6d8ed29203843df03a4bc89
7
- data.tar.gz: cc36d62392f7c923dbc1fd3cd4588652f7c86fb60fd9f247f8c22047a5d1bcc7c6ef0a71a72b9ea8b21539478ed148f0864c629fbcca70455f54235d30dd18de
6
+ metadata.gz: f3ad0eea275e652f949b9e0e434d3b049dc52d9cd4007e1e7071c72adb6bd66b655c5d13a5e870dbc4ead65a913b63248b148e4516b5710942ab5211aedcf3e2
7
+ data.tar.gz: 44fb91749aed2e712e09c98aac1babda93a78323a95dd273b6b75731de3dbfae6d4b73f1db2c0e4b0e6bafa64e90f831d3e1abd6863a6700486d820de7da680c
@@ -1,3 +1,3 @@
1
1
  module Vmonkey
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
@@ -83,6 +83,13 @@ class RbVmomi::VIM::VirtualApp
83
83
  self.CloneVApp_Task(params).wait_for_completion
84
84
  end
85
85
 
86
+ def clone_to!(path, opts = {})
87
+ dest_vapp = monkey.vapp(path)
88
+ dest_vapp.destroy if dest_vapp
89
+
90
+ clone_to(path)
91
+ end
92
+
86
93
  def find_property(name)
87
94
  vAppConfig.property.find { |p| p.props[:id] == name.to_s }
88
95
  end
@@ -97,11 +104,13 @@ class RbVmomi::VIM::VirtualApp
97
104
  value
98
105
  end
99
106
 
100
- def set_property(name, value, opts={})
101
- opts = {
107
+ def set_property(name, value, requested_opts={})
108
+ default_opts = {
102
109
  type: 'string',
103
110
  userConfigurable: true
104
- }.merge opts
111
+ }
112
+
113
+ existing_opts = {}
105
114
 
106
115
  if vAppConfig.property
107
116
  existing_property = find_property(name)
@@ -109,12 +118,15 @@ class RbVmomi::VIM::VirtualApp
109
118
 
110
119
  if existing_property
111
120
  operation = 'edit'
121
+ existing_opts = existing_property.props
112
122
  property_key = existing_property.props[:key]
113
123
  else
114
124
  operation = 'add'
115
125
  property_key = name.object_id
116
126
  end
117
127
 
128
+ opts = default_opts.merge(existing_opts).merge(requested_opts)
129
+
118
130
  vapp_config_spec = RbVmomi::VIM.VAppConfigSpec(
119
131
  property: [
120
132
  RbVmomi::VIM.VAppPropertySpec(
@@ -128,6 +140,20 @@ class RbVmomi::VIM::VirtualApp
128
140
  self.UpdateVAppConfig( spec: vapp_config_spec )
129
141
  end
130
142
 
143
+ def set_properties(props)
144
+ props.each do |key, v|
145
+ if v.is_a?(Hash)
146
+ value = v.delete :value
147
+ opts = v
148
+ else
149
+ value = v
150
+ opts = {}
151
+ end
152
+
153
+ set_property key, value, opts
154
+ end
155
+ end
156
+
131
157
  def port_ready?(port, timeout=5)
132
158
  return false if vapp_state? 'stopped'
133
159
  ready=self.vm.all? { |vm| vm.port_ready?(port, 2) }
@@ -0,0 +1,47 @@
1
+ require_relative 'spec_helper'
2
+ using VMonkey unless RUBY_VERSION.split('.')[0] == '1'
3
+
4
+ describe RbVmomi::VIM::VirtualApp do
5
+
6
+ before :all do
7
+ @monkey ||= VMonkey.connect
8
+ @vapp ||= @monkey.vapp VM_SPEC_OPTS[:vapp_path]
9
+ @spec_vapp_path = "#{VM_SPEC_OPTS[:working_folder]}/vmonkey_spec_vapp"
10
+ end
11
+
12
+ context 'with a cloned vapp' do
13
+ before(:all) { @spec_vapp = @vapp.clone_to @spec_vapp_path }
14
+ after(:all) { @spec_vapp.destroy }
15
+
16
+ describe '#clone_to' do
17
+ context 'to a Folder' do
18
+ subject { @monkey.vapp @spec_vapp_path }
19
+ it { should_not be_nil }
20
+ end
21
+
22
+ it 'should raise an error when given a path of an existing vApp' do
23
+ expect { @spec_vapp.clone_to @spec_vapp_path }.to raise_error
24
+ end
25
+ end
26
+
27
+ describe '#clone_to!' do
28
+ before(:all) do
29
+ @other_path = "#{@spec_vapp_path}-other"
30
+ @other_vapp = @spec_vapp.clone_to @other_path
31
+ @other_vapp.property :clone_to_bang, 'before'
32
+ end
33
+
34
+ after(:all) do
35
+ other_vapp = @monkey.vapp @other_path
36
+ other_vapp.destroy if other_vapp
37
+ end
38
+
39
+ it 'should overwrite a vApp when given a path of an existing vApp' do
40
+ @spec_vapp.clone_to! @other_path
41
+ after_vapp = @monkey.vapp @other_path
42
+ expect(after_vapp).to_not be_nil
43
+ expect(after_vapp.property :clone_to_bang).to be_nil
44
+ end
45
+ end
46
+ end
47
+ end
@@ -47,5 +47,34 @@ describe RbVmomi::VIM::VirtualApp do
47
47
  it { expect(@spec_vapp.find_property(:ip_prop_with_default)[:type]).to eq 'ip' }
48
48
  end
49
49
 
50
+ describe '#set_properties' do
51
+ before(:all) do
52
+ @spec_vapp.set_properties({
53
+ multi_prop: 'xyzzy',
54
+ multi_ip_prop: { value: '1.1.1.1', type: 'ip' },
55
+ multi_ip_prop_with_default: { value: nil, type: 'ip', defaultValue: '0.0.0.0' }
56
+ })
57
+ end
58
+
59
+ it 'should set multiple properies from scratch' do
60
+ expect(@spec_vapp.property :multi_prop).to eq 'xyzzy'
61
+ expect(@spec_vapp.property :multi_ip_prop).to eq '1.1.1.1'
62
+ expect(@spec_vapp.property :multi_ip_prop_with_default).to eq '0.0.0.0'
63
+ end
64
+
65
+ it 'should overwrite multiple properies that already exist' do
66
+ @spec_vapp.set_properties({
67
+ multi_prop: 'abc123',
68
+ multi_ip_prop: '2.2.2.2',
69
+ multi_ip_prop_with_default: { value: '3.3.3.3', type: 'string' }
70
+ })
71
+
72
+ expect(@spec_vapp.property :multi_prop).to eq 'abc123'
73
+ expect(@spec_vapp.property :multi_ip_prop).to eq '2.2.2.2'
74
+ expect(@spec_vapp.find_property(:multi_ip_prop)[:type]).to eq 'ip'
75
+ expect(@spec_vapp.property :multi_ip_prop_with_default).to eq '3.3.3.3'
76
+ expect(@spec_vapp.find_property(:multi_ip_prop_with_default)[:type]).to eq 'string'
77
+ end
78
+ end
50
79
  end
51
80
  end
@@ -28,13 +28,6 @@ describe RbVmomi::VIM::VirtualApp do
28
28
  before(:all) { @spec_vapp = @vapp.clone_to @spec_vapp_path }
29
29
  after(:all) { @spec_vapp.destroy }
30
30
 
31
- describe '#clone' do
32
- context 'to a Folder' do
33
- subject { @monkey.vapp @spec_vapp_path }
34
- it { should_not be_nil }
35
- end
36
- end
37
-
38
31
  describe '#move_to' do
39
32
  it 'should raise a RuntimeError when given a path of an existing vApp' do
40
33
  expect { @spec_vapp.move_to @spec_vapp_path }.to raise_error RuntimeError
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.8.0
4
+ version: 0.9.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-09-19 00:00:00.000000000 Z
12
+ date: 2014-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -29,73 +29,73 @@ dependencies:
29
29
  name: rbvmomi
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
34
  version: '1.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.5'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: '1.6'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.6'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
76
  version: '2.14'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
83
  version: '2.14'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec-its
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - '>='
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
- description: " simple to use vsphere methods "
98
+ description: ' simple to use vsphere methods '
99
99
  email:
100
100
  - brian@duprasville.com
101
101
  - dsmith@rallydev.com
@@ -103,7 +103,7 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
- - ".gitignore"
106
+ - .gitignore
107
107
  - CHANGELOG.md
108
108
  - Gemfile
109
109
  - LICENSE.txt
@@ -119,6 +119,7 @@ files:
119
119
  - spec/datacenter_spec.rb
120
120
  - spec/folder_spec.rb
121
121
  - spec/spec_helper.rb
122
+ - spec/vapp_clone_spec.rb
122
123
  - spec/vapp_property_spec.rb
123
124
  - spec/vapp_spec.rb
124
125
  - spec/vim_spec.rb
@@ -136,17 +137,17 @@ require_paths:
136
137
  - lib
137
138
  required_ruby_version: !ruby/object:Gem::Requirement
138
139
  requirements:
139
- - - ">="
140
+ - - '>='
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  requirements:
144
- - - ">="
145
+ - - '>='
145
146
  - !ruby/object:Gem::Version
146
147
  version: '0'
147
148
  requirements: []
148
149
  rubyforge_project:
149
- rubygems_version: 2.2.2
150
+ rubygems_version: 2.0.14
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: simple to use vsphere methods
@@ -154,6 +155,7 @@ test_files:
154
155
  - spec/datacenter_spec.rb
155
156
  - spec/folder_spec.rb
156
157
  - spec/spec_helper.rb
158
+ - spec/vapp_clone_spec.rb
157
159
  - spec/vapp_property_spec.rb
158
160
  - spec/vapp_spec.rb
159
161
  - spec/vim_spec.rb