gogetit 0.21.0 → 0.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gogetit/cli.rb +24 -24
- data/lib/gogetit/util.rb +3 -3
- data/lib/gogetit/version.rb +1 -1
- data/lib/providers/libvirt.rb +12 -9
- data/lib/providers/lxd.rb +22 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec3025d3d37da25d264556d84373b5211c09640877117aaf2edfde182545f64
|
4
|
+
data.tar.gz: e7e3d060a85d03cf7720f9563582f35c45472eb53dd338c47b6abef3393ad036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c55e8011cbd55993e901135cf4fdb0b8eca24c8abe8c5b78e43f233396689eb6a4931569245f898d3794cf7c7d350a9b3da125dfdb4d169b9462921edf73a25
|
7
|
+
data.tar.gz: 19798bb065fba34ac5f6c51ebf699bed5cab7e9143d26bcc97ae335e21d43c8d454899a827a5c01735fc383ed5bff5dfe2d24415afeb64c4bb27a7b708396e29
|
data/lib/gogetit/cli.rb
CHANGED
@@ -78,32 +78,32 @@ module Gogetit
|
|
78
78
|
:desc => 'File location(only for LXD provider)'
|
79
79
|
def create(name)
|
80
80
|
abort("'vlans' and 'ipaddresses' can not be set together.") \
|
81
|
-
if options[
|
81
|
+
if options[:vlans] and options[:ipaddresses]
|
82
82
|
abort("'chef' and 'zero' can not be set together.") \
|
83
|
-
if options[
|
83
|
+
if options[:chef] and options[:zero]
|
84
84
|
abort("when 'no-maas', the network configuration have to be set by 'file'.") \
|
85
|
-
if options['no-maas'] and (options[
|
85
|
+
if options[:'no-maas'] and (options[:vlans] or options[:ipaddresses])
|
86
86
|
abort("'no-maas' and 'file' have to be set together.") \
|
87
|
-
if options['no-maas'] ^ !!options[
|
88
|
-
abort("'distro' has to be set with libvirt provider.") \
|
89
|
-
if options[
|
87
|
+
if options[:'no-maas'] ^ !!options[:file]
|
88
|
+
abort("'distro' has to be set only with libvirt provider.") \
|
89
|
+
if options[:distro] and options[:provider] == 'lxd'
|
90
90
|
abort("'alias' has to be set with lxd provider.") \
|
91
|
-
if options[
|
91
|
+
if options[:alias] and options[:provider] == 'libvirt'
|
92
92
|
|
93
|
-
case options[
|
93
|
+
case options[:provider]
|
94
94
|
when 'lxd'
|
95
|
-
Gogetit::CLI.result = lxd.create(name, options
|
95
|
+
Gogetit::CLI.result = lxd.create(name, options)
|
96
96
|
when 'libvirt'
|
97
|
-
Gogetit::CLI.result = libvirt.create(name, options
|
97
|
+
Gogetit::CLI.result = libvirt.create(name, options)
|
98
98
|
else
|
99
99
|
abort('Invalid argument entered.')
|
100
100
|
end
|
101
101
|
|
102
102
|
# post-tasks
|
103
|
-
if options[
|
103
|
+
if options[:chef]
|
104
104
|
knife_bootstrap_chef(name, options[:provider], config)
|
105
105
|
update_databags(config)
|
106
|
-
elsif options[
|
106
|
+
elsif options[:zero]
|
107
107
|
knife_bootstrap_zero(name, options[:provider], config)
|
108
108
|
end
|
109
109
|
end
|
@@ -115,7 +115,7 @@ module Gogetit
|
|
115
115
|
:default => false, :desc => 'Chef Zero awareness'
|
116
116
|
def destroy(name)
|
117
117
|
abort("'chef' and 'zero' can not be set together.") \
|
118
|
-
if options[
|
118
|
+
if options[:chef] and options[:zero]
|
119
119
|
|
120
120
|
provider = get_provider_of(name, providers)
|
121
121
|
if provider
|
@@ -129,10 +129,10 @@ module Gogetit
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
# post-tasks
|
132
|
-
if options[
|
132
|
+
if options[:chef]
|
133
133
|
knife_remove(name, options)
|
134
134
|
update_databags(config)
|
135
|
-
elsif options[
|
135
|
+
elsif options[:zero]
|
136
136
|
knife_remove(name, options)
|
137
137
|
end
|
138
138
|
end
|
@@ -146,15 +146,15 @@ module Gogetit
|
|
146
146
|
:default => false, :desc => 'Chef Zero awareness'
|
147
147
|
def deploy(name)
|
148
148
|
abort("'chef' and 'zero' can not be set together.") \
|
149
|
-
if options[
|
149
|
+
if options[:chef] and options[:zero]
|
150
150
|
|
151
|
-
Gogetit::CLI.result = libvirt.deploy(name, options
|
151
|
+
Gogetit::CLI.result = libvirt.deploy(name, options)
|
152
152
|
|
153
153
|
# post-tasks
|
154
|
-
if options[
|
154
|
+
if options[:chef]
|
155
155
|
knife_bootstrap(name, options[:provider], config)
|
156
156
|
update_databags(config)
|
157
|
-
elsif options[
|
157
|
+
elsif options[:zero]
|
158
158
|
knife_bootstrap_zero(name, options[:provider], config)
|
159
159
|
end
|
160
160
|
end
|
@@ -167,15 +167,15 @@ module Gogetit
|
|
167
167
|
:default => false, :desc => 'Chef Zero awareness'
|
168
168
|
def release(name)
|
169
169
|
abort("'chef' and 'zero' can not be set together.") \
|
170
|
-
if options[
|
170
|
+
if options[:chef] and options[:zero]
|
171
171
|
|
172
172
|
Gogetit::CLI.result = libvirt.release(name)
|
173
173
|
|
174
174
|
# post-tasks
|
175
|
-
if options[
|
175
|
+
if options[:chef]
|
176
176
|
knife_remove(name, options)
|
177
177
|
update_databags(config)
|
178
|
-
elsif options[
|
178
|
+
elsif options[:zero]
|
179
179
|
knife_remove(name, options)
|
180
180
|
end
|
181
181
|
end
|
@@ -188,7 +188,7 @@ module Gogetit
|
|
188
188
|
:default => false, :desc => 'Chef Zero awareness'
|
189
189
|
def rebuild(name)
|
190
190
|
abort("'chef' and 'zero' can not be set together.") \
|
191
|
-
if options[
|
191
|
+
if options[:chef] and options[:zero]
|
192
192
|
|
193
193
|
provider = get_provider_of(name, providers)
|
194
194
|
if provider
|
@@ -212,7 +212,7 @@ module Gogetit
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
# post-tasks
|
215
|
-
if options[
|
215
|
+
if options[:chef]
|
216
216
|
knife_remove(name) if options[:chef]
|
217
217
|
update_databags(config)
|
218
218
|
end
|
data/lib/gogetit/util.rb
CHANGED
@@ -104,7 +104,7 @@ module Gogetit
|
|
104
104
|
def knife_remove(name, options)
|
105
105
|
logger.info("Calling <#{__method__.to_s}>")
|
106
106
|
if find_executable 'knife'
|
107
|
-
if options[
|
107
|
+
if options[:chef]
|
108
108
|
if system('knife ssl check')
|
109
109
|
logger.info("With chef-server..")
|
110
110
|
puts "Deleting node #{name}.."
|
@@ -116,7 +116,7 @@ module Gogetit
|
|
116
116
|
else
|
117
117
|
abort('knife is not configured properly.')
|
118
118
|
end
|
119
|
-
elsif options[
|
119
|
+
elsif options[:zero]
|
120
120
|
logger.info("With chef-zero..")
|
121
121
|
puts "Deleting node #{name}.."
|
122
122
|
logger.info("knife node delete -y #{name}")
|
@@ -270,7 +270,7 @@ module Gogetit
|
|
270
270
|
# preserve source list for a while
|
271
271
|
user_data['apt']['preserve_sources_list'] = true
|
272
272
|
|
273
|
-
if options['no-maas']
|
273
|
+
if options[:'no-maas']
|
274
274
|
# When there is no MAAS, containers should be able to resolve
|
275
275
|
# their name with hosts file.
|
276
276
|
user_data['manage_etc_hosts'] = true
|
data/lib/gogetit/version.rb
CHANGED
data/lib/providers/libvirt.rb
CHANGED
@@ -4,6 +4,8 @@ require 'oga'
|
|
4
4
|
require 'rexml/document'
|
5
5
|
require 'gogetit/util'
|
6
6
|
require 'yaml'
|
7
|
+
require 'base64'
|
8
|
+
require 'hashie'
|
7
9
|
|
8
10
|
module Gogetit
|
9
11
|
class GogetLibvirt
|
@@ -161,11 +163,11 @@ module Gogetit
|
|
161
163
|
domain = config[:libvirt][:specs][:default]
|
162
164
|
ifaces = nil
|
163
165
|
|
164
|
-
if options[
|
165
|
-
ifaces = check_ip_available(options[
|
166
|
+
if options[:ipaddresses]
|
167
|
+
ifaces = check_ip_available(options[:ipaddresses], maas)
|
166
168
|
domain = generate_nics(ifaces, domain)
|
167
|
-
elsif options[
|
168
|
-
#check_vlan_available(options[
|
169
|
+
elsif options[:vlans]
|
170
|
+
#check_vlan_available(options[:vlans])
|
169
171
|
else
|
170
172
|
domain[:nic] = [
|
171
173
|
{
|
@@ -184,10 +186,10 @@ module Gogetit
|
|
184
186
|
system_id = maas.get_system_id(domain[:name])
|
185
187
|
maas.wait_until_state(system_id, 'Ready')
|
186
188
|
|
187
|
-
if options[
|
189
|
+
if options[:ipaddresses]
|
188
190
|
configure_interfaces(ifaces, system_id)
|
189
|
-
elsif options[
|
190
|
-
#check_vlan_available(options[
|
191
|
+
elsif options[:vlans]
|
192
|
+
#check_vlan_available(options[:vlans])
|
191
193
|
else
|
192
194
|
end
|
193
195
|
|
@@ -250,10 +252,11 @@ module Gogetit
|
|
250
252
|
distro = options[:distro]
|
251
253
|
end
|
252
254
|
|
253
|
-
require 'base64'
|
254
255
|
user_data = Base64.encode64(
|
255
256
|
"#cloud-config\n" +
|
256
|
-
YAML.dump(
|
257
|
+
YAML.dump(
|
258
|
+
generate_cloud_init_config(options, config)
|
259
|
+
)[4..-1]
|
257
260
|
)
|
258
261
|
|
259
262
|
maas.conn.request(
|
data/lib/providers/lxd.rb
CHANGED
@@ -51,7 +51,7 @@ module Gogetit
|
|
51
51
|
|
52
52
|
lxd_params[:config] = {}
|
53
53
|
|
54
|
-
if options['no-maas']
|
54
|
+
if options[:'no-maas']
|
55
55
|
lxd_params[:config][:"user.user-data"] = {}
|
56
56
|
else
|
57
57
|
sshkeys = maas.get_sshkeys
|
@@ -73,11 +73,11 @@ module Gogetit
|
|
73
73
|
lxd_params[:config][:"user.user-data"]['maas'] = true
|
74
74
|
end
|
75
75
|
|
76
|
-
if options['maas-on-lxc']
|
76
|
+
if options[:'maas-on-lxc']
|
77
77
|
lxd_params[:config][:"security.privileged"] = "true"
|
78
78
|
end
|
79
79
|
|
80
|
-
if options['lxd-in-lxd']
|
80
|
+
if options[:'lxd-in-lxd']
|
81
81
|
lxd_params[:config][:"security.nesting"] = "true"
|
82
82
|
end
|
83
83
|
|
@@ -103,22 +103,22 @@ module Gogetit
|
|
103
103
|
def generate_network_config(lxd_params, options)
|
104
104
|
logger.info("Calling <#{__method__.to_s}>")
|
105
105
|
|
106
|
-
if options['no-maas']
|
106
|
+
if options[:'no-maas']
|
107
107
|
lxd_params[:config][:'user.network-config'] = \
|
108
|
-
YAML.load_file(options[
|
108
|
+
YAML.load_file(options[:file])['network']
|
109
109
|
|
110
110
|
# physical device will be the gate device
|
111
111
|
lxd_params[:config][:"user.network-config"]['config'].each do |iface|
|
112
112
|
if iface['type'] == "physical"
|
113
|
-
options[
|
113
|
+
options[:ip_to_access] = iface['subnets'][0]['address'].split('/')[0]
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
lxd_params[:config][:"user.network-config"] = \
|
118
118
|
YAML.dump(lxd_params[:config][:"user.network-config"])[4..-1]
|
119
119
|
|
120
|
-
elsif options[
|
121
|
-
options[:ifaces] = check_ip_available(options[
|
120
|
+
elsif options[:ipaddresses]
|
121
|
+
options[:ifaces] = check_ip_available(options[:ipaddresses], maas)
|
122
122
|
abort("There is no dns server specified for the gateway network.") \
|
123
123
|
unless options[:ifaces][0]['dns_servers'][0]
|
124
124
|
abort("There is no gateway specified for the gateway network.") \
|
@@ -200,8 +200,8 @@ module Gogetit
|
|
200
200
|
logger.info("Calling <#{__method__.to_s}>")
|
201
201
|
lxd_params[:devices] = {}
|
202
202
|
|
203
|
-
if options['no-maas']
|
204
|
-
lxd_params[:devices] = YAML.load_file(options[
|
203
|
+
if options[:'no-maas']
|
204
|
+
lxd_params[:devices] = YAML.load_file(options[:file])['devices']
|
205
205
|
|
206
206
|
# Now, LXD API can handle integer as a value of a map
|
207
207
|
lxd_params[:devices].each do |k, v|
|
@@ -214,7 +214,7 @@ module Gogetit
|
|
214
214
|
|
215
215
|
lxd_params[:devices] = (Hashie.symbolize_keys lxd_params[:devices])
|
216
216
|
|
217
|
-
elsif options[
|
217
|
+
elsif options[:ipaddresses]
|
218
218
|
options[:ifaces].each_with_index do |iface,index|
|
219
219
|
if index == 0
|
220
220
|
if iface['vlan']['name'] == 'untagged' # or vid == 0
|
@@ -275,7 +275,7 @@ module Gogetit
|
|
275
275
|
}
|
276
276
|
end
|
277
277
|
|
278
|
-
if options['maas-on-lxc']
|
278
|
+
if options[:'maas-on-lxc']
|
279
279
|
# https://docs.maas.io/2.4/en/installconfig-lxd-install
|
280
280
|
for i in 0..7
|
281
281
|
i = i.to_s
|
@@ -327,21 +327,18 @@ module Gogetit
|
|
327
327
|
def create(name, options = {})
|
328
328
|
logger.info("Calling <#{__method__.to_s}>")
|
329
329
|
|
330
|
-
# options from the kitchen driver have keys as symbol
|
331
|
-
Hashie.stringify_keys! options
|
332
|
-
|
333
330
|
abort("Container #{name} already exists!") \
|
334
331
|
if container_exists?(name)
|
335
332
|
|
336
333
|
abort("Domain #{name}.#{maas.get_domain} already exists!") \
|
337
|
-
if maas.domain_name_exists?(name) unless options['no-maas']
|
334
|
+
if maas.domain_name_exists?(name) unless options[:'no-maas']
|
338
335
|
|
339
336
|
lxd_params = {}
|
340
337
|
|
341
|
-
if options[
|
338
|
+
if options[:alias].nil? or options[:alias].empty?
|
342
339
|
lxd_params[:alias] = config[:lxd][:default_alias]
|
343
340
|
else
|
344
|
-
lxd_params[:alias] = options[
|
341
|
+
lxd_params[:alias] = options[:alias]
|
345
342
|
end
|
346
343
|
|
347
344
|
lxd_params = generate_user_data(lxd_params, options)
|
@@ -357,7 +354,7 @@ module Gogetit
|
|
357
354
|
|
358
355
|
# https://github.com/jeffshantz/hyperkit/blob/master/lib/hyperkit/client/containers.rb#L240
|
359
356
|
# Adding configurations that are necessary for shipping MAAS on lxc
|
360
|
-
if options['maas-on-lxc']
|
357
|
+
if options[:'maas-on-lxc']
|
361
358
|
container.config = container.config.to_hash
|
362
359
|
# https://docs.maas.io/2.4/en/installconfig-lxd-install
|
363
360
|
container.config[:"raw.lxc"] = "\
|
@@ -371,13 +368,13 @@ lxc.cgroup.devices.allow = b 7:* rwm"
|
|
371
368
|
container = conn.container(name)
|
372
369
|
|
373
370
|
reserve_ips(name, options, container) \
|
374
|
-
if options[
|
375
|
-
unless options['no-maas']
|
371
|
+
if options[:vlans] or options[:ipaddresses] \
|
372
|
+
unless options[:'no-maas']
|
376
373
|
|
377
374
|
conn.start_container(name, :sync=>"true")
|
378
375
|
|
379
|
-
if options['no-maas']
|
380
|
-
ip_or_fqdn = options[
|
376
|
+
if options[:'no-maas']
|
377
|
+
ip_or_fqdn = options[:ip_to_access]
|
381
378
|
else
|
382
379
|
ip_or_fqdn = name + '.' + maas.get_domain
|
383
380
|
end
|
@@ -395,8 +392,8 @@ lxc.cgroup.devices.allow = b 7:* rwm"
|
|
395
392
|
wait_until_available(ip_or_fqdn, default_user)
|
396
393
|
logger.info("#{name} has been created.")
|
397
394
|
|
398
|
-
if options['no-maas']
|
399
|
-
puts "ssh #{default_user}@#{options[
|
395
|
+
if options[:'no-maas']
|
396
|
+
puts "ssh #{default_user}@#{options[:ip_to_access]}"
|
400
397
|
else
|
401
398
|
puts "ssh #{default_user}@#{name}"
|
402
399
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gogetit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.21.
|
4
|
+
version: 0.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Draper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|