vm_shepherd 1.0.0 → 1.0.1

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: a0fc9f0b7a52ae491f167a0102a7a04f6b49f8ce
4
- data.tar.gz: 7c602729eb8a957c869b4d995f1d072070497fef
3
+ metadata.gz: bb6310bb53bda4135f7be984028062f68866a5df
4
+ data.tar.gz: 0a44fc8da3d7606e2a737c7813ba47d9e2ce8f4d
5
5
  SHA512:
6
- metadata.gz: ae2def494be27f83ab4528e3cce896fa9fd10ea6df91dd3060d36523e62bb43331915b1e3e2bed3873e5a46c6af223617f86d97302c5caf7329d66b66f7758f1
7
- data.tar.gz: cb19597cef1a5cfb96fb565eaf3d461eca74bf2ccdbaab8745a39b39aa3a330d9feee288353e936ffad3311fa8278547f51eca46689136ebf39606f94d45ba78
6
+ metadata.gz: d62fb69276e46d6ac4ef6dba996f90efda53023f0847bb9f0de991a92c754703d5bf09113a237ac630b6d05e0826a36d3c1e810bf60b50c1191abc026a9e107a
7
+ data.tar.gz: 5df72d123fdef410c9c98d23ef9216617f4e39fb74d808bc54dc72bce387ab7cc03d8f3f4aa886982712992e4891c4b924f994aa3ca0935fb75eb2058a3e7530
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem install bundler -v '~> 1.9'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # VmShepherd
1
+ # VmShepherd [![Build Status](https://travis-ci.org/pivotal-cf-experimental/vm_shepherd.svg)](https://travis-ci.org/pivotal-cf-experimental/vm_shepherd)
2
2
 
3
3
  Gem for deploying and destroying a VM on different IAASs such as AWS, vSphere, vCloud, and Openstack
4
4
 
@@ -6,11 +6,15 @@ module VmShepherd
6
6
  @settings = settings
7
7
  end
8
8
 
9
- def deploy(path:)
9
+ def deploy(paths:)
10
10
  unless valid_iaas_types.include?(settings.iaas_type)
11
11
  fail(InvalidIaas, "Unknown IaaS type: #{settings.iaas_type.inspect}")
12
12
  end
13
- vm_shepherd_configs(settings).each do |vm_shepherd_config|
13
+ configs = vm_shepherd_configs(settings)
14
+ unless configs.size == paths.size
15
+ fail(ArgumentError, "mismatch in available images to deploy (needed #{configs.size}, got #{paths.size})")
16
+ end
17
+ configs.zip(paths).each do |vm_shepherd_config, path|
14
18
  case settings.iaas_type
15
19
  when VmShepherd::VCLOUD_IAAS_TYPE then
16
20
  VmShepherd::VcloudManager.new(
@@ -1,3 +1,3 @@
1
1
  module VmShepherd
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -42,7 +42,7 @@ module VmShepherd
42
42
  ).and_return(last_vcloud_manager)
43
43
 
44
44
  expect(first_vcloud_manager).to receive(:deploy).with(
45
- 'FAKE_PATH',
45
+ 'FIRST_FAKE_PATH',
46
46
  {
47
47
  name: first_config.vapp.ops_manager_name,
48
48
  ip: first_config.vapp.ip,
@@ -56,7 +56,7 @@ module VmShepherd
56
56
  )
57
57
 
58
58
  expect(last_vcloud_manager).to receive(:deploy).with(
59
- 'FAKE_PATH',
59
+ 'LAST_FAKE_PATH',
60
60
  {
61
61
  name: last_config.vapp.ops_manager_name,
62
62
  ip: last_config.vapp.ip,
@@ -69,7 +69,11 @@ module VmShepherd
69
69
  }
70
70
  )
71
71
 
72
- manager.deploy(path: 'FAKE_PATH')
72
+ manager.deploy(paths: ['FIRST_FAKE_PATH', 'LAST_FAKE_PATH'])
73
+ end
74
+
75
+ it 'fails if improper paths are given' do
76
+ expect { manager.deploy(paths: ['FIRST_FAKE_PATH']) }.to raise_error(ArgumentError)
73
77
  end
74
78
  end
75
79
 
@@ -95,7 +99,7 @@ module VmShepherd
95
99
  ).and_return(last_ova_manager)
96
100
 
