Class: Receiver::AmbariRestAPIConnector

Inherits:
RestApiConnector show all
Defined in:
lib/receiver/ambari_rest_api_connector.rb

Overview

Class linking to the Ambari Rest API.

Author:

  • tnoguer

Instance Attribute Summary

Attributes inherited from RestApiConnector

#auth_type, #dest_ip, #dest_port, #timeout

Instance Method Summary collapse

Methods inherited from RestApiConnector

#get_message_html, #launch_request, #launch_request_mock

Constructor Details

#initialize(logger = nil) ⇒ AmbariRestAPIConnector

TODO:

Change the conf file path to a relative path

Default constructor.

Raises:

  • (ArgumentError)

    If the value of the arguments are nil or invalid.

Author:

  • tnoguer



17
18
19
20
21
22
23
# File 'lib/receiver/ambari_rest_api_connector.rb', line 17

def initialize(logger = nil)
  file = File.new(File.dirname(__FILE__) + "/../../resources/cloudbox-server.conf", "r")
  json = file.read()
  conf = JSON.parse(json)
  super(conf["ambari_server_ip"], conf["ambari_server_port"], "BASIC", conf["ambari_user"], conf["ambari_password"], 10000, logger)
  @logger.info("Receiver::AmbariRestAPIConnector   initialize the parameters...")
end

Instance Method Details

#add_host(cluster_name, host_name) ⇒ Object

Adds an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host to add.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



356
357
358
359
360
361
362
# File 'lib/receiver/ambari_rest_api_connector.rb', line 356

def add_host(cluster_name, host_name)
  if host_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("POST", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}")
end

#add_host_component(cluster_name, host_name, component_name) ⇒ Object

Adds a component to an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

  • component_name

    The name of the component to add.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



236
237
238
239
240
241
242
# File 'lib/receiver/ambari_rest_api_connector.rb', line 236

def add_host_component(cluster_name, host_name, component_name)
  if cluster_name == nil || host_name == nil || component_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("POST", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}/host_components/#{component_name}")
end

#add_service_component(cluster_name, service_name, component_name) ⇒ Object

Adds a component to a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

  • component_name

    The name of the component to add.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



412
413
414
415
416
417
418
419
# File 'lib/receiver/ambari_rest_api_connector.rb', line 412

def add_service_component(cluster_name, service_name, component_name)
  if service_name == nil || component_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("POST", "/api/v1/clusters/#{cluster_name}/services/#{service_name}/components/#{component_name}")

end

#apply_configuration(cluster_name, configuration_type, configuration_tag) ⇒ Object

Apply a configuration into a cluster.

Parameters:

  • cluster_name

    The name of the cluster.

  • configuration_type

    The type of the configuration to add.

  • configuration_tag

    The tag of the configuration to add.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/receiver/ambari_rest_api_connector.rb', line 85

def apply_configuration(cluster_name, configuration_type, configuration_tag)
  if cluster_name == nil || configuration_type == nil || configuration_tag == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  body = {"Clusters" => {
      "desired_config" => {
          "type" => configuration_type,
          "tag" => configuration_tag
      }
  }}

  return launch_request("PUT", "/api/v1/clusters/#{cluster_name}", body.to_json)
end

#create_apply_configuration(cluster_name, configuration_type, configuration_tag, properties) ⇒ Object

Create and apply a configuration into a cluster.

Parameters:

  • cluster_name

    The name of the cluster.

  • configuration_type

    The type of the configuration to add.

  • configuration_tag

    The tag of the configuration to add.

  • properties

    The hash of properties for the configuration. (ex: 1” => “value”, “Property 2” => “value”)

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/receiver/ambari_rest_api_connector.rb', line 61

def create_apply_configuration(cluster_name, configuration_type, configuration_tag, properties)
  if cluster_name == nil || configuration_type == nil || configuration_tag == nil || properties == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end
  body = {"Clusters" => {
      "desired_config" => {
          "type" => configuration_type.to_s,
          "tag" => configuration_tag.to_s,
          "properties" => {}
      }
  }}
  body['Clusters']['desired_config']['properties'].update(properties)
  return launch_request("PUT", "/api/v1/clusters/#{cluster_name}", body.to_json)
end

#create_configuration(cluster_name, configuration_type, configuration_tag, properties) ⇒ Object

