gogetit 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61751267d26d38a3483ce27309262a216614f6a1
4
- data.tar.gz: 4ca2a6149614790a782b225786f16f8707f87a86
3
+ metadata.gz: 0890aeef5f381b7a754be4830c3cb9e4ac68505a
4
+ data.tar.gz: 3d984331c7ea4ddd357544e6e82161167d054333
5
5
  SHA512:
6
- metadata.gz: 39493d947b7aa4464abdbcf49770911662b349461a151a2c9584d1f768c929cf17f1c03818b5ba86ee0797265affe056680693f8a156f3b7474cc547ee1f59fa
7
- data.tar.gz: b90078303ea89a51598197c789b9b6ba8ac8d87da3368c9e0df19abaf7ac5fd724a9461e59375b2b7ad1027acdf06a6ed07bd779115208317ea700ee7c53c6e0
6
+ metadata.gz: 066366221ebb84db77e72387836b0ae08221caa25d6c8698773e3bfe82c0038bdf4e2742dcb9fea2df65985bea01e3cb1938f913c2a8eb9acb34efb81e6e4fa9
7
+ data.tar.gz: f549b6db39ab79199e082ba7cef1b237cfaac796404cebf1029a7580363d1c8dd51cdb520d355b50a933f94d84f2ac2530f206dede2a0d490bbc2f8af59e1a2b
data/lib/gogetit/util.rb CHANGED
@@ -8,12 +8,13 @@ require 'timeout'
8
8
 
9
9
  module Gogetit
10
10
  module Util
11
- def run_command(cmd, logger)
11
+ def run_command(cmd)
12
12
  logger.info("Calling <#{__method__.to_s}> to run #{cmd}")
13
13
  system(cmd)
14
14
  end
15
15
 
16
16
  def is_port_open?(ip, port)
17
+ logger.info("Calling <#{__method__.to_s}> to check #{ip}:#{port}")
17
18
  begin
18
19
  Timeout::timeout(1) do
19
20
  begin
@@ -50,7 +51,7 @@ module Gogetit
50
51
  end
51
52
  end
52
53
 
53
- def knife_bootstrap(name, provider, config, logger)
54
+ def knife_bootstrap(name, provider, config)
54
55
  logger.info("Calling <#{__method__.to_s}>")
55
56
  config[:chef][:target_environment] ||= '_default'
56
57
  if find_executable 'knife'
@@ -71,7 +72,7 @@ module Gogetit
71
72
  end
72
73
  end
73
74
 
74
- def update_databags(config, logger)
75
+ def update_databags(config)
75
76
  logger.info("Calling <#{__method__.to_s}>")
76
77
  data_bags_dir = "#{config[:chef][:chef_repo_root]}/data_bags"
77
78
 
@@ -89,7 +90,7 @@ module Gogetit
89
90
  )
90
91
  case answer
91
92
  when 'y'
92
- run_command("knife data bag delete -y #{bag}", logger)
93
+ run_command("knife data bag delete -y #{bag}")
93
94
  when 'n'
94
95
  puts 'Keeping..'
95
96
  end
@@ -98,7 +99,7 @@ module Gogetit
98
99
  puts 'Checking databags to create..'
99
100
  (databags_to_be - databags_as_is).each do |bag|
100
101
  puts "Creating databag '#{bag}'.."
101
- run_command("knife data bag create #{bag}", logger)
102
+ run_command("knife data bag create #{bag}")
102
103
  end
103
104
 
104
105
  puts 'Checking items..'
@@ -113,28 +114,25 @@ module Gogetit
113
114
  if items_as_is.include? item
114
115
  run_command(
115
116
  "knife vault update #{bag} #{item} --json #{item_file}"\
116
- " --search '*:*' -M client",
117
- logger
117
+ " --search '*:*' -M client"
118
118
  )
119
119
  else
120
120
  run_command(
121
121
  "knife vault create #{bag} #{item} --json #{item_file}"\
122
- " --search '*:*' -M client",
123
- logger
122
+ " --search '*:*' -M client"
124
123
  )
125
124
  end
126
125
  run_command(
127
- "knife vault refresh #{bag} #{item} --clean-unknown-clients -M client",
128
- logger
126
+ "knife vault refresh #{bag} #{item} --clean-unknown-clients -M client"
129
127
  )
130
128
  else
131
- run_command("knife data bag from file #{bag} #{item_file}", logger)
129
+ run_command("knife data bag from file #{bag} #{item_file}")
132
130
  end
133
131
  end
134
132
  end
135
133
  end
136
134
 
137
- def knife_remove(name, logger)
135
+ def knife_remove(name)
138
136
  logger.info("Calling <#{__method__.to_s}>")
139
137
  if find_executable 'knife'
140
138
  if system('knife ssl check')
@@ -170,29 +168,29 @@ module Gogetit
170
168
  end
171
169
  end
172
170
 
173
- def wait_until_available(ip_or_fqdn, distro_name, logger)
171
+ def wait_until_available(ip_or_fqdn, distro_name)
174
172
  logger.info("Calling <#{__method__.to_s}>")
175
- until ping_available?(ip_or_fqdn, logger)
173
+ until ping_available?(ip_or_fqdn)
176
174
  logger.info("Calling <#{__method__.to_s}> for ping to be ready..")
177
175
  sleep 3
178
176
  end
179
177
  logger.info("#{ip_or_fqdn} is now available to ping..")
180
178
 
181
- until ssh_available?(ip_or_fqdn, distro_name, logger)
179
+ until ssh_available?(ip_or_fqdn, distro_name)
182
180
  logger.info("Calling <#{__method__.to_s}> for ssh to be ready..")
183
181
  sleep 3
184
182
  end
