Class: Vmit::Network
Instance Attribute Summary
#lockfile_dir, #lockfile_path, #name
Class Method Summary
collapse
Instance Method Summary
collapse
#auto, #initialize, make_temp
Class Method Details
.create(config) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/vmit/network.rb', line 39
def self.create(config)
case config
when Hash then from_config(config)
when String then from_alias(config)
else raise "Can't build network from #{config}"
end
end
|
.from_alias(name) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/vmit/network.rb', line 47
def self.from_alias(name)
File.open(File.join(ENV['HOME'], '.vmit', 'networks.yml')) do |f|
networks = YAML::load(f)
if networks.has_key?(name)
return from_config(networks[name].symbolize_keys)
else
raise "Unknown network #{name}"
end
end
end
|
.from_config(config) ⇒ Object
59
60
61
|
# File 'lib/vmit/network.rb', line 59
def self.from_config(config)
BridgedNetwork.new(config[:address])
end
|
Instance Method Details
#resource_class ⇒ Object
35
36
37
|
# File 'lib/vmit/network.rb', line 35
def resource_class
'network'
end
|