Create a configuration into a cluster.

Parameters:

  • cluster_name

    The name of the cluster.

  • configuration_type

    The type of the configuration to add.

  • configuration_tag

    The tag of the configuration to add.

  • properties

    The hash of properties for the configuration. (ex: 1” => “value”, “Property 2” => “value”)

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/receiver/ambari_rest_api_connector.rb', line 35

def create_configuration(cluster_name, configuration_type, configuration_tag, properties)
  if cluster_name == nil || configuration_type == nil || configuration_tag == nil || properties == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  body = {"type" => configuration_type,
          "tag" => configuration_tag,
          "Config" => {
              "cluster_name" => cluster_name
          },
          "properties" => {}
  }
  body["properties"].update(properties)
  return launch_request("POST", "/api/v1/clusters/#{cluster_name}/configurations", body.to_json)
end

#define_cluster(cluster_name, cluster_version) ⇒ Object

Defines a new cluster.

Parameters:

  • cluster_name

    The name of the cluster to be defined.

  • cluster_version

    The version of the cluster to be created.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.add

Author:

  • tnoguer



108
109
110
111
112
113
114
# File 'lib/receiver/ambari_rest_api_connector.rb', line 108

def define_cluster(cluster_name, cluster_version)
  if cluster_name == nil || cluster_version == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("POST", "/api/v1/clusters/#{cluster_name}", "{\"Clusters\": {\"version\" : \"#{cluster_version}\"}}")
end

#define_service(cluster_name, service_name) ⇒ Object

Defines a new service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service to define.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



429
430
431
432
433
434
435
# File 'lib/receiver/ambari_rest_api_connector.rb', line 429

def define_service(cluster_name, service_name)
  if service_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("POST", "/api/v1/clusters/#{cluster_name}/services/#{service_name}")
end

#delete_cluster(cluster_name) ⇒ Object

Deletes a new cluster.

Parameters:

  • cluster_name

    The name of the cluster to be deleted.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



123
124
125
126
127
128
129
# File 'lib/receiver/ambari_rest_api_connector.rb', line 123

def delete_cluster(cluster_name)
  if cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}")
end

#delete_host(cluster_name, host_name) ⇒ Object

Deletes an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host to delete.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



269
270
271
272
273
274
275
# File 'lib/receiver/ambari_rest_api_connector.rb', line 269

def delete_host(cluster_name, host_name)
  if host_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}")
end

#delete_host_component(cluster_name, host_name, component_name) ⇒ Object

Deletes a component from an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

  • component_name

    The name of the component to delete.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



253
254
255
256
257
258
259
# File 'lib/receiver/ambari_rest_api_connector.rb', line 253

def delete_host_component(cluster_name, host_name, component_name)
  if host_name == nil || component_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}/host_components/#{component_name}")
end

#delete_service(cluster_name, service_name) ⇒ Object

Deletes a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service to delete.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



445
446
447
448
449
450
451
# File 'lib/receiver/ambari_rest_api_connector.rb', line 445

def delete_service(cluster_name, service_name)
  if service_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("DELETE", "/api/v1/clusters/#{cluster_name}/services/#{service_name}")
end

#detach_host_component(cluster_name, host_name, component_name) ⇒ Object

Detachs a component of an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

  • component_name

    The name of the component to detach.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer0



325
326
327
# File 'lib/receiver/ambari_rest_api_connector.rb', line 325

def detach_host_component(cluster_name, host_name, component_name)
  return set_status_host_component(cluster_name, host_name, component_name, "MAINTENANCE")
end

#get_cluster_configuration(cluster_name, type, tag) ⇒ Object

Launches a GET request on a specifique configuration.

Parameters:

  • cluster_name

    The name of the cluster.

  • type

    The type of configuration.

  • tag

    The tag ot configuration.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



155
156
157
158
159
160
161
# File 'lib/receiver/ambari_rest_api_connector.rb', line 155

def get_cluster_configuration(cluster_name, type, tag)
  if cluster_name == nil || type == nil || tag == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}/configurations?type=#{type}&tag=#{tag}")
end

#install_host_component(cluster_name, host_name, component_name) ⇒ Object

Installs a component of an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

  • component_name

    The name of the component to install.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



