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,599 @@
|
|
|
1
|
+
# This file is part of cloudbox-server project
|
|
2
|
+
# Author: tnoguer (INGENSI)
|
|
3
|
+
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'receiver/rest_api_connector'
|
|
6
|
+
|
|
7
|
+
module Receiver
|
|
8
|
+
# Class linking to the Ambari Rest API.
|
|
9
|
+
# @author tnoguer
|
|
10
|
+
class AmbariRestAPIConnector < RestApiConnector
|
|
11
|
+
|
|
12
|
+
public
|
|
13
|
+
# Default constructor.
|
|
14
|
+
# @raise [ArgumentError] If the value of the arguments are nil or invalid.
|
|
15
|
+
# @author tnoguer
|
|
16
|
+
# @todo Change the conf file path to a relative path
|
|
17
|
+
def initialize(logger = nil)
|
|
18
|
+
file = File.new(File.dirname(__FILE__) + "/../../resources/cloudbox-server.conf", "r")
|
|
19
|
+
json = file.read()
|
|
20
|
+
conf = JSON.parse(json)
|
|
21
|
+
super(conf["ambari_server_ip"], conf["ambari_server_port"], "BASIC", conf["ambari_user"], conf["ambari_password"], 10000, logger)
|
|
22
|
+
@logger.info("Receiver::AmbariRestAPIConnector initialize the parameters...")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
public
|
|
26
|
+
# Create a configuration into a cluster.
|
|
27
|
+
# @param cluster_name The name of the cluster.
|
|
28
|
+
# @param configuration_type The type of the configuration to add.
|
|
29
|
+
# @param configuration_tag The tag of the configuration to add.
|
|
30
|
+
# @param properties The hash of properties for the configuration. (ex: {"Property 1" => "value", "Property 2" => "value"})
|
|
31
|
+
# @return The http response.
|
|
32
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
33
|
+
# @raise [HTTPError] If the request is invalid.
|
|
34
|
+
# @author tnoguer
|
|
35
|
+
def create_configuration(cluster_name, configuration_type, configuration_tag, properties)
|
|
36
|
+
if cluster_name == nil || configuration_type == nil || configuration_tag == nil || properties == nil
|
|
37
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
body = {"type" => configuration_type,
|
|
41
|
+
"tag" => configuration_tag,
|
|
42
|
+
"Config" => {
|
|
43
|
+
"cluster_name" => cluster_name
|
|
44
|
+
},
|
|
45
|
+
"properties" => {}
|
|
46
|
+
}
|
|
47
|
+
body["properties"].update(properties)
|
|
48
|
+
return launch_request("POST", "/api/v1/clusters/#{cluster_name}/configurations", body.to_json)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
public
|
|
52
|
+
# Create and apply a configuration into a cluster.
|
|
53
|
+
# @param cluster_name The name of the cluster.
|
|
54
|
+
# @param configuration_type The type of the configuration to add.
|
|
55
|
+
# @param configuration_tag The tag of the configuration to add.
|
|
56
|
+
# @param properties The hash of properties for the configuration. (ex: {"Property 1" => "value", "Property 2" => "value"})
|
|
57
|
+
# @return The http response.
|
|
58
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
59
|
+
# @raise [HTTPError] If the request is invalid.
|
|
60
|
+
# @author tnoguer
|
|
61
|
+
def create_apply_configuration(cluster_name, configuration_type, configuration_tag, properties)
|
|
62
|
+
if cluster_name == nil || configuration_type == nil || configuration_tag == nil || properties == nil
|
|
63
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
64
|
+
end
|
|
65
|
+
body = {"Clusters" => {
|
|
66
|
+
"desired_config" => {
|
|
67
|
+
"type" => configuration_type.to_s,
|
|
68
|
+
"tag" => configuration_tag.to_s,
|
|
69
|
+
"properties" => {}
|
|
70
|
+
}
|
|
71
|
+
}}
|
|
72
|
+
body['Clusters']['desired_config']['properties'].update(properties)
|
|
73
|
+
return launch_request("PUT", "/api/v1/clusters/#{cluster_name}", body.to_json)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
public
|
|
77
|
+
# Apply a configuration into a cluster.
|
|
78
|
+
# @param cluster_name The name of the cluster.
|
|
79
|
+
# @param configuration_type The type of the configuration to add.
|
|
80
|
+
# @param configuration_tag The tag of the configuration to add.
|
|
81
|
+
# @return The http response.
|
|
82
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
83
|
+
# @raise [HTTPError] If the request is invalid.
|
|
84
|
+
# @author tnoguer
|
|
85
|
+
def apply_configuration(cluster_name, configuration_type, configuration_tag)
|
|
86
|
+
if cluster_name == nil || configuration_type == nil || configuration_tag == nil
|
|
87
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
body = {"Clusters" => {
|
|
91
|
+
"desired_config" => {
|
|
92
|
+
"type" => configuration_type,
|
|
93
|
+
"tag" => configuration_tag
|
|
94
|
+
}
|
|
95
|
+
}}
|
|
96
|
+
|
|
97
|
+
return launch_request("PUT", "/api/v1/clusters/#{cluster_name}", body.to_json)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
public
|
|
101
|
+
# Defines a new cluster.
|
|
102
|
+
# @param cluster_name The name of the cluster to be defined.
|
|
103
|
+
# @param cluster_version The version of the cluster to be created.
|
|
104
|
+
# @return The http response.
|
|
105
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
106
|
+
# @raise [HTTPError] If the request is invalid.add
|
|
107
|
+
# @author tnoguer
|
|
108
|
+
def define_cluster(cluster_name, cluster_version)
|
|
109
|
+
if cluster_name == nil || cluster_version == nil
|
|
110
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
return launch_request("POST", "/api/v1/clusters/#{cluster_name}", "{\"Clusters\": {\"version\" : \"#{cluster_version}\"}}")
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
public
|
|
117
|
+
# Deletes a new cluster.
|
|
118
|
+
# @param cluster_name The name of the cluster to be deleted.
|
|
119
|
+
# @return The http response.
|
|
120
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
121
|
+
# @raise [HTTPError] If the request is invalid.
|
|
122
|
+
# @author tnoguer
|
|
123
|
+
def delete_cluster(cluster_name)
|
|
124
|
+
if cluster_name == nil
|
|
125
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
public
|
|
132
|
+
# Shows the services of a cluster.
|
|
133
|
+
# @param cluster_name The name of the cluster.
|
|
134
|
+
# @return The http response.
|
|
135
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
136
|
+
# @raise [HTTPError] If the request is invalid.
|
|
137
|
+
# @author tnoguer
|
|
138
|
+
def show_cluster_services(cluster_name)
|
|
139
|
+
if cluster_name == nil
|
|
140
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}/services")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
public
|
|
147
|
+
# Launches a GET request on a specifique configuration.
|
|
148
|
+
# @param cluster_name The name of the cluster.
|
|
149
|
+
# @param type The type of configuration.
|
|
150
|
+
# @param tag The tag ot configuration.
|
|
151
|
+
# @return The http response.
|
|
152
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
153
|
+
# @raise [HTTPError] If the request is invalid.
|
|
154
|
+
# @author tnoguer
|
|
155
|
+
def get_cluster_configuration(cluster_name, type, tag)
|
|
156
|
+
if cluster_name == nil || type == nil || tag == nil
|
|
157
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}/configurations?type=#{type}&tag=#{tag}")
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
public
|
|
164
|
+
# Shows the requests of a cluster.
|
|
165
|
+
# @param cluster_name The name of the cluster.
|
|
166
|
+
# @return The http response.
|
|
167
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
168
|
+
# @raise [HTTPError] If the request is invalid.
|
|
169
|
+
# @author tnoguer
|
|
170
|
+
def show_requests(cluster_name)
|
|
171
|
+
if cluster_name == nil
|
|
172
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}/requests")
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
public
|
|
179
|
+
# Shows the information of a request.
|
|
180
|
+
# @param cluster_name The name of the cluster.
|
|
181
|
+
# @param request_id The ID of the request.
|
|
182
|
+
# @return The http response.
|
|
183
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
184
|
+
# @raise [HTTPError] If the request is invalid.
|
|
185
|
+
# @author tnoguer
|
|
186
|
+
def show_request(cluster_name, request_id)
|
|
187
|
+
if cluster_name == nil || request_id == nil
|
|
188
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}/requests/#{request_id}?fields=tasks/*")
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
public
|
|
196
|
+
# Shows the information of a cluster.
|
|
197
|
+
# @param cluster_name The name of the cluster.
|
|
198
|
+
# @param show_host True to show the detail of the hosts. False otherwise.
|
|
199
|
+
# @param show_components True to show the detail of the components. False otherwise.
|
|
200
|
+
# @return The http response.
|
|
201
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
202
|
+
# @raise [HTTPError] If the request is invalid.
|
|
203
|
+
# @author tnoguer
|
|
204
|
+
def show_cluster(cluster_name, show_host=false, show_components=false)
|
|
205
|
+
if cluster_name == nil
|
|
206
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
show_host = false unless show_host
|
|
210
|
+
show_components = false unless show_components
|
|
211
|
+
fields = "?fields=*"
|
|
212
|
+
fields += ",services/*" if show_components
|
|
213
|
+
fields += ",services/components/*" if show_host
|
|
214
|
+
|
|
215
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}#{fields}")
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
public
|
|
219
|
+
# Shows the list of clusters.
|
|
220
|
+
# @return The http response.
|
|
221
|
+
# @raise [HTTPError] If the request is invalid.
|
|
222
|
+
# @author tnoguer
|
|
223
|
+
def list_clusters
|
|
224
|
+
return launch_request("GET", "/api/v1/clusters")
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
public
|
|
228
|
+
# Adds a component to an host.
|
|
229
|
+
# @param cluster_name The name of the cluster.
|
|
230
|
+
# @param host_name The name of the host.
|
|
231
|
+
# @param component_name The name of the component to add.
|
|
232
|
+
# @return The http response.
|
|
233
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
234
|
+
# @raise [HTTPError] If the request is invalid.
|
|
235
|
+
# @author tnoguer
|
|
236
|
+
def add_host_component(cluster_name, host_name, component_name)
|
|
237
|
+
if cluster_name == nil || host_name == nil || component_name == nil
|
|
238
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
return launch_request("POST", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}/host_components/#{component_name}")
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
public
|
|
245
|
+
# Deletes a component from an host.
|
|
246
|
+
# @param cluster_name The name of the cluster.
|
|
247
|
+
# @param host_name The name of the host.
|
|
248
|
+
# @param component_name The name of the component to delete.
|
|
249
|
+
# @return The http response.
|
|
250
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
251
|
+
# @raise [HTTPError] If the request is invalid.
|
|
252
|
+
# @author tnoguer
|
|
253
|
+
def delete_host_component(cluster_name, host_name, component_name)
|
|
254
|
+
if host_name == nil || component_name == nil || cluster_name == nil
|
|
255
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}/host_components/#{component_name}")
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
public
|
|
262
|
+
# Deletes an host.
|
|
263
|
+
# @param cluster_name The name of the cluster.
|
|
264
|
+
# @param host_name The name of the host to delete.
|
|
265
|
+
# @return The http response.
|
|
266
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
267
|
+
# @raise [HTTPError] If the request is invalid.
|
|
268
|
+
# @author tnoguer
|
|
269
|
+
def delete_host(cluster_name, host_name)
|
|
270
|
+
if host_name == nil || cluster_name == nil
|
|
271
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}")
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
public
|
|
278
|
+
# Installs a component of an host.
|
|
279
|
+
# @param cluster_name The name of the cluster.
|
|
280
|
+
# @param host_name The name of the host.
|
|
281
|
+
# @param component_name The name of the component to install.
|
|
282
|
+
# @return The http response.
|
|
283
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
284
|
+
# @raise [HTTPError] If the request is invalid.
|
|
285
|
+
# @author tnoguer
|
|
286
|
+
def install_host_component(cluster_name, host_name, component_name)
|
|
287
|
+
return set_status_host_component(cluster_name, host_name, component_name, "INSTALLED")
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
public
|
|
291
|
+
# Starts a component of an host.
|
|
292
|
+
# @param cluster_name The name of the cluster.
|
|
293
|
+
# @param host_name The name of the host.
|
|
294
|
+
# @param component_name The name of the component to start.
|
|
295
|
+
# @return The http response.
|
|
296
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
297
|
+
# @raise [HTTPError] If the request is invalid.
|
|
298
|
+
# @author tnoguer
|
|
299
|
+
def start_host_component(cluster_name, host_name, component_name)
|
|
300
|
+
return set_status_host_component(cluster_name, host_name, component_name, "STARTED")
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
public
|
|
304
|
+
# Stops a component of an host.
|
|
305
|
+
# @param cluster_name The name of the cluster.
|
|
306
|
+
# @param host_name The name of the host.
|
|
307
|
+
# @param component_name The name of the component to stop.
|
|
308
|
+
# @return The http response.
|
|
309
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
310
|
+
# @raise [HTTPError] If the request is invalid.
|
|
311
|
+
# @author tnoguer
|
|
312
|
+
def stop_host_component(cluster_name, host_name, component_name)
|
|
313
|
+
return set_status_host_component(cluster_name, host_name, component_name, "INSTALLED")
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
public
|
|
317
|
+
# Detachs a component of an host.
|
|
318
|
+
# @param cluster_name The name of the cluster.
|
|
319
|
+
# @param host_name The name of the host.
|
|
320
|
+
# @param component_name The name of the component to detach.
|
|
321
|
+
# @return The http response.
|
|
322
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
323
|
+
# @raise [HTTPError] If the request is invalid.
|
|
324
|
+
# @author tnoguer0
|
|
325
|
+
def detach_host_component(cluster_name, host_name, component_name)
|
|
326
|
+
return set_status_host_component(cluster_name, host_name, component_name, "MAINTENANCE")
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
private
|
|
330
|
+
# Set the status of a component of an host.
|
|
331
|
+
# @param cluster_name The name of the cluster.
|
|
332
|
+
# @param host_name The name of the host.
|
|
333
|
+
# @param component_name The name of the component.
|
|
334
|
+
# @param status The status to set. (INSTALLED, STARTED, MAINTENANCE)
|
|
335
|
+
# @return The http response.
|
|
336
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
337
|
+
# @raise [HTTPError] If the request is invalid.
|
|
338
|
+
# @author tnoguer
|
|
339
|
+
def set_status_host_component(cluster_name, host_name, component_name, status)
|
|
340
|
+
if host_name == nil || component_name == nil || cluster_name == nil || status == nil
|
|
341
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
return launch_request("PUT", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}/host_components/#{component_name}",
|
|
345
|
+
"{ \"HostRoles\" : { \"state\" : \"#{status}\"}}")
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
public
|
|
349
|
+
# Adds an host.
|
|
350
|
+
# @param cluster_name The name of the cluster.
|
|
351
|
+
# @param host_name The name of the host to add.
|
|
352
|
+
# @return The http response.
|
|
353
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
354
|
+
# @raise [HTTPError] If the request is invalid.
|
|
355
|
+
# @author tnoguer
|
|
356
|
+
def add_host(cluster_name, host_name)
|
|
357
|
+
if host_name == nil || cluster_name == nil
|
|
358
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
return launch_request("POST", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}")
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
#public
|
|
365
|
+
# Creates and applies a configuration to an host from a configuration file.
|
|
366
|
+
# @param cluster_name The name of the cluster.
|
|
367
|
+
# @param host_name The name of the host.
|
|
368
|
+
# @param configuration_type The type of the configuration to add.
|
|
369
|
+
# @param configuration_tag The tag of the configuration to add.
|
|
370
|
+
# @param file_path The path to the file containing the properties of the configuration.
|
|
371
|
+
# @return The http response.
|
|
372
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
373
|
+
# @raise [HTTPError] If the request is invalid.
|
|
374
|
+
# @author tnoguer
|
|
375
|
+
#def configure_host(cluster_name, host_name, configuration_type, configuration_tag, file_path)
|
|
376
|
+
# if file_path == nil || cluster_name == nil || host_name == nil || configuration_type == nil || configuration_tag == nil
|
|
377
|
+
# raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
378
|
+
# end
|
|
379
|
+
#
|
|
380
|
+
# config = {:Clusters => {:desired_configs => {:type => configuration_type, :tag => configuration_tag, :properties => {}}}}
|
|
381
|
+
# config[:Clusters][:desired_configs][:properties].update(xml2json(file_path))
|
|
382
|
+
# config = config.to_json
|
|
383
|
+
#
|
|
384
|
+
# return launch_request("PUT", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}", config)
|
|
385
|
+
#end
|
|
386
|
+
|
|
387
|
+
public
|
|
388
|
+
# Shows information of an host.
|
|
389
|
+
# @param cluster_name The name of the cluster.
|
|
390
|
+
# @param host_name The name of the host.
|
|
391
|
+
# @return The http response.
|
|
392
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
393
|
+
# @raise [HTTPError] If the request is invalid.
|
|
394
|
+
# @author tnoguer
|
|
395
|
+
def show_host(cluster_name, host_name)
|
|
396
|
+
if host_name == nil || cluster_name == nil
|
|
397
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}?fields=*,host_components/*")
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
public
|
|
404
|
+
# Adds a component to a service.
|
|
405
|
+
# @param cluster_name The name of the cluster.
|
|
406
|
+
# @param service_name The name of the service.
|
|
407
|
+
# @param component_name The name of the component to add.
|
|
408
|
+
# @return The http response.
|
|
409
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
410
|
+
# @raise [HTTPError] If the request is invalid.
|
|
411
|
+
# @author tnoguer
|
|
412
|
+
def add_service_component(cluster_name, service_name, component_name)
|
|
413
|
+
if service_name == nil || component_name == nil || cluster_name == nil
|
|
414
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
return launch_request("POST", "/api/v1/clusters/#{cluster_name}/services/#{service_name}/components/#{component_name}")
|
|
418
|
+
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
public
|
|
422
|
+
# Defines a new service.
|
|
423
|
+
# @param cluster_name The name of the cluster.
|
|
424
|
+
# @param service_name The name of the service to define.
|
|
425
|
+
# @return The http response.
|
|
426
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
427
|
+
# @raise [HTTPError] If the request is invalid.
|
|
428
|
+
# @author tnoguer
|
|
429
|
+
def define_service(cluster_name, service_name)
|
|
430
|
+
if service_name == nil || cluster_name == nil
|
|
431
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
return launch_request("POST", "/api/v1/clusters/#{cluster_name}/services/#{service_name}")
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
public
|
|
438
|
+
# Deletes a service.
|
|
439
|
+
# @param cluster_name The name of the cluster.
|
|
440
|
+
# @param service_name The name of the service to delete.
|
|
441
|
+
# @return The http response.
|
|
442
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
443
|
+
# @raise [HTTPError] If the request is invalid.
|
|
444
|
+
# @author tnoguer
|
|
445
|
+
def delete_service(cluster_name, service_name)
|
|
446
|
+
if service_name == nil || cluster_name == nil
|
|
447
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}/services/#{service_name}")
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
public
|
|
454
|
+
# Installs a service.
|
|
455
|
+
# @param cluster_name The name of the cluster.
|
|
456
|
+
# @param service_name The name of the service to install.
|
|
457
|
+
# @return The http response.
|
|
458
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
459
|
+
# @raise [HTTPError] If the request is invalid.
|
|
460
|
+
# @author tnoguer
|
|
461
|
+
def install_service(cluster_name, service_name)
|
|
462
|
+
return set_status_service(cluster_name, service_name, "INSTALLED")
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
public
|
|
466
|
+
# Starts a service.
|
|
467
|
+
# @param cluster_name The name of the cluster.
|
|
468
|
+
# @param service_name The name of the service to start.
|
|
469
|
+
# @return The http response.
|
|
470
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
471
|
+
# @raise [HTTPError] If the request is invalid.
|
|
472
|
+
# @author tnoguer
|
|
473
|
+
def start_service(cluster_name, service_name)
|
|
474
|
+
return set_status_service(cluster_name, service_name, "STARTED")
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
public
|
|
478
|
+
# Stops a service.
|
|
479
|
+
# @param cluster_name The name of the cluster.
|
|
480
|
+
# @param service_name The name of the service to stop.
|
|
481
|
+
# @return The http response.
|
|
482
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
483
|
+
# @raise [HTTPError] If the request is invalid.
|
|
484
|
+
# @author tnoguer
|
|
485
|
+
def stop_service(cluster_name, service_name)
|
|
486
|
+
return set_status_service(cluster_name, service_name, "INSTALLED")
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
private
|
|
490
|
+
# Set the status of a service.
|
|
491
|
+
# @param cluster_name The name of the cluster.
|
|
492
|
+
# @param service_name The name of the service.
|
|
493
|
+
# @param status The status to set. (INSTALLED STARTED)
|
|
494
|
+
# @return The http response.
|
|
495
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
496
|
+
# @raise [HTTPError] If the request is invalid.
|
|
497
|
+
# @author tnoguer
|
|
498
|
+
def set_status_service(cluster_name, service_name, status)
|
|
499
|
+
if service_name == nil || cluster_name == nil
|
|
500
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
return launch_request("PUT", "/api/v1/clusters/#{cluster_name}/services/#{service_name}",
|
|
504
|
+
"{\"ServiceInfo\": {\"state\" : \"#{status}\"}}")
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
public
|
|
508
|
+
# Installs a type of components of a service.
|
|
509
|
+
# @param cluster_name The name of the cluster.
|
|
510
|
+
# @param service_name The name of the service.
|
|
511
|
+
# @param component_name The name of the components to install.
|
|
512
|
+
# @return The http response.
|
|
513
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
514
|
+
# @raise [HTTPError] If the request is invalid.
|
|
515
|
+
# @author tnoguer
|
|
516
|
+
def install_service_components(cluster_name, service_name, component_name)
|
|
517
|
+
return set_status_service_components(cluster_name, service_name, component_name, "INSTALLED")
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
public
|
|
521
|
+
# Starts a type of components of a service.
|
|
522
|
+
# @param cluster_name The name of the cluster.
|
|
523
|
+
# @param service_name The name of the service.
|
|
524
|
+
# @param component_name The name of the components to start.
|
|
525
|
+
# @return The http response.
|
|
526
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
527
|
+
# @raise [HTTPError] If the request is invalid.
|
|
528
|
+
# @author tnoguer
|
|
529
|
+
def start_service_components(cluster_name, service_name, component_name)
|
|
530
|
+
return set_status_service_components(cluster_name, service_name, component_name, "STARTED")
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
public
|
|
534
|
+
# Stops a type of components of a service.
|
|
535
|
+
# @param cluster_name The name of the cluster.
|
|
536
|
+
# @param service_name The name of the service.
|
|
537
|
+
# @param component_name The name of the components to stops.
|
|
538
|
+
# @return The http response.
|
|
539
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
540
|
+
# @raise [HTTPError] If the request is invalid.
|
|
541
|
+
# @author tnoguer
|
|
542
|
+
def stop_service_components(cluster_name, service_name, component_name)
|
|
543
|
+
return set_status_service_components(cluster_name, service_name, component_name, "INSTALLED")
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
private
|
|
547
|
+
# Set the status of a type of components of a service.
|
|
548
|
+
# @param cluster_name The name of the cluster.
|
|
549
|
+
# @param service_name The name of the service.
|
|
550
|
+
# @param component_name The name of the components.
|
|
551
|
+
# @param status The status to set. (INSTALLED STARTED)
|
|
552
|
+
# @return The http response.
|
|
553
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
554
|
+
# @raise [HTTPError] If the request is invalid.
|
|
555
|
+
# @author tnoguer
|
|
556
|
+
def set_status_service_components(cluster_name, service_name, component_name, status)
|
|
557
|
+
if service_name == nil || cluster_name == nil || component_name == nil || status == nil
|
|
558
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
559
|
+
end
|
|
560
|
+
|
|
561
|
+
return launch_request("PUT", "/api/v1/clusters/#{cluster_name}/services/#{service_name}/components/#{component_name}",
|
|
562
|
+
"{\"ServiceComponentInfo\": {\"state\" : \"#{status}\"}}")
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
public
|
|
566
|
+
# Shows information of a type of components of a service.
|
|
567
|
+
# @param cluster_name The name of the cluster.
|
|
568
|
+
# @param service_name The name of the service.
|
|
569
|
+
# @param component_name The name of the components.
|
|
570
|
+
# @return The http response.
|
|
571
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
572
|
+
# @raise [HTTPError] If the request is invalid.
|
|
573
|
+
# @author tnoguer
|
|
574
|
+
def show_service_components(cluster_name, service_name, component_name)
|
|
575
|
+
if service_name == nil || cluster_name == nil ||component_name == nil
|
|
576
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
577
|
+
end
|
|
578
|
+
|
|
579
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}/services/#{service_name}/components/#{component_name}?fields=host_components/*")
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
public
|
|
583
|
+
# Shows the list of service of a cluster.
|
|
584
|
+
# @param cluster_name The name of the cluster.
|
|
585
|
+
# @param service_name The name of the service.
|
|
586
|
+
# @return The http response.
|
|
587
|
+
# @raise [ArgumentError] If any argument is nil.
|
|
588
|
+
# @raise [HTTPError] If the request is invalid.
|
|
589
|
+
# @author tnoguer
|
|
590
|
+
def show_service(cluster_name, service_name)
|
|
591
|
+
if service_name == nil || cluster_name == nil
|
|
592
|
+
raise(ArgumentError, 'Arguments can\'t be nil!')
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
return launch_request("GET", "/api/v1/clusters/#{cluster_name}/services/#{service_name}?fields=*,components/ServiceComponentInfo,components/host_components/*")
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
end
|
|
599
|
+
end
|