Fixed GitHub Issue #17 - nova network failures

The Nova network create command now needs a label to create a network.
I've created a label parameter in the nova_network type that currently
defaults to novanetwork.

The nova network list command also now fails if no networks exist.
I've wrapped it in a rescue block which returns false is the command
fails which is clearly not the right response but I need this to work
for a demo.
This commit is contained in:
James Turnbull 2011-07-23 04:08:49 +10:00
parent 321d2ae3c2
commit 7cea1c1a38
2 changed files with 11 additions and 2 deletions

View File

@ -7,11 +7,15 @@ Puppet::Type.type(:nova_network).provide(:nova_manage) do
commands :nova_manage => 'nova-manage'
def exists?
nova_manage("network", "list").match(/^#{resource[:network]}\/[0-9]{1,2} /)
begin
nova_manage("network", "list").match(/^#{resource[:network]}\/[0-9]{1,2} /)
rescue
return false
end
end
def create
nova_manage("network", "create", resource[:network], "1", resource[:available_ips])
nova_manage("network", "create", resource[:label], resource[:network], "1", resource[:available_ips])
end
def destroy

View File

@ -13,6 +13,11 @@ Puppet::Type.newtype(:nova_network) do
newvalues(/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.0$/)
end
newparam(:label) do
desc "The Nova network label"
defaultto "novanetwork"
end
newparam(:available_ips) do
desc "# of available IPs. Must be greater than 4."
validate do |value|