Class: Chef::Knife::UcsPoolCreate

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UCSBase

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

Instance Attribute Details

#initial_sleep_delayObject

Returns the value of attribute initial_sleep_delay.



36
37
38
# File 'lib/chef/knife/ucs_pool_create.rb', line 36

def initial_sleep_delay
  @initial_sleep_delay
end

Instance Method Details

#runObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/chef/knife/ucs_pool_create.rb', line 74

def run
  $stdout.sync = true
    
  pool_type = "#{Chef::Config[:knife][:pooltype]}".downcase
  case pool_type
  when 'managementip'
    json = { :start_ip => Chef::Config[:knife][:start],   :end_ip => Chef::Config[:knife][:end],
             :subnet_mask => Chef::Config[:knife][:mask], :gateway => Chef::Config[:knife][:gateway] }.to_json
    
    xml_response = provisioner.set_management_ip_pool(json)
    xml_doc = Nokogiri::XML(xml_response)
  
    xml_doc.xpath("configConfMos/outConfigs/pair/ippoolBlock").each do |ippool|
      puts ''
      puts "Management IP Block from: #{ui.color("#{ippool.attributes['from']}", :blue)} to: #{ui.color("#{ippool.attributes['to']}", :blue)}" + 
            " status: #{ui.color("#{ippool.attributes['status']}", :green)}"
    end

    
    xml_doc.xpath("configConfMos").each do |ippool|
       puts "#{ippool.attributes['errorCode']} #{ui.color("#{ippool.attributes['errorDescr']}", :red)}"
    end
    
  when 'mac'
    json =  { :mac_pool_name => Chef::Config[:knife][:name],  :mac_pool_start => Chef::Config[:knife][:start], 
              :mac_pool_end => Chef::Config[:knife][:end],    :org => Chef::Config[:knife][:org] }.to_json
    
    xml_response = provisioner.set_mac_pool(json)
    xml_doc = Nokogiri::XML(xml_response)
  
    xml_doc.xpath("configConfMos/outConfigs/pair/macpoolPool").each do |macpool|
      puts ''
      puts "MAC address pool : #{ui.color("#{macpool.attributes['name']}", :blue)}" + 
            " status: #{ui.color("#{macpool.attributes['status']}", :green)}"
    end

    
    xml_doc.xpath("configConfMos").each do |macpool|
       puts "#{macpool.attributes['errorCode']} #{ui.color("#{macpool.attributes['errorDescr']}", :red)}"
    end          

  when 'wwnn'
    json =  { :wwnn_name => Chef::Config[:knife][:name],  :wwnn_from => Chef::Config[:knife][:start], 
              :wwnn_to => Chef::Config[:knife][:end],     :org => Chef::Config[:knife][:org] }.to_json
    
    xml_response = provisioner.set_wwnn_pool(json)
    xml_doc = Nokogiri::XML(xml_response)
      
    xml_doc.xpath("configConfMos/outConfigs/pair/fcpoolInitiators").each do |wwnn|
      puts ''
      puts "WWNN pool : #{ui.color("#{wwnn.attributes['name']}", :blue)}" + 
            " status: #{ui.color("#{wwnn.attributes['status']}", :green)}"
    end
    
    
    xml_doc.xpath("configConfMos").each do |wwnn|
       puts "#{wwnn.attributes['errorCode']} #{ui.color("#{wwnn.attributes['errorDescr']}", :red)}"
    end


  when 'wwpn'
    json =  { :wwpn_name => Chef::Config[:knife][:name],  :wwpn_from => Chef::Config[:knife][:start], 
              :wwpn_to => Chef::Config[:knife][:end],     :org => Chef::Config[:knife][:org] }.to_json
  
    xml_response = provisioner.set_wwpn_pool(json)
    xml_doc = Nokogiri::XML(xml_response)
    
    xml_doc.xpath("configConfMos/outConfigs/pair/fcpoolInitiators").each do |wwpn|
      puts ''
      puts "WWPN pool : #{ui.color("#{wwpn.attributes['name']}", :blue)}" + 
            " status: #{ui.color("#{wwpn.attributes['status']}", :green)}"
    end
  
    
    xml_doc.xpath("configConfMos").each do |wwpn|
       puts "#{wwpn.attributes['errorCode']} #{ui.color("#{wwpn.attributes['errorDescr']}", :red)}"
    end
  
  when 'uuid'
    json =  { :uuid_pool_name => Chef::Config[:knife][:name], :uuid_from => Chef::Config[:knife][:start], 
              :uuid_to => Chef::Config[:knife][:end],         :org => Chef::Config[:knife][:org] }.to_json
  
    xml_response = provisioner.set_uuid_pool(json)
    xml_doc = Nokogiri::XML(xml_response)
    
    xml_doc.xpath("configConfMos/outConfigs/pair/uuidpoolPool").each do |uuid|
      puts ''
      puts "UUID pool : #{ui.color("#{uuid.attributes['name']}", :blue)}" + 
            " status: #{ui.color("#{uuid.attributes['status']}", :green)}"
    end
  
    
    xml_doc.xpath("configConfMos").each do |uuid|
       puts "#{uuid.attributes['errorCode']} #{ui.color("#{uuid.attributes['errorDescr']}", :red)}"
    end


  else
    puts "Incorrect options. Please make sure you are using one of the following: mac,uuid,wwpn,wwnn,managementip"
  end

end