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.
Files changed (147) hide show
  1. data/.yardopts +3 -0
  2. data/README.md +17 -0
  3. data/bin/cb-cluster-allocate +5 -0
  4. data/bin/cb-cluster-create +5 -0
  5. data/bin/cb-cluster-delete +5 -0
  6. data/bin/cb-cluster-desallocate +5 -0
  7. data/bin/cb-cluster-info +5 -0
  8. data/bin/cb-cluster-ls +5 -0
  9. data/bin/cb-node-destroy +5 -0
  10. data/bin/cb-node-detach +6 -0
  11. data/bin/cb-node-info +5 -0
  12. data/bin/cb-node-install +5 -0
  13. data/bin/cb-node-ls +5 -0
  14. data/bin/cb-service-add +5 -0
  15. data/bin/cb-service-component-add +5 -0
  16. data/bin/cb-service-component-delete +5 -0
  17. data/bin/cb-service-component-detach +5 -0
  18. data/bin/cb-service-conf-apply +5 -0
  19. data/bin/cb-service-conf-create +5 -0
  20. data/bin/cb-service-conf-get +5 -0
  21. data/bin/cb-service-conf-ls +5 -0
  22. data/bin/cb-service-follow-request +5 -0
  23. data/bin/cb-service-info +5 -0
  24. data/bin/cb-service-install +5 -0
  25. data/bin/cb-service-ls +5 -0
  26. data/bin/cb-service-start +5 -0
  27. data/bin/cb-service-stop +5 -0
  28. data/lib/command.rb +61 -0
  29. data/lib/command/ambari_add_host.rb +19 -0
  30. data/lib/command/ambari_cluster_command.rb +26 -0
  31. data/lib/command/ambari_cluster_component_command.rb +26 -0
  32. data/lib/command/ambari_cluster_component_host_command.rb +26 -0
  33. data/lib/command/ambari_cluster_create.rb +19 -0
  34. data/lib/command/ambari_cluster_host_command.rb +27 -0
  35. data/lib/command/ambari_cluster_list.rb +20 -0
  36. data/lib/command/ambari_cluster_service_command.rb +26 -0
  37. data/lib/command/ambari_cluster_service_host_command.rb +26 -0
  38. data/lib/command/ambari_command.rb +21 -0
  39. data/lib/command/ambari_create_cluster_configuration.rb +39 -0
  40. data/lib/command/ambari_get_cluster_configuration.rb +29 -0
  41. data/lib/command/ambari_host_list.rb +19 -0
  42. data/lib/command/ambari_install_cluster.rb +19 -0
  43. data/lib/command/ambari_install_component.rb +19 -0
  44. data/lib/command/ambari_install_host.rb +19 -0
  45. data/lib/command/ambari_install_host_component.rb +19 -0
  46. data/lib/command/ambari_install_host_components.rb +19 -0
  47. data/lib/command/ambari_install_service_components.rb +19 -0
  48. data/lib/command/ambari_service_add.rb +27 -0
  49. data/lib/command/ambari_service_component_add.rb +21 -0
  50. data/lib/command/ambari_service_component_delete.rb +21 -0
  51. data/lib/command/ambari_service_component_detach.rb +21 -0
  52. data/lib/command/ambari_service_component_info.rb +29 -0
  53. data/lib/command/ambari_service_conf_apply.rb +31 -0
  54. data/lib/command/ambari_service_conf_ls.rb +30 -0
  55. data/lib/command/ambari_service_delete.rb +21 -0
  56. data/lib/command/ambari_service_info.rb +20 -0
  57. data/lib/command/ambari_service_list.rb +21 -0
  58. data/lib/command/ambari_start_cluster.rb +19 -0
  59. data/lib/command/ambari_start_component.rb +19 -0
  60. data/lib/command/ambari_start_host.rb +19 -0
  61. data/lib/command/ambari_start_host_component.rb +19 -0
  62. data/lib/command/ambari_start_host_components.rb +19 -0
  63. data/lib/command/ambari_start_service_components.rb +19 -0
  64. data/lib/command/ambari_stop_cluster.rb +19 -0
  65. data/lib/command/ambari_stop_component.rb +19 -0
  66. data/lib/command/ambari_stop_host.rb +19 -0
  67. data/lib/command/ambari_stop_host_component.rb +19 -0
  68. data/lib/command/ambari_stop_host_components.rb +19 -0
  69. data/lib/command/ambari_stop_service_components.rb +19 -0
  70. data/lib/command/basic_command.rb +44 -0
  71. data/lib/command/cluster_create.rb +50 -0
  72. data/lib/command/cluster_delete.rb +30 -0
  73. data/lib/command/cluster_info.rb +30 -0
  74. data/lib/command/cluster_ls.rb +30 -0
  75. data/lib/command/crowbar_cluster_allocate.rb +42 -0
  76. data/lib/command/crowbar_command.rb +30 -0
  77. data/lib/command/crowbar_get_barclamps_list.rb +30 -0
  78. data/lib/command/crowbar_node_command.rb +21 -0
  79. data/lib/command/crowbar_node_list.rb +40 -0
  80. data/lib/command/crowbar_vcluster_command.rb +20 -0
  81. data/lib/command/filter.rb +15 -0
  82. data/lib/command/node_destroy.rb +58 -0
  83. data/lib/command/node_detach.rb +44 -0
  84. data/lib/command/node_info.rb +27 -0
  85. data/lib/command/node_install.rb +46 -0
  86. data/lib/command/node_reinstall.rb +44 -0
  87. data/lib/command/state_filter.rb +16 -0
  88. data/lib/common.rb +11 -0
  89. data/lib/common/cb-lib-node-erase-hard-disk.sh +29 -0
  90. data/lib/common/cloudbox_exceptions.rb +631 -0
  91. data/lib/common/cloudbox_logger.rb +81 -0
  92. data/lib/common/cloudbox_logger_mock.rb +43 -0
  93. data/lib/common/color.rb +267 -0
  94. data/lib/common/config_properties.rb +2027 -0
  95. data/lib/common/services_description.rb +192 -0
  96. data/lib/exec.rb +35 -0
  97. data/lib/exec/check_parameter.rb +208 -0
  98. data/lib/exec/cluster_allocate.rb +163 -0
  99. data/lib/exec/cluster_create.rb +99 -0
  100. data/lib/exec/cluster_delete.rb +38 -0
  101. data/lib/exec/cluster_desallocate.rb +37 -0
  102. data/lib/exec/cluster_info.rb +177 -0
  103. data/lib/exec/cluster_ls.rb +150 -0
  104. data/lib/exec/command_option.rb +222 -0
  105. data/lib/exec/executable_command.rb +194 -0
  106. data/lib/exec/node_destroy.rb +101 -0
  107. data/lib/exec/node_detach.rb +98 -0
  108. data/lib/exec/node_info.rb +280 -0
  109. data/lib/exec/node_install.rb +234 -0
  110. data/lib/exec/node_ls.rb +160 -0
  111. data/lib/exec/service_add.rb +224 -0
  112. data/lib/exec/service_component_add.rb +39 -0
  113. data/lib/exec/service_component_delete.rb +37 -0
  114. data/lib/exec/service_component_detach.rb +37 -0
  115. data/lib/exec/service_conf_apply.rb +57 -0
  116. data/lib/exec/service_conf_create.rb +80 -0
  117. data/lib/exec/service_conf_get.rb +165 -0
  118. data/lib/exec/service_conf_ls.rb +103 -0
  119. data/lib/exec/service_follow_request.rb +49 -0
  120. data/lib/exec/service_info.rb +346 -0
  121. data/lib/exec/service_install.rb +87 -0
  122. data/lib/exec/service_ls.rb +124 -0
  123. data/lib/exec/service_start.rb +110 -0
  124. data/lib/exec/service_stop.rb +112 -0
  125. data/lib/receiver.rb +14 -0
  126. data/lib/receiver/ambari_receiver.rb +812 -0
  127. data/lib/receiver/ambari_rest_api_connector.rb +599 -0
  128. data/lib/receiver/basic_receiver.rb +28 -0
  129. data/lib/receiver/connector.rb +28 -0
  130. data/lib/receiver/crowbar_receiver.rb +588 -0
  131. data/lib/receiver/crowbar_rest_api_connector.rb +518 -0
  132. data/lib/receiver/crowbar_shell_api.rb +643 -0
  133. data/lib/receiver/rest_api_connector.rb +275 -0
  134. data/resources/ambari-configurations/HBASE/default_hbase-site +33 -0
  135. data/resources/ambari-configurations/HDFS/default_hdfs-site +49 -0
  136. data/resources/ambari-configurations/HIVE/default_hive-site +33 -0
  137. data/resources/ambari-configurations/MAPREDUCE/default_mapred-site +72 -0
  138. data/resources/ambari-configurations/OOZIE/default_oozie-site +28 -0
  139. data/resources/ambari-configurations/WEBHCAT/default_webhcat-site +18 -0
  140. data/resources/ambari-configurations/ZOOKEEPER/default_zookeeper-site +8 -0
  141. data/resources/ambari-configurations/default_core-site +22 -0
  142. data/resources/ambari-configurations/default_global +141 -0
  143. data/resources/cloudbox-server.conf +10 -0
  144. data/spec/common/services_description.rb +130 -0
  145. data/spec/exec/check_parameter.rb +152 -0
  146. data/spec/exec/command_option_spec.rb +97 -0
  147. metadata +328 -0