286
287
288
# File 'lib/receiver/ambari_rest_api_connector.rb', line 286

def install_host_component(cluster_name, host_name, component_name)
  return set_status_host_component(cluster_name, host_name, component_name, "INSTALLED")
end

#install_service(cluster_name, service_name) ⇒ Object

Installs a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service to install.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



461
462
463
# File 'lib/receiver/ambari_rest_api_connector.rb', line 461

def install_service(cluster_name, service_name)
  return set_status_service(cluster_name, service_name, "INSTALLED")
end

#install_service_components(cluster_name, service_name, component_name) ⇒ Object

Installs a type of components of a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

  • component_name

    The name of the components to install.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



516
517
518
# File 'lib/receiver/ambari_rest_api_connector.rb', line 516

def install_service_components(cluster_name, service_name, component_name)
  return set_status_service_components(cluster_name, service_name, component_name, "INSTALLED")
end

#list_clustersObject

Shows the list of clusters.

Returns:

  • The http response.

Raises:

Author:

  • tnoguer



223
224
225
# File 'lib/receiver/ambari_rest_api_connector.rb', line 223

def list_clusters
  return launch_request("GET", "/api/v1/clusters")
end

#set_status_host_component(cluster_name, host_name, component_name, status) ⇒ Object (private)

Set the status of a component of an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

  • component_name

    The name of the component.

  • status

    The status to set. (INSTALLED, STARTED, MAINTENANCE)

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



339
340
341
342
343
344
345
346
# File 'lib/receiver/ambari_rest_api_connector.rb', line 339

def set_status_host_component(cluster_name, host_name, component_name, status)
  if host_name == nil || component_name == nil || cluster_name == nil || status == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("PUT", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}/host_components/#{component_name}",
                        "{ \"HostRoles\" : { \"state\" : \"#{status}\"}}")
end

#set_status_service(cluster_name, service_name, status) ⇒ Object (private)

Set the status of a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

  • status

    The status to set. (INSTALLED STARTED)

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



498
499
500
501
502
503
504
505
# File 'lib/receiver/ambari_rest_api_connector.rb', line 498

def set_status_service(cluster_name, service_name, status)
  if service_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("PUT", "/api/v1/clusters/#{cluster_name}/services/#{service_name}",
                        "{\"ServiceInfo\": {\"state\" : \"#{status}\"}}")
end

#set_status_service_components(cluster_name, service_name, component_name, status) ⇒ Object (private)

Set the status of a type of components of a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

  • component_name

    The name of the components.

  • status

    The status to set. (INSTALLED STARTED)

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



556
557
558
559
560
561
562
563
# File 'lib/receiver/ambari_rest_api_connector.rb', line 556

def set_status_service_components(cluster_name, service_name, component_name, status)
  if service_name == nil || cluster_name == nil || component_name == nil || status == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("PUT", "/api/v1/clusters/#{cluster_name}/services/#{service_name}/components/#{component_name}",
                        "{\"ServiceComponentInfo\": {\"state\" : \"#{status}\"}}")
end

#show_cluster(cluster_name, show_host = false, show_components = false) ⇒ Object

Shows the information of a cluster.

Parameters:

  • cluster_name

    The name of the cluster.

  • show_host (defaults to: false)

    True to show the detail of the hosts. False otherwise.

  • show_components (defaults to: false)

    True to show the detail of the components. False otherwise.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/receiver/ambari_rest_api_connector.rb', line 204

def show_cluster(cluster_name, show_host=false, show_components=false)
  if cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  show_host = false unless show_host
  show_components = false unless show_components
  fields = "?fields=*"
  fields += ",services/*" if show_components
  fields += ",services/components/*" if show_host

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}#{fields}")
end

#show_cluster_services(cluster_name) ⇒ Object

Shows the services of a cluster.

Parameters:

  • cluster_name

    The name of the cluster.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



138
139
140
141
142
143
144
# File 'lib/receiver/ambari_rest_api_connector.rb', line 138

def show_cluster_services(cluster_name)
  if cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}/services")
end

#show_host(cluster_name, host_name) ⇒ Object

Shows information of an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



395
396
397
398
399
400
401
# File 'lib/receiver/ambari_rest_api_connector.rb', line 395

