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,160 @@
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 'command/crowbar_node_list'
7
+ require 'exec/command_option'
8
+
9
+ module Exec
10
+ # Allows the user to list the nodes along with some piece of information.
11
+ # @author mbretaud
12
+ class NodeLs < ExecutableCommand
13
+
14
+ public
15
+ # Default constructor of the class.
16
+ # @note Overrides default constructor by passing CustomCommandOption to super().
17
+ # @author mbretaud
18
+ def initialize(argv, stdin, stdout, stderr, command_name)
19
+ super(argv, stdin, stdout, stderr, command_name)
20
+ end
21
+
22
+ private
23
+ # Parse and check the parameters of the function.
24
+ # @author mbretaud
25
+ def set_options
26
+ @logger.info("Exec::NodeLs Setting options")
27
+ @options.add_option("s", "status", "Filter by status : \n\t\t\t\t\t Delete, Installed, Delete Final, Ready, Discovered, Readying, Hardware Installed,\n\t\t\t\t\t Reinstall, Hardware Installing, Reset, Hardware Updated, Update or Hardware Updating.", false, true)
28
+ @options.add_option("f", "follow", "Display informations until interruption of the user (Ctrl+C).", false)
29
+ end
30
+
31
+ # The execution of the command.
32
+ # @author mbretaud
33
+ def exec
34
+ @logger.info("Exec::NodeLs Executing NodeLs")
35
+ output = ""
36
+
37
+ ### Normal displays ###
38
+ if !@values['follow'] && @values['status'].nil?
39
+ @logger.info("Exec::NodeLs Executing of a normal displays")
40
+ @logger.info("Exec::NodeLs Display nodes into the bash screen...")
41
+ Color::print_log("NONE", "Display nodes into the bash screen...", @stdout)
42
+
43
+ # Retrieves the list of nodes.
44
+ begin
45
+ @logger.info("Exec::NodeLs Getting the nodes list.")
46
+ cmd = Command::CrowbarNodeList.new(@logger)
47
+ list_nodes = cmd.exec
48
+ rescue => e
49
+ raise NodeListError.new("Retrieves the list of nodes.")
50
+ end
51
+
52
+ # Displays the list of all nodes.
53
+ begin
54
+ output += "#{display_list(list_nodes)}\n"
55
+ rescue => e
56
+ raise NodeListError.new("Displays the list of all nodes.")
57
+ end
58
+
59
+ Color::echo_ok(@stdout)
60
+ @logger.info(output)
61
+ if !output.empty? && output.length > 1
62
+ @stdout.print output
63
+ else
64
+ @logger.info("Exec::NodeLs No machines available!")
65
+ @stdout.printf_red "No machines available!\n"
66
+ end
67
+ end
68
+
69
+ ### Status displays ###
70
+ if !@values['follow'] && !@values['status'].nil?
71
+ @logger.info("Exec::NodeLs Executing of a status displays")
72
+ Color::print_log("NONE", "Display nodes into the bash screen with status '#{@values['status']}'...", @stdout)
73
+
74
+ # Retrieves the list of nodes.
75
+ begin
76
+ @logger.info("Exec::NodeLs Getting the nodes list.")
77
+ cmd = Command::CrowbarNodeList.new(@logger, @values['status'])
78
+ list_nodes = cmd.exec
79
+ rescue => e
80
+ raise NodeListError.new("Retrieves the list of nodes with the status '#{@values['status']}'..")
81
+ end
82
+
83
+ # Displays the list of all nodes.
84
+ if is_correct_status(@values['status'])
85
+ list_nodes = cmd.exec
86
+
87
+ output += "#{display_list(list_nodes)}\n"
88
+ else
89
+ raise NodeListError.new("The status '#{@values['status']}' is not correct.")
90
+ end
91
+
92
+ Color::echo_ok(@stdout)
93
+ @logger.info(output)
94
+ if !output.empty? && output.length > 1
95
+ @stdout.print output
96
+ else
97
+ @logger.info("Exec::NodeLs No machines available!")
98
+ @stdout.print "No machines '#{@values['status']}' available!\n"
99
+ end
100
+
101
+ @logger.end_execution()
102
+ end
103
+
104
+ ### Waiting displays ###
105
+ if @values['follow'] && @values['status'].nil?
106
+ #`watch -d -n 4 bin/cb-node-ls`
107
+ @stdout.puts "TODO"
108
+ @logger.info("Exec::NodeLs Follow display nodes to do!")
109
+ # @todo The waiting displays for cb-node-ls
110
+ end
111
+ end
112
+
113
+ private
114
+ # Displays the elements of the list
115
+ # @param list_nodes list The list of elements
116
+ # return [String] The output standard
117
+ # @author mbretaud
118
+ def display_list(list_nodes)
119
+ @logger.info("Exec::NodeLs display_list(list_nodes)")
120
+ output = ""
121
+ begin
122
+ if !list_nodes.nil? && list_nodes.length > 0
123
+ list_nodes_to_diplay = Array.new
124
+
125
+ list_nodes.each { |node|
126
+ list_nodes_to_diplay.<< " - #{node}"
127
+ }
128
+
129
+ if !list_nodes_to_diplay.nil? && list_nodes_to_diplay.length > 0
130
+ output += "\n"
131
+ list_nodes_to_diplay.sort.each { |node|
132
+ output += "#{node}\n"
133
+ }
134
+ end
135
+ end
136
+ rescue => e
137
+ raise NodeListError.new("Displays the elements of the list.")
138
+ end
139
+
140
+ return output
141
+ end
142
+
143
+ # @param status_node [String] the name node
144
+ # @return [Boolean] true if the status is correct, false else
145
+ # @todo refactor in a library
146
+ # @author mbretaud
147
+ def is_correct_status(status_node)
148
+ list_status = ["Applying", "Delete", "Delete Final", "Deleting Final", "Discovered", "Discovering", "Hardware Installed",
149
+ "Hardware Installing", "Hardware Updated", "Hardware Updating", "Installed", "Installing", "Pending",
150
+ "Ready", "Readying", "Reinstall", "Reset", "Update", "Updated"]
151
+
152
+ list_status.each { |status|
153
+ if status_node == status
154
+ return true
155
+ end
156
+ }
157
+ return false
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,224 @@
1
+ # This file is part of cloudbox-service project
2
+ # @author tmarmin (INGENSI)
3
+
4
+ require 'exec/executable_command'
5
+ require 'exec/check_parameter'
6
+ require 'command/ambari_service_add'
7
+ require 'command/ambari_service_component_add'
8
+ require 'command/ambari_service_conf_ls'
9
+ require 'command/ambari_host_list'
10
+ require 'command/ambari_service_component_info'
11
+ require 'command/ambari_create_cluster_configuration'
12
+ require 'command/ambari_service_delete'
13
+ require 'common/services_description'
14
+ require 'common/cloudbox_exceptions'
15
+
16
+ include Exec::CheckParameter
17
+ include Common::ServicesDescription
18
+
19
+ module Exec
20
+ # Allows user to add a new service to the ambari cluster
21
+ class ServiceAdd < ExecutableCommand
22
+
23
+ private
24
+ # @todo Use relative path technique for the attribute below
25
+ @configuration_directory
26
+
27
+ private
28
+ # @todo Change the way of getting the jdk_home for default configurations
29
+ @jdk_home
30
+
31
+ public
32
+ # Default constructor.
33
+ # @param argv The arguments of the command.
34
+ # @param stdin [IO] The input stream of the command.
35
+ # @param stdout [IO] The output stream of the command.
36
+ # @param stderr [IO] The error stream of the command.
37
+ # @param command_name [String] The name of the executed command.
38
+ # @author tnoguer
39
+ def initialize(argv, stdin, stdout, stderr, command_name)
40
+ super(argv, stdin, stdout, stderr, command_name)
41
+ @configuration_directory = File.dirname(__FILE__) + "/../../resources/ambari-configurations"
42
+ @jdk_home = '/usr/jdk64/jdk1.6.0_31'
43
+ end
44
+
45
+ private
46
+ # Parse and check the parameters of the function.
47
+ # @author tmarmin
48
+ def set_options
49
+ @logger.info("setting options")
50
+ @options.add_option("C", "cluster", "The virtual cluster name where to list services.", true, true, method(:check_cluster_name))
51
+ @options.add_option("s", "service", "The service that will be add.", true, true, method(:check_hadoop_service_name))
52
+ @options.add_option("m", "master", "The master node of the service.", true, true)
53
+ end
54
+
55
+ private
56
+ # Execution of the command.
57
+ # @author tmarmin
58
+ def exec
59
+
60
+ begin
61
+ Color::print_log("NONE", "Checking dependencies...", @stdout)
62
+ services = []
63
+ Command::AmbariServiceList.new(@values["cluster"]).exec["items"].each do |service|
64
+ services.push(service["ServiceInfo"]["service_name"])
65
+ end
66
+
67
+ Common::ServicesDescription.get_deps(@values["service"]).each do |deps_name|
68
+ raise MissingDependency.new("Service(s) #{Common::ServicesDescription.get_deps(@values["service"]).join(", ")} has to be defined in cluster before add #{@values["service"]} service.") unless services.include?(deps_name)
69
+ end
70
+ Color::echo_ok(@stdout)
71
+
72
+ if @values["service"] == "HBASE"
73
+ data = Command::AmbariServiceComponentInfo.new("HDFS", @values["cluster"], "NAMENODE").exec
74
+ data["host_components"].each do |component|
75
+ if component["HostRoles"]["state"] == "STARTED"
76
+ raise Common::AddServiceHbaseError.new("The service HDFS must be Stopped for add service HBASE and restart after add service ")
77
+ end
78
+ end
79
+ end
80
+
81
+ Color::print_log("NONE", "Adding service on cluster...", @stdout)
82
+ Command::AmbariServiceAdd.new(@values["cluster"], @values["service"]).exec()
83
+ Color::echo_ok(@stdout)
84
+ rescue CloudboxError => e
85
+ Color::echo_fail(@stdout)
86
+ raise e
87
+ end
88
+
89
+ begin
90
+ if @values["service"] == "ZOOKEEPER" or @values["service"]=="HBASE"
91
+ Common::ServicesDescription.get_master_nodes(@values["service"]).each do |component_name|
92
+ Color::print_log("NONE", "Adding ZOOKEEPER_HOST component #{component_name} on master node...")
93
+ list_host=[]
94
+ list_host= (@values["master"]).delete(' ').split(",")
95
+ list_host.each do |host|
96
+ Command::AmbariServiceComponentAdd.new(@values["cluster"], component_name,host ).exec
97
+ end
98
+ end
99
+ else
100
+ Common::ServicesDescription.get_master_nodes(@values["service"]).each do |component_name|
101
+ begin
102
+ Color::print_log("NONE", "Adding master component #{component_name} on master node...")
103
+ Command::AmbariServiceComponentAdd.new(@values["cluster"], component_name, @values["master"]).exec()
104
+ Color::echo_ok(@stdout)
105
+ rescue AlreadyExistsEntity => e
106
+ Color::echo_warn(@stdout)
107
+ @stdout.puts(e)
108
+ end
109
+ end
110
+ end
111
+
112
+
113
+ Common::ServicesDescription.get_slave_nodes_on_master(@values["service"]).each do |component_name|
114
+ begin
115
+ Color::print_log("NONE", "Adding slave component #{component_name} on master node...")
116
+ Command::AmbariServiceComponentAdd.new(@values["cluster"], component_name, @values["master"]).exec()
117
+ Color::echo_ok(@stdout)
118
+ rescue AlreadyExistsEntity => e
119
+ Color::echo_warn(@stdout)
120
+ @stdout.puts(e)
121
+ end
122
+ end
123
+
124
+
125
+ Common::ServicesDescription.get_slave_nodes(@values["service"]).each do |component_name|
126
+ begin
127
+ Color::print_log("NONE", "Adding slave component #{component_name} on other nodes...")
128
+ Command::AmbariHostList.new(@values["cluster"]).exec().each do |host_name|
129
+ unless host_name == @values["master"]
130
+ Command::AmbariServiceComponentAdd.new(@values["cluster"], component_name, host_name).exec()
131
+ end
132
+ end
133
+ Color::echo_ok(@stdout)
134
+ rescue AlreadyExistsEntity => e
135
+ Color::echo_warn(@stdout)
136
+ @stdout.puts(e)
137
+ end
138
+ end
139
+
140
+ Color::print_log("NONE", "Setting up default configurations...")
141
+ configure_service(@values["cluster"], @values["service"], @configuration_directory)
142
+ Color::echo_ok(@stdout)
143
+
144
+ rescue => e
145
+ Color::echo_fail(@stdout)
146
+ @stdout.puts "Deleting service..."
147
+ Command::AmbariServiceDelete.new(@values["cluster"], @values["service"]).exec()
148
+ raise e
149
+ end
150
+ end
151
+
152
+ private
153
+ # Adds the default configurations for the service.
154
+ # @param cluster_name The name of the cluster.
155
+ # @param service_name The name of the service.
156
+ # @param conf_dir The configuration directory.
157
+ # @author tmarmin
158
+ def configure_service(cluster_name, service_name, conf_dir)
159
+ @logger.begin_main_step("configureServices")
160
+
161
+ @logger.debug("Getting configuration list")
162
+ confs = Command::AmbariServiceConfLs.new(cluster_name).exec()
163
+ @logger.debug("confs:\n" + confs.to_s)
164
+ core_site = false
165
+ global = false
166
+ confs.each do |conf|
167
+ if conf["type"] == "core-site"
168
+ core_site = true
169
+ elsif conf["type"] == "global"
170
+ global = true
171
+ end
172
+ end
173
+
174
+ @logger.debug("check if global already exists")
175
+ if !global
176
+ create_common_default_conf(cluster_name, "global", conf_dir)
177
+ end
178
+
179
+ @logger.debug("check if default core-site already exists")
180
+ if !core_site
181
+ create_common_default_conf(cluster_name, "core-site", conf_dir)
182
+ end
183
+
184
+
185
+ conf_name = Common::ServicesDescription.get_config_name_service(@values["service"])
186
+ unless conf_name.nil?
187
+
188
+ service_configs_path = conf_dir + "/" + service_name
189
+ raise(StandardError, "Default configuration directory doesn't exists for service #{service_name}: #{service_configs_path.to_s}") if !File.directory?(service_configs_path)
190
+
191
+ @logger.debug("adding needed configuration #{conf_name}")
192
+ create_common_default_conf(cluster_name, conf_name, service_configs_path)
193
+ end
194
+ end
195
+
196
+ private
197
+ # Creates and applies a default configuration into the cluster.
198
+ # @param cluster_name The name of the cluster.
199
+ # @param conf_type The type of configuration.
200
+ # @param dir The directory of the configuration file.
201
+ # @author tmarmin
202
+ def create_common_default_conf(cluster_name, conf_type, dir)
203
+ @logger.debug("default #{conf_type} doesn't already exists!")
204
+ file_path = dir + "/default_#{conf_type}"
205
+ raise(StandardError, "Default #{conf_type} configuration doesn't exists: #{file_path}") if !File.file?(file_path)
206
+ file = File.open(file_path, "r")
207
+ if conf_type == "hbase-site"
208
+ zk_server=[]
209
+ zk = Command::AmbariServiceComponentInfo.new("ZOOKEEPER", @values["cluster"], "ZOOKEEPER_SERVER").exec
210
+ zk["host_components"].each do |component|
211
+ zk_server.push(component["HostRoles"]["host_name"])
212
+ end
213
+ zk_host = zk_server.join(",")
214
+ data = file.read.gsub("__MASTERNODE__", @values["master"].to_s).gsub("__HOST_ZOOKEEPER__", zk_host.to_s)
215
+ else
216
+ data = file.read.gsub("__MASTERNODE__", @values["master"].to_s).gsub("__JDK_HOME__", @jdk_home.to_s)
217
+ end
218
+ properties = JSON.parse(data)
219
+ Command::AmbariCreateClusterConfiguration.new(cluster_name, conf_type, "default", properties, true).exec()
220
+ @logger.debug("default #{conf_type} created")
221
+ end
222
+
223
+ end
224
+ end
@@ -0,0 +1,39 @@
1
+ # This file is part of cloudbox-service project
2
+ # @author tmarmin (INGENSI)
3
+
4
+ require 'exec/executable_command'
5
+ require 'exec/check_parameter'
6
+ require 'command/ambari_service_component_add'
7
+
8
+ include Exec::CheckParameter
9
+
10
+ module Exec
11
+ # Allows the user to add a service component.
12
+ class ServiceComponentAdd < ExecutableCommand
13
+
14
+ private
15
+ # Parse and check the parameters of the function.
16
+ # @author tmarmin
17
+ def set_options
18
+ @logger.info("setting options")
19
+ @options.add_option("C", "cluster", "The virtual cluster name.", true, true, method(:check_cluster_name))
20
+ @options.add_option("H", "host", "Limit request to this host.", true, true, method(:check_ambari_host_name))
21
+ @options.add_option("c", "component", "Limit request to this component type.", false, true, method(:check_hadoop_component_name))
22
+ @options.add_option("f", "follow", "Follow completion of the request.", false)
23
+ end
24
+
25
+ private
26
+ # Execution of the command
27
+ def exec
28
+ # @todo traiter les exceptions
29
+ Color::print_log("NONE", "adding service on cluser...", @stdout)
30
+ @values["host"].split(" ").each do |host|
31
+ cmd = Command::AmbariServiceComponentAdd.new(@values["cluster"], @values["component"], host)
32
+ cmd.exec()
33
+ Color::echo_ok(@stdout)
34
+ @stdout.puts("Component #{@values["component"]} has been successfully added on host #{@values["host"]} in cluster #{@values["cluster"]}.")
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ # This file is part of cloudbox-service project
2
+ # @author tmarmin (INGENSI)
3
+
4
+ require 'exec/executable_command'
5
+ require 'exec/check_parameter'
6
+ require 'command/ambari_service_component_delete'
7
+
8
+ include Exec::CheckParameter
9
+
10
+ module Exec
11
+ # Allows the user to delete a service component.
12
+ class ServiceComponentDelete < ExecutableCommand
13
+
14
+ private
15
+ # Parse and check the parameters of the function.
16
+ # @author tmarmin
17
+ def set_options
18
+ @logger.info("setting options")
19
+ @options.add_option("C", "cluster", "The virtual cluster name.", true, true, method(:check_cluster_name))
20
+ @options.add_option("H", "host", "Limit request to this host.", true, true, method(:check_ambari_host_name))
21
+ @options.add_option("c", "component", "Limit request to this component type.", false, true, method(:check_hadoop_component_name))
22
+ @options.add_option("f", "follow", "Follow completion of the request.", false)
23
+ end
24
+
25
+ private
26
+ # Execution of the command
27
+ def exec
28
+ # @todo traiter les exceptions
29
+ Color::print_log("NONE", "deleting service component...", @stdout)
30
+ cmd = Command::AmbariServiceComponentDelete.new(@values["cluster"], @values["component"], @values["host"])
31
+ cmd.exec()
32
+ Color::echo_ok(@stdout)
33
+ @stdout.puts("Component #{@values["component"]} has been successfully removed from host #{@values["host"]} in cluster #{@values["cluster"]}.")
34
+ end
35
+
36
+ end
37
+ end