@@ -0,0 +1,30 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'command/crowbar_vcluster_command'
5
+
6
+ #
7
+ # @author mbretaud
8
+ module Command
9
+ # display a list of cluster
10
+ class ClusterLs < CrowbarVclusterCommand
11
+
12
+ public
13
+ # Default constructor.
14
+ # @param vcluster_name [String] The cluster name.
15
+ # @param proposal_name [String] The proposal name.
16
+ # @author mbretaud
17
+ def initialize(vcluster_name, proposal_name)
18
+ super()
19
+ @logger.info("Command::ClusterLs initialize the parameters...")
20
+ @vcluster_name = vcluster_name
21
+ @proposal_name = proposal_name
22
+ end
23
+
24
+
25
+ # Method who return a List of cluster
26
+ def exec()
27
+ return @receiver.crowbar_vcluster_ls(@vcluster_name, @proposal_name)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ # This file is part of cloudbox-server project
2
+ # Author: mbr (INGENSI)
3
+ # Created: 22/08/13 11:42
4
+
5
+ # You are a good developer if you document this class
6
+
7
+ require 'receiver/crowbar_receiver'
8
+ require 'command/crowbar_command'
9
+ require 'command/filter'
10
+
11
+ module Command
12
+
13
+ # CrowbarCommand implementation for list Crowbar nodes.
14
+ # @author aboudot
15
+ class CrowbarClusterAllocate < CrowbarCommand
16
+
17
+ attr_reader :list_nodes
18
+ attr_reader :cluster_name
19
+
20
+ public
21
+ # Default constructor
22
+ #
23
+ def initialize(logger, cluster_name, all_nodes, list_node = nil)
24
+ super(logger)
25
+ @logger.info("Command::CrowbarClusterAllocate initialize the parameters...")
26
+ @list_node = list_node
27
+ @all_nodes = all_nodes
28
+ @cluster_name = cluster_name
29
+ end
30
+
31
+ public
32
+ # Run the command on receiver.
33
+ # @return output The output standard
34
+ def exec()
35
+ output = ""
36
+
37
+ output += @receiver.crowbar_allocate_cluster(@cluster_name, @all_nodes, @list_node)
38
+
39
+ return output
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,30 @@
1
+ # This file is part of cloudbox-server project
2
+ # Author: mbr (INGENSI)
3
+ # Created: 22/08/13 11:43
4
+
5
+ require 'command/basic_command'
6
+ require 'receiver/crowbar_receiver'
7
+
8
+ module Command
9
+
10
+ # This class implement a BasicCommand. It essentially constrain the receiver to be a CrowbarReceiver.
11
+ # @author aboudot
12
+ class CrowbarCommand < BasicCommand
13
+
14
+ # Default CrowbarCommand which take a CrowbarReceiver as default receiver
15
+ # @author aboudot
16
+ private
17
+ def initialize(logger = nil)
18
+ super(Receiver::CrowbarReceiver.new(logger), logger)
19
+ @logger.info("Command::CrowbarCommand initialize the parameters...")
20
+ end
21
+
22
+ # Run the command. It has to be implemented in subclasses.
23
+ # @raise [NotImplementedError] All time.
24
+ public
25
+ def exec()
26
+ raise NotImplementedError
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'receiver/crowbar_receiver'
5
+ require 'command/crowbar_command'
6
+
7
+ #
8
+ # @author mbretaud
9
+ module Command
10
+ # Allows to get the list of barclamps
11
+ # @author mbretaud
12
+ class CrowbarGetBarclampsList < CrowbarCommand
13
+
14
+ public
15
+ # Default constructor
16
+ #
17
+ def initialize(logger)
18
+ super(logger)
19
+ @logger.info("Command::CrowbarGetBarclampsList initialize the parameters...")
20
+ end
21
+
22
+ public
23
+ # Run the command on receiver.
24
+ # @return The list of Barclamps
25
+ def exec()
26
+ return @receiver.crowbar_get_barclamps_list()
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ # This file is part of cloudbox-server project
2
+ # Author: mbr (INGENSI)
3
+ # Created: 22/08/13 11:42
4
+
5
+ # You are a good developer if you document this class
6
+
7
+ require 'command/crowbar_command'
8
+
9
+ module Command
10
+ # A superclass who manage Node command
11
+ class CrowbarNodeCommand < CrowbarCommand
12
+
13
+ public
14
+ # Default constructor
15
+ # @author mbretaud
16
+ def initialize()
17
+ super()
18
+ @logger.info("Command::CrowbarNodeCommand initialize the parameters...")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,40 @@
1
+ # This file is part of cloudbox-server project
2
+ # Author: mbr (INGENSI)
3
+ # Created: 22/08/13 11:42
4
+
5
+ # You are a good developer if you document this class
6
+
7
+ require 'receiver/crowbar_receiver'
8
+ require 'command/crowbar_command'
9
+ require 'command/filter'
10
+
11
+ module Command
12
+
13
+ # CrowbarCommand implementation for list Crowbar nodes.
14
+ # @author aboudot
15
+ class CrowbarNodeList < CrowbarCommand
16
+
17
+ public
18
+ attr_reader :state_filter
19
+
20
+ public
21
+ # Default constructor
22
+ # @param logger [logger] The logger
23
+ # @param state [String] The state wanted
24
+ # @author mbretaud
25
+ def initialize(logger, state = nil)
26
+ super(logger)
27
+ @logger.info("Command::CrowbarNodeList initialize the parameters...")
28
+ @state_filter = state
29
+ end
30
+
31
+
32
+ public
33
+ # Run the command on receiver.
34
+ # @return The list of nodes
35
+ def exec()
36
+ @logger.info("Command::CrowbarNodeList : call the receiver with the function 'crowbar_node_list_nodes(#{@state_filter})'")
37
+ return @receiver.crowbar_node_list_nodes(@state_filter)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'command/crowbar_command'
5
+
6
+ #
7
+ # @author mbretaud
8
+ module Command
9
+ # A superclass who manage cluster command
10
+ class CrowbarVclusterCommand < CrowbarCommand
11
+
12
+ public
13
+ #
14
+ # @author mbretaud
15
+ def initialize()
16
+ super()
17
+ @logger.info("Command::CrowbarVclusterCommand initialize the parameters...")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author tmarmin (INGENSI)
3
+
4
+ # This class is the main class of filter classes.
5
+ # @abstract
6
+ class Filter
7
+
8
+ # Default protected constructor.
9
+ # @author tmarmin
10
+ protected
11
+ def initialize()
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,58 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'command/crowbar_node_command'
5
+
6
+ #
7
+ # @author mbretaud
8
+ module Command
9
+ # Allows to destroy a node
10
+ class NodeDestroy < CrowbarNodeCommand
11
+
12
+ attr_reader :node_name
13
+
14
+ public
15
+ # Default constructor
16
+ # @param node_name [String] The name of the node
17
+ # @author mbretaud
18
+ def initialize(node_name)
19
+ super()
20
+ @logger.info("Command::NodeDestroy initialize the parameters...")
21
+ @node_name = node_name
22
+ end
23
+
24
+ # Method who call crowbar receiver in order to destroy a node
25
+ # @author mbretaud
26
+ def exec()
27
+ begin
28
+ @receiver.crowbar_node_delete_proposal(@node_name)
29
+ rescue => e
30
+ puts "Error: Delete the node '#{@node_name}' in all proposals : " + e.message
31
+ end
32
+
33
+ begin
34
+ @receiver.crowbar_node_delete(@node_name)
35
+ rescue => e
36
+ puts "Error: Delete the node '#{@node_name}' of Crowbar : " + e.message
37
+ end
38
+
39
+ begin
40
+ @receiver.crowbar_erase_node_hard_disk(node_name)
41
+ rescue => e
42
+ puts "Error: Erase the hard disk into the node '#{@node_name}' : " + e.message
43
+ end
44
+
45
+ begin
46
+ @receiver.crowbar_erase_node_server(@node_name)
47
+ rescue => e
48
+ puts "Error: Erase the node '#{@node_name}' in the server Crowbar : " + e.message
49
+ end
50
+
51
+ begin
52
+ @receiver.crowbar_reboot_node(node_name)
53
+ rescue => e
54
+ puts "Error: Reboot the node '#{@node_name}' : " + e.message
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,44 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'command/crowbar_node_command'
5
+
6
+ module Command
7
+ # Allows to detach a node
8
+ class NodeDetach < CrowbarNodeCommand
9
+
10
+ attr_reader :node_name
11
+
12
+ public
13
+ # Default constructor
14
+ # @param node_name [String] The name of the node
15
+ # @author mbretaud
16
+ def initialize(node_name)
17
+ super()
18
+ @logger.info("Command::NodeDetach initialize the parameters...")
19
+ @node_name = node_name
20
+ end
21
+
22
+ # Method who call crowbar receiver in order to detach a node
23
+ # @author mbretaud
24
+ def exec()
25
+ begin
26
+ @receiver.crowbar_node_delete_proposal(@node_name)
27
+ rescue => e
28
+ puts "Error: Delete the node '#{@node_name}' in all proposals : " + e.message
29
+ end
30
+
31
+ begin
32
+ @receiver.crowbar_node_delete(@node_name)
33
+ rescue => e
34
+ puts "Error: Delete the node '#{@node_name}' of Crowbar : " + e.message
35
+ end
36
+
37
+ begin
38
+ @receiver.crowbar_erase_node_server(@node_name)
39
+ rescue => e
40
+ puts "Error: Erase the node '#{@node_name}' in the server Crowbar : " + e.message
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,27 @@
1
+ # This file is part of cloudbox-server project
2
+ # Author: mbr (INGENSI)
3
+ # Created: 22/08/13 11:03
4
+
5
+ # You are a good developer if you document this class
6
+
7
+ require 'command/crowbar_node_command'
8
+
9
+ module Command
10
+ # Allows to display a information 's node
11
+ class NodeInfo < CrowbarNodeCommand
12
+
13
+ attr_reader :nodeName
14
+
15
+ def initialize(nodeName)
16
+ super()
17
+ @logger.info("Command::NodeInfo initialize the parameters...")
18
+ @nodeName = nodeName
19
+ end
20
+
21
+ def exec()
22
+ return @receiver.crowbar_node_info(@nodeName)
23
+ end
24
+
25
+
26
+ end
27
+ end
@@ -0,0 +1,46 @@
1
+ # This file is part of cloudbox-server project
2
+ # Author: mbr (INGENSI)
3
+
4
+ require 'command/crowbar_node_command'
5
+
6
+ module Command
7
+ # Allows to install node
8
+ class NodeInstall < CrowbarNodeCommand
9
+
10
+ attr_reader :node_name
11
+ attr_reader :bios_name
12
+ attr_reader :raid_name
13
+
14
+ public
15
+ # Default constructor
16
+ # @param node_name [String] The name of the node
17
+ # @param bios_name [String] The name of the bios
18
+ # @param raid_name [String] The name of the raid
19
+ # @author mbretaud
20
+ def initialize(node_name, bios_name = nil, raid_name = nil)
21
+ super()
22
+ @logger.info("Command::NodeInstall initialize the parameters...")
23
+ @node_name = node_name
24
+ @bios_name = bios_name
25
+ @raid_name = raid_name
26
+ end
27
+
28
+ # Method to call crowbar receiver for install a node
29
+ # @author mbretaud
30
+ def exec()
31
+ if @raid_name.nil?
32
+ @raid_name = "JBODOnly"
33
+ end
34
+
35
+ if !@bios_name.nil? && !@raid_name.nil?
36
+ @receiver.crowbar_set_bios_raid(@node_name, @bios_name, @raid_name)
37
+ end
38
+
39
+ if @bios_name.nil? && !@raid_name.nil?
40
+ @receiver.crowbar_set_raid(@node_name, @raid_name)
41
+ end
42
+
43
+ @receiver.crowbar_node_install(@node_name)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,44 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'command/crowbar_node_command'
5
+
6
+ module Command
7
+ # Allows to reinstall a node
8
+ class NodeReinstall < CrowbarNodeCommand
9
+
10
+ attr_reader :node_name
11
+ attr_reader :bios_name
12
+ attr_reader :raid_name
13
+
14
+ public
15
+ # Default constructor
16
+ # @param node_name [String] The name of the node
17
+ # @param bios_name [String] The name of the bios
18
+ # @param raid_name [String] The name of the raid
19
+ # @author mbretaud
20
+ def initialize(node_name, bios_name = nil, raid_name = nil)
21
+ super()
22
+ @logger.info("Command::NodeReinstall initialize the parameters...")
23
+ @node_name = node_name
24
+ @bios_name = bios_name
25
+ @raid_name = raid_name
26
+ end
27
+
28
+ # Method to call crowbar receiver for reinstall a node
29
+ # @author mbretaud
30
+ def exec()
31
+ if @raid_name.nil?
32
+ @receiver.crowbar_set_raid(@node_name, "JBODOnly")
33
+ else
34
+ @receiver.crowbar_set_raid(@node_name, @raid_name)
35
+ end
36
+
37
+ if !@bios_name.nil?
38
+ @receiver.crowbar_set_bios(@node_name, @bios_name)
39
+ end
40
+
41
+ @receiver.crowbar_node_reinstall(@node_name)
42
+ end
43
+ end
44
+ end