Module: Vmit::Bootstrap::MethodAutoYaST

Included in:
SUSEMedia
Defined in:
lib/vmit/bootstrap.rb

Instance Method Summary collapse

Instance Method Details

#execute_autoinstall(args) ⇒ Object

Parameters:

  • args (Hash)

    Arguments for 1st stage



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/vmit/bootstrap.rb', line 111

def execute_autoinstall(args)
  auto_install_args = {}
  auto_install_args.merge!(args)
  kernel_append_arg = case media
    when Vmit::VFS::URI then "install=#{location}"
    when Vmit::VFS::ISO then 'install=cdrom'
    else raise ArgumentError.new("Unsupported autoinstallation: #{location}")
  end
  auto_install_args.merge!(:append => kernel_append_arg)
  if media.is_a?(Vmit::VFS::ISO)
    auto_install_args.merge!(:cdrom => location.to_s)
  end

  Dir.mktmpdir do |floppy_dir|
    qemu_args = {:floppy => floppy_dir,
                :append => "autoyast=device://fd0/autoinst.xml",
                :reboot => false}
    # transform duplicates into an array
    qemu_args.merge!(auto_install_args) do |key, oldv, newv|
      case key
        when :append then [oldv, newv].flatten
        else newv
      end
    end

    autoyast = Vmit::AutoYaST.new

    # WTF SLE and openSUSE have different
    # base pattern names
    media.open('/content') do |content_file|
      content_file.each_line do |line|
        case line
          when /^DISTRIBUTION (.+)$/
            case $1
              when /SUSE_SLE/ then autoyast.minimal_sle!
              when /openSUSE/ then autoyast.minimal_opensuse!
            end
        end
      end
    end

    # Configure the autoinstallation profile to persist eth0
    # for the current MAC address
    # The interface will be setup with DHCP by default.
    # TODO: make this more flexible in the future?
    #autoyast.name_network_device(vm[:mac_address], 'eth0')
    File.write(File.join(floppy_dir, 'autoinst.xml'), autoyast.to_xml)
    Vmit.logger.info "AutoYaST: 1st stage."
    vm.run(qemu_args)
    Vmit.logger.info "AutoYaST: 2st stage."
    # 2nd stage
    vm.run(:reboot => false)
  end
end