Class: Receiver::CrowbarReceiver
- Inherits:
-
BasicReceiver
- Object
- BasicReceiver
- Receiver::CrowbarReceiver
- Defined in:
- lib/receiver/crowbar_receiver.rb
Overview
Class listing all the available methods to interact with Crowbar
Instance Method Summary collapse
-
#check_cluster_name(cluster_name, barclamps_path) ⇒ Boolean
private
Check if the name of the cluster is already used or not.
-
#check_configuration_cluster_allocate(cluster_name, barclamps_path, all_nodes, list_nodes = nil) ⇒ Object
private
Check the configuration of the cluster.
-
#check_network_address(network_address, barclamps_path, proposal_name) ⇒ Object
private
Check if the network address is already used or not.
-
#check_vlan_id(vlan_id, cluster_name, barclamps_path, proposal_name) ⇒ Object
private
Check if the vlan id is already used or not.
-
#crowbar_allocate_cluster(cluster_name, all_nodes, list_node = nil) ⇒ Object
Allocate nodes on a vcluster.
-
#crowbar_configure_proposal(cluster_name, network_adress, mask, cpu_weight, ram, idvlan, description) ⇒ Object
Set the configuration of proposal .
-
#crowbar_create_cluster(cluster_name, network_address, mask, cpu_weight, ram, vlan_id, description) ⇒ Object
Create a vcluster.
-
#crowbar_create_proposal(cluster_name) ⇒ Object
create proposal for a barclamp.
-
#crowbar_erase_node_hard_disk(node_name) ⇒ Object
Erase all data into all hard disks on the node and unmount partitions of /dev.
-
#crowbar_erase_node_server(node_name) ⇒ Object
Erase a node in the server Crowbar.
-
#crowbar_get_barclamps_list ⇒ JSON
Get a list of barclamps.
-
#crowbar_node_delete(node_name) ⇒ Object
remove node of the crowbar admin.
-
#crowbar_node_delete_proposal(node_name) ⇒ Object
Delete node in the proposal.
-
#crowbar_node_info(node_name) ⇒ Object
display a information of node.
-
#crowbar_node_install(node_name) ⇒ Object
Install a node with crowbar.
-
#crowbar_node_list_nodes(status = nil) ⇒ Object
display a list of node accord to a status #return List the list of node.
-
#crowbar_node_reinstall(node_name) ⇒ Object
Reinstall a node with crowbar.
-
#crowbar_reboot_node(node_name) ⇒ Object
reboot node with crowbar shell.
-
#crowbar_remove_node_proposal(cluster_name) ⇒ Object
Remove node in proposal’s barclamp.
-
#crowbar_set_bios(node_name, bios_name) ⇒ Object
set bios name of node.
-
#crowbar_set_bios_raid(node_name, bios_name, raid_name) ⇒ Object
set raid JbodOnly or Raid10 and set bios on node.
-
#crowbar_set_raid(node_name, raid_name) ⇒ Object
set raid of node JbodOnly or Raid10.
-
#crowbar_vcluster_delete(cluster_name) ⇒ Object
Delete a vcluster.
-
#crowbar_vcluster_info(cluster_name, proposal_name) ⇒ Object
Get the informations about the vcluster.
-
#crowbar_vcluster_ls(cluster_name, proposal_name) ⇒ Object
Displays a list of vclusters.
-
#initialize(logger = nil) ⇒ CrowbarReceiver
constructor
A new instance of CrowbarReceiver.
-
#is_ambari_proposal_exists(proposal) ⇒ Boolean
Check if the ambari proposal exists or not.
-
#reload_service(cluster_name) ⇒ Object
install a barclamp to th server crowbar.
-
#set_cluster_machine(cluster_name, liste_nodes) ⇒ Object
Set the list of nodes to the proposal.
-
#verify_committed_barclamps(barclamp_name, list_node) ⇒ Object
Verify a barclamp is commited with a good node.
Constructor Details
#initialize(logger = nil) ⇒ CrowbarReceiver
Returns a new instance of CrowbarReceiver.
15 16 17 18 19 20 |
# File 'lib/receiver/crowbar_receiver.rb', line 15 def initialize(logger = nil) super(logger) @logger.info("Receiver::CrowbarReceiver initialize the parameters...") @shell_connector = Receiver::CrowbarShellAPI.new(logger) @rest_connector = Receiver::CrowbarRestAPIConnector.new(logger) # @TODO gestion des confs end |
Instance Method Details
#check_cluster_name(cluster_name, barclamps_path) ⇒ Boolean (private)
Check if the name of the cluster is already used or not
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/receiver/crowbar_receiver.rb', line 212 def check_cluster_name(cluster_name, ) @logger.info("Exec::ClusterCreate Check if the name of the cluster '#{cluster_name}' is already used or not...") list = Dir["#{}/cb*"] list.each { |dir| if File::directory?(dir) = File.basename(dir) vc_name = [2..-1] if vc_name == cluster_name raise Common::CheckClusterNameError.new("The vcluster '#{cluster_name}' is already in use by another virtual cluster.") end end } return true end |
#check_configuration_cluster_allocate(cluster_name, barclamps_path, all_nodes, list_nodes = nil) ⇒ Object (private)
Check the configuration of the cluster
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 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 |
# File 'lib/receiver/crowbar_receiver.rb', line 30 def check_configuration_cluster_allocate(cluster_name, , all_nodes, list_nodes = nil) @logger.info("Exec::ClusterCreate Check the configuration for the vcluster '#{cluster_name}'...") proposal_name = "default" if list_nodes.nil? raise Common::CheckConfigurationClusterAllocateError.new("The list of nodes to allocate is not exists.") end cmd = Command::ClusterInfo.new(cluster_name, proposal_name) p = cmd.exec() if p.nil? raise Common::CheckConfigurationClusterAllocateError.new("The cluster '#{cluster_name}' don't exists!") end cmd = Command::CrowbarNodeList.new(@logger, "Ready") list1 = cmd.exec() list_node_ready = Array.new list1.each do |node| list_node_ready << node.split(" ").at(0).strip.to_s end cmd = Command::CrowbarNodeList.new(@logger, "Applying") list2 = cmd.exec() = Array.new list2.each do |node| << node.split(" ").at(0).strip.to_s end if .length > 0 raise Common::CheckConfigurationClusterAllocateError.new("Some machines are Applying.") end available_machines = Array.new list_node_ready.each { |node| available_machines << node } vcluster_exists = false list = Dir["#{}/cb*"] list.each { |dir| if File::directory?(dir) = File.basename(dir) vc_name = [2..-1] if vc_name == cluster_name vcluster_exists = true end end } if !vcluster_exists raise Common::CheckConfigurationClusterAllocateError.new("The vcluster '#{cluster_name}' don't exists.") end if !available_machines.empty? # if all machine have to affected, get machines list by calling crowbar cmd if all_nodes && list_nodes != nil unknown_machines = Array.new list_nodes.each { |node| found = false available_machines.each { |node_available| if node == node_available found = true break 1 end } if !found unknown_machines << node end } if !unknown_machines.empty? raise Common::CheckConfigurationClusterAllocateError.new("Unknown machine(s) have been setted: #{unknown_machines}.") end end else raise Common::CheckConfigurationClusterAllocateError.new("No machines are Ready.") end return "Check the configuration for the vcluster '#{cluster_name}'... [ OK ]\n" end |
#check_network_address(network_address, barclamps_path, proposal_name) ⇒ Object (private)
Check if the network address is already used or not
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/receiver/crowbar_receiver.rb', line 239 def check_network_address(network_address, , proposal_name) @logger.info("Exec::ClusterCreate Check if the network address '#{network_address}' is already used or not...") list = Dir["#{}/cb*"] list.each { |dir| if File::directory?(dir) = File.basename(dir) vc_name = [2..-1] begin cmd = Command::ClusterInfo.new(vc_name, proposal_name) p = cmd.exec() if p['deployment'][] != nil if p['attributes'][]['network']['address'] != nil bc_network = p['attributes'][]['network']['address'].strip.to_s end end rescue raise Common::CheckNetworkAddressError.new("An error occurred while trying to get network address into all vclusters. The proposal 'default' probably doesn't exist in a barclamp of one vcluster... or the vcluster no longer exists.") end if network_address == bc_network raise Common::CheckNetworkAddressError.new("The network '#{network_address}' is already in use by another virtual cluster.") end end } return true end |
#check_vlan_id(vlan_id, cluster_name, barclamps_path, proposal_name) ⇒ Object (private)
Check if the vlan id is already used or not. If the id is already used, create a new vlan id.
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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/receiver/crowbar_receiver.rb', line 125 def check_vlan_id(vlan_id, cluster_name, , proposal_name) @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...") vlan_ids = Array.new vlan_ids << "1" # id 1 have not to be used list = Dir["#{}/cb*"] list.each { |dir| if File::directory?(dir) = File.basename(dir) vc_name = [2..-1] if vc_name == cluster_name raise Common::CheckVlanIdError.new("The vcluster '#{cluster_name}' is already in use by another virtual cluster.") end begin cmd = Command::ClusterInfo.new(vc_name, proposal_name) p = cmd.exec() if p['deployment'][] != nil if p['attributes'][]['network']['idvlan'] != nil bc_vlan_id = p['attributes'][]['network']['idvlan'].strip.to_s end end rescue raise Common::CheckVlanIdError.new("An error occured while trying to get idvlan into all vclusters. The proposal 'default' probably doesn't exist in a barclamp of one vcluster... or the vcluster no longer exists.") end vlan_ids << "#{bc_vlan_id}" end } if vlan_id.nil? || vlan_id == "" ### Determining vlan id... ### new_vlan_id = "" (10..4094).to_a.each { |id| used = false vlan_ids.each { |already_used| if id.to_s == already_used used = true break end } unless used new_vlan_id = id break end } if new_vlan_id == "" raise Common::CheckVlanIdError.new("An error occured while trying to get network address into all vclusters. The proposal 'default' probably doesn't exist in a barclamp of one vcluster... or the vcluster no longer exists.") else vlan_id = new_vlan_id end else used = false vlan_ids.each { |already_used| if vlan_id == already_used used = true break end } if used raise Common::CheckVlanIdError.new("The vlan id '#{vlan_id}' is already used.") end end return vlan_id end |
#crowbar_allocate_cluster(cluster_name, all_nodes, list_node = nil) ⇒ Object
Allocate nodes on a vcluster
279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/receiver/crowbar_receiver.rb', line 279 def (cluster_name, all_nodes, list_node = nil) @logger.info("Receiver::CrowbarReceiver Allocate nodes on the vcluster '#{cluster_name}'...") output = "" = "/opt/dell/barclamps" = "cb#{cluster_name}" output += check_configuration_cluster_allocate(cluster_name, , all_nodes, list_node) output += ("vcluster_core", list_node) output += (, list_node) return output end |
#crowbar_configure_proposal(cluster_name, network_adress, mask, cpu_weight, ram, idvlan, description) ⇒ Object
Set the configuration of proposal .
385 386 387 388 |
# File 'lib/receiver/crowbar_receiver.rb', line 385 def (cluster_name, network_adress, mask, cpu_weight, ram, idvlan, description) @logger.info("Receiver::CrowbarReceiver Configure the proposal for the cluster '#{cluster_name}'...") return @rest_connector.configure_proposal(cluster_name, network_adress, mask, idvlan, cpu_weight, ram, description) end |
#crowbar_create_cluster(cluster_name, network_address, mask, cpu_weight, ram, vlan_id, description) ⇒ Object
Create a vcluster
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/receiver/crowbar_receiver.rb', line 304 def (cluster_name, network_address, mask, cpu_weight, ram, vlan_id, description) @logger.info("Receiver::CrowbarReceiver Create the vcluster '#{cluster_name}'...") output = "" = "/opt/dell/barclamps" proposal_name = "default" if ("default") if check_cluster_name(cluster_name, proposal_name) vlan_id = check_vlan_id(vlan_id, cluster_name, , proposal_name) if check_network_address(network_address, , proposal_name) output += @shell_connector.("/opt/dell/barclamps/vcluster", "/opt/dell/barclamps/cb#{cluster_name}", cluster_name, network_address, mask, vlan_id, cpu_weight, ram, description, "") output += @shell_connector.reload_service("cb#{cluster_name}") output += (cluster_name) (cluster_name) else raise ArgumentError.new("The name of the cluster '#{cluster_name}' and/or the address of network '#{network_address}' are not correct.") end end end return output end |
#crowbar_create_proposal(cluster_name) ⇒ Object
create proposal for a barclamp
368 369 370 371 372 |
# File 'lib/receiver/crowbar_receiver.rb', line 368 def (cluster_name) @logger.info("Receiver::CrowbarReceiver Create proposal for the barclamp cb#{cluster_name}...") = "cb#{cluster_name}" return @shell_connector.create_proposal() end |
#crowbar_erase_node_hard_disk(node_name) ⇒ Object
Erase all data into all hard disks on the node and unmount partitions of /dev.
464 465 466 467 |
# File 'lib/receiver/crowbar_receiver.rb', line 464 def (node_name) @logger.info("Receiver::CrowbarReceiver Erase all data into all hard disks on the node '#{node_name}' and unmount partitions of /dev...") return @shell_connector.erase_node_hard_disk(node_name) end |
#crowbar_erase_node_server(node_name) ⇒ Object
Erase a node in the server Crowbar
473 474 475 476 |
# File 'lib/receiver/crowbar_receiver.rb', line 473 def (node_name) @logger.info("Receiver::CrowbarReceiver Erase the node '#{node_name}' in the server Crowbar") return @shell_connector.erase_node_server(node_name) end |
#crowbar_get_barclamps_list ⇒ JSON
Get a list of barclamps
358 359 360 361 |
# File 'lib/receiver/crowbar_receiver.rb', line 358 def () @logger.info("Receiver::CrowbarReceiver Get the list of barclamps...") return @rest_connector.() end |
#crowbar_node_delete(node_name) ⇒ Object
remove node of the crowbar admin
396 397 398 399 |
# File 'lib/receiver/crowbar_receiver.rb', line 396 def (node_name) @logger.info("Receiver::CrowbarReceiver Remove node '#{node_name}' of the crowbar admin...") return @shell_connector.node_delete(node_name) end |
#crowbar_node_delete_proposal(node_name) ⇒ Object
Delete node in the proposal
406 407 408 409 |
# File 'lib/receiver/crowbar_receiver.rb', line 406 def (node_name) @logger.info("Receiver::CrowbarReceiver Delete the node '#{node_name}' in all proposals...") return @rest_connector.delete_node_proposal(node_name) end |
#crowbar_node_info(node_name) ⇒ Object
display a information of node
416 417 418 419 |
# File 'lib/receiver/crowbar_receiver.rb', line 416 def (node_name) @logger.info("Receiver::CrowbarReceiver Display informations about the node '#{node_name}'...") return @shell_connector.node_info(node_name) end |
#crowbar_node_install(node_name) ⇒ Object
Install a node with crowbar
426 427 428 429 |
# File 'lib/receiver/crowbar_receiver.rb', line 426 def (node_name) @logger.info("Receiver::CrowbarReceiver Install the node '#{node_name}' with crowbar...") return @shell_connector.node_install(node_name) end |
#crowbar_node_list_nodes(status = nil) ⇒ Object
display a list of node accord to a status #return List the list of node
436 437 438 439 |
# File 'lib/receiver/crowbar_receiver.rb', line 436 def (status = nil) @logger.info("Receiver::CrowbarReceiver Call the connector with the function 'node_list_nodes(#{status})'") return @shell_connector.node_list_nodes(status) end |
#crowbar_node_reinstall(node_name) ⇒ Object
Reinstall a node with crowbar
454 455 456 457 |
# File 'lib/receiver/crowbar_receiver.rb', line 454 def (node_name) @logger.info("Receiver::CrowbarReceiver Reinstall the node '#{node_name}' with crowbar...") return @shell_connector.node_reinstall(node_name) end |
#crowbar_reboot_node(node_name) ⇒ Object
reboot node with crowbar shell
483 484 485 486 |
# File 'lib/receiver/crowbar_receiver.rb', line 483 def (node_name) @logger.info("Receiver::CrowbarReceiver Reboot the node '#{node_name}' with crowbar command...") return @shell_connector.reboot_node(node_name) end |
#crowbar_remove_node_proposal(cluster_name) ⇒ Object
Remove node in proposal’s barclamp
444 445 446 447 |
# File 'lib/receiver/crowbar_receiver.rb', line 444 def (cluster_name) @logger.info("Receiver::CrowbarReceiver Remove node in the proposal of the barclamp 'cb#{cluster_name}'...") @rest_connector.remove_nodes(cluster_name) end |
#crowbar_set_bios(node_name, bios_name) ⇒ Object
set bios name of node
517 518 519 520 |
# File 'lib/receiver/crowbar_receiver.rb', line 517 def (node_name, bios_name) @logger.info("Receiver::CrowbarReceiver Set bios name of node '#{node_name}'...") return @rest_connector.set_bios(node_name, bios_name) end |
#crowbar_set_bios_raid(node_name, bios_name, raid_name) ⇒ Object
set raid JbodOnly or Raid10 and set bios on node
540 541 542 543 |
# File 'lib/receiver/crowbar_receiver.rb', line 540 def (node_name, bios_name, raid_name) @logger.info("Receiver::CrowbarReceiver Set raid JbodOnly or Raid10 and set bios on node '#{node_name}'...") return @rest_connector.set_bios_raid(node_name, bios_name, raid_name) end |
#crowbar_set_raid(node_name, raid_name) ⇒ Object
set raid of node JbodOnly or Raid10
528 529 530 531 |
# File 'lib/receiver/crowbar_receiver.rb', line 528 def (node_name, raid_name) @logger.info("Receiver::CrowbarReceiver Set raid of node '#{node_name}' JbodOnly or Raid10...") return @rest_connector.set_raid(node_name, raid_name) end |
#crowbar_vcluster_delete(cluster_name) ⇒ Object
Delete a vcluster
549 550 551 552 |
# File 'lib/receiver/crowbar_receiver.rb', line 549 def (cluster_name) @logger.info("Receiver::CrowbarReceiver Delete the vcluster '#{cluster_name}'...") return @rest_connector.vcluster_delete(cluster_name) end |
#crowbar_vcluster_info(cluster_name, proposal_name) ⇒ Object
Get the informations about the vcluster
561 562 563 564 |
# File 'lib/receiver/crowbar_receiver.rb', line 561 def (cluster_name, proposal_name) @logger.info("Receiver::CrowbarReceiver Get the informations about the vcluster '#{cluster_name}'...") return @shell_connector.vcluster_info(cluster_name, proposal_name) end |
#crowbar_vcluster_ls(cluster_name, proposal_name) ⇒ Object
Displays a list of vclusters
573 574 575 576 |
# File 'lib/receiver/crowbar_receiver.rb', line 573 def (cluster_name, proposal_name) @logger.info("Receiver::CrowbarReceiver Displays a list of vclusters...") return @shell_connector.vcluster_ls(cluster_name, proposal_name) end |
#is_ambari_proposal_exists(proposal) ⇒ Boolean
Check if the ambari proposal exists or not
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/receiver/crowbar_receiver.rb', line 334 def (proposal) p = () proposal_exists = false if p['i18n'] != nil get_keys = p['i18n'].keys get_keys.each{|e| if e.include? "ambari_" proposal_exists = true end } end if !proposal_exists raise Common::VerifyBarclampError.new("The proposal '#{proposal}' is not created on the barclamp 'Ambari'.") else return true end end |
#reload_service(cluster_name) ⇒ Object
install a barclamp to th server crowbar
582 583 584 585 586 |
# File 'lib/receiver/crowbar_receiver.rb', line 582 def reload_service(cluster_name) @logger.info("Receiver::CrowbarReceiver Install the barclamp 'cb#{cluster_name}' to the server crowbar...") ="cb#{cluster_name}" return @shell_connector.reload_service() end |
#set_cluster_machine(cluster_name, liste_nodes) ⇒ Object
Set the list of nodes to the proposal.
505 506 507 508 509 |
# File 'lib/receiver/crowbar_receiver.rb', line 505 def set_cluster_machine(cluster_name , liste_nodes) @logger.info("Receiver::CrowbarReceiver Set the list of nodes to the proposal...") = "cb#{cluster_name}" return @shell_connector.set_cluster_machine(cluster_name, , liste_nodes) end |
#verify_committed_barclamps(barclamp_name, list_node) ⇒ Object
Verify a barclamp is commited with a good node
494 495 496 497 |
# File 'lib/receiver/crowbar_receiver.rb', line 494 def (,list_node) @logger.info("Receiver::CrowbarReceiver Verify barclamp '#{}' is commited with a good node...") return @rest_connector.(,list_node) end |