lib/providers/lxd.rb in gogetit-0.13.1 vs lib/providers/lxd.rb in gogetit-0.13.2
- old
+ new
@@ -21,37 +21,41 @@
end
def list_all_containers
logger.debug("Calling <#{__method__.to_s}>")
+ nodes = []
config[:lxd][:nodes].each do |node|
puts "Listing LXC containers on #{node[:url]}..."
+
conn = Hyperkit::Client.new(
api_endpoint: node[:url],
verify_ssl: false
)
- nodes = []
conn.containers.each do |con|
row = {}
row[:name] = conn.container(con).to_hash[:name]
row[:status] = conn.container_state(con).to_hash[:status].upcase
if conn.container_state(con).to_hash[:network] && \
conn.container_state(con).to_hash[:network][:eth0] && \
conn.container_state(con).to_hash[:network][:eth0][:addresses] && \
conn.container_state(con).to_hash[:network][:eth0][:addresses][0] && \
conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
row[:ipv4] = \
+ # only print the first IP address on the first interface
conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
else
row[:ipv4] = "NA"
end
+ row[:host] = node[:name]
nodes << row
end
- tp nodes, :name, :status, :ipv4
- puts
end
+ puts '-----------------------------------------------------------'
+ tp nodes, :name, :status, :ipv4, :host
+ puts
end
def list
logger.info("Calling <#{__method__.to_s}>")
conn.containers
@@ -81,12 +85,10 @@
def generate_user_data(args, options)
logger.info("Calling <#{__method__.to_s}>")
args[:config] = {}
- args[:config][:"user.user-data"]['maas'] = true
-
if options['no-maas']
args[:config][:'user.user-data'] = \
YAML.load_file(options['file'])[:config]['user.user-data']
else
sshkeys = maas.get_sshkeys
@@ -102,12 +104,14 @@
if repo['name'] == 'main_archive'
args[:config][:'user.user-data']['apt_mirror'] = repo['url']
end
end
- args[:config][:"user.user-data"]['maas'] = true
args[:config][:"user.user-data"]['source_image_alias'] = args[:alias]
+ args[:config][:"user.user-data"]['maas'] = true
end
+
+ args[:config][:"user.user-data"]['gogetit'] = true
# To disable to update apt database on first boot
# so chef client can keep doing its job.
args[:config][:'user.user-data']['package_update'] = false
args[:config][:'user.user-data']['package_upgrade'] = false