def generate_devices(lxd_params, options)
      logger.info("Calling <#{__method__.to_s}>")
      lxd_params[:devices] = {}

      if options[:'no-maas']
        lxd_params[:devices] = YAML.load_file(options[:file])['devices']

        # Now, LXD API can handle integer as a value of a map
        lxd_params[:devices].each do |k, v|
          v.each do |kk, vv|
            if vv.is_a? Integer
              v[kk] = vv.to_s
            end
          end
        end

        lxd_params[:devices] = (Hashie.symbolize_keys lxd_params[:devices])

      elsif options[:ipaddresses]
        config[:ifaces].each_with_index do |iface,index|
          if index == 0
            if iface['vlan']['name'] == 'untagged' # or vid == 0
              lxd_params[:devices][:"eth#{index}"] = {
                mtu: iface['vlan']['mtu'].to_s,   #This must be string
                name: "eth#{index}",
                nictype: 'bridged',
                parent: config[:default][:root_bridge],
                type: 'nic'
              }
            elsif iface['vlan']['name'] != 'untagged' # or vid != 0
              lxd_params[:devices][:"eth#{index}"] = {
                mtu: iface['vlan']['mtu'].to_s,   #This must be string
                name: "eth#{index}",
                nictype: 'bridged',
                parent: config[:default][:root_bridge] + "-" + iface['vlan']['vid'].to_s,
                type: 'nic'
              }
            end
          # When config[:ifaces][0]['vlan']['name'] == 'untagged' and index > 0,
          # it does not need to generate more devices 
          # since it will configure the IPs with tagged VLANs.
          elsif config[:ifaces][0]['vlan']['name'] != 'untagged'
            lxd_params[:devices][:"eth#{index}"] = {
              mtu: iface['vlan']['mtu'].to_s,   #This must be string
              name: "eth#{index}",
              nictype: 'bridged',
              parent: config[:default][:root_bridge] + "-" + iface['vlan']['vid'].to_s,
              type: 'nic'
            }
          end
        end
      else
        abort("root_bridge #{config[:default][:root_bridge]} does not exist.") \
           unless conn.networks.include? config[:default][:root_bridge]

        root_bridge_mtu = nil
        # It assumes you only use one fabric as of now,
        # since there might be more fabrics with each untagged vlans on them,
        # which might make finding exact mtu fail as following process.
        default_fabric = 'fabric-0'

        maas.get_subnets.each do |subnet|
          if subnet['vlan']['name'] == 'untagged' and \
              subnet['vlan']['fabric'] == default_fabric
            root_bridge_mtu = subnet['vlan']['mtu']
            break
          end
        end

        lxd_params[:devices] = {}
        lxd_params[:devices][:"eth0"] = {
          mtu: root_bridge_mtu.to_s,   #This must be string
          name: 'eth0',
          nictype: 'bridged',
          parent: config[:default][:root_bridge],
          type: 'nic'
        }
      end

      if options[:'maas-on-lxc']
        # https://docs.maas.io/2.4/en/installconfig-lxd-install
        for i in 0..7
          i = i.to_s
          lxd_params[:devices]["loop" + i] = {}
          lxd_params[:devices]["loop" + i]["path"] = "/dev/loop" + i
          lxd_params[:devices]["loop" + i]["type"] = "unix-block"
        end
      end

      return lxd_params
    end
def generate_devices(lxd_params, options)
      logger.info("Calling <#{__method__.to_s}>")
      lxd_params[:devices] = {}

      if options[:'no-maas']
        lxd_params[:devices] = YAML.load_file(options[:file])['devices']

        # Now, LXD API can handle integer as a value of a map
        lxd_params[:devices].each do |k, v|
          v.each do |kk, vv|
            if vv.is_a? Integer
              v[kk] = vv.to_s
            end
          end
        end

        lxd_params[:devices] = (Hashie.symbolize_keys lxd_params[:devices])

      elsif options[:ipaddresses]
        config[:ifaces].each_with_index do |iface,index|
          if index == 0
            if iface['vlan']['name'] == 'untagged' # or vid == 0
              lxd_params[:devices][:"eth#{index}"] = {
                mtu: iface['vlan']['mtu'].to_s,   #This must be string
                name: "eth#{index}",
                nictype: 'bridged',
                parent: config[:default][:root_bridge],
                type: 'nic'
              }
            elsif iface['vlan']['name'] != 'untagged' # or vid != 0
              lxd_params[:devices][:"eth#{index}"] = {
                mtu: iface['vlan']['mtu'].to_s,   #This must be string
                name: "eth#{index}",
                nictype: 'bridged',
                parent: config[:default][:root_bridge] + "-" + iface['vlan']['vid'].to_s,
                type: 'nic'
              }
            end
          # When config[:ifaces][0]['vlan']['name'] == 'untagged' and index > 0,
          # it does not need to generate more devices 
          # since it will configure the IPs with tagged VLANs.
          elsif config[:ifaces][0]['vlan']['name'] != 'untagged'
            lxd_params[:devices][:"eth#{index}"] = {
              mtu: iface['vlan']['mtu'].to_s,   #This must be string
              name: "eth#{index}",
              nictype: 'bridged',
              parent: config[:default][:root_bridge] + "-" + iface['vlan']['vid'].to_s,
              type: 'nic'
            }
          end
        end
      else
        abort("root_bridge #{config[:default][:root_bridge]} does not exist.") \
           unless conn.networks.include? config[:default][:root_bridge]

        root_bridge_mtu = nil
        # It assumes you only use one fabric as of now,
        # since there might be more fabrics with each untagged vlans on them,
        # which might make finding exact mtu fail as following process.
        default_fabric = 'fabric-0'

        maas.get_subnets.each do |subnet|
          if subnet['vlan']['name'] == 'untagged' and \
              subnet['vlan']['fabric'] == default_fabric
            root_bridge_mtu = subnet['vlan']['mtu']
            break
          end
        end

        lxd_params[:devices] = {}
        lxd_params[:devices][:"eth0"] = {
          mtu: root_bridge_mtu.to_s,   #This must be string
          name: 'eth0',
          nictype: 'bridged',
          parent: config[:default][:root_bridge],
          type: 'nic'
        }
      end

      if options[:'maas-on-lxc']
        # https://docs.maas.io/2.4/en/installconfig-lxd-install
        for i in 0..7
          i = i.to_s
          lxd_params[:devices]["loop" + i] = {}
          lxd_params[:devices]["loop" + i]["path"] = "/dev/loop" + i
          lxd_params[:devices]["loop" + i]["type"] = "unix-block"
        end
      end

      return lxd_params
    end
To configure devices