185
183
  logger.info("#{ip_or_fqdn} is now available to ssh..")
186
184
  end
187
185
 
188
- def ping_available?(host, logger)
186
+ def ping_available?(host)
189
187
  # host can be both IP and ip_or_fqdn.
190
188
  logger.info("Calling <#{__method__.to_s}> for #{host}")
191
189
  `ping -c 1 -W 1 #{host}`
192
190
  $?.exitstatus == 0
193
191
  end
194
192
 
195
- def ssh_available?(ip_or_fqdn, user, logger)
193
+ def ssh_available?(ip_or_fqdn, user)
196
194
  logger.info("Calling <#{__method__.to_s}>")
197
195
  begin
198
196
  Net::SSH.start(ip_or_fqdn, user).class
@@ -201,11 +199,11 @@ module Gogetit
201
199
  end
202
200
  end
203
201
 
204
- def check_ip_available(addresses, maas, logger)
202
+ def check_ip_available(addresses, maas)
205
203
  logger.info("Calling <#{__method__.to_s}>")
206
204
  # to do a ping test
207
205
  addresses.each do |ip|
208
- abort("#{ip} is already being used.") if ping_available?(ip, logger)
206
+ abort("#{ip} is already being used.") if ping_available?(ip)
209
207
  end
210
208
  # to check with MAAS
211
209
  ifaces = maas.ip_reserved?(addresses)
@@ -214,7 +212,7 @@ module Gogetit
214
212
  return ifaces
215
213
  end
216
214
 
217
- def run_through_ssh(host, distro_name, commands, logger)
215
+ def run_through_ssh(host, distro_name, commands)
218
216
  logger.info("Calling <#{__method__.to_s}>")
219
217
  Net::SSH.start(host, distro_name) do |ssh|
220
218
  commands.each do |cmd|
@@ -1,3 +1,3 @@
1
1
  module Gogetit
2
- VERSION = "0.12.2"
2
+ VERSION = "0.12.3"
3
3
  end
@@ -153,7 +153,7 @@ module Gogetit
153
153
  ifaces = nil
154
154
 
155
155
  if options['ipaddresses']
156
- ifaces = check_ip_available(options['ipaddresses'], maas, logger)
156
+ ifaces = check_ip_available(options['ipaddresses'], maas)
157
157
  domain = generate_nics(ifaces, domain)
158
158
  elsif options['vlans']
159
159
  #check_vlan_available(options['vlans'])
@@ -197,7 +197,7 @@ module Gogetit
197
197
 
198
198
  fqdn = name + '.' + maas.get_domain
199
199
  distro_name = maas.get_distro_name(system_id)
200
- wait_until_available(fqdn, distro_name, logger)
200
+ wait_until_available(fqdn, distro_name)
201
201
 
202
202
  # To enable serial console to use 'virsh console'
203
203
  if distro_name == 'ubuntu'
@@ -205,7 +205,7 @@ module Gogetit
205
205
  'sudo systemctl enable serial-getty@ttyS0.service',
206
206
  'sudo systemctl start serial-getty@ttyS0.service'
207
207
  ]
208
- run_through_ssh(fqdn, distro_name, commands, logger)
208
+ run_through_ssh(fqdn, distro_name, commands)
209
209
  end
210
210
 
211
211
  logger.info("#{domain[:name]} has been created.")
@@ -283,7 +283,7 @@ module Gogetit
283
283
 
284
284
  fqdn = name + '.' + maas.get_domain
285
285
  distro_name = maas.get_distro_name(system_id)
286
- wait_until_available(fqdn, distro_name, logger)
286
+ wait_until_available(fqdn, distro_name)
287
287
 
288
288
  # To enable serial console to use 'virsh console'
289
289
  if distro_name == 'ubuntu'
@@ -291,15 +291,17 @@ module Gogetit
291
291
  'sudo systemctl enable serial-getty@ttyS0.service',
292
292
  'sudo systemctl start serial-getty@ttyS0.service'
293
293
  ]
294
- run_through_ssh(fqdn, distro_name, commands, logger)
294
+ run_through_ssh(fqdn, distro_name, commands)
295
295
  end
296
296
 
297
297
  logger.info("#{name} has been created.")
298
298
  puts "ssh #{distro_name}@#{name}"
299
299
 
300
- distro[:default_user] = distro_name
300
+ info = {}
301
+ info[:distro] = distro
302
+ info[:default_user] = distro_name
301
303
 
302
- { result: true, info: distro }
304
+ { result: true, info: info }
303
305
  end
304
306
 
305
307
  def release(name)
data/lib/providers/lxd.rb CHANGED
@@ -171,7 +171,7 @@ echo \"RevokedKeys #{config[:cloud_init][:ssh_ca_public_key][:revocation_path]}\
171
171
  YAML.dump(args[:config][:"user.network-config"])[4..-1]
172
172
 
173
173
  elsif options['ipaddresses']
174
- options[:ifaces] = check_ip_available(options['ipaddresses'], maas, logger)
174
+ options[:ifaces] = check_ip_available(options['ipaddresses'], maas)
175
175
  abort("There is no dns server specified for the gateway network.") \
176
176
  unless options[:ifaces][0]['dns_servers'][0]
177
177
  abort("There is no gateway specified for the gateway network.") \
@@ -410,7 +410,7 @@ echo \"RevokedKeys #{config[:cloud_init][:ssh_ca_public_key][:revocation_path]}\
410
410
 
411
411
  args[:default_user] = default_user
412
412
 
413
- wait_until_available(ip_or_fqdn, default_user, logger)
413
+ wait_until_available(ip_or_fqdn, default_user)
414
414
  logger.info("#{name} has been created.")
415
415
 
416
416
  if options['no-maas']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gogetit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Draper