Replace optional_commands with commands in providers

Optional commands can be used to specify that a
command may not exist when provider suitability
is determined. This is because it may be installed
during the same run where it needs to be used.

Previously, an empty default provider was created
just to prevent failures when provider suitability
was determined. This also required that the provider
be explicitly overridden when the type is used.

Using optional_commands instead of command reduces
the amount of required code. It allows the default
providers to be removed as well as the explicit
provider attributes.

This changed has been implemented for the following
types:
  - nova_manage
  - nova_network
  - nova_admin
This commit is contained in:
Dan Bode 2012-01-24 22:00:38 -08:00
parent 807a437471
commit bcca7bedc4
8 changed files with 3 additions and 60 deletions

View File

@ -1,16 +0,0 @@
Puppet::Type.type(:nova_admin).provide(:default) do
desc "This is a default provider that does nothing. This allows us to install nova-manage on the same puppet run where we want to use it."
def create
return false
end
def destroy
return false
end
def exists?
fail('This is just the default provider for nova_admin, all it does is fail')
end
end

View File

@ -2,9 +2,7 @@ Puppet::Type.type(:nova_admin).provide(:nova_manage) do
desc "Manage nova admin user"
defaultfor :kernel => 'Linux'
commands :nova_manage => 'nova-manage'
optional_commands :nova_manage => 'nova-manage'
def exists?
nova_manage("user", "list").match(/^#{resource[:name]}$/)

View File

@ -1,16 +0,0 @@
Puppet::Type.type(:nova_network).provide(:default) do
desc "This is a default provider that does nothing. This allows us to install nova-manage on the same puppet run where we want to use it."
def create
return false
end
def destroy
return false
end
def exists?
fail('This is just the default provider for nova_admin, all it does is fail')
end
end

View File

@ -2,9 +2,7 @@ Puppet::Type.type(:nova_network).provide(:nova_manage) do
desc "Manage nova network"
defaultfor :kernel => 'Linux'
commands :nova_manage => 'nova-manage'
optional_commands :nova_manage => 'nova-manage'
def exists?
begin

View File

@ -1,17 +0,0 @@
Puppet::Type.type(:nova_project).provide(:default) do
desc "This is a default provider that does nothing. This allows us to install nova-manage on the same puppet run where we want to use it."
def create
return false
end
def destroy
return false
end
def exists?
fail('This is just the default provider for nova_project, all it does is fail')
end
end

View File

@ -2,9 +2,7 @@ Puppet::Type.type(:nova_project).provide(:nova_manage) do
desc "Manage nova project"
defaultfor :kernel => 'Linux'
commands :nova_manage => 'nova-manage'
optional_commands :nova_manage => 'nova-manage'
def exists?
nova_manage("project", "list").match(/^#{resource[:name]}$/)

View File

@ -7,7 +7,6 @@ define nova::manage::network ( $network, $available_ips ) {
ensure => present,
network => $network,
available_ips => $available_ips,
provider => 'nova_manage',
notify => Exec["nova-db-sync"],
}
}

View File

@ -5,7 +5,6 @@ define nova::manage::project ( $owner ) {
nova_project { $name:
ensure => present,
provider => 'nova_manage',
owner => $owner,
notify => Exec["nova-db-sync"],
require => Nova::Manage::Admin[$owner],