Method: Exec::NodeInfo#if_node_exist
- Defined in:
- lib/exec/node_info.rb
#if_node_exist(node_name, status) ⇒ Boolean (private)
TODO:
refactor in a library
Check if the node exists or not
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/exec/node_info.rb', line 257 def if_node_exist(node_name, status) @logger.info("Exec::NodeInstall Check if the node '#{node_name}' exists or not.") # Retrieves the list of nodes. begin @logger.info("Exec::NodeInstall Getting the nodes list.") cmd = Command::.new(@logger, status) list_nodes = cmd.exec rescue => e raise NodeListError.new("Retrieves the list of nodes with the status '#{status}'.") end if !list_nodes.nil? && list_nodes.length > 0 list_nodes.each { |node| if node_name.split(" ").at(0).strip.to_s() == node.split(" ").at(0).strip.to_s() return true end } end return false end |