Class: Xen::XenToolsConf
- Inherits:
-
Object
- Object
- Xen::XenToolsConf
- Defined in:
- lib/xen/xen_tools_conf.rb
Overview
puts Xen::XenToolsConf.load.to_hash.inspect
Instance Attribute Summary collapse
-
#accounts ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#boot ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#broadcast ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#cache ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#copy_cmd ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#debootstrap__cmd ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#dhcp ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#dir ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#disk_device ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#dist ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#ext2_options ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#ext3_options ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#extension ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#fs ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#gateway ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#image ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#initrd ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#install__method ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#install__source ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#kernel ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#lvm ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#memory ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#mirror ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#netmask ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#noswap ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#output ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#passwd ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#reiser_options ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#serial_device ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#size ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#swap ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#tar_cmd ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
-
#xfs_options ⇒ Object
XXX underscorize :install-method, install-source, copy_cmd, tar-cmd.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ XenToolsConf
constructor
A new instance of XenToolsConf.
- #load_from_config_file(file_contents) ⇒ Object
- #save(filename = nil) ⇒ Object
- #to_file ⇒ Object
- #to_hash ⇒ Object
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
#accounts ⇒ Object
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 |
#boot ⇒ Object
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 |
#broadcast ⇒ Object
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 |
#cache ⇒ Object
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_cmd ⇒ Object
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__cmd ⇒ Object
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 |
#dhcp ⇒ Object
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 |
#dir ⇒ Object
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_device ⇒ Object
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 |
#dist ⇒ Object
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_options ⇒ Object
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 end |
#ext3_options ⇒ Object
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 end |
#extension ⇒ Object
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 |
#fs ⇒ Object
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 |
#gateway ⇒ Object
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 |
#image ⇒ Object
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 |
#initrd ⇒ Object
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__method ⇒ Object
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__source ⇒ Object
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 |
#kernel ⇒ Object
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 |
#lvm ⇒ Object
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 |
#memory ⇒ Object
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 |
#mirror ⇒ Object
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 |
#netmask ⇒ Object
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 |
#noswap ⇒ Object
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 |
#output ⇒ Object
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 |
#passwd ⇒ Object
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_options ⇒ Object
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 end |
#serial_device ⇒ Object
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 |
#size ⇒ Object
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 |
#swap ⇒ Object
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_cmd ⇒ Object
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_options ⇒ Object
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 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_file ⇒ Object
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_hash ⇒ Object
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 |