vm_shepherd 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vm_shepherd/aws_manager.rb +1 -3
- data/lib/vm_shepherd/shepherd.rb +17 -11
- data/lib/vm_shepherd/version.rb +1 -1
- data/lib/vm_shepherd/vsphere_manager.rb +2 -4
- data/spec/vm_shepherd/aws_manager_spec.rb +2 -1
- data/spec/vm_shepherd/shepherd_spec.rb +16 -9
- data/spec/vm_shepherd/vsphere_manager_spec.rb +2 -5
- data/vm_shepherd.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a51063e75ce1a10f12e746299821c382150bd4d
|
4
|
+
data.tar.gz: 013d846fff397f280bf6ef7b28a0517c530dcd19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c881a78a01d8263536e58a36312d8310e63807985a11a880e90c0c00f3a4e5a7f632359544f01525287418fffd890a479c089bbbdc32b24e352d30ada080fa
|
7
|
+
data.tar.gz: 95480a3391d27a8e8b6fe93265d7a4d460a6a5c00d17cfc524f51f68e67aa8cba4b4b35b93d97ebd9ec1067d5401ff0e1ad5a6dbed35f8c39e380190b3abc57e
|
@@ -16,9 +16,7 @@ module VmShepherd
|
|
16
16
|
DELETE_IN_PROGRESS = 'DELETE_IN_PROGRESS'
|
17
17
|
DELETE_COMPLETE = 'DELETE_COMPLETE'
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
def initialize(env_config)
|
19
|
+
def initialize(env_config:, logger:)
|
22
20
|
AWS.config(
|
23
21
|
access_key_id: env_config.fetch(:aws_access_key),
|
24
22
|
secret_access_key: env_config.fetch(:aws_secret_key),
|
data/lib/vm_shepherd/shepherd.rb
CHANGED
@@ -37,6 +37,7 @@ module VmShepherd
|
|
37
37
|
vm_shepherd_config.vcenter_creds.username,
|
38
38
|
vm_shepherd_config.vcenter_creds.password,
|
39
39
|
vm_shepherd_config.vsphere.datacenter,
|
40
|
+
error_logger,
|
40
41
|
).deploy(
|
41
42
|
path,
|
42
43
|
{
|
@@ -87,6 +88,7 @@ module VmShepherd
|
|
87
88
|
vm_shepherd_config.vcenter_creds.username,
|
88
89
|
vm_shepherd_config.vcenter_creds.password,
|
89
90
|
vm_shepherd_config.vsphere.datacenter,
|
91
|
+
error_logger,
|
90
92
|
).prepare_environment
|
91
93
|
end
|
92
94
|
when VmShepherd::AWS_IAAS_TYPE then
|
@@ -121,6 +123,7 @@ module VmShepherd
|
|
121
123
|
vm_shepherd_config.vcenter_creds.username,
|
122
124
|
vm_shepherd_config.vcenter_creds.password,
|
123
125
|
vm_shepherd_config.vsphere.datacenter,
|
126
|
+
error_logger,
|
124
127
|
).destroy(vm_shepherd_config.vm.ip, vm_shepherd_config.vsphere.resource_pool)
|
125
128
|
when VmShepherd::AWS_IAAS_TYPE then
|
126
129
|
ami_manager.destroy(vm_shepherd_config.to_h)
|
@@ -155,6 +158,7 @@ module VmShepherd
|
|
155
158
|
vm_shepherd_config.vcenter_creds.username,
|
156
159
|
vm_shepherd_config.vcenter_creds.password,
|
157
160
|
vm_shepherd_config.cleanup.datacenter,
|
161
|
+
error_logger,
|
158
162
|
).clean_environment(
|
159
163
|
datacenter_folders_to_clean: vm_shepherd_config.cleanup.datacenter_folders_to_clean,
|
160
164
|
datastores: vm_shepherd_config.cleanup.datastores,
|
@@ -195,17 +199,19 @@ module VmShepherd
|
|
195
199
|
end
|
196
200
|
|
197
201
|
def ami_manager
|
198
|
-
@ami_manager ||=
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
202
|
+
@ami_manager ||=
|
203
|
+
VmShepherd::AwsManager.new(
|
204
|
+
env_config: {
|
205
|
+
stack_name: settings.vm_shepherd.env_config.stack_name,
|
206
|
+
aws_access_key: settings.vm_shepherd.env_config.aws_access_key,
|
207
|
+
aws_secret_key: settings.vm_shepherd.env_config.aws_secret_key,
|
208
|
+
region: settings.vm_shepherd.env_config.region,
|
209
|
+
json_file: settings.vm_shepherd.env_config.json_file,
|
210
|
+
parameters: settings.vm_shepherd.env_config.parameters_as_a_hash,
|
211
|
+
outputs: settings.vm_shepherd.env_config.outputs.to_h,
|
212
|
+
}.merge(ami_elb_config),
|
213
|
+
logger: error_logger,
|
214
|
+
)
|
209
215
|
end
|
210
216
|
|
211
217
|
def ami_elb_config
|
data/lib/vm_shepherd/version.rb
CHANGED
@@ -7,14 +7,12 @@ module VmShepherd
|
|
7
7
|
VALID_FOLDER_REGEX = /\A([\w-]{1,80}\/)*[\w-]{1,80}\/?\z/
|
8
8
|
VALID_DISK_FOLDER_REGEX = /\A[\w-]{1,80}\z/
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(host, username, password, datacenter_name)
|
10
|
+
def initialize(host, username, password, datacenter_name, logger)
|
13
11
|
@host = host
|
14
12
|
@username = username
|
15
13
|
@password = password
|
16
14
|
@datacenter_name = datacenter_name
|
17
|
-
@logger =
|
15
|
+
@logger = logger
|
18
16
|
end
|
19
17
|
|
20
18
|
def deploy(ova_path, vm_config, vsphere_config)
|
@@ -41,8 +41,9 @@ module VmShepherd
|
|
41
41
|
vm_name: 'some-vm-name',
|
42
42
|
}
|
43
43
|
end
|
44
|
+
let(:fake_logger) { instance_double(Logger).as_null_object }
|
44
45
|
|
45
|
-
subject(:ami_manager) { AwsManager.new(env_config
|
46
|
+
subject(:ami_manager) { AwsManager.new(env_config: env_config, logger: fake_logger) }
|
46
47
|
|
47
48
|
before do
|
48
49
|
expect(AWS).to receive(:config).with(
|
@@ -119,14 +119,15 @@ module VmShepherd
|
|
119
119
|
first_config.vcenter_creds.username,
|
120
120
|
first_config.vcenter_creds.password,
|
121
121
|
first_config.vsphere.datacenter,
|
122
|
+
instance_of(Logger),
|
122
123
|
).and_return(first_ova_manager)
|
123
124
|
|
124
|
-
|
125
125
|
expect(VsphereManager).to receive(:new).with(
|
126
126
|
last_config.vcenter_creds.ip,
|
127
127
|
last_config.vcenter_creds.username,
|
128
128
|
last_config.vcenter_creds.password,
|
129
129
|
last_config.vsphere.datacenter,
|
130
|
+
instance_of(Logger),
|
130
131
|
).and_return(last_ova_manager)
|
131
132
|
|
132
133
|
expect(first_ova_manager).to receive(:deploy).with(
|
@@ -182,7 +183,7 @@ module VmShepherd
|
|
182
183
|
let(:last_aws_options) { {vm_name: 'vm-name-2'} }
|
183
184
|
|
184
185
|
it 'uses AwsManager to launch a VM' do
|
185
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(aws_manager)
|
186
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
186
187
|
expect(aws_manager).to receive(:deploy).with(ami_file_path: first_ami_file_path, vm_config: first_aws_options)
|
187
188
|
expect(aws_manager).to receive(:deploy).with(ami_file_path: last_ami_file_path, vm_config: last_aws_options)
|
188
189
|
|
@@ -198,7 +199,7 @@ module VmShepherd
|
|
198
199
|
let(:aws_elb_config) { {} }
|
199
200
|
|
200
201
|
it 'uses AwsManager to launch a VM' do
|
201
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(aws_manager)
|
202
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
202
203
|
expect(aws_manager).to receive(:deploy).with(ami_file_path: first_ami_file_path, vm_config: first_aws_options)
|
203
204
|
expect(aws_manager).to receive(:deploy).with(ami_file_path: last_ami_file_path, vm_config: last_aws_options)
|
204
205
|
|
@@ -338,6 +339,7 @@ module VmShepherd
|
|
338
339
|
first_config.vcenter_creds.username,
|
339
340
|
first_config.vcenter_creds.password,
|
340
341
|
first_config.vsphere.datacenter,
|
342
|
+
instance_of(Logger),
|
341
343
|
).and_return(first_ova_manager)
|
342
344
|
expect(first_ova_manager).to receive(:destroy).with(first_config.vm.ip, first_config.vsphere.resource_pool)
|
343
345
|
|
@@ -346,6 +348,7 @@ module VmShepherd
|
|
346
348
|
last_config.vcenter_creds.username,
|
347
349
|
last_config.vcenter_creds.password,
|
348
350
|
last_config.vsphere.datacenter,
|
351
|
+
instance_of(Logger),
|
349
352
|
).and_return(last_ova_manager)
|
350
353
|
expect(last_ova_manager).to receive(:destroy).with(last_config.vm.ip, last_config.vsphere.resource_pool)
|
351
354
|
|
@@ -360,7 +363,7 @@ module VmShepherd
|
|
360
363
|
let(:last_ami_options) { {vm_name: 'vm-name-2'} }
|
361
364
|
|
362
365
|
it 'uses AwsManager to destroy a VM' do
|
363
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(aws_manager)
|
366
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
364
367
|
expect(aws_manager).to receive(:destroy).with(first_ami_options)
|
365
368
|
expect(aws_manager).to receive(:destroy).with(last_ami_options)
|
366
369
|
|
@@ -372,7 +375,7 @@ module VmShepherd
|
|
372
375
|
let(:aws_elb_config) {{}}
|
373
376
|
|
374
377
|
it 'uses AwsManager to destroy a VM' do
|
375
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(aws_manager)
|
378
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
376
379
|
expect(aws_manager).to receive(:destroy).with(first_ami_options)
|
377
380
|
expect(aws_manager).to receive(:destroy).with(last_ami_options)
|
378
381
|
|
@@ -521,6 +524,7 @@ module VmShepherd
|
|
521
524
|
first_config.vcenter_creds.username,
|
522
525
|
first_config.vcenter_creds.password,
|
523
526
|
first_config.cleanup.datacenter,
|
527
|
+
instance_of(Logger),
|
524
528
|
).and_return(first_ova_manager)
|
525
529
|
expect(first_ova_manager).to receive(:clean_environment).with(first_clean_environment_options)
|
526
530
|
expect(VsphereManager).to receive(:new).with(
|
@@ -528,6 +532,7 @@ module VmShepherd
|
|
528
532
|
last_config.vcenter_creds.username,
|
529
533
|
last_config.vcenter_creds.password,
|
530
534
|
last_config.cleanup.datacenter,
|
535
|
+
instance_of(Logger),
|
531
536
|
).and_return(last_ova_manager)
|
532
537
|
expect(last_ova_manager).to receive(:clean_environment).with(last_clean_environment_options)
|
533
538
|
|
@@ -540,7 +545,7 @@ module VmShepherd
|
|
540
545
|
let(:aws_manager) { instance_double(AwsManager) }
|
541
546
|
|
542
547
|
it 'uses AwsManager to destroy a VM' do
|
543
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(aws_manager)
|
548
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
544
549
|
expect(aws_manager).to receive(:clean_environment)
|
545
550
|
manager.clean_environment
|
546
551
|
end
|
@@ -550,7 +555,7 @@ module VmShepherd
|
|
550
555
|
let(:aws_elb_config) {{}}
|
551
556
|
|
552
557
|
it 'uses AwsManager to destroy a VM' do
|
553
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(aws_manager)
|
558
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(aws_manager)
|
554
559
|
expect(aws_manager).to receive(:clean_environment)
|
555
560
|
manager.clean_environment
|
556
561
|
end
|
@@ -603,7 +608,7 @@ module VmShepherd
|
|
603
608
|
let(:ams_manager) { instance_double(AwsManager) }
|
604
609
|
|
605
610
|
it 'uses AwsManager to create an environment' do
|
606
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(ams_manager)
|
611
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(ams_manager)
|
607
612
|
expect(ams_manager).to receive(:prepare_environment).with('cloudformation.json')
|
608
613
|
manager.prepare_environment
|
609
614
|
end
|
@@ -613,7 +618,7 @@ module VmShepherd
|
|
613
618
|
let(:aws_elb_config) {{}}
|
614
619
|
|
615
620
|
it 'uses AwsManager to create an environment' do
|
616
|
-
expect(AwsManager).to receive(:new).with(aws_env_config).and_return(ams_manager)
|
621
|
+
expect(AwsManager).to receive(:new).with(env_config: aws_env_config, logger: instance_of(Logger)).and_return(ams_manager)
|
617
622
|
expect(ams_manager).to receive(:prepare_environment).with('cloudformation.json')
|
618
623
|
manager.prepare_environment
|
619
624
|
end
|
@@ -666,6 +671,7 @@ module VmShepherd
|
|
666
671
|
first_config.vcenter_creds.username,
|
667
672
|
first_config.vcenter_creds.password,
|
668
673
|
first_config.vsphere.datacenter,
|
674
|
+
instance_of(Logger),
|
669
675
|
).and_return(first_ova_manager)
|
670
676
|
expect(first_ova_manager).to receive(:prepare_environment)
|
671
677
|
expect(VsphereManager).to receive(:new).with(
|
@@ -673,6 +679,7 @@ module VmShepherd
|
|
673
679
|
last_config.vcenter_creds.username,
|
674
680
|
last_config.vcenter_creds.password,
|
675
681
|
last_config.vsphere.datacenter,
|
682
|
+
instance_of(Logger),
|
676
683
|
).and_return(last_ova_manager)
|
677
684
|
expect(last_ova_manager).to receive(:prepare_environment)
|
678
685
|
|
@@ -10,12 +10,9 @@ module VmShepherd
|
|
10
10
|
let(:vm2) { instance_double(RbVmomi::VIM::VirtualMachine, name: 'vm_name2', resourcePool: instance_double(RbVmomi::VIM::ResourcePool, name: 'second_resource_pool')) }
|
11
11
|
let(:vm3) { instance_double(RbVmomi::VIM::VirtualMachine, name: 'vm_name3', resourcePool: instance_double(RbVmomi::VIM::ResourcePool, name: 'second_resource_pool')) }
|
12
12
|
let(:vms) { [vm1, vm2, vm3] }
|
13
|
+
let(:fake_logger) { instance_double(Logger).as_null_object }
|
13
14
|
|
14
|
-
subject(:vsphere_manager)
|
15
|
-
manager = VsphereManager.new(host, username, password, datacenter_name)
|
16
|
-
manager.logger = Logger.new(StringIO.new)
|
17
|
-
manager
|
18
|
-
end
|
15
|
+
subject(:vsphere_manager) { VsphereManager.new(host, username, password, datacenter_name, fake_logger) }
|
19
16
|
|
20
17
|
it 'loads' do
|
21
18
|
expect { vsphere_manager }.not_to raise_error
|
data/vm_shepherd.gemspec
CHANGED
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.5.
|
4
|
+
version: 1.5.3
|
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-
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: ruby_vcloud_sdk
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.7.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.7.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rbvmomi
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|