Class: Chef::Knife::UcsServiceprofilesList

Inherits:
Chef::Knife
  • Object
show all
Includes:
UCSBase
Defined in:
lib/chef/knife/ucs_serviceprofiles_list.rb

Instance Method Summary collapse

Methods included from UCSBase

#connection, #destroyer, included, #inventory, #locate_config_value, #manager, #msg_pair, #provisioner

Instance Method Details

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/chef/knife/ucs_serviceprofiles_list.rb', line 30

def run

 #Using Chef's UI (much better looking:)) instead of list methods provided by ucslib.
 
 serviceprofile_list = [
   ui.color('Name',           :bold),
   ui.color('Path',           :bold),
   ui.color('UUID',           :bold),
   ui.color('BootPolicy',     :bold),
   ui.color('State',          :bold),
   ui.color('Association',    :bold)
 ]
 
 inventory.xpath("configResolveClasses/outConfigs/lsServer").each do |serviceprofile|
   serviceprofile_list << "#{serviceprofile.attributes["name"]}"
   serviceprofile_list << "#{serviceprofile.attributes["dn"]}"
   serviceprofile_list << "#{serviceprofile.attributes["uuid"]}"
   serviceprofile_list << "#{serviceprofile.attributes["operBootPolicyName"]}"
   serviceprofile_list << "#{serviceprofile.attributes["operState"]}"
   serviceprofile_list << begin
     state = "#{serviceprofile.attributes["assocState"]}"
     case state
     when 'associated'
       ui.color(state, :green)
     when 'associating'
       ui.color(state, :yellow)
     else
       ui.color(state, :red)
     end
   end
 end
 puts ui.list(serviceprofile_list, :uneven_columns_across, 6)        
  
  
end