Class: VagrantPlugins::Dotvm::ConfigParser

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-dotvm/configparser.rb

Class Method Summary collapse

Class Method Details

.parse(yaml) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/vagrant-dotvm/configparser.rb', line 42

def self.parse(yaml)
  config = {
    :machines => []
  }

  yaml['machines'].each do |machine|
    item = parse_machine(machine)

    machine['networks'] and machine['networks'].each do |net|
      item[:networks] << self.parse_net(net)
    end

    machine['provision'] and machine['provision'].each do |prv|
      item[:provision] << self.parse_provision(prv)
    end

    config[:machines] << item
  end

  return config
end

.parse_machine(machine) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/vagrant-dotvm/configparser.rb', line 5

def self.parse_machine(machine)
  return {
    :nick       => machine['nick'],
    :name       => machine['name'],
    :box        => machine['box'],
    :memory     => machine['memory'],
    :cpus       => machine['cpus'],
    :cpucap     => machine['cpucap'],
    :networks   => [],
    :provision  => [],
  }
end

.parse_net(net) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/vagrant-dotvm/configparser.rb', line 19

def self.parse_net(net)
  return {
    :net  => net['net'],
    :type => net['type'],
    :ip   => net['ip'],
    :mask => net['mask'],
  }
end

.parse_provision(prv) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vagrant-dotvm/configparser.rb', line 29

def self.parse_provision(prv)
  return {
    :type     => prv['type'],
    :source         => prv['source'],
    :destination    => prv['destination'],
    :path     => prv['path'],
    :module_path    => prv['module_path'],
    :manifests_path => prv['manifests_path'],
    :manifest_file  => prv['manifest_file'],
  }
end