Class: Exec::ServiceInstall

Inherits:
ExecutableCommand show all
Defined in:
lib/exec/service_install.rb

Overview

Allows the user to install services.

Author:

  • tnoguer

Instance Attribute Summary

Attributes inherited from ExecutableCommand

#argv, #command_name, #logger, #options, #stderr, #stdin, #stdout, #values

Instance Method Summary collapse

Methods inherited from ExecutableCommand

#check_parameters, #create_logger, #initialize, #run

Constructor Details

This class inherits a constructor from Exec::ExecutableCommand

Instance Method Details

#execObject (private)

Execution of the command



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/exec/service_install.rb', line 35

def exec
  msg = "Unknown combination of attributes... (should never happend)"
  cmd = nil

  if (!@values["host"].nil? && !@values["component"].nil?) || (!@values["service"].nil? && !@values["host"].nil? && !@values["component"].nil?)
    # 3
    # one component on one host
    msg = "Install components #{@values["component"]} on host #{@values["host"]} (@cluster #{@values["cluster"]})."
    cmd = Command::AmbariInstallHostComponent.new(@values["cluster"], @values["component"], @values["host"])

  elsif !@values["component"].nil? || (!@values["service"].nil? && !@values["component"].nil?)
    # 1
    # one component on all hosts
    msg = "Install all components (@cluster #{@values["cluster"]})."
    cmd = Command::AmbariInstallComponent.new(@values["cluster"], @values["component"])

  elsif !@values["service"].nil? && !@values["host"].nil?
    # 5
    # all component on one host for one service
    # @todo it is the same case than number 3
    msg = "Install components #{@values["component"]} of service #{@values["service"]} on host #{@values["host"]} (@cluster #{@values["cluster"]})."
    cmd = Command::AmbariInstallHostComponents.new(@values["cluster"], @values["service"], @values["host"])

  elsif !@values["host"].nil?
    # 2
    # all component on one host
    msg = "Install all components on host #{@values["host"]} (@cluster #{@values["cluster"]})."
    cmd = Command::AmbariInstallHost.new(@values["cluster"], @values["host"])

  elsif !@values["service"].nil?
    # 4
    # all component on all hosts for one service
    msg = "Install all components #{@values["component"]} of service #{@values["service"]} on all hosts (@cluster #{@values["cluster"]})."
    cmd = Command::AmbariInstallServiceComponents.new(@values["cluster"], @values["service"])

  elsif @values["service"].nil? && @values["host"].nil? && @values["component"].nil?
    # 6
    # all component on all host for all service
    msg = "Install all components of all services on all hosts (@cluster #{@values["cluster"]})."
    cmd = Command::AmbariInstallCluster.new(@values["cluster"])

  else
    raise StandardError(msg)
  end

  Color::print_log("NONE", msg, @stdout)
  cmd.exec()
  Color::echo_ok(@stdout)

end

#set_optionsObject (private)

Parse and check the parameters of the function.

Author:

  • tmarmin



24
25
26
27
28
29
30
31
# File 'lib/exec/service_install.rb', line 24

def set_options
  @logger.info("setting options")
  @options.add_option("C", "cluster", "The virtual cluster name.", true, true, method(:check_cluster_name))
  @options.add_option("s", "service", "Limit request to this service.", false, true, method(:check_hadoop_service_name))
  @options.add_option("H", "host", "Limit request to this host.", false, true, method(:check_ambari_host_name))
  @options.add_option("c", "component", "Limit request to this component type.", false, true, method(:check_hadoop_component_name))
  @options.add_option("f", "follow", "Follow completion of the request.", false)
end