def show_host(cluster_name, host_name)
  if host_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}/hosts/#{host_name}?fields=*,host_components/*")
end

#show_request(cluster_name, request_id) ⇒ Object

Shows the information of a request.

Parameters:

  • cluster_name

    The name of the cluster.

  • request_id

    The ID of the request.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



186
187
188
189
190
191
192
# File 'lib/receiver/ambari_rest_api_connector.rb', line 186

def show_request(cluster_name, request_id)
  if cluster_name == nil || request_id == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}/requests/#{request_id}?fields=tasks/*")
end

#show_requests(cluster_name) ⇒ Object

Shows the requests of a cluster.

Parameters:

  • cluster_name

    The name of the cluster.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



170
171
172
173
174
175
176
# File 'lib/receiver/ambari_rest_api_connector.rb', line 170

def show_requests(cluster_name)
  if cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}/requests")
end

#show_service(cluster_name, service_name) ⇒ Object

Shows the list of service of a cluster.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



590
591
592
593
594
595
596
# File 'lib/receiver/ambari_rest_api_connector.rb', line 590

def show_service(cluster_name, service_name)
  if service_name == nil || cluster_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}/services/#{service_name}?fields=*,components/ServiceComponentInfo,components/host_components/*")
end

#show_service_components(cluster_name, service_name, component_name) ⇒ Object

Shows information of a type of components of a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

  • component_name

    The name of the components.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



574
575
576
577
578
579
580
# File 'lib/receiver/ambari_rest_api_connector.rb', line 574

def show_service_components(cluster_name, service_name, component_name)
  if service_name == nil || cluster_name == nil ||component_name == nil
    raise(ArgumentError, 'Arguments can\'t be nil!')
  end

  return launch_request("GET", "/api/v1/clusters/#{cluster_name}/services/#{service_name}/components/#{component_name}?fields=host_components/*")
end

#start_host_component(cluster_name, host_name, component_name) ⇒ Object

Starts a component of an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

  • component_name

    The name of the component to start.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



299
300
301
# File 'lib/receiver/ambari_rest_api_connector.rb', line 299

def start_host_component(cluster_name, host_name, component_name)
  return set_status_host_component(cluster_name, host_name, component_name, "STARTED")
end

#start_service(cluster_name, service_name) ⇒ Object

Starts a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service to start.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



473
474
475
# File 'lib/receiver/ambari_rest_api_connector.rb', line 473

def start_service(cluster_name, service_name)
  return set_status_service(cluster_name, service_name, "STARTED")
end

#start_service_components(cluster_name, service_name, component_name) ⇒ Object

Starts a type of components of a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

  • component_name

    The name of the components to start.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



529
530
531
# File 'lib/receiver/ambari_rest_api_connector.rb', line 529

def start_service_components(cluster_name, service_name, component_name)
  return set_status_service_components(cluster_name, service_name, component_name, "STARTED")
end

#stop_host_component(cluster_name, host_name, component_name) ⇒ Object

Stops a component of an host.

Parameters:

  • cluster_name

    The name of the cluster.

  • host_name

    The name of the host.

  • component_name

    The name of the component to stop.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



312
313
314
# File 'lib/receiver/ambari_rest_api_connector.rb', line 312

def stop_host_component(cluster_name, host_name, component_name)
  return set_status_host_component(cluster_name, host_name, component_name, "INSTALLED")
end

#stop_service(cluster_name, service_name) ⇒ Object

Stops a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service to stop.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



485
486
487
# File 'lib/receiver/ambari_rest_api_connector.rb', line 485

def stop_service(cluster_name, service_name)
  return set_status_service(cluster_name, service_name, "INSTALLED")
end

#stop_service_components(cluster_name, service_name, component_name) ⇒ Object

Stops a type of components of a service.

Parameters:

  • cluster_name

    The name of the cluster.

  • service_name

    The name of the service.

  • component_name

    The name of the components to stops.

Returns:

  • The http response.

Raises:

  • (ArgumentError)

    If any argument is nil.

  • (HTTPError)

    If the request is invalid.

Author:

  • tnoguer



542
543
544
# File 'lib/receiver/ambari_rest_api_connector.rb', line 542

def stop_service_components(cluster_name, service_name, component_name)
  return set_status_service_components(cluster_name, service_name, component_name, "INSTALLED")
end