Module: Chef::Knife::HardwareBase

Included in:
HardwareEdit, HardwareShow
Defined in:
lib/chef/knife/hardware_base.rb

Instance Method Summary collapse

Instance Method Details

#getUuidObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/chef/knife/hardware_base.rb', line 24

def getUuid
  unless name_args.size == 1
    puts "You need to specify a node"
    show_usage
    exit 1
  end

  node = Chef::Node.load(name_args[0])
  unless node.has_key? 'uuid'
    puts "Node has no UUID, cannot link to a hardware data bag item"
    show_usage
    exit 1
  end
  if node.uuid.nil?
    puts "UUID was nil so I can't lookup the data bag"
    show_usage
    exit 1
  end
  puts "Working on #{node.uuid}"
  return node.uuid
end