cloudbox-server 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +3 -0
- data/README.md +17 -0
- data/bin/cb-cluster-allocate +5 -0
- data/bin/cb-cluster-create +5 -0
- data/bin/cb-cluster-delete +5 -0
- data/bin/cb-cluster-desallocate +5 -0
- data/bin/cb-cluster-info +5 -0
- data/bin/cb-cluster-ls +5 -0
- data/bin/cb-node-destroy +5 -0
- data/bin/cb-node-detach +6 -0
- data/bin/cb-node-info +5 -0
- data/bin/cb-node-install +5 -0
- data/bin/cb-node-ls +5 -0
- data/bin/cb-service-add +5 -0
- data/bin/cb-service-component-add +5 -0
- data/bin/cb-service-component-delete +5 -0
- data/bin/cb-service-component-detach +5 -0
- data/bin/cb-service-conf-apply +5 -0
- data/bin/cb-service-conf-create +5 -0
- data/bin/cb-service-conf-get +5 -0
- data/bin/cb-service-conf-ls +5 -0
- data/bin/cb-service-follow-request +5 -0
- data/bin/cb-service-info +5 -0
- data/bin/cb-service-install +5 -0
- data/bin/cb-service-ls +5 -0
- data/bin/cb-service-start +5 -0
- data/bin/cb-service-stop +5 -0
- data/lib/command.rb +61 -0
- data/lib/command/ambari_add_host.rb +19 -0
- data/lib/command/ambari_cluster_command.rb +26 -0
- data/lib/command/ambari_cluster_component_command.rb +26 -0
- data/lib/command/ambari_cluster_component_host_command.rb +26 -0
- data/lib/command/ambari_cluster_create.rb +19 -0
- data/lib/command/ambari_cluster_host_command.rb +27 -0
- data/lib/command/ambari_cluster_list.rb +20 -0
- data/lib/command/ambari_cluster_service_command.rb +26 -0
- data/lib/command/ambari_cluster_service_host_command.rb +26 -0
- data/lib/command/ambari_command.rb +21 -0
- data/lib/command/ambari_create_cluster_configuration.rb +39 -0
- data/lib/command/ambari_get_cluster_configuration.rb +29 -0
- data/lib/command/ambari_host_list.rb +19 -0
- data/lib/command/ambari_install_cluster.rb +19 -0
- data/lib/command/ambari_install_component.rb +19 -0
- data/lib/command/ambari_install_host.rb +19 -0
- data/lib/command/ambari_install_host_component.rb +19 -0
- data/lib/command/ambari_install_host_components.rb +19 -0
- data/lib/command/ambari_install_service_components.rb +19 -0
- data/lib/command/ambari_service_add.rb +27 -0
- data/lib/command/ambari_service_component_add.rb +21 -0
- data/lib/command/ambari_service_component_delete.rb +21 -0
- data/lib/command/ambari_service_component_detach.rb +21 -0
- data/lib/command/ambari_service_component_info.rb +29 -0
- data/lib/command/ambari_service_conf_apply.rb +31 -0
- data/lib/command/ambari_service_conf_ls.rb +30 -0
- data/lib/command/ambari_service_delete.rb +21 -0
- data/lib/command/ambari_service_info.rb +20 -0
- data/lib/command/ambari_service_list.rb +21 -0
- data/lib/command/ambari_start_cluster.rb +19 -0
- data/lib/command/ambari_start_component.rb +19 -0
- data/lib/command/ambari_start_host.rb +19 -0
- data/lib/command/ambari_start_host_component.rb +19 -0
- data/lib/command/ambari_start_host_components.rb +19 -0
- data/lib/command/ambari_start_service_components.rb +19 -0
- data/lib/command/ambari_stop_cluster.rb +19 -0
- data/lib/command/ambari_stop_component.rb +19 -0
- data/lib/command/ambari_stop_host.rb +19 -0
- data/lib/command/ambari_stop_host_component.rb +19 -0
- data/lib/command/ambari_stop_host_components.rb +19 -0
- data/lib/command/ambari_stop_service_components.rb +19 -0
- data/lib/command/basic_command.rb +44 -0
- data/lib/command/cluster_create.rb +50 -0
- data/lib/command/cluster_delete.rb +30 -0
- data/lib/command/cluster_info.rb +30 -0
- data/lib/command/cluster_ls.rb +30 -0
- data/lib/command/crowbar_cluster_allocate.rb +42 -0
- data/lib/command/crowbar_command.rb +30 -0
- data/lib/command/crowbar_get_barclamps_list.rb +30 -0
- data/lib/command/crowbar_node_command.rb +21 -0
- data/lib/command/crowbar_node_list.rb +40 -0
- data/lib/command/crowbar_vcluster_command.rb +20 -0
- data/lib/command/filter.rb +15 -0
- data/lib/command/node_destroy.rb +58 -0
- data/lib/command/node_detach.rb +44 -0
- data/lib/command/node_info.rb +27 -0
- data/lib/command/node_install.rb +46 -0
- data/lib/command/node_reinstall.rb +44 -0
- data/lib/command/state_filter.rb +16 -0
- data/lib/common.rb +11 -0
- data/lib/common/cb-lib-node-erase-hard-disk.sh +29 -0
- data/lib/common/cloudbox_exceptions.rb +631 -0
- data/lib/common/cloudbox_logger.rb +81 -0
- data/lib/common/cloudbox_logger_mock.rb +43 -0
- data/lib/common/color.rb +267 -0
- data/lib/common/config_properties.rb +2027 -0
- data/lib/common/services_description.rb +192 -0
- data/lib/exec.rb +35 -0
- data/lib/exec/check_parameter.rb +208 -0
- data/lib/exec/cluster_allocate.rb +163 -0
- data/lib/exec/cluster_create.rb +99 -0
- data/lib/exec/cluster_delete.rb +38 -0
- data/lib/exec/cluster_desallocate.rb +37 -0
- data/lib/exec/cluster_info.rb +177 -0
- data/lib/exec/cluster_ls.rb +150 -0
- data/lib/exec/command_option.rb +222 -0
- data/lib/exec/executable_command.rb +194 -0
- data/lib/exec/node_destroy.rb +101 -0
- data/lib/exec/node_detach.rb +98 -0
- data/lib/exec/node_info.rb +280 -0
- data/lib/exec/node_install.rb +234 -0
- data/lib/exec/node_ls.rb +160 -0
- data/lib/exec/service_add.rb +224 -0
- data/lib/exec/service_component_add.rb +39 -0
- data/lib/exec/service_component_delete.rb +37 -0
- data/lib/exec/service_component_detach.rb +37 -0
- data/lib/exec/service_conf_apply.rb +57 -0
- data/lib/exec/service_conf_create.rb +80 -0
- data/lib/exec/service_conf_get.rb +165 -0
- data/lib/exec/service_conf_ls.rb +103 -0
- data/lib/exec/service_follow_request.rb +49 -0
- data/lib/exec/service_info.rb +346 -0
- data/lib/exec/service_install.rb +87 -0
- data/lib/exec/service_ls.rb +124 -0
- data/lib/exec/service_start.rb +110 -0
- data/lib/exec/service_stop.rb +112 -0
- data/lib/receiver.rb +14 -0
- data/lib/receiver/ambari_receiver.rb +812 -0
- data/lib/receiver/ambari_rest_api_connector.rb +599 -0
- data/lib/receiver/basic_receiver.rb +28 -0
- data/lib/receiver/connector.rb +28 -0
- data/lib/receiver/crowbar_receiver.rb +588 -0
- data/lib/receiver/crowbar_rest_api_connector.rb +518 -0
- data/lib/receiver/crowbar_shell_api.rb +643 -0
- data/lib/receiver/rest_api_connector.rb +275 -0
- data/resources/ambari-configurations/HBASE/default_hbase-site +33 -0
- data/resources/ambari-configurations/HDFS/default_hdfs-site +49 -0
- data/resources/ambari-configurations/HIVE/default_hive-site +33 -0
- data/resources/ambari-configurations/MAPREDUCE/default_mapred-site +72 -0
- data/resources/ambari-configurations/OOZIE/default_oozie-site +28 -0
- data/resources/ambari-configurations/WEBHCAT/default_webhcat-site +18 -0
- data/resources/ambari-configurations/ZOOKEEPER/default_zookeeper-site +8 -0
- data/resources/ambari-configurations/default_core-site +22 -0
- data/resources/ambari-configurations/default_global +141 -0
- data/resources/cloudbox-server.conf +10 -0
- data/spec/common/services_description.rb +130 -0
- data/spec/exec/check_parameter.rb +152 -0
- data/spec/exec/command_option_spec.rb +97 -0
- metadata +328 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
# This file is part of Devcloudbox project
|
2
|
+
# @author aboudot (INGENSI)
|
3
|
+
|
4
|
+
require 'exec/executable_command'
|
5
|
+
require 'common/cloudbox_exceptions'
|
6
|
+
require 'optparse'
|
7
|
+
require 'command/node_detach'
|
8
|
+
|
9
|
+
include Exec::CheckParameter
|
10
|
+
|
11
|
+
module Exec
|
12
|
+
# Allows the user to detach node's of crowbar server.
|
13
|
+
# @author mbretaud
|
14
|
+
class NodeDetach < ExecutableCommand
|
15
|
+
|
16
|
+
public
|
17
|
+
# Default constructor of the class.
|
18
|
+
# @note Overrides default constructor by passing CustomCommandOption to super().
|
19
|
+
# @author mbretaud
|
20
|
+
def initialize(argv, stdin, stdout, stderr, command_name)
|
21
|
+
super(argv, stdin, stdout, stderr, command_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
# Parse and check the parameters of the function.
|
26
|
+
# @author mbretaud
|
27
|
+
def set_options
|
28
|
+
@logger.info("Exec::NodeDetach Setting options")
|
29
|
+
@options.add_option("n", "node", "The Node name that will be Destroy.", true, true, method(:check_crowbar_node_name))
|
30
|
+
end
|
31
|
+
|
32
|
+
# The execution of the command.
|
33
|
+
# @author mbretaud
|
34
|
+
def exec()
|
35
|
+
@logger.info("Exec::NodeDetach Executing NodeDetach")
|
36
|
+
detach_node(@values['node'])
|
37
|
+
end
|
38
|
+
|
39
|
+
public
|
40
|
+
# Detach a node from the server Crowbar
|
41
|
+
# @param node_name [String] the name node
|
42
|
+
# @raise NodeError If the node don't exists or is not Ready
|
43
|
+
# @author mbretaud
|
44
|
+
def detach_node(node_name)
|
45
|
+
@logger.info("Exec::NodeDetach detach_node(#{node_name})")
|
46
|
+
Color::print_log("NONE", "Detach the node '#{node_name}'...", @stdout)
|
47
|
+
|
48
|
+
output = ""
|
49
|
+
unless node_name.nil?
|
50
|
+
if if_node_exist(node_name, "Ready")
|
51
|
+
cmd = Command::NodeDetach.new(node_name)
|
52
|
+
cmd.exec
|
53
|
+
#output += "Detach the node '#{node_name}'.\n"
|
54
|
+
else
|
55
|
+
raise NodeDetachError.new("The node '#{node_name}' doesn't exists or is not 'Ready'.")
|
56
|
+
end
|
57
|
+
else
|
58
|
+
raise NodeDetachError.new("The node name is nil.")
|
59
|
+
end
|
60
|
+
|
61
|
+
Color::echo_ok(@stdout)
|
62
|
+
@logger.info(output)
|
63
|
+
if !output.empty? && output.length > 1
|
64
|
+
@stdout.print output
|
65
|
+
else
|
66
|
+
@logger.info("Exec::NodeDetach No machines available.")
|
67
|
+
@stdout.printf_red "No machines available.\n"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
# @param node_name [String] the name node
|
73
|
+
# @return [Boolean] true if the node exists, false else
|
74
|
+
# @todo refactor in a library
|
75
|
+
# @author mbretaud
|
76
|
+
def if_node_exist(node_name, status)
|
77
|
+
# Retrieves the list of nodes.
|
78
|
+
begin
|
79
|
+
@logger.info("Exec::NodeDetach Getting the nodes list.")
|
80
|
+
cmd = Command::CrowbarNodeList.new(@logger, status)
|
81
|
+
list_nodes = cmd.exec
|
82
|
+
rescue => e
|
83
|
+
raise NodeListError.new("Retrieves the list of nodes with the status '#{status}'..")
|
84
|
+
end
|
85
|
+
|
86
|
+
if !list_nodes.nil? && list_nodes.length > 0
|
87
|
+
list_nodes.each { |node|
|
88
|
+
if node_name == node.split(" ").at(0).strip.to_s()
|
89
|
+
return true
|
90
|
+
end
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
return false
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
# This file is part of cloudbox-server project
|
2
|
+
# @author mbretaud (INGENSI)
|
3
|
+
|
4
|
+
require 'exec/executable_command'
|
5
|
+
require 'common/cloudbox_exceptions'
|
6
|
+
require 'command/node_info'
|
7
|
+
require 'command/crowbar_node_command'
|
8
|
+
|
9
|
+
include Exec::CheckParameter
|
10
|
+
|
11
|
+
module Exec
|
12
|
+
# Allows the user to display node's information.
|
13
|
+
# @author mbretaud
|
14
|
+
class NodeInfo < ExecutableCommand
|
15
|
+
|
16
|
+
public
|
17
|
+
# Default constructor of the class.
|
18
|
+
# @note Overrides default constructor by passing CustomCommandOption to super().
|
19
|
+
# @author mbretaud
|
20
|
+
def initialize(argv, stdin, stdout, stderr, command_name)
|
21
|
+
super(argv, stdin, stdout, stderr, command_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
# Parse and check the parameters of the function.
|
26
|
+
# @author tnoguer
|
27
|
+
def set_options
|
28
|
+
@logger.info("Exec::NodeInfo Setting options")
|
29
|
+
@options.add_option("n", "node", "Displays informations about a node.", true, true, method(:check_crowbar_node_name))
|
30
|
+
end
|
31
|
+
|
32
|
+
# The execution of the command.
|
33
|
+
# @author tnoguer
|
34
|
+
def exec()
|
35
|
+
@logger.info("Exec::NodeInfo Executing NodeInfo")
|
36
|
+
@logger.info("Exec::NodeDestroy Getting informations about the node '#{@values['node']}'")
|
37
|
+
|
38
|
+
Color::print_log("NONE", "Displays informations for the node '#{@values['node']}'...", @stdout)
|
39
|
+
|
40
|
+
node_name = @values['node']
|
41
|
+
|
42
|
+
if !if_node_exist(node_name, "Ready")
|
43
|
+
raise NodeInfoError.new("The node '#{node_name}' doesn't exists or is not 'Ready.")
|
44
|
+
end
|
45
|
+
|
46
|
+
cmd = Command::NodeInfo.new(node_name)
|
47
|
+
p = cmd.exec()
|
48
|
+
|
49
|
+
output = ""
|
50
|
+
|
51
|
+
unless p.nil?
|
52
|
+
output += "Node '#{node_name}' informations:\n"
|
53
|
+
output += " Machine:\n"
|
54
|
+
if p['name'] != nil
|
55
|
+
output += " -Name: " + p['name'] + "\n"
|
56
|
+
end
|
57
|
+
if p['os'] != nil
|
58
|
+
output += " -OS: " + p['os'] + "\n"
|
59
|
+
end
|
60
|
+
if p['os_version']
|
61
|
+
output += " -OS version: " + p['os_version'] + "\n"
|
62
|
+
end
|
63
|
+
if p['dmi'] != nil
|
64
|
+
if p['dmi']['system'] != nil
|
65
|
+
if p['dmi']['system']['product_name'] != nil
|
66
|
+
output += " -Product Name : " + p['dmi']['system']['product_name'] + "\n"
|
67
|
+
end
|
68
|
+
if p['dmi']['system']['version'] != nil
|
69
|
+
output += " -Version : " + p['dmi']['system']['version'] + "\n"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
if p['memory'] != nil
|
74
|
+
if p['memory']['total'] != nil
|
75
|
+
memory = (p['memory']['total'].to_f) / 1048576
|
76
|
+
output += " -Memory: " + "%5.2f" % memory.to_s + " GB\n"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
if p['platform']
|
80
|
+
output += " -Platform: " + p['platform'] + "\n"
|
81
|
+
end
|
82
|
+
if p['platform_version']
|
83
|
+
output += " -Platform version: " + p['platform_version'] + "\n"
|
84
|
+
end
|
85
|
+
if p['cpu'] != nil
|
86
|
+
if p['cpu']['total'] != nil
|
87
|
+
if p['cpu']['0'] != nil
|
88
|
+
if p['cpu']['0']['model_name'] != nil
|
89
|
+
output += " -CPU: " + p['cpu']['total'].to_s + " * " + p['cpu']['0']['model_name'] + "\n"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
output += "\n"
|
95
|
+
output += " System:\n"
|
96
|
+
if p['uptime'] != nil
|
97
|
+
output += " -Uptime: " + p['uptime'] + "\n"
|
98
|
+
end
|
99
|
+
if p['idletime']
|
100
|
+
output += " -Idletime: " + p['idletime'] + "\n"
|
101
|
+
end
|
102
|
+
if p['raid'] != nil
|
103
|
+
output += " -Raid: " + p['raid']['enable'].to_s + "\n"
|
104
|
+
end
|
105
|
+
output += "\n"
|
106
|
+
output += " Network:\n"
|
107
|
+
if p['hostname'] != nil
|
108
|
+
output += " -Hostname: " + p['hostname'] + "\n"
|
109
|
+
end
|
110
|
+
if p['domain'] != nil
|
111
|
+
output += " -Domain: " + p['domain'] + "\n"
|
112
|
+
end
|
113
|
+
if p['ipaddress'] != nil
|
114
|
+
output += " -IP address: " + p['ipaddress'] + "\n"
|
115
|
+
end
|
116
|
+
if p['macaddress'] != nil
|
117
|
+
output += " -MAC address: " + p['macaddress'] + "\n"
|
118
|
+
end
|
119
|
+
if p['fqdn'] != nil
|
120
|
+
output += " -FQDN: " + p['fqdn'] + "\n"
|
121
|
+
end
|
122
|
+
output += "\n"
|
123
|
+
output += " Crowbar/Chef:\n"
|
124
|
+
if p['state'] != nil
|
125
|
+
output += " -State: " + p['state'] + "\n"
|
126
|
+
end
|
127
|
+
if p['filesystem'] != nil
|
128
|
+
output += " -Filesystem:\n"
|
129
|
+
get_keys = p['filesystem'].keys
|
130
|
+
|
131
|
+
get_keys.each { |x|
|
132
|
+
if x.start_with?('/dev/')
|
133
|
+
output += " -#{x}:\n"
|
134
|
+
if p['filesystem'][x]['mount'] != nil
|
135
|
+
output += " -Mount: " + p['filesystem'][x]['mount'] + "\n"
|
136
|
+
end
|
137
|
+
if p['filesystem'][x]['percent_used'] != nil
|
138
|
+
output += " -Percent used: " + p['filesystem'][x]['percent_used'].gsub("%", "") + "\n"
|
139
|
+
end
|
140
|
+
if p['filesystem'][x]['fs_type'] != nil
|
141
|
+
output += " -FS type: " + p['filesystem'][x]['fs_type'] + "\n"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
}
|
145
|
+
end
|
146
|
+
if p['crowbar'] != nil
|
147
|
+
if p['crowbar']['disks'] != nil
|
148
|
+
output += " -Disks:\n"
|
149
|
+
get_keys = p['crowbar']['disks'].keys
|
150
|
+
|
151
|
+
get_keys.each { |x|
|
152
|
+
output += " -#{x}:\n"
|
153
|
+
if p['crowbar']['disks'][x]['model'] != nil
|
154
|
+
output += " -Model: " + p['crowbar']['disks'][x]['model'] + "\n"
|
155
|
+
end
|
156
|
+
if p['crowbar']['disks'][x]['vendor'] != nil
|
157
|
+
output += " -Vendor: " + p['crowbar']['disks'][x]['vendor'] + "\n"
|
158
|
+
end
|
159
|
+
if p['crowbar']['disks'][x]['state'] != nil
|
160
|
+
output += " -State: " + p['crowbar']['disks'][x]['state'] + "\n"
|
161
|
+
end
|
162
|
+
}
|
163
|
+
end
|
164
|
+
if p['crowbar']['hardware'] != nil
|
165
|
+
output += " -Hardware:\n"
|
166
|
+
if p['crowbar']['hardware']['bios_set'] != nil
|
167
|
+
output += " -Bios set: " + p['crowbar']['hardware']['bios_set'] + "\n"
|
168
|
+
end
|
169
|
+
if p['crowbar']['hardware']['raid_set'] != nil
|
170
|
+
output += " -Raid set: " + p['crowbar']['hardware']['raid_set'] + "\n"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
if p['crowbar']['network'] != nil && (p['crowbar']['network']['bmc'] != nil || p['crowbar']['network']['admin'] != nil)
|
174
|
+
output += " -Network:\n"
|
175
|
+
get_keys = p['crowbar']['network'].keys
|
176
|
+
|
177
|
+
get_keys.each { |x|
|
178
|
+
output += " -#{x}:\n"
|
179
|
+
if p['crowbar']['network'][x]['address'] != nil
|
180
|
+
output += " -Address: " + p['crowbar']['network'][x]['address'] + "\n"
|
181
|
+
end
|
182
|
+
if p['crowbar']['network'][x]['subnet'] != nil
|
183
|
+
output += " -Subnet: " + p['crowbar']['network'][x]['subnet'] + "\n"
|
184
|
+
end
|
185
|
+
if p['crowbar']['network'][x]['netmask'] != nil
|
186
|
+
output += " -Netmask: " + p['crowbar']['network'][x]['netmask'] + "\n"
|
187
|
+
end
|
188
|
+
if p['crowbar']['network'][x]['broadcast'] != nil
|
189
|
+
output += " -Broadcast: " + p['crowbar']['network'][x]['broadcast'] + "\n"
|
190
|
+
end
|
191
|
+
}
|
192
|
+
end
|
193
|
+
end
|
194
|
+
if p['roles'] != nil
|
195
|
+
output += " -Roles:\n"
|
196
|
+
p['roles'].each { |x|
|
197
|
+
output += " -#{x}\n"
|
198
|
+
}
|
199
|
+
end
|
200
|
+
if p['chef_packages'] != nil
|
201
|
+
if p['chef_packages']['chef'] != nil
|
202
|
+
output += " -Chef:\n"
|
203
|
+
if p['chef_packages']['chef']['version']
|
204
|
+
output += " -Version: " + p['chef_packages']['chef']['version'] + "\n"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
output += "\n"
|
209
|
+
if p['kernel'] != nil
|
210
|
+
output += " Kernel:\n"
|
211
|
+
if p['kernel']['name'] != nil
|
212
|
+
output += " -Name: " + p['kernel']['name'] + "\n"
|
213
|
+
end
|
214
|
+
if p['kernel']['version'] != nil
|
215
|
+
output += " -Version: " + p['kernel']['version'] + "\n"
|
216
|
+
end
|
217
|
+
if p['kernel']['os'] != nil
|
218
|
+
output += " -OS: " + p['kernel']['os'] + "\n"
|
219
|
+
end
|
220
|
+
if p['kernel']['release']
|
221
|
+
output += " -Release: " + p['kernel']['release'] + "\n"
|
222
|
+
end
|
223
|
+
if p['kernel']['machine']
|
224
|
+
output += " -Machine: " + p['kernel']['machine'] + "\n"
|
225
|
+
end
|
226
|
+
end
|
227
|
+
output += "\n"
|
228
|
+
if p['languages'] != nil
|
229
|
+
output += " Languages versions:\n"
|
230
|
+
get_keys = p['languages'].keys
|
231
|
+
|
232
|
+
get_keys.each { |x|
|
233
|
+
if p['languages'][x]['version'] != nil
|
234
|
+
output += " -#{x}: " + p['languages'][x]['version'] + "\n"
|
235
|
+
end
|
236
|
+
}
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
Color::echo_ok(@stdout)
|
241
|
+
@logger.info(output)
|
242
|
+
|
243
|
+
if !output.empty? && output.length > 1
|
244
|
+
@stdout.print output
|
245
|
+
else
|
246
|
+
@logger.info("Exec::NodeInfo No informations about the node '#{node_name}'.")
|
247
|
+
@stdout.printf_red "No informations about the node '#{node_name}'.\n"
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
private
|
252
|
+
# Check if the node exists or not
|
253
|
+
# @param node_name [String] the name node
|
254
|
+
# @return [Boolean] true if the node exists, false else
|
255
|
+
# @todo refactor in a library
|
256
|
+
# @author mbretaud
|
257
|
+
def if_node_exist(node_name, status)
|
258
|
+
@logger.info("Exec::NodeInstall Check if the node '#{node_name}' exists or not.")
|
259
|
+
|
260
|
+
# Retrieves the list of nodes.
|
261
|
+
begin
|
262
|
+
@logger.info("Exec::NodeInstall Getting the nodes list.")
|
263
|
+
cmd = Command::CrowbarNodeList.new(@logger, status)
|
264
|
+
list_nodes = cmd.exec
|
265
|
+
rescue => e
|
266
|
+
raise NodeListError.new("Retrieves the list of nodes with the status '#{status}'.")
|
267
|
+
end
|
268
|
+
|
269
|
+
if !list_nodes.nil? && list_nodes.length > 0
|
270
|
+
list_nodes.each { |node|
|
271
|
+
if node_name.split(" ").at(0).strip.to_s() == node.split(" ").at(0).strip.to_s()
|
272
|
+
return true
|
273
|
+
end
|
274
|
+
}
|
275
|
+
end
|
276
|
+
|
277
|
+
return false
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
# This file is part of cloudbox-service project
|
2
|
+
# @author mbretaud (INGENSI)
|
3
|
+
|
4
|
+
require 'exec/executable_command'
|
5
|
+
require 'common/cloudbox_exceptions'
|
6
|
+
require 'optparse'
|
7
|
+
require 'command/node_install'
|
8
|
+
require 'command/node_reinstall'
|
9
|
+
|
10
|
+
# @todo use CommandOption to check parameters format
|
11
|
+
include Exec::CheckParameter
|
12
|
+
|
13
|
+
module Exec
|
14
|
+
# Allows the user to deploy nodes on a cluster with Crowbar.
|
15
|
+
# @author mbretaud
|
16
|
+
class NodeInstall < ExecutableCommand
|
17
|
+
|
18
|
+
public
|
19
|
+
# Default constructor of the class.
|
20
|
+
# @note Overrides default constructor by passing CustomCommandOption to super().
|
21
|
+
# @author mbretaud
|
22
|
+
def initialize(argv, stdin, stdout, stderr, command_name)
|
23
|
+
super(argv, stdin, stdout, stderr, command_name, CustomCommandOption)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
# Parse and check the parameters of the function.
|
28
|
+
# @author mbretaud
|
29
|
+
def set_options()
|
30
|
+
@logger.info("Exec::NodeInstall Setting options")
|
31
|
+
@options.add_option("n", "node", "The Node name that will be installed.", true, true, method(:check_crowbar_node_name))
|
32
|
+
@options.add_option("a", "all", "install OS on all nodes.", true, false)
|
33
|
+
@options.add_option("b", "bios", "Set the bios name (Hadoop, HadoopInfra, Storage or Virtualization)", false, true)
|
34
|
+
@options.add_option("r", "raid", "Set the raid name (Raid10 or JBODOnly).", false, true, method(:check_param_for_raid))
|
35
|
+
@options.add_option("f", "force", "force the reinstallation of an already installed node.", false)
|
36
|
+
end
|
37
|
+
|
38
|
+
# The execution of the command.
|
39
|
+
# @author mbretaud
|
40
|
+
def exec()
|
41
|
+
@logger.info("Exec::NodeInstall Executing NodeInstall")
|
42
|
+
|
43
|
+
output = ""
|
44
|
+
|
45
|
+
### All installations ###
|
46
|
+
if @values['all'] && !@values['force'] && @values['node'].nil?
|
47
|
+
@logger.info("Exec::NodeInstall All installations")
|
48
|
+
Color::print_log("NONE", "Installation of all node 'Discovered'...", @stdout)
|
49
|
+
|
50
|
+
# Retrieves the list of nodes.
|
51
|
+
begin
|
52
|
+
@logger.info("Exec::NodeInstall Getting the nodes list.")
|
53
|
+
cmd = Command::CrowbarNodeList.new(@logger, "Discovered")
|
54
|
+
list_nodes = cmd.exec
|
55
|
+
rescue => e
|
56
|
+
raise NodeListError.new("Retrieves the list of nodes with the status 'Discovered'.")
|
57
|
+
end
|
58
|
+
|
59
|
+
bios_name = @values['bios']
|
60
|
+
raid_name = @values['raid']
|
61
|
+
|
62
|
+
if !list_nodes.nil? && list_nodes.length > 0
|
63
|
+
list_nodes.each { |node_name|
|
64
|
+
begin
|
65
|
+
output += install_node(node_name, bios_name, raid_name) + "\n"
|
66
|
+
rescue => e
|
67
|
+
raise NodeInstallError.new("Installation of the node '#{node_name}'.")
|
68
|
+
end
|
69
|
+
}
|
70
|
+
else
|
71
|
+
raise NodeInstallError.new("No machines are Discovered.")
|
72
|
+
end
|
73
|
+
|
74
|
+
Color::echo_ok(@stdout)
|
75
|
+
@logger.info(output)
|
76
|
+
if !output.empty? && output.length > 1
|
77
|
+
@stdout.print output
|
78
|
+
else
|
79
|
+
@logger.info("Exec::NodeLs No machines available.")
|
80
|
+
@stdout.printf_red "No machines available.\n"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
### Installation on one node ###
|
85
|
+
if !@values['all'] && !@values['force'] && !@values['node'].nil?
|
86
|
+
@logger.info("Exec::NodeInstall Installation on the node '#{@values['node']}'")
|
87
|
+
Color::print_log("NONE", "Installation of the node '#{@values['node']}'...", @stdout)
|
88
|
+
|
89
|
+
node_name = @values['node']
|
90
|
+
bios_name = @values['bios']
|
91
|
+
raid_name = @values['raid']
|
92
|
+
|
93
|
+
if !if_node_exist(node_name, "Discovered")
|
94
|
+
raise NodeInfoError.new("The node '#{node_name}' doesn't exists or is not 'Discovered'.")
|
95
|
+
end
|
96
|
+
|
97
|
+
begin
|
98
|
+
output += install_node(node_name, bios_name, raid_name) + "\n"
|
99
|
+
rescue => e
|
100
|
+
raise NodeInstallError.new("Installation of the node '#{node_name}'.")
|
101
|
+
end
|
102
|
+
|
103
|
+
Color::echo_ok(@stdout)
|
104
|
+
@logger.info(output)
|
105
|
+
if !output.empty? && output.length > 1
|
106
|
+
@stdout.print output
|
107
|
+
else
|
108
|
+
@logger.info("Exec::NodeLs No machines available.")
|
109
|
+
@stdout.printf_red "No machines available.\n"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
### Reinstallation on one node Ready ###
|
114
|
+
if !@values['all'] && @values['force'] && !@values['node'].nil?
|
115
|
+
@logger.info("Exec::NodeInstall Reinstallation on the node '#{@values['node']}'")
|
116
|
+
Color::print_log("NONE", "Reinstallation of the node '#{@values['node']}'...", @stdout)
|
117
|
+
|
118
|
+
node_name = @values['node']
|
119
|
+
bios_name = @values['bios']
|
120
|
+
raid_name = @values['raid']
|
121
|
+
|
122
|
+
if !if_node_exist(node_name, "Ready")
|
123
|
+
raise NodeInfoError.new("The node '#{node_name}' doesn't exists or is not 'Ready.")
|
124
|
+
end
|
125
|
+
|
126
|
+
begin
|
127
|
+
output += reinstall_node(node_name, bios_name, raid_name) + "\n"
|
128
|
+
rescue => e
|
129
|
+
raise NodeReinstallError.new("Reinstallation of the node '#{node_name}'.")
|
130
|
+
end
|
131
|
+
|
132
|
+
Color::echo_ok(@stdout)
|
133
|
+
@logger.info(output)
|
134
|
+
if !output.empty? && output.length > 1
|
135
|
+
@stdout.print output
|
136
|
+
else
|
137
|
+
@logger.info("Exec::NodeLs No machines available.")
|
138
|
+
@stdout.printf_red "No machines available.\n"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
public
|
144
|
+
# Install a node
|
145
|
+
# @param node_name [String] the name node
|
146
|
+
# @raise NodeError If the node don't exists or is not Discovered
|
147
|
+
# @author mbretaud
|
148
|
+
def install_node(node_name, bios_name = nil, raid_name = nil)
|
149
|
+
@logger.info("Exec::NodeInstall install_node(#{node_name}, #{bios_name}, #{raid_name})")
|
150
|
+
|
151
|
+
output = ""
|
152
|
+
unless node_name.nil?
|
153
|
+
if if_node_exist(node_name, "Discovered")
|
154
|
+
cmd = Command::NodeInstall.new(node_name, bios_name, raid_name)
|
155
|
+
cmd.exec
|
156
|
+
output += "Installation of the node '#{node_name}'.\n"
|
157
|
+
else
|
158
|
+
raise NodeInstallError.new("The node '#{node_name}' doesn't exists or is not 'Discovered.")
|
159
|
+
end
|
160
|
+
end
|
161
|
+
return output
|
162
|
+
end
|
163
|
+
|
164
|
+
public
|
165
|
+
# Reinstall a node
|
166
|
+
# @param node_name [String] the name node
|
167
|
+
# @raise NodeError If the node don't exists or is not Discovered
|
168
|
+
# @author mbretaud
|
169
|
+
def reinstall_node(node_name, bios_name = nil, raid_name = nil)
|
170
|
+
@logger.info("Exec::NodeInstall reinstall_node(#{node_name}, #{bios_name}, #{raid_name})")
|
171
|
+
|
172
|
+
output = ""
|
173
|
+
unless node_name.nil?
|
174
|
+
if if_node_exist(node_name, "Ready")
|
175
|
+
cmd = Command::NodeReinstall.new(node_name, bios_name, raid_name)
|
176
|
+
cmd.exec
|
177
|
+
output += "Reinstallation of the node '#{node_name}'.\n"
|
178
|
+
else
|
179
|
+
raise NodeReinstallError.new("The node '#{node_name}' doesn't exists or is not 'Ready.")
|
180
|
+
end
|
181
|
+
end
|
182
|
+
return output
|
183
|
+
end
|
184
|
+
|
185
|
+
private
|
186
|
+
# Check if the node exists or not
|
187
|
+
# @param node_name [String] the name node
|
188
|
+
# @return [Boolean] true if the node exists, false else
|
189
|
+
# @todo refactor in a library
|
190
|
+
# @author mbretaud
|
191
|
+
def if_node_exist(node_name, status)
|
192
|
+
@logger.info("Exec::NodeInstall Check if the node '#{node_name}' exists or not.")
|
193
|
+
|
194
|
+
# Retrieves the list of nodes.
|
195
|
+
begin
|
196
|
+
@logger.info("Exec::NodeInstall Getting the nodes list.")
|
197
|
+
cmd = Command::CrowbarNodeList.new(@logger, status)
|
198
|
+
list_nodes = cmd.exec
|
199
|
+
rescue => e
|
200
|
+
raise NodeListError.new("Retrieves the list of nodes with the status '#{status}'.")
|
201
|
+
end
|
202
|
+
|
203
|
+
if !list_nodes.nil? && list_nodes.length > 0
|
204
|
+
list_nodes.each { |node|
|
205
|
+
if node_name.split(" ").at(0).strip.to_s() == node.split(" ").at(0).strip.to_s()
|
206
|
+
return true
|
207
|
+
end
|
208
|
+
}
|
209
|
+
end
|
210
|
+
|
211
|
+
return false
|
212
|
+
end
|
213
|
+
|
214
|
+
private
|
215
|
+
# Inherited CommandOption used only by ServiceLs.
|
216
|
+
class CustomCommandOption < CommandOption
|
217
|
+
|
218
|
+
public
|
219
|
+
# This method overrides the default bannger generating
|
220
|
+
def get_banner
|
221
|
+
return "Usage: -a|-n NODE_NAME [-b BIOS_NAME] [-r RAID_NAME] [-f] [-h]"
|
222
|
+
end
|
223
|
+
|
224
|
+
protected
|
225
|
+
# This method overrides the default behaviour.
|
226
|
+
# @raise [Common::MissingParameter] Never raise exception for the moment :)
|
227
|
+
def check_mandatory
|
228
|
+
raise Common::MissingParameter.new("-n or -a", get_help()) if !@values["help"] && !@values["all"] && @values["node"].nil?
|
229
|
+
raise Common::InconsistentParameter.new("can not be used together.", get_help(), "-a", "-n") if !@values["help"] && @values["all"] && !@values["node"].nil?
|
230
|
+
raise Common::InconsistentParameter.new("can not be used together.", get_help(), "-a", "-f") if !@values["help"] && @values["all"] && @values["force"]
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|