cloudbox-server 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,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_detach'
7
+
8
+ include Exec::CheckParameter
9
+
10
+ module Exec
11
+ # Allows the user to detach a service component.
12
+ class ServiceComponentDetach < 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::AmbariServiceComponentDetach.new(@values["cluster"], @values["component"], @values["host"])
31
+ cmd.exec()
32
+ Color::echo_ok(@stdout)
33
+ @stdout.puts("Component #{@values["component"]} has been successfully detached from host #{@values["host"]} in cluster #{@values["cluster"]}.")
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,57 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'exec/executable_command'
5
+ require 'exec/command_option'
6
+ require 'exec/check_parameter'
7
+ require 'common/cloudbox_exceptions'
8
+ require 'command/ambari_service_conf_apply'
9
+
10
+ include Exec::CheckParameter
11
+
12
+ #
13
+ # @author mbretaud
14
+ module Exec
15
+ # Allows the user to apply a configuration on a cluster.
16
+ # @author mbretaud
17
+ class ServiceConfApply < ExecutableCommand
18
+
19
+ private
20
+ # Parse and check the parameters of the function.
21
+ # @author mbretaud
22
+ def set_options
23
+ @logger.info("setting options")
24
+ @options.add_option("C", "cluster", "The cluster name.", true, true, method(:check_cluster_name))
25
+ @options.add_option("T", "type", "The type of the configuration.", true, true)
26
+ @options.add_option("t", "tag", "The tag of the configuration.", true, true)
27
+ end
28
+
29
+ public
30
+ # The execution of the command.
31
+ # @author mbretaud
32
+ def exec
33
+ Color::print_log("NONE", "Applying configuration to the cluster '#{@values["cluster"]}'", @stdout)
34
+
35
+ if !@values["cluster"].nil? && !@values["type"].nil? && !@values["tag"].nil?
36
+ apply_configuration(@values["cluster"], @values["type"], @values["tag"])
37
+ Color::echo_ok(@stdout)
38
+ else
39
+ raise ArgumentError.new("Arguments can't be nil!")
40
+ end
41
+ end
42
+
43
+ private
44
+ # Applies a service configuration.
45
+ # @param cluster_name The name of the cluster.
46
+ # @param type_conf The type of configuration.
47
+ # @param tag_conf The tag ot configuration.
48
+ # @author mbretaud
49
+ def apply_configuration(cluster_name = @values["cluster"], type_conf = @values["type"], tag_conf = @values["tag"])
50
+ @logger.begin_main_step("applyConfigurations")
51
+ command = Command::AmbariServiceConfApply.new(cluster_name, type_conf, tag_conf)
52
+ command.exec()
53
+ @logger.end_main_step("applyConfigurations")
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,80 @@
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_create_cluster_configuration'
9
+ require 'json'
10
+
11
+ #require 'command/ambari_get_cluster_configuration'
12
+
13
+ include Exec::CheckParameter
14
+
15
+ module Exec
16
+ # Allows the user to create a service configuration.
17
+ class ServiceConfCreate < ExecutableCommand
18
+
19
+ private
20
+ # @todo Use relative path technique for the attribute below
21
+ @configuration_directory
22
+
23
+ public
24
+ # Default constructor.
25
+ # @param argv The arguments of the command.
26
+ # @param stdin [IO] The input stream of the command.
27
+ # @param stdout [IO] The output stream of the command.
28
+ # @param stderr [IO] The error stream of the command.
29
+ # @param command_name [String] The name of the executed command.
30
+ # @author aboudot
31
+ def initialize(argv, stdin, stdout, stderr, command_name)
32
+ super(argv, stdin, stdout, stderr, command_name)
33
+ @configuration_directory = File.dirname(__FILE__) + "/../../resources/ambari-configurations"
34
+ end
35
+
36
+ private
37
+ # Parse and check the parameters of the function.
38
+ # @author aboudot
39
+ def set_options
40
+ @logger.info("setting options")
41
+ @options.add_option("C", "cluster", "The virtual cluster name where to get configuration.", true, true, method(:check_cluster_name))
42
+ @options.add_option("T", "type", "The type that will be get.", true, true)
43
+ @options.add_option("t", "tag", "The tag that will be get.", true, true)
44
+ @options.add_option("f", "fileName", "The path and fileName where you save configuration.", false, true)
45
+ @options.add_option("a", "Apply", "Apply configuration to a cluster", false, false)
46
+ end
47
+
48
+
49
+ # Execution of the command
50
+ def exec()
51
+
52
+ if !@values["cluster"].nil? && !@values["type"].nil? && !@values["tag"].nil? && !@values["fileName"].nil?
53
+ Color::print_log("NONE", "Create a configuration on a cluster...", @stdout)
54
+ properties=read_files(@values["fileName"])
55
+ cmd=Command::AmbariCreateClusterConfiguration.new(@values['cluster'], @values['type'], @values['tag'], properties, @values['Apply'])
56
+ cmd.exec()
57
+ end
58
+ end
59
+
60
+ # Reads a json configuration file and returns its content.
61
+ # @param path The path to the file.
62
+ # @return The content of the file.
63
+ def read_files(path)
64
+ if File.exists?(path)
65
+ begin
66
+ f = nil
67
+ f = File.open(path, "r")
68
+ p=JSON.parse(f.read)
69
+ return p
70
+ rescue => e
71
+ raise e
72
+ else
73
+ f.close()
74
+ end
75
+ end
76
+ end
77
+
78
+ end
79
+ end
80
+
@@ -0,0 +1,165 @@
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_get_cluster_configuration'
9
+ require 'json'
10
+
11
+ include Exec::CheckParameter
12
+
13
+ module Exec
14
+ # Allows the user to get the properties of a service configuration.
15
+ class ServiceConfGet < ExecutableCommand
16
+
17
+ # @todo Use relative path technique for the attribute below
18
+ @configuration_directory
19
+
20
+ public
21
+ # Default constructor.
22
+ # @param argv The arguments of the command.
23
+ # @param stdin [IO] The input stream of the command.
24
+ # @param stdout [IO] The output stream of the command.
25
+ # @param stderr [IO] The error stream of the command.
26
+ # @param command_name [String] The name of the executed command.
27
+ # @author aboudot
28
+ def initialize(argv, stdin, stdout, stderr, command_name)
29
+ super(argv, stdin, stdout, stderr, command_name)
30
+ @configuration_directory = File.dirname(__FILE__) + "/../../resources/ambari-configurations"
31
+ end
32
+
33
+ private
34
+ # Parse and check the parameters of the function.
35
+ # @author aboudot
36
+ def set_options
37
+ @logger.info("setting options")
38
+ @options.add_option("C", "cluster", "The virtual cluster name where to get configuration.", true, true, method(:check_cluster_name))
39
+ @options.add_option("T", "type", "The type that will be get.", true, true)
40
+ @options.add_option("t", "tag", "The tag that will be get.", true, true)
41
+ @options.add_option("f", "file", "The the path and fileName where you save configuration.", false, true)
42
+ end
43
+
44
+
45
+ # Execution of the command
46
+ def exec()
47
+
48
+ if !@values["cluster"].nil? && !@values["type"].nil? && !@values["tag"].nil? && @values["file"].nil?
49
+ Color::print_log("NONE", "Display a configuration on the cluster '#{@values["cluster"]}'...", @stdout)
50
+
51
+ output = display_configurations(@values["cluster"], @values["type"], @values["tag"], "\t - ")
52
+
53
+ Color::echo_ok(@stdout)
54
+
55
+ output.each{|conf|
56
+ @stdout.print conf
57
+ }
58
+ elsif !@values["cluster"].nil? && !@values["type"].nil? && !@values["tag"].nil? && !@values["file"].nil?
59
+ begin
60
+ Color::print_log("NONE", "Save a configuration in file...", @stdout)
61
+
62
+ if store_configuration(values["cluster"], @values["type"], @values["tag"], @values["file"])
63
+ Color::echo_ok(@stdout)
64
+ else
65
+ Color::echo_fail(@stdout)
66
+ end
67
+ rescue => e
68
+ @logger.debug(e.message)
69
+ @logger.debug(e.backtrace.join('/n'))
70
+ raise e
71
+ end
72
+ end
73
+ end
74
+
75
+ private
76
+ # display the configurations of a cluster.
77
+ # @param cluster_name The name of the cluster.
78
+ # @param prefix The prefix to display.
79
+ # @return output The output string to display.
80
+ # @author mbretaud
81
+ def display_configurations(cluster_name = @values["cluster"], type_conf = @values["type"], tag_conf = @values["tag"], prefix = '')
82
+ @logger.begin_main_step("listConfigurations")
83
+ begin
84
+ properties = Array.new
85
+ output = Array.new
86
+
87
+ cmd = Command::AmbariGetClusterConfiguration.new(cluster_name, type_conf, tag_conf)
88
+
89
+ data = cmd.exec()
90
+
91
+ return "No properties available on the cluster '#{cluster_name}' with type '#{type_conf}' and tag '#{tag_conf}'.\n" if data.nil? || data.empty?
92
+
93
+ data.each do |name, valeur|
94
+ properties << "#{name} : #{valeur}\n"
95
+ end
96
+ rescue => e
97
+ raise e
98
+ end
99
+
100
+ @logger.debug("configuration list output: #{output}")
101
+ @logger.end_main_step("listConfigurations")
102
+
103
+ properties = properties.sort
104
+
105
+ output << ""
106
+ output << "Configurations available on the cluster '#{cluster_name}' :"
107
+ output << "\n\n"
108
+ output << "#{prefix}Type : #{type_conf}\n"
109
+ output << "#{prefix}Tag : #{tag_conf}\n"
110
+ output << "\n"
111
+ output << "#{prefix}[PROPERTIES : VALUE]\n"
112
+ properties.each{|propertie|
113
+ output << "#{prefix}#{propertie}"
114
+ }
115
+ output << "\n"
116
+
117
+ return output
118
+ end
119
+
120
+ public
121
+ # Store the configuration in a file
122
+ # @param cluster_name The name of the cluster
123
+ # @param type_conf The name of the type of the configuration
124
+ # @param tag_conf The name of the tag of the configuration
125
+ # @author mbretaud
126
+ def store_configuration(cluster_name = @values["cluster"], type_conf = @values["type"], tag_conf = @values["tag"], file_name = nil)
127
+ cmd=Command::AmbariGetClusterConfiguration.new(cluster_name, type_conf, tag_conf)
128
+
129
+ data = cmd.exec()
130
+
131
+ begin
132
+ return true if create_file(file_name, data)
133
+ rescue => e
134
+ raise e
135
+ return false
136
+ end
137
+
138
+ return true
139
+ end
140
+
141
+ private
142
+ # Create a file configuration.
143
+ # @param path The path of the file.
144
+ # @param p The json data.
145
+ # @author mbretaud
146
+ def create_file(path, p)
147
+ if File.exists?(path)
148
+ raise Common::FileError.new("File already exists in #{path}!")
149
+ else
150
+ f = nil
151
+ begin
152
+ f = File.new(path.to_s, "w")
153
+ f.puts(JSON.pretty_generate(p))
154
+ rescue => e
155
+ raise e
156
+ return false
157
+ else
158
+ f.close()
159
+ end
160
+ end
161
+
162
+ return true
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,103 @@
1
+ # This file is part of cloudbox-server project
2
+ # @author mbretaud (INGENSI)
3
+
4
+ require 'exec/executable_command'
5
+ require 'exec/command_option'
6
+ require 'exec/check_parameter'
7
+ require 'common/cloudbox_exceptions'
8
+ require 'command/ambari_service_conf_ls'
9
+ require 'json'
10
+
11
+ include Exec::CheckParameter
12
+
13
+ #
14
+ # @author mbretaud
15
+ module Exec
16
+ # Allows the user to display a configuration about cluster.
17
+ # @author mbretaud
18
+ class ServiceConfLs < ExecutableCommand
19
+
20
+ private
21
+ # Parse and check the parameters of the function.
22
+ # @author mbretaud
23
+ def set_options
24
+ @logger.info("setting options")
25
+ @options.add_option("C", "cluster", "The cluster name.", true, true, method(:check_cluster_name))
26
+ end
27
+
28
+ public
29
+ # The execution of the command.
30
+ # @author mbretaud
31
+ def exec
32
+ Color::print_log("NONE", "Display a configuration about the cluster '#{@values["cluster"]}'", @stdout)
33
+
34
+ if !@values["cluster"].nil?
35
+ output = display_configurations(@values["cluster"], "\t - ")
36
+ end
37
+
38
+ Color::echo_ok(@stdout)
39
+
40
+ output.each{|conf|
41
+ @stdout.print conf
42
+ }
43
+ end
44
+
45
+ private
46
+ # display the configurations of a cluster.
47
+ # @param cluster_name The name of the cluster.
48
+ # @param prefix The prefix to display.
49
+ # @return output The output string to display.
50
+ # @author mbretaud
51
+ def display_configurations(cluster_name = @values["cluster"], prefix = '')
52
+ @logger.begin_main_step("listConfigurations")
53
+ begin
54
+ configs = Array.new
55
+ output = Array.new
56
+
57
+ command = Command::AmbariServiceConfLs.new(cluster_name)
58
+ data = command.exec()
59
+
60
+ return "No configurations available on the cluster '#{cluster_name}'.\n" if data.nil? || data.empty?
61
+
62
+ error = false
63
+ data.each{|conf|
64
+ if !conf['active'].nil?
65
+ if conf['active']
66
+ active = Color::color_green("[Active]")
67
+ configs << "#{prefix}#{conf['type']} : #{conf['tag']} #{active}\n"
68
+ else
69
+ configs << "#{prefix}#{conf['type']} : #{conf['tag']} [Not Active]\n"
70
+ end
71
+ else
72
+ error = true
73
+ end
74
+ }
75
+ rescue => e
76
+ raise e
77
+ end
78
+
79
+ @logger.debug("configuration list output: #{output}")
80
+ @logger.end_main_step("listConfigurations")
81
+
82
+ if error
83
+ output << ""
84
+ output << "Error: Retrieve the configuration on the cluster '#{cluster_name}'."
85
+ output << "\n"
86
+ else
87
+ configs = configs.sort
88
+
89
+ output << ""
90
+ output << "Configurations available on the cluster '#{cluster_name}' :"
91
+ output << "\n\n"
92
+ output << "#{prefix}[TYPE : TAG] [Status]\n"
93
+ configs.each{|conf|
94
+ output << conf
95
+ }
96
+ output << "\n"
97
+ end
98
+
99
+ return output
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,49 @@
1
+ # This file is part of cloudbox-service project
2
+ # @author tmarmin (INGENSI)
3
+
4
+ require 'exec/executable_command'
5
+ require 'exec/command_option'
6
+ require 'exec/check_parameter'
7
+ require 'common/cloudbox_exceptions'
8
+
9
+ include Exec::CheckParameter
10
+
11
+ module Exec
12
+ # Allows the user to follow the completion of a request.
13
+ # @author tnoguer
14
+ class ServiceFollowRequest < ExecutableCommand
15
+
16
+ private
17
+ # Parse and check the parameters of the function.
18
+ # @author tmarmin
19
+ def set_options
20
+ @logger.info("setting options")
21
+ @options.add_option("C", "cluster", "The virtual cluster name.", true, true, method(:check_cluster_name))
22
+ @options.add_option("r", "request", "The request ID.", true, true, method(:check_request_id))
23
+ @options.add_option("l", "list", "List all requests.", false)
24
+ end
25
+
26
+ private
27
+ # Execution of the command
28
+ def exec
29
+ Color::print_log("NONE", "following request...", @stdout)
30
+ raise NotImplemented # @todo Implement ServiceFollowRequest Exec body
31
+ end
32
+
33
+ private
34
+ # Inherited CommandOption used only by ServiceFollowRequest.
35
+ class CustomCommandOption < CommandOption
36
+
37
+ protected
38
+ # This method overrides the default behaviour.
39
+ # @raise [Common::MissingParameter] Never raise exception for the moment :)
40
+ def check_mandatory
41
+ if if !@values["help"] && !@values["list"]
42
+ raise Common::MissingParameter.new("-C", get_help()) if @values["cluster"].nil?
43
+ raise Common::MissingParameter.new("-r", get_help()) if @values["request"].nil?
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end