Class: Vmit::Bootstrap::FromMedia

Inherits:
Object
  • Object
show all
Defined in:
lib/vmit/bootstrap.rb

Overview

Boostraps a vm from a SUSE repository

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vm, location) ⇒ FromMedia

Returns a new instance of FromMedia.



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/vmit/bootstrap.rb', line 222

def initialize(vm, location)
  @location = location
  @vm = vm
  @media = Vmit::VFS.from(location)

  # TODO FIXME we need a clever way to detect the
  # location distro type. I could uname the kernel, but
  # I need the type to know the location.
  media_handler = case location.to_s.downcase
    when /fedora|redhat|centos/ then FedoraMedia
    when /suse/ then SUSEMedia
    when /debian/ then DebianMedia
    else
      raise "Don't know how to bootstrap media #{location}"
  end
  self.extend media_handler

  @boot_kernel = get_kernel
  @boot_initrd = get_initrd
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



210
211
212
# File 'lib/vmit/bootstrap.rb', line 210

def location
  @location
end

#mediaObject (readonly)

Returns the value of attribute media.



209
210
211
# File 'lib/vmit/bootstrap.rb', line 209

def media
  @media
end

#vmObject (readonly)

Returns the value of attribute vm.



208
209
210
# File 'lib/vmit/bootstrap.rb', line 208

def vm
  @vm
end

Class Method Details

.accept?(location) ⇒ Boolean

Parameters:

  • location (URI)

Returns:

  • (Boolean)


213
214
215
216
217
218
219
220
# File 'lib/vmit/bootstrap.rb', line 213

def self.accept?(location)
  # either a local ISO or a remote repository
  # (and not a remote file, but we don't have
  # a good way to check)
  Vmit::VFS::ISO.accept?(location) ||
    (Vmit::VFS::URI.accept?(location) &&
      File.extname(location.to_s) == '')
end

Instance Method Details

#executeObject



243
244
245
246
247
# File 'lib/vmit/bootstrap.rb', line 243

def execute
  args = {}
  args.merge!({:kernel => @boot_kernel.path, :initrd => @boot_initrd.path})
  execute_autoinstall(args)
end