cloudbox-server 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,28 @@
|
|
|
1
|
+
# This file is part of cloudbox-server project
|
|
2
|
+
# @author tnoguer (INGENSI)
|
|
3
|
+
|
|
4
|
+
require 'common/color'
|
|
5
|
+
require 'common/cloudbox_logger'
|
|
6
|
+
require 'common/cloudbox_logger_mock'
|
|
7
|
+
|
|
8
|
+
module Receiver
|
|
9
|
+
# Basic class of a receiver. It contains every attributes and methods all receiver need.
|
|
10
|
+
class BasicReceiver
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
# The connector to shell API.
|
|
14
|
+
@shell_connector
|
|
15
|
+
# The connector to REST API.
|
|
16
|
+
@rest_connector
|
|
17
|
+
# The logger.
|
|
18
|
+
@logger
|
|
19
|
+
|
|
20
|
+
public
|
|
21
|
+
def initialize(logger = nil)
|
|
22
|
+
@logger = logger
|
|
23
|
+
@logger = Common::CloudboxLoggerMock.new if @logger.nil?
|
|
24
|
+
@logger.info("Receiver::BasicReceiver initialize the parameters...")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This file is part of cloudbox-server project
|
|
2
|
+
# Author: mbr (INGENSI)
|
|
3
|
+
|
|
4
|
+
require 'common/color'
|
|
5
|
+
require 'common/cloudbox_logger'
|
|
6
|
+
require 'common/cloudbox_logger_mock'
|
|
7
|
+
|
|
8
|
+
# The Receiver module
|
|
9
|
+
module Receiver
|
|
10
|
+
# Basic class of a connector. It contains every attributes and methods all connector need.
|
|
11
|
+
class Connector
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
# The logger.
|
|
15
|
+
@logger
|
|
16
|
+
|
|
17
|
+
public
|
|
18
|
+
# Default constructor of the class.
|
|
19
|
+
# @note Overrides default constructor by passing CustomCommandOption to super().
|
|
20
|
+
# @author mbretaud
|
|
21
|
+
def initialize(logger = nil)
|
|
22
|
+
@logger = logger
|
|
23
|
+
@logger = Common::CloudboxLoggerMock.new if @logger.nil?
|
|
24
|
+
@logger.info("Receiver::Connector initialize the parameters...")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
# This file is part of cloudbox-server project
|
|
2
|
+
# Author: mbr (INGENSI)
|
|
3
|
+
|
|
4
|
+
require 'receiver/basic_receiver'
|
|
5
|
+
require 'receiver/connector'
|
|
6
|
+
require 'receiver/crowbar_shell_api'
|
|
7
|
+
require 'receiver/crowbar_rest_api_connector'
|
|
8
|
+
require 'common/cloudbox_exceptions'
|
|
9
|
+
|
|
10
|
+
module Receiver
|
|
11
|
+
# Class listing all the available methods to interact with Crowbar
|
|
12
|
+
class CrowbarReceiver < BasicReceiver
|
|
13
|
+
|
|
14
|
+
public
|
|
15
|
+
def initialize(logger = nil)
|
|
16
|
+
super(logger)
|
|
17
|
+
@logger.info("Receiver::CrowbarReceiver initialize the parameters...")
|
|
18
|
+
@shell_connector = Receiver::CrowbarShellAPI.new(logger)
|
|
19
|
+
@rest_connector = Receiver::CrowbarRestAPIConnector.new(logger) # @TODO gestion des confs
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
# Check the configuration of the cluster
|
|
24
|
+
# @param cluster_name The vcluser name to allocate
|
|
25
|
+
# @param barclamps_path The path of the barclamps
|
|
26
|
+
# @param list_nodes The list of nodes to allocate if the list is specified in options of the command
|
|
27
|
+
# @return true If the configuration is corrects
|
|
28
|
+
# @return false If the configuration is not corrects
|
|
29
|
+
# @author mbretaud
|
|
30
|
+
def check_configuration_cluster_allocate(cluster_name, barclamps_path, all_nodes, list_nodes = nil)
|
|
31
|
+
@logger.info("Exec::ClusterCreate Check the configuration for the vcluster '#{cluster_name}'...")
|
|
32
|
+
|
|
33
|
+
proposal_name = "default"
|
|
34
|
+
|
|
35
|
+
if list_nodes.nil?
|
|
36
|
+
raise Common::CheckConfigurationClusterAllocateError.new("The list of nodes to allocate is not exists.")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
cmd = Command::ClusterInfo.new(cluster_name, proposal_name)
|
|
40
|
+
p = cmd.exec()
|
|
41
|
+
|
|
42
|
+
if p.nil?
|
|
43
|
+
raise Common::CheckConfigurationClusterAllocateError.new("The cluster '#{cluster_name}' don't exists!")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
cmd = Command::CrowbarNodeList.new(@logger, "Ready")
|
|
47
|
+
list1 = cmd.exec()
|
|
48
|
+
|
|
49
|
+
list_node_ready = Array.new
|
|
50
|
+
list1.each do |node|
|
|
51
|
+
list_node_ready << node.split(" ").at(0).strip.to_s
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
cmd = Command::CrowbarNodeList.new(@logger, "Applying")
|
|
55
|
+
list2 = cmd.exec()
|
|
56
|
+
|
|
57
|
+
list_node_applying = Array.new
|
|
58
|
+
list2.each do |node|
|
|
59
|
+
list_node_applying << node.split(" ").at(0).strip.to_s
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if list_node_applying.length > 0
|
|
63
|
+
raise Common::CheckConfigurationClusterAllocateError.new("Some machines are Applying.")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
available_machines = Array.new
|
|
67
|
+
list_node_ready.each { |node|
|
|
68
|
+
available_machines << node
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
vcluster_exists = false
|
|
72
|
+
list = Dir["#{barclamps_path}/cb*"]
|
|
73
|
+
list.each { |dir|
|
|
74
|
+
if File::directory?(dir)
|
|
75
|
+
barclamp = File.basename(dir)
|
|
76
|
+
vc_name = barclamp[2..-1]
|
|
77
|
+
|
|
78
|
+
if vc_name == cluster_name
|
|
79
|
+
vcluster_exists = true
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if !vcluster_exists
|
|
85
|
+
raise Common::CheckConfigurationClusterAllocateError.new("The vcluster '#{cluster_name}' don't exists.")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if !available_machines.empty?
|
|
89
|
+
# if all machine have to affected, get machines list by calling crowbar cmd
|
|
90
|
+
if all_nodes && list_nodes != nil
|
|
91
|
+
unknown_machines = Array.new
|
|
92
|
+
list_nodes.each { |node|
|
|
93
|
+
found = false
|
|
94
|
+
available_machines.each { |node_available|
|
|
95
|
+
if node == node_available
|
|
96
|
+
found = true
|
|
97
|
+
break 1
|
|
98
|
+
end
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if !found
|
|
102
|
+
unknown_machines << node
|
|
103
|
+
end
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if !unknown_machines.empty?
|
|
107
|
+
raise Common::CheckConfigurationClusterAllocateError.new("Unknown machine(s) have been setted: #{unknown_machines}.")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
else
|
|
111
|
+
raise Common::CheckConfigurationClusterAllocateError.new("No machines are Ready.")
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
return "Check the configuration for the vcluster '#{cluster_name}'... [ OK ]\n"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
private
|
|
118
|
+
# Check if the vlan id is already used or not. If the id is already used, create a new vlan id.
|
|
119
|
+
# @param vlan_id The id of the vlan
|
|
120
|
+
# @param cluster_name The name of the cluster
|
|
121
|
+
# @param proposal_name The name of the proposal
|
|
122
|
+
# @return vlan_id The id of the vlan
|
|
123
|
+
# @raise [ArgumentError] if the name of the cluster is already used
|
|
124
|
+
# @author mbretaud
|
|
125
|
+
def check_vlan_id(vlan_id, cluster_name, barclamps_path, proposal_name)
|
|
126
|
+
@logger.info("Exec::ClusterCreate Check if the vlan id '#{vlan_id}' is already used or not. If the id is already used, create a new vlan id...")
|
|
127
|
+
|
|
128
|
+
vlan_ids = Array.new
|
|
129
|
+
vlan_ids << "1" # id 1 have not to be used
|
|
130
|
+
|
|
131
|
+
list = Dir["#{barclamps_path}/cb*"]
|
|
132
|
+
list.each { |dir|
|
|
133
|
+
if File::directory?(dir)
|
|
134
|
+
barclamp = File.basename(dir)
|
|
135
|
+
vc_name = barclamp[2..-1]
|
|
136
|
+
|
|
137
|
+
if vc_name == cluster_name
|
|
138
|
+
raise Common::CheckVlanIdError.new("The vcluster '#{cluster_name}' is already in use by another virtual cluster.")
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
begin
|
|
142
|
+
cmd = Command::ClusterInfo.new(vc_name, proposal_name)
|
|
143
|
+
p = cmd.exec()
|
|
144
|
+
|
|
145
|
+
if p['deployment'][barclamp] != nil
|
|
146
|
+
if p['attributes'][barclamp]['network']['idvlan'] != nil
|
|
147
|
+
bc_vlan_id = p['attributes'][barclamp]['network']['idvlan'].strip.to_s
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
rescue
|
|
151
|
+
raise Common::CheckVlanIdError.new("An error occured while trying to get idvlan into all vclusters.
|
|
152
|
+
The proposal 'default' probably doesn't exist in a barclamp of one vcluster...
|
|
153
|
+
or the vcluster no longer exists.")
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
vlan_ids << "#{bc_vlan_id}"
|
|
157
|
+
end
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if vlan_id.nil? || vlan_id == ""
|
|
161
|
+
### Determining vlan id... ###
|
|
162
|
+
new_vlan_id = ""
|
|
163
|
+
|
|
164
|
+
(10..4094).to_a.each { |id|
|
|
165
|
+
used = false
|
|
166
|
+
|
|
167
|
+
vlan_ids.each { |already_used|
|
|
168
|
+
if id.to_s == already_used
|
|
169
|
+
used = true
|
|
170
|
+
break
|
|
171
|
+
end
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
unless used
|
|
175
|
+
new_vlan_id = id
|
|
176
|
+
break
|
|
177
|
+
end
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if new_vlan_id == ""
|
|
181
|
+
raise Common::CheckVlanIdError.new("An error occured while trying to get network address into all vclusters.
|
|
182
|
+
The proposal 'default' probably doesn't exist in a barclamp of one vcluster...
|
|
183
|
+
or the vcluster no longer exists.")
|
|
184
|
+
else
|
|
185
|
+
vlan_id = new_vlan_id
|
|
186
|
+
end
|
|
187
|
+
else
|
|
188
|
+
used = false
|
|
189
|
+
|
|
190
|
+
vlan_ids.each { |already_used|
|
|
191
|
+
if vlan_id == already_used
|
|
192
|
+
used = true
|
|
193
|
+
break
|
|
194
|
+
end
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if used
|
|
198
|
+
raise Common::CheckVlanIdError.new("The vlan id '#{vlan_id}' is already used.")
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
return vlan_id
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
private
|
|
206
|
+
# Check if the name of the cluster is already used or not
|
|
207
|
+
# @param cluster_name The name of the cluster
|
|
208
|
+
# @param barclamps_path The path of the barclamp
|
|
209
|
+
# @return [Boolean] true if the name of the cluster is not used
|
|
210
|
+
# @raise [ArgumentError] if the name of the cluster is already used
|
|
211
|
+
# @author mbretaud
|
|
212
|
+
def check_cluster_name(cluster_name, barclamps_path)
|
|
213
|
+
@logger.info("Exec::ClusterCreate Check if the name of the cluster '#{cluster_name}' is already used or not...")
|
|
214
|
+
|
|
215
|
+
list = Dir["#{barclamps_path}/cb*"]
|
|
216
|
+
list.each { |dir|
|
|
217
|
+
if File::directory?(dir)
|
|
218
|
+
barclamp = File.basename(dir)
|
|
219
|
+
vc_name = barclamp[2..-1]
|
|
220
|
+
|
|
221
|
+
if vc_name == cluster_name
|
|
222
|
+
raise Common::CheckClusterNameError.new("The vcluster '#{cluster_name}' is already in use by another virtual cluster.")
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return true
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
private
|
|
231
|
+
# Check if the network address is already used or not
|
|
232
|
+
# @param network_address The address of the network
|
|
233
|
+
# @param barclamps_path The path of the barclamp
|
|
234
|
+
# @param proposal_name The name of the proposal
|
|
235
|
+
# @return true if the network address is not used
|
|
236
|
+
# @raise [ArgumentError] if an error occurred while trying to get network address into all vclusters
|
|
237
|
+
# @raise [ArgumentError] if the the network address is already in use by another virtual cluster.
|
|
238
|
+
# @author mbretaud
|
|
239
|
+
def check_network_address(network_address, barclamps_path, proposal_name)
|
|
240
|
+
@logger.info("Exec::ClusterCreate Check if the network address '#{network_address}' is already used or not...")
|
|
241
|
+
|
|
242
|
+
list = Dir["#{barclamps_path}/cb*"]
|
|
243
|
+
list.each { |dir|
|
|
244
|
+
if File::directory?(dir)
|
|
245
|
+
barclamp = File.basename(dir)
|
|
246
|
+
vc_name = barclamp[2..-1]
|
|
247
|
+
|
|
248
|
+
begin
|
|
249
|
+
cmd = Command::ClusterInfo.new(vc_name, proposal_name)
|
|
250
|
+
p = cmd.exec()
|
|
251
|
+
|
|
252
|
+
if p['deployment'][barclamp] != nil
|
|
253
|
+
if p['attributes'][barclamp]['network']['address'] != nil
|
|
254
|
+
bc_network = p['attributes'][barclamp]['network']['address'].strip.to_s
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
rescue
|
|
258
|
+
raise Common::CheckNetworkAddressError.new("An error occurred while trying to get network address into all vclusters.
|
|
259
|
+
The proposal 'default' probably doesn't exist in a barclamp of one vcluster...
|
|
260
|
+
or the vcluster no longer exists.")
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
if network_address == bc_network
|
|
264
|
+
raise Common::CheckNetworkAddressError.new("The network '#{network_address}' is already in use by another virtual cluster.")
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return true
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
public
|
|
273
|
+
# Allocate nodes on a vcluster
|
|
274
|
+
# @param cluster_name The name of the vcluster
|
|
275
|
+
# @param list_node A list of nodes
|
|
276
|
+
# @return barclamps_path The name of the barclamp
|
|
277
|
+
# @raise
|
|
278
|
+
# @author
|
|
279
|
+
def crowbar_allocate_cluster(cluster_name, all_nodes, list_node = nil)
|
|
280
|
+
@logger.info("Receiver::CrowbarReceiver Allocate nodes on the vcluster '#{cluster_name}'...")
|
|
281
|
+
|
|
282
|
+
output = ""
|
|
283
|
+
barclamps_path = "/opt/dell/barclamps"
|
|
284
|
+
barclamp_name = "cb#{cluster_name}"
|
|
285
|
+
|
|
286
|
+
output += check_configuration_cluster_allocate(cluster_name, barclamps_path, all_nodes, list_node)
|
|
287
|
+
output += verify_committed_barclamps("vcluster_core", list_node)
|
|
288
|
+
output += verify_committed_barclamps(barclamp_name, list_node)
|
|
289
|
+
|
|
290
|
+
return output
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
public
|
|
294
|
+
# Create a vcluster
|
|
295
|
+
# @param cluster_name The name of the vcluster
|
|
296
|
+
# @param network_address The network address
|
|
297
|
+
# @param mask The mask address
|
|
298
|
+
# @param vlan_id The id of the vlan
|
|
299
|
+
# @param cpu_weight The cpu weight
|
|
300
|
+
# @param ram The ram capacity
|
|
301
|
+
# @param description The description of the barclamp, it role
|
|
302
|
+
# @raise [ArgumentError] if the name of the cluster and/or the address of network are not correct.
|
|
303
|
+
# @author mbretaud
|
|
304
|
+
def crowbar_create_cluster(cluster_name, network_address, mask, cpu_weight, ram, vlan_id, description)
|
|
305
|
+
@logger.info("Receiver::CrowbarReceiver Create the vcluster '#{cluster_name}'...")
|
|
306
|
+
|
|
307
|
+
output = ""
|
|
308
|
+
barclamps_path = "/opt/dell/barclamps"
|
|
309
|
+
proposal_name = "default"
|
|
310
|
+
|
|
311
|
+
if is_ambari_proposal_exists("default")
|
|
312
|
+
if check_cluster_name(cluster_name, proposal_name)
|
|
313
|
+
vlan_id = check_vlan_id(vlan_id, cluster_name, barclamps_path, proposal_name)
|
|
314
|
+
|
|
315
|
+
if check_network_address(network_address, barclamps_path, proposal_name)
|
|
316
|
+
output += @shell_connector.copy_barclamp("/opt/dell/barclamps/vcluster", "/opt/dell/barclamps/cb#{cluster_name}", cluster_name, network_address, mask, vlan_id, cpu_weight, ram, description, "")
|
|
317
|
+
output += @shell_connector.reload_service("cb#{cluster_name}")
|
|
318
|
+
output += crowbar_create_proposal(cluster_name)
|
|
319
|
+
crowbar_remove_node_proposal(cluster_name)
|
|
320
|
+
else
|
|
321
|
+
raise ArgumentError.new("The name of the cluster '#{cluster_name}' and/or the address of network '#{network_address}' are not correct.")
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
return output
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
public
|
|
330
|
+
# Check if the ambari proposal exists or not
|
|
331
|
+
# @return [Boolean] if true the ambari proposal exists.
|
|
332
|
+
# @raise
|
|
333
|
+
# @author mbretaud
|
|
334
|
+
def is_ambari_proposal_exists(proposal)
|
|
335
|
+
p = crowbar_get_barclamps_list()
|
|
336
|
+
|
|
337
|
+
proposal_exists = false
|
|
338
|
+
if p['i18n'] != nil
|
|
339
|
+
get_keys = p['i18n'].keys
|
|
340
|
+
get_keys.each{|e|
|
|
341
|
+
if e.include? "ambari_"
|
|
342
|
+
proposal_exists = true
|
|
343
|
+
end
|
|
344
|
+
}
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
if !proposal_exists
|
|
348
|
+
raise Common::VerifyBarclampError.new("The proposal '#{proposal}' is not created on the barclamp 'Ambari'.")
|
|
349
|
+
else
|
|
350
|
+
return true
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
public
|
|
355
|
+
# Get a list of barclamps
|
|
356
|
+
# @return [JSON] list The list of barclamps
|
|
357
|
+
# @author mbretaud
|
|
358
|
+
def crowbar_get_barclamps_list()
|
|
359
|
+
@logger.info("Receiver::CrowbarReceiver Get the list of barclamps...")
|
|
360
|
+
return @rest_connector.get_barclamps_list()
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
public
|
|
364
|
+
# create proposal for a barclamp
|
|
365
|
+
# @param cluster_name The name of barclamp
|
|
366
|
+
# @return boolean true is successful and false if error
|
|
367
|
+
# @author mbretaud
|
|
368
|
+
def crowbar_create_proposal(cluster_name)
|
|
369
|
+
@logger.info("Receiver::CrowbarReceiver Create proposal for the barclamp cb#{cluster_name}...")
|
|
370
|
+
barclamp_name = "cb#{cluster_name}"
|
|
371
|
+
return @shell_connector.create_proposal(barclamp_name)
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
public
|
|
375
|
+
# Set the configuration of proposal .
|
|
376
|
+
# @param cluster_name the name of cluster
|
|
377
|
+
# @param network_adress is network adress
|
|
378
|
+
# @param mask is the cidr of network adress
|
|
379
|
+
# @param idvlan the value of VLANID
|
|
380
|
+
# @param cpu_weight is the weight of cpu
|
|
381
|
+
# @param ram is the weight of ram memory
|
|
382
|
+
# @param description is description of cluster
|
|
383
|
+
# @return Boolean true is successful and false if error
|
|
384
|
+
# @author mbretaud
|
|
385
|
+
def crowbar_configure_proposal(cluster_name, network_adress, mask, cpu_weight, ram, idvlan, description)
|
|
386
|
+
@logger.info("Receiver::CrowbarReceiver Configure the proposal for the cluster '#{cluster_name}'...")
|
|
387
|
+
return @rest_connector.configure_proposal(cluster_name, network_adress, mask, idvlan, cpu_weight, ram, description)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
public
|
|
391
|
+
# remove node of the crowbar admin
|
|
392
|
+
# @param node_name the name of node
|
|
393
|
+
# @author mbretaud
|
|
394
|
+
# @return Boolean true is successful and false if error
|
|
395
|
+
# @author mbretaud
|
|
396
|
+
def crowbar_node_delete(node_name)
|
|
397
|
+
@logger.info("Receiver::CrowbarReceiver Remove node '#{node_name}' of the crowbar admin...")
|
|
398
|
+
return @shell_connector.node_delete(node_name)
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
public
|
|
402
|
+
# Delete node in the proposal
|
|
403
|
+
# @param node_name the name of node
|
|
404
|
+
# @return Boolean true is successful and false if error
|
|
405
|
+
# @author mbretaud
|
|
406
|
+
def crowbar_node_delete_proposal(node_name)
|
|
407
|
+
@logger.info("Receiver::CrowbarReceiver Delete the node '#{node_name}' in all proposals...")
|
|
408
|
+
return @rest_connector.delete_node_proposal(node_name)
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
public
|
|
412
|
+
# display a information of node
|
|
413
|
+
# @param node_name the name of node
|
|
414
|
+
# @return Boolean true is successful and false if error
|
|
415
|
+
# @author mbretaud
|
|
416
|
+
def crowbar_node_info(node_name)
|
|
417
|
+
@logger.info("Receiver::CrowbarReceiver Display informations about the node '#{node_name}'...")
|
|
418
|
+
return @shell_connector.node_info(node_name)
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
public
|
|
422
|
+
# Install a node with crowbar
|
|
423
|
+
# @param node_name the name of node
|
|
424
|
+
# @return Boolean true is successful and false if error
|
|
425
|
+
# @author mbretaud
|
|
426
|
+
def crowbar_node_install(node_name)
|
|
427
|
+
@logger.info("Receiver::CrowbarReceiver Install the node '#{node_name}' with crowbar...")
|
|
428
|
+
return @shell_connector.node_install(node_name)
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
public
|
|
432
|
+
# display a list of node accord to a status
|
|
433
|
+
# @param status the status of node
|
|
434
|
+
# #return List the list of node
|
|
435
|
+
# @author mbretaud
|
|
436
|
+
def crowbar_node_list_nodes(status = nil)
|
|
437
|
+
@logger.info("Receiver::CrowbarReceiver Call the connector with the function 'node_list_nodes(#{status})'")
|
|
438
|
+
return @shell_connector.node_list_nodes(status)
|
|
439
|
+
end
|
|
440
|
+
# Remove node in proposal's barclamp
|
|
441
|
+
# @param cluster_name the name of barclamp
|
|
442
|
+
# @return boolean true is successful and false if error
|
|
443
|
+
# @author mbretaud
|
|
444
|
+
def crowbar_remove_node_proposal(cluster_name)
|
|
445
|
+
@logger.info("Receiver::CrowbarReceiver Remove node in the proposal of the barclamp 'cb#{cluster_name}'...")
|
|
446
|
+
@rest_connector.remove_nodes(cluster_name)
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
public
|
|
450
|
+
# Reinstall a node with crowbar
|
|
451
|
+
# @param node_name the name of node
|
|
452
|
+
# @return Boolean true is successful and false if error
|
|
453
|
+
# @author mbretaud
|
|
454
|
+
def crowbar_node_reinstall(node_name)
|
|
455
|
+
@logger.info("Receiver::CrowbarReceiver Reinstall the node '#{node_name}' with crowbar...")
|
|
456
|
+
return @shell_connector.node_reinstall(node_name)
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
public
|
|
460
|
+
# Erase all data into all hard disks on the node and unmount partitions of /dev.
|
|
461
|
+
# @param node_name The name of the node
|
|
462
|
+
# @return out The output displays
|
|
463
|
+
# @author mbretaud
|
|
464
|
+
def crowbar_erase_node_hard_disk(node_name)
|
|
465
|
+
@logger.info("Receiver::CrowbarReceiver Erase all data into all hard disks on the node '#{node_name}' and unmount partitions of /dev...")
|
|
466
|
+
return @shell_connector.erase_node_hard_disk(node_name)
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
public
|
|
470
|
+
# Erase a node in the server Crowbar
|
|
471
|
+
# @param node_name The name of the node
|
|
472
|
+
# @author mbretaud
|
|
473
|
+
def crowbar_erase_node_server(node_name)
|
|
474
|
+
@logger.info("Receiver::CrowbarReceiver Erase the node '#{node_name}' in the server Crowbar")
|
|
475
|
+
return @shell_connector.erase_node_server(node_name)
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
public
|
|
479
|
+
# reboot node with crowbar shell
|
|
480
|
+
# @param node_name the name of node
|
|
481
|
+
# @return Output of crowbar command
|
|
482
|
+
# @author mbretaud
|
|
483
|
+
def crowbar_reboot_node(node_name)
|
|
484
|
+
@logger.info("Receiver::CrowbarReceiver Reboot the node '#{node_name}' with crowbar command...")
|
|
485
|
+
return @shell_connector.reboot_node(node_name)
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
public
|
|
489
|
+
# Verify a barclamp is commited with a good node
|
|
490
|
+
# @param barclamp_name the name of barclamp
|
|
491
|
+
# @param list_node the list of node
|
|
492
|
+
# @return true is successful and false if error
|
|
493
|
+
# @author mbretaud
|
|
494
|
+
def verify_committed_barclamps(barclamp_name,list_node)
|
|
495
|
+
@logger.info("Receiver::CrowbarReceiver Verify barclamp '#{barclamp_name}' is commited with a good node...")
|
|
496
|
+
return @rest_connector.verify_committed_barclamp(barclamp_name,list_node)
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
public
|
|
500
|
+
# Set the list of nodes to the proposal.
|
|
501
|
+
# @param cluster_name name the name of cluster
|
|
502
|
+
# @param liste_nodes the List of node
|
|
503
|
+
# @return Boolean true is successful and false if error
|
|
504
|
+
# @author mbretaud
|
|
505
|
+
def set_cluster_machine(cluster_name , liste_nodes)
|
|
506
|
+
@logger.info("Receiver::CrowbarReceiver Set the list of nodes to the proposal...")
|
|
507
|
+
barclamp_name = "cb#{cluster_name}"
|
|
508
|
+
return @shell_connector.set_cluster_machine(cluster_name, barclamp_name, liste_nodes)
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
public
|
|
512
|
+
# set bios name of node
|
|
513
|
+
# @param node_name the name of node
|
|
514
|
+
# @param bios_name the name of bios
|
|
515
|
+
# @return true is successful and false if error
|
|
516
|
+
# @author mbretaud
|
|
517
|
+
def crowbar_set_bios(node_name, bios_name)
|
|
518
|
+
@logger.info("Receiver::CrowbarReceiver Set bios name of node '#{node_name}'...")
|
|
519
|
+
return @rest_connector.set_bios(node_name, bios_name)
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
public
|
|
523
|
+
# set raid of node JbodOnly or Raid10
|
|
524
|
+
# @param node_name the name of node
|
|
525
|
+
# @param raid_name the name of raid JbodOnly or Raid10
|
|
526
|
+
# @return true is successful and false if error
|
|
527
|
+
# @author mbretaud
|
|
528
|
+
def crowbar_set_raid(node_name, raid_name)
|
|
529
|
+
@logger.info("Receiver::CrowbarReceiver Set raid of node '#{node_name}' JbodOnly or Raid10...")
|
|
530
|
+
return @rest_connector.set_raid(node_name, raid_name)
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
public
|
|
534
|
+
# set raid JbodOnly or Raid10 and set bios on node
|
|
535
|
+
# @param node_name the name of node
|
|
536
|
+
# @param bios_name the name of bios
|
|
537
|
+
# @param raid_name type of raid JbodOnly or Raid10
|
|
538
|
+
# @return true is successful and false if error
|
|
539
|
+
# @author mbretaud
|
|
540
|
+
def crowbar_set_bios_raid(node_name, bios_name, raid_name)
|
|
541
|
+
@logger.info("Receiver::CrowbarReceiver Set raid JbodOnly or Raid10 and set bios on node '#{node_name}'...")
|
|
542
|
+
return @rest_connector.set_bios_raid(node_name, bios_name, raid_name)
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
public
|
|
546
|
+
# Delete a vcluster
|
|
547
|
+
# @param cluster_name The name of the vlcuster
|
|
548
|
+
# @author mbretaud
|
|
549
|
+
def crowbar_vcluster_delete(cluster_name)
|
|
550
|
+
@logger.info("Receiver::CrowbarReceiver Delete the vcluster '#{cluster_name}'...")
|
|
551
|
+
return @rest_connector.vcluster_delete(cluster_name)
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
public
|
|
555
|
+
# Get the informations about the vcluster
|
|
556
|
+
# @param cluster_name The name of the vlcuster
|
|
557
|
+
# @param proposal_name The name of the proposal
|
|
558
|
+
# @return The informations about the vcluster
|
|
559
|
+
# @raise Error Execute the shell command
|
|
560
|
+
# @author mbretaud
|
|
561
|
+
def crowbar_vcluster_info(cluster_name, proposal_name)
|
|
562
|
+
@logger.info("Receiver::CrowbarReceiver Get the informations about the vcluster '#{cluster_name}'...")
|
|
563
|
+
return @shell_connector.vcluster_info(cluster_name, proposal_name)
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
public
|
|
567
|
+
# Displays a list of vclusters
|
|
568
|
+
# @param cluster_name The name of the vlcuster
|
|
569
|
+
# @param proposal_name The name of the proposal
|
|
570
|
+
# @return info_vcluster The informations about the vcluster
|
|
571
|
+
# @raise Error Execute the shell command
|
|
572
|
+
# @author mbretaud
|
|
573
|
+
def crowbar_vcluster_ls(cluster_name, proposal_name)
|
|
574
|
+
@logger.info("Receiver::CrowbarReceiver Displays a list of vclusters...")
|
|
575
|
+
return @shell_connector.vcluster_ls(cluster_name, proposal_name)
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
# install a barclamp to th server crowbar
|
|
579
|
+
# @param cluster_name the name of barclamp
|
|
580
|
+
# @return the output of crowbar's command
|
|
581
|
+
# @author mbretaud
|
|
582
|
+
def reload_service(cluster_name)
|
|
583
|
+
@logger.info("Receiver::CrowbarReceiver Install the barclamp 'cb#{cluster_name}' to the server crowbar...")
|
|
584
|
+
barclamp_name="cb#{cluster_name}"
|
|
585
|
+
return @shell_connector.reload_service(barclamp_name)
|
|
586
|
+
end
|
|
587
|
+
end
|
|
588
|
+
end
|