Sanitize nova_manage output in provider
nova-manage can output a warning message in some cases (see [1] for
an example with the latest oslo.db), and that confuses the nova_manage
provider.
Since the command in a provider cannot separate stdout and stderr[2],
we use a workaround with Puppet::Util::Execution.execute, and
use that instead of the provider command in the nova_cells and
nova_cell_v2 providers.
[1] - https://logs.rdoproject.org/23/9323/2/experimental/gate-weirdo-dlrn-master-puppet-scenario001/Z6a290513d2904561a2adc60ddbfd7084/weirdo-project/puppet.txt.gz
[2] - https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/execution.rb#L14-L16
Change-Id: I79f76592672d968b96338b3e0f6a86c9b7faeb93
(cherry picked from commit 682174b778
)
This commit is contained in:
parent
badc922792
commit
29b873f37e
|
@ -38,6 +38,20 @@ class Puppet::Provider::Nova < Puppet::Provider::Openstack
|
||||||
Puppet::Provider::Openstack.request(service, action, properties, @credentials)
|
Puppet::Provider::Openstack.request(service, action, properties, @credentials)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.nova_manage_request(*args)
|
||||||
|
# Not using the nova-manage command directly,
|
||||||
|
# so we can disable combining of stderr/stdout output.
|
||||||
|
Puppet::Util::Execution.execute("#{Puppet::Util.which('nova-manage')} #{args.join(' ')}", {
|
||||||
|
:failonfail => true,
|
||||||
|
:combine => false,
|
||||||
|
:custom_environment => {}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
def nova_manage_request(*args)
|
||||||
|
self.class.nova_manage_request(args)
|
||||||
|
end
|
||||||
|
|
||||||
def self.conf_filename
|
def self.conf_filename
|
||||||
'/etc/nova/nova.conf'
|
'/etc/nova/nova.conf'
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,8 +8,6 @@ Puppet::Type.type(:nova_cell_v2).provide(
|
||||||
|
|
||||||
desc "Manage nova cellv2 cells"
|
desc "Manage nova cellv2 cells"
|
||||||
|
|
||||||
optional_commands :nova_manage => 'nova-manage'
|
|
||||||
|
|
||||||
mk_resource_methods
|
mk_resource_methods
|
||||||
|
|
||||||
def initialize(value={})
|
def initialize(value={})
|
||||||
|
@ -18,7 +16,7 @@ Puppet::Type.type(:nova_cell_v2).provide(
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.instances
|
def self.instances
|
||||||
cells_list = nova_manage("cell_v2", "list_cells", "--verbose")
|
cells_list = nova_manage_request("cell_v2", "list_cells", "--verbose")
|
||||||
|
|
||||||
cells_list.split("\n")[3..-2].collect do |cell|
|
cells_list.split("\n")[3..-2].collect do |cell|
|
||||||
$name, $uuid, $transport_url, $database_connection = cell.split('|')[1..-1].map{ |x| x.strip}
|
$name, $uuid, $transport_url, $database_connection = cell.split('|')[1..-1].map{ |x| x.strip}
|
||||||
|
@ -93,7 +91,7 @@ Puppet::Type.type(:nova_cell_v2).provide(
|
||||||
optional_opts.push(opt).push(resource[param])
|
optional_opts.push(opt).push(resource[param])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cell_uuid = nova_manage('cell_v2', 'create_cell',
|
cell_uuid = nova_manage_request('cell_v2', 'create_cell',
|
||||||
optional_opts, "--verbose"
|
optional_opts, "--verbose"
|
||||||
)
|
)
|
||||||
@property_hash = {
|
@property_hash = {
|
||||||
|
@ -119,7 +117,7 @@ Puppet::Type.type(:nova_cell_v2).provide(
|
||||||
def flush
|
def flush
|
||||||
@property_hash.update(@property_flush)
|
@property_hash.update(@property_flush)
|
||||||
if @property_flush[:ensure] == :absent
|
if @property_flush[:ensure] == :absent
|
||||||
nova_manage("cell_v2", "delete_cell", "--cell_uuid", @property_hash[:uuid])
|
nova_manage_request("cell_v2", "delete_cell", "--cell_uuid", @property_hash[:uuid])
|
||||||
elsif @property_flush[:transport_url] or @property_flush[:database_connection]
|
elsif @property_flush[:transport_url] or @property_flush[:database_connection]
|
||||||
opts = []
|
opts = []
|
||||||
if not @property_flush[:transport_url]
|
if not @property_flush[:transport_url]
|
||||||
|
@ -140,8 +138,8 @@ Puppet::Type.type(:nova_cell_v2).provide(
|
||||||
end
|
end
|
||||||
opts.push('--database_connection').push(@property_flush[:database_connection])
|
opts.push('--database_connection').push(@property_flush[:database_connection])
|
||||||
|
|
||||||
nova_manage("cell_v2", "update_cell", "--cell_uuid", @property_hash[:uuid], opts)
|
nova_manage_request("cell_v2", "update_cell", "--cell_uuid", @property_hash[:uuid], opts)
|
||||||
end
|
end
|
||||||
@property_flush = {}
|
@property_flush = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,15 +20,18 @@
|
||||||
# nova_cells provider
|
# nova_cells provider
|
||||||
#
|
#
|
||||||
|
|
||||||
Puppet::Type.type(:nova_cells).provide(:nova_manage) do
|
require File.join(File.dirname(__FILE__), '..','..','..', 'puppet/provider/nova')
|
||||||
|
|
||||||
|
Puppet::Type.type(:nova_cells).provide(
|
||||||
|
:nova_manage,
|
||||||
|
:parent => Puppet::Provider::Nova
|
||||||
|
) do
|
||||||
|
|
||||||
desc "Manage nova cells"
|
desc "Manage nova cells"
|
||||||
|
|
||||||
optional_commands :nova_manage => 'nova-manage'
|
|
||||||
|
|
||||||
def self.instances
|
def self.instances
|
||||||
begin
|
begin
|
||||||
cells_list = nova_manage("cell", "list")
|
cells_list = nova_manage_request("cell", "list")
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
if e.message =~ /No cells defined/
|
if e.message =~ /No cells defined/
|
||||||
return []
|
return []
|
||||||
|
@ -63,14 +66,14 @@ Puppet::Type.type(:nova_cells).provide(:nova_manage) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nova_manage('cell', 'create',
|
nova_manage_request('cell', 'create',
|
||||||
optional_opts
|
optional_opts
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
begin
|
begin
|
||||||
cells_list = nova_manage("cell", "list")
|
cells_list = nova_manage_request("cell", "list")
|
||||||
return cells_list.split("\n")[1..-1].detect do |n|
|
return cells_list.split("\n")[1..-1].detect do |n|
|
||||||
n =~ /^(\S+)\s+(#{resource[:cells].split('/').first})/
|
n =~ /^(\S+)\s+(#{resource[:cells].split('/').first})/
|
||||||
end
|
end
|
||||||
|
@ -81,7 +84,7 @@ Puppet::Type.type(:nova_cells).provide(:nova_manage) do
|
||||||
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
nova_manage("cell", "delete", resource[:name])
|
nova_manage_request("cell", "delete", resource[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue