"crm configure show foo" exits 0 with no output if foo doesn't exist

This commit is contained in:
Adam Spiers
2014-01-23 16:29:28 +00:00
parent ebf3f7c429
commit 6cef509353
3 changed files with 5 additions and 8 deletions

View File

@@ -18,7 +18,8 @@ module Chef::Libraries
end
def cib_object_exists?(name)
! get_cib_object_definition(name).nil?
dfn = get_cib_object_definition(name)
!! (dfn && ! dfn.empty?)
end
def cib_object_type(obj_definition)

View File

@@ -78,11 +78,8 @@ def load_current_resource
name = @new_resource.name
obj_definition = get_cib_object_definition(name)
return unless obj_definition
if obj_definition.empty? # probably overly paranoid
raise "CIB object '#{name}' existed but definition was empty?!"
end
return if ! obj_definition or obj_definition.empty?
Chef::Log.debug "CIB object definition #{obj_definition}"
unless obj_definition =~ /\Aprimitive #{name} (\S+)/
Chef::Log.warn "Resource '#{name}' was not a primitive"

View File

@@ -54,8 +54,7 @@ describe "Chef::Provider::PacemakerPrimitive" do
# get_cib_object_definition is invoked by load_current_resource
# and later used to see whether to create or modify.
expect(provider).to receive(:get_cib_object_definition).and_return(nil)
expect(provider).to receive(:get_cib_object_definition).and_return("")
# Later, the :create action calls cib_object_exists? to check
# that creation succeeded.