vm_shepherd 3.1.5 → 3.1.6
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/openstack_manager.rb +68 -63
- data/lib/vm_shepherd/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f73287b799bf724b192d5f7344f8d2e6391a31
|
4
|
+
data.tar.gz: 08bb033f69ac1f3a2bfdfa72ff4d8cbc62b21924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 690db91ffe1554092ac8c9a3e33f33ca88961a2f6844206b12c69ec0fa1cb34ab8606e09d9da462c3ea65a181b70c8b84f57d35934d7d93c878b69d12a7f9260
|
7
|
+
data.tar.gz: ef60773ed1d23b22a47484ef5c29e0dbc5518e68280eeb3c6d88795564ca3f28b327f84f7977a81a49de485b77a85d3e996f2dbbc94022076647d4b32cc54e66
|
@@ -8,41 +8,41 @@ module VmShepherd
|
|
8
8
|
def initialize(auth_url:, username:, api_key:, tenant:)
|
9
9
|
@auth_url = auth_url
|
10
10
|
@username = username
|
11
|
-
@api_key
|
12
|
-
@tenant
|
11
|
+
@api_key = api_key
|
12
|
+
@tenant = tenant
|
13
13
|
end
|
14
14
|
|
15
15
|
def deploy(raw_file_path, vm_options)
|
16
16
|
say "Uploading the image #{raw_file_path}"
|
17
17
|
image = image_service.images.create(
|
18
|
-
name:
|
19
|
-
size:
|
20
|
-
disk_format:
|
18
|
+
name: "#{vm_options[:name]} #{Time.now}",
|
19
|
+
size: File.size(raw_file_path),
|
20
|
+
disk_format: 'raw',
|
21
21
|
container_format: 'bare',
|
22
|
-
location:
|
22
|
+
location: raw_file_path,
|
23
23
|
)
|
24
24
|
say 'Finished uploading the image'
|
25
25
|
|
26
|
-
flavor
|
27
|
-
network
|
26
|
+
flavor = find_flavor(vm_options[:flavor_name])
|
27
|
+
network = network_service.networks.find { |net| net.name == vm_options[:network_name] }
|
28
28
|
security_groups = vm_options[:security_group_names]
|
29
29
|
|
30
30
|
say('Launching an instance')
|
31
31
|
server = service.servers.create(
|
32
|
-
name:
|
33
|
-
flavor_ref:
|
34
|
-
image_ref:
|
35
|
-
key_name:
|
32
|
+
name: vm_options[:name],
|
33
|
+
flavor_ref: flavor.id,
|
34
|
+
image_ref: image.id,
|
35
|
+
key_name: vm_options[:key_name],
|
36
36
|
security_groups: security_groups,
|
37
|
-
nics:
|
38
|
-
|
39
|
-
|
37
|
+
nics: [
|
38
|
+
{net_id: network.id, v4_fixed_ip: vm_options[:private_ip]}
|
39
|
+
],
|
40
40
|
)
|
41
41
|
server.wait_for { ready? }
|
42
42
|
say('Finished launching an instance')
|
43
43
|
|
44
44
|
say('Assigning a Public IP to the instance')
|
45
|
-
ip
|
45
|
+
ip = service.addresses.find { |address| address.instance_id.nil? && address.ip == vm_options[:public_ip] }
|
46
46
|
ip.server = server
|
47
47
|
say('Finished assigning a Public IP to the instance')
|
48
48
|
end
|
@@ -73,45 +73,50 @@ module VmShepherd
|
|
73
73
|
def clean_environment
|
74
74
|
say("Destroying #{service.servers.size} instances:")
|
75
75
|
retry_until(retry_limit: 2) do
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
begin
|
77
|
+
service.servers.each do |server|
|
78
|
+
server.volumes.each do |volume|
|
79
|
+
say(" Detaching volume #{volume.id} from server #{server.id}")
|
80
|
+
server.detach_volume(volume.id)
|
81
|
+
volume.wait_for { volume.ready? }
|
82
|
+
end
|
83
|
+
|
84
|
+
say(" Destroying instance #{server.id}")
|
85
|
+
server.destroy
|
80
86
|
end
|
81
87
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
server_count = service.servers.count
|
88
|
-
say(" Waiting for #{server_count} servers to be destroyed")
|
89
|
-
server_count == 0
|
90
|
-
end
|
91
|
-
end
|
88
|
+
retry_until(retry_limit: 15) do
|
89
|
+
server_count = service.servers.count
|
90
|
+
say(" Waiting for #{server_count} servers to be destroyed")
|
91
|
+
server_count == 0
|
92
|
+
end
|
92
93
|
|
93
|
-
|
94
|
+
private_images = image_service.images.reject(&:is_public)
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
say("Destroying #{private_images.size} images:")
|
97
|
+
private_images.each do |image|
|
98
|
+
next if image.status == 'deleted'
|
99
|
+
say(" Destroying image #{image.id}")
|
100
|
+
image.destroy
|
101
|
+
end
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
say("Destroying #{service.volumes.size} volumes:")
|
104
|
+
service.volumes.each do |volume|
|
105
|
+
say(" Destroying volume #{volume.id}; current status: [#{volume.status}]")
|
106
|
+
volume.wait_for { volume.ready? }
|
107
|
+
volume.destroy
|
108
|
+
end
|
108
109
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
110
|
+
say("Destroying contents of #{storage_service.directories.size} containers:")
|
111
|
+
storage_service.directories.each do |directory|
|
112
|
+
say(" Destroying #{directory.files.size} files from #{directory.key}")
|
113
|
+
directory.files.each do |file|
|
114
|
+
say(" Destroying file #{file.key}")
|
115
|
+
file.destroy
|
116
|
+
end
|
117
|
+
end
|
118
|
+
rescue VmShepherd::RetryHelper::RetryLimitExceeded, Fog::Errors::TimeoutError => e
|
119
|
+
say("Going to retry to cleanup again. First attempt raised #{e.class}: #{e.message}")
|
115
120
|
end
|
116
121
|
end
|
117
122
|
end
|
@@ -127,22 +132,22 @@ module VmShepherd
|
|
127
132
|
|
128
133
|
def service
|
129
134
|
@service ||= Fog::Compute.new(
|
130
|
-
provider:
|
135
|
+
provider: 'openstack',
|
131
136
|
openstack_auth_url: auth_url,
|
132
137
|
openstack_username: username,
|
133
|
-
openstack_tenant:
|
134
|
-
openstack_api_key:
|
138
|
+
openstack_tenant: tenant,
|
139
|
+
openstack_api_key: api_key,
|
135
140
|
connection_options: connection_options,
|
136
141
|
)
|
137
142
|
end
|
138
143
|
|
139
144
|
def image_service
|
140
145
|
@image_service ||= Fog::Image.new(
|
141
|
-
provider:
|
142
|
-
openstack_auth_url:
|
143
|
-
openstack_username:
|
144
|
-
openstack_tenant:
|
145
|
-
openstack_api_key:
|
146
|
+
provider: 'openstack',
|
147
|
+
openstack_auth_url: auth_url,
|
148
|
+
openstack_username: username,
|
149
|
+
openstack_tenant: tenant,
|
150
|
+
openstack_api_key: api_key,
|
146
151
|
openstack_endpoint_type: 'publicURL',
|
147
152
|
connection_options: connection_options,
|
148
153
|
)
|
@@ -150,22 +155,22 @@ module VmShepherd
|
|
150
155
|
|
151
156
|
def network_service
|
152
157
|
@network_service ||= Fog::Network.new(
|
153
|
-
provider:
|
158
|
+
provider: 'openstack',
|
154
159
|
openstack_auth_url: auth_url,
|
155
160
|
openstack_username: username,
|
156
|
-
openstack_tenant:
|
157
|
-
openstack_api_key:
|
161
|
+
openstack_tenant: tenant,
|
162
|
+
openstack_api_key: api_key,
|
158
163
|
connection_options: connection_options,
|
159
164
|
)
|
160
165
|
end
|
161
166
|
|
162
167
|
def storage_service
|
163
168
|
@network_service ||= Fog::Storage.new(
|
164
|
-
provider:
|
169
|
+
provider: 'openstack',
|
165
170
|
openstack_auth_url: auth_url,
|
166
171
|
openstack_username: username,
|
167
|
-
openstack_tenant:
|
168
|
-
openstack_api_key:
|
172
|
+
openstack_tenant: tenant,
|
173
|
+
openstack_api_key: api_key,
|
169
174
|
connection_options: connection_options,
|
170
175
|
)
|
171
176
|
end
|
data/lib/vm_shepherd/version.rb
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: 3.1.
|
4
|
+
version: 3.1.6
|
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: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
206
|
version: '0'
|
207
207
|
requirements: []
|
208
208
|
rubyforge_project:
|
209
|
-
rubygems_version: 2.
|
209
|
+
rubygems_version: 2.5.1
|
210
210
|
signing_key:
|
211
211
|
specification_version: 4
|
212
212
|
summary: A tool for booting and tearing down Ops Manager VMs on various Infrastructures.
|