Class: Command::NodeDestroy

Inherits:
CrowbarNodeCommand show all
Defined in:
lib/command/node_destroy.rb

Overview

Allows to destroy a node

Instance Attribute Summary collapse

Attributes inherited from BasicCommand

#logger, #receiver

Instance Method Summary collapse

Constructor Details

#initialize(node_name) ⇒ NodeDestroy

Default constructor

Parameters:

  • node_name (String)

    The name of the node

Author:

  • mbretaud



18
19
20
21
22
# File 'lib/command/node_destroy.rb', line 18

def initialize(node_name)
  super()
  @logger.info("Command::NodeDestroy   initialize the parameters...")
  @node_name = node_name
end

Instance Attribute Details

#node_nameObject (readonly)

Returns the value of attribute node_name.



12
13
14
# File 'lib/command/node_destroy.rb', line 12

def node_name
  @node_name
end

Instance Method Details

#execObject

Method who call crowbar receiver in order to destroy a node

Author:

  • mbretaud



26
27
28
29
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
# File 'lib/command/node_destroy.rb', line 26

def exec()
  begin
    @receiver.crowbar_node_delete_proposal(@node_name)
  rescue => e
    puts "Error: Delete the node '#{@node_name}' in all proposals : " + e.message
  end

  begin
    @receiver.crowbar_node_delete(@node_name)
  rescue => e
    puts "Error: Delete the node '#{@node_name}' of Crowbar : " + e.message
  end

  begin
    @receiver.crowbar_erase_node_hard_disk(node_name)
  rescue => e
    puts "Error: Erase the hard disk into the node '#{@node_name}' : " + e.message
  end

  begin
    @receiver.crowbar_erase_node_server(@node_name)
  rescue => e
    puts "Error: Erase the node '#{@node_name}' in the server Crowbar : " + e.message
  end

  begin
    @receiver.crowbar_reboot_node(node_name)
  rescue => e
    puts "Error: Reboot the node '#{@node_name}' : " + e.message
  end
end