2011-06-15 22:20:09 +00:00
|
|
|
Puppet::Type.type(:nova_network).provide(:nova_manage) do
|
|
|
|
|
|
|
|
desc "Manage nova network"
|
|
|
|
|
2012-01-25 06:00:38 +00:00
|
|
|
optional_commands :nova_manage => 'nova-manage'
|
2011-06-15 22:20:09 +00:00
|
|
|
|
|
|
|
def exists?
|
2011-07-22 18:08:49 +00:00
|
|
|
begin
|
2012-01-25 06:04:22 +00:00
|
|
|
network_list = nova_manage("network", "list")
|
|
|
|
return network_list.split("\n")[1..-1].detect do |n|
|
|
|
|
n =~ /^(\S+)\s+(#{resource[:network]})/
|
|
|
|
end
|
2011-07-22 18:08:49 +00:00
|
|
|
rescue
|
|
|
|
return false
|
|
|
|
end
|
2011-06-15 22:20:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2012-03-20 00:59:00 +00:00
|
|
|
nova_manage("network", "create", resource[:label], resource[:network], "1", resource[:available_ips], "--bridge=br100")
|
2011-06-15 22:20:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
nova_manage("network", "delete", resource[:network])
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|