lib/providers/lxd.rb in gogetit-0.15.1 vs lib/providers/lxd.rb in gogetit-0.15.2

- old
+ new

@@ -50,12 +50,11 @@ logger.info("Calling <#{__method__.to_s}>") args[:config] = {} if options['no-maas'] - args[:config][:'user.user-data'] = \ - YAML.load_file(options['file'])[:config]['user.user-data'] + args[:config][:"user.user-data"] = {} else sshkeys = maas.get_sshkeys pkg_repos = maas.get_package_repos args[:config][:'user.user-data'] = { 'ssh_authorized_keys' => [] } @@ -161,17 +160,22 @@ return args end def generate_network_config(args, options) logger.info("Calling <#{__method__.to_s}>") + if options['no-maas'] args[:config][:'user.network-config'] = \ - YAML.load_file(options['file'])[:config][:'user.network-config'] + YAML.load_file(options['file'])['network'] - options['ip_to_access'] = \ - args[:config][:"user.network-config"]['config'][1]['subnets'][0]['address'] - .split('/')[0] + # physical device will be the gate device + args[:config][:"user.network-config"]['config'].each do |iface| + if iface['type'] == "physical" + options['ip_to_access'] = iface['subnets'][0]['address'].split('/')[0] + end + end + args[:config][:"user.network-config"] = \ YAML.dump(args[:config][:"user.network-config"])[4..-1] elsif options['ipaddresses'] options[:ifaces] = check_ip_available(options['ipaddresses'], maas) @@ -256,11 +260,19 @@ logger.info("Calling <#{__method__.to_s}>") args[:devices] = {} if options['no-maas'] args[:devices] = \ - YAML.load_file(options['file'])[:devices] + (Hashie.symbolize_keys YAML.load_file(options['file'])['devices']) + # Now, LXD API can handle integer as a value of a map + args[:devices].each do |k, v| + v.each do |kk, vv| + if vv.is_a? Integer + v[kk] = vv.to_s + end + end + end elsif options['ipaddresses'] options[:ifaces].each_with_index do |iface,index| if index == 0 if iface['vlan']['name'] == 'untagged' # or vid == 0 @@ -385,9 +397,12 @@ conn.create_container(name, args) container = conn.container(name) container.devices = args[:devices].merge!(container.devices.to_hash) + + require 'pry'; binding.pry + conn.update_container(name, container) # Fetch container object again container = conn.container(name) reserve_ips(name, options, container) \