97
101
  expect(first_ova_manager).to receive(:deploy).with(
98
- 'FAKE_PATH',
102
+ 'FIRST_FAKE_PATH',
99
103
  {
100
104
  ip: first_config.vm.ip,
101
105
  gateway: first_config.vm.gateway,
@@ -113,7 +117,7 @@ module VmShepherd
113
117
  )
114
118
 
115
119
  expect(last_ova_manager).to receive(:deploy).with(
116
- 'FAKE_PATH',
120
+ 'LAST_FAKE_PATH',
117
121
  {
118
122
  ip: last_config.vm.ip,
119
123
  gateway: last_config.vm.gateway,
@@ -130,7 +134,11 @@ module VmShepherd
130
134
  },
131
135
  )
132
136
 
133
- manager.deploy(path: 'FAKE_PATH')
137
+ manager.deploy(paths: ['FIRST_FAKE_PATH', 'LAST_FAKE_PATH'])
138
+ end
139
+
140
+ it 'fails if improper paths are given' do
141
+ expect { manager.deploy(paths: ['FIRST_FAKE_PATH']) }.to raise_error(ArgumentError)
134
142
  end
135
143
  end
136
144
 
@@ -138,7 +146,8 @@ module VmShepherd
138
146
  let(:settings_fixture_name) { 'aws.yml' }
139
147
  let(:first_ams_manager) { instance_double(AwsManager) }
140
148
  let(:last_ams_manager) { instance_double(AwsManager) }
141
- let(:ami_file_path) { 'PATH_TO_AMI_FILE' }
149
+ let(:first_ami_file_path) { 'PATH_TO_AMI_FILE' }
150
+ let(:last_ami_file_path) { 'PATH_TO_AMI_FILE-2' }
142
151
  let(:first_aws_options) do
143
152
  {
144
153
  aws_access_key: 'aws-access-key',
@@ -166,18 +175,23 @@ module VmShepherd
166
175
 
167
176
  it 'uses AwsManager to launch a VM' do
168
177
  expect(AwsManager).to receive(:new).with(first_aws_options).and_return(first_ams_manager)
169
- expect(first_ams_manager).to receive(:deploy).with(ami_file_path)
178
+ expect(first_ams_manager).to receive(:deploy).with(first_ami_file_path)
170
179
 
171
180
  expect(AwsManager).to receive(:new).with(last_aws_options).and_return(last_ams_manager)
172
- expect(last_ams_manager).to receive(:deploy).with(ami_file_path)
181
+ expect(last_ams_manager).to receive(:deploy).with(last_ami_file_path)
173
182
 
174
- manager.deploy(path: ami_file_path)
183
+ manager.deploy(paths: [first_ami_file_path, last_ami_file_path])
184
+ end
185
+
186
+ it 'fails if improper paths are given' do
187
+ expect { manager.deploy(paths: ['FIRST_FAKE_PATH']) }.to raise_error(ArgumentError)
175
188
  end
176
189
  end
177
190
 
178
191
  context 'with OpenStack settings' do
179
192
  let(:settings_fixture_name) { 'openstack.yml' }
180
- let(:qcow2_file_path) { 'PATH_TO_QCOW2_FILE' }
193
+ let(:first_qcow2_file_path) { 'PATH_TO_QCOW2_FILE' }
194
+ let(:last_qcow2_file_path) { 'PATH_TO_QCOW2_FILE-2' }
181
195
  let(:first_qcow2_manager) { instance_double(OpenstackManager) }
182
196
  let(:last_qcow2_manager) { instance_double(OpenstackManager) }
183
197
  let(:first_openstack_options) do
@@ -229,12 +243,16 @@ module VmShepherd
229
243
 
230
244
  it 'uses OpenstackManager to launch a VM' do
231
245
  expect(OpenstackManager).to receive(:new).with(first_openstack_options).and_return(first_qcow2_manager)
232
- expect(first_qcow2_manager).to receive(:deploy).with(qcow2_file_path, first_openstack_vm_options)
246
+ expect(first_qcow2_manager).to receive(:deploy).with(first_qcow2_file_path, first_openstack_vm_options)
233
247
 
234
248
  expect(OpenstackManager).to receive(:new).with(last_openstack_options).and_return(last_qcow2_manager)
235
- expect(last_qcow2_manager).to receive(:deploy).with(qcow2_file_path, last_openstack_vm_options)
249
+ expect(last_qcow2_manager).to receive(:deploy).with(last_qcow2_file_path, last_openstack_vm_options)
250
+
251
+ manager.deploy(paths: [first_qcow2_file_path, last_qcow2_file_path])
252
+ end
236
253
 
237
- manager.deploy(path: qcow2_file_path)
254
+ it 'fails if improper paths are given' do
255
+ expect { manager.deploy(paths: ['FIRST_FAKE_PATH']) }.to raise_error(ArgumentError)
238
256
  end
239
257
  end
240
258
 
@@ -242,7 +260,7 @@ module VmShepherd
242
260
  let(:settings_fixture_name) { 'unknown.yml' }
243
261
 
244
262
  it 'raises an exception' do
245
- expect { manager.deploy(path: 'FAKE_PATH') }.to raise_error(Shepherd::InvalidIaas)
263
+ expect { manager.deploy(paths: ['FAKE_PATH']) }.to raise_error(Shepherd::InvalidIaas)
246
264
  end
247
265
  end
248
266
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vm_shepherd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ops Manager Team
@@ -146,6 +146,7 @@ files:
146
146
  - ".gitignore"
147
147
  - ".rspec"
148
148
  - ".ruby-version"
149
+ - ".travis.yml"
149
150
  - Gemfile
150
151
  - LICENSE.txt
151
152
  - README.md
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  version: '0'
192
193
  requirements: []
193
194
  rubyforge_project:
194
- rubygems_version: 2.4.5
195
+ rubygems_version: 2.4.6
195
196
  signing_key:
196
197
  specification_version: 4
197
198
  summary: A tool for booting and tearing down Ops Manager VMs on various Infrastructures.