Class: Xen::XenToolsConf

Inherits:
Object
  • Object
show all
Defined in:
lib/xen/xen_tools_conf.rb

Overview

puts Xen::XenToolsConf.load.to_hash.inspect

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ XenToolsConf

Returns a new instance of XenToolsConf.



16
17
# File 'lib/xen/xen_tools_conf.rb', line 16

def initialize(*args)
end

Instance Attribute Details

#accountsObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def accounts
  @accounts
end

#bootObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def boot
  @boot
end

#broadcastObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def broadcast
  @broadcast
end

#cacheObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def cache
  @cache
end

#copy_cmdObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def copy_cmd
  @copy_cmd
end

#debootstrap__cmdObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def debootstrap__cmd
  @debootstrap__cmd
end

#dhcpObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def dhcp
  @dhcp
end

#dirObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def dir
  @dir
end

#disk_deviceObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def disk_device
  @disk_device
end

#distObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def dist
  @dist
end

#ext2_optionsObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def ext2_options
  @ext2_options
end

#ext3_optionsObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def ext3_options
  @ext3_options
end

#extensionObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def extension
  @extension
end

#fsObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def fs
  @fs
end

#gatewayObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def gateway
  @gateway
end

#imageObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def image
  @image
end

#initrdObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def initrd
  @initrd
end

#install__methodObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def install__method
  @install__method
end

#install__sourceObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def install__source
  @install__source
end

#kernelObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def kernel
  @kernel
end

#lvmObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def lvm
  @lvm
end

#memoryObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def memory
  @memory
end

#mirrorObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def mirror
  @mirror
end

#netmaskObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def netmask
  @netmask
end

#noswapObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def noswap
  @noswap
end

#outputObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def output
  @output
end

#passwdObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def passwd
  @passwd
end

#reiser_optionsObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def reiser_options
  @reiser_options
end

#serial_deviceObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def serial_device
  @serial_device
end

#sizeObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def size
  @size
end

#swapObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def swap
  @swap
end

#tar_cmdObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def tar_cmd
  @tar_cmd
end

#xfs_optionsObject

XXX underscorize :install-method, install-source, copy_cmd, tar-cmd



7
8
9
# File 'lib/xen/xen_tools_conf.rb', line 7

def xfs_options
  @xfs_options
end

Class Method Details

.find(file = nil) ⇒ Object



19
20
21
22
23
24
# File 'lib/xen/xen_tools_conf.rb', line 19

def self.find(file=nil)
  file ||= Xen::XEN_TOOLS_CONFIG_FILE
  xtc = new # Create a new XenToolsConf object
  xtc.load_from_config_file(File.readlines(file))
  xtc
end

Instance Method Details

#load_from_config_file(file_contents) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/xen/xen_tools_conf.rb', line 26

def load_from_config_file(file_contents)
  file_contents.reject! { |line| line.match /^\s*#/ } # Ignore commented out lines
  file_contents.grep(/(.*) = (.*)/).each { |setting|
    setting.scan(/\s*(.+?)\s*=\s*([^#]+)/).each { |match|
      key, val = match    
      instance_variable_set("@#{key.strip.underscorize}", val.strip) 
    }
  }
end

#save(filename = nil) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/xen/xen_tools_conf.rb', line 47

def save(filename=nil)
  filename ||= Xen::XEN_TOOLS_CONFIG_FILE
  File.open(filename, 'w') do |f|
    f.write(to_file)
  end
  # XXX check for errors
end

#to_fileObject



42
43
44
45
# File 'lib/xen/xen_tools_conf.rb', line 42

def to_file
  template = ERB.new(IO.read(File.join(TEMPLATES_BASE, 'xen-tools.conf.erb')))
  template.result(binding)
end

#to_hashObject



36
37
38
39
40
# File 'lib/xen/xen_tools_conf.rb', line 36

def to_hash
  self.instance_variables.inject({}) { |m, variable_name| 
    m[variable_name.sub('@','').ununderscorize] = instance_variable_get(variable_name); m 
  }
end