crowbar-client 1.0.0

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 (232) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6 -0
  3. data/LICENSE +202 -0
  4. data/README.md +49 -0
  5. data/bin/crowbar +37 -0
  6. data/lib/crowbar-client.rb +17 -0
  7. data/lib/crowbar/client.rb +82 -0
  8. data/lib/crowbar/client/app.rb +60 -0
  9. data/lib/crowbar/client/app/barclamp.rb +77 -0
  10. data/lib/crowbar/client/app/base.rb +97 -0
  11. data/lib/crowbar/client/app/batch.rb +100 -0
  12. data/lib/crowbar/client/app/entry.rb +121 -0
  13. data/lib/crowbar/client/app/host_ip.rb +65 -0
  14. data/lib/crowbar/client/app/interface.rb +63 -0
  15. data/lib/crowbar/client/app/network.rb +35 -0
  16. data/lib/crowbar/client/app/node.rb +451 -0
  17. data/lib/crowbar/client/app/proposal.rb +300 -0
  18. data/lib/crowbar/client/app/repository.rb +149 -0
  19. data/lib/crowbar/client/app/reset.rb +58 -0
  20. data/lib/crowbar/client/app/role.rb +140 -0
  21. data/lib/crowbar/client/app/virtual_ip.rb +65 -0
  22. data/lib/crowbar/client/command.rb +54 -0
  23. data/lib/crowbar/client/command/barclamp.rb +26 -0
  24. data/lib/crowbar/client/command/barclamp/list.rb +64 -0
  25. data/lib/crowbar/client/command/base.rb +55 -0
  26. data/lib/crowbar/client/command/batch.rb +29 -0
  27. data/lib/crowbar/client/command/batch/build.rb +36 -0
  28. data/lib/crowbar/client/command/batch/export.rb +36 -0
  29. data/lib/crowbar/client/command/host_ip.rb +29 -0
  30. data/lib/crowbar/client/command/host_ip/allocate.rb +50 -0
  31. data/lib/crowbar/client/command/host_ip/deallocate.rb +42 -0
  32. data/lib/crowbar/client/command/interface.rb +29 -0
  33. data/lib/crowbar/client/command/interface/disable.rb +42 -0
  34. data/lib/crowbar/client/command/interface/enable.rb +50 -0
  35. data/lib/crowbar/client/command/node.rb +74 -0
  36. data/lib/crowbar/client/command/node/allocate.rb +48 -0
  37. data/lib/crowbar/client/command/node/delete.rb +44 -0
  38. data/lib/crowbar/client/command/node/hardware.rb +48 -0
  39. data/lib/crowbar/client/command/node/identify.rb +48 -0
  40. data/lib/crowbar/client/command/node/list.rb +71 -0
  41. data/lib/crowbar/client/command/node/powercycle.rb +48 -0
  42. data/lib/crowbar/client/command/node/poweroff.rb +48 -0
  43. data/lib/crowbar/client/command/node/poweron.rb +48 -0
  44. data/lib/crowbar/client/command/node/reboot.rb +48 -0
  45. data/lib/crowbar/client/command/node/reinstall.rb +48 -0
  46. data/lib/crowbar/client/command/node/rename.rb +44 -0
  47. data/lib/crowbar/client/command/node/reset.rb +48 -0
  48. data/lib/crowbar/client/command/node/role.rb +44 -0
  49. data/lib/crowbar/client/command/node/show.rb +67 -0
  50. data/lib/crowbar/client/command/node/shutdown.rb +48 -0
  51. data/lib/crowbar/client/command/node/status.rb +71 -0
  52. data/lib/crowbar/client/command/node/transition.rb +44 -0
  53. data/lib/crowbar/client/command/proposal.rb +44 -0
  54. data/lib/crowbar/client/command/proposal/commit.rb +50 -0
  55. data/lib/crowbar/client/command/proposal/create.rb +130 -0
  56. data/lib/crowbar/client/command/proposal/delete.rb +48 -0
  57. data/lib/crowbar/client/command/proposal/dequeue.rb +48 -0
  58. data/lib/crowbar/client/command/proposal/edit.rb +129 -0
  59. data/lib/crowbar/client/command/proposal/list.rb +68 -0
  60. data/lib/crowbar/client/command/proposal/show.rb +71 -0
  61. data/lib/crowbar/client/command/repository.rb +38 -0
  62. data/lib/crowbar/client/command/repository/activate.rb +44 -0
  63. data/lib/crowbar/client/command/repository/activate_all.rb +42 -0
  64. data/lib/crowbar/client/command/repository/deactivate.rb +44 -0
  65. data/lib/crowbar/client/command/repository/deactivate_all.rb +42 -0
  66. data/lib/crowbar/client/command/repository/list.rb +71 -0
  67. data/lib/crowbar/client/command/reset.rb +29 -0
  68. data/lib/crowbar/client/command/reset/nodes.rb +36 -0
  69. data/lib/crowbar/client/command/reset/proposal.rb +36 -0
  70. data/lib/crowbar/client/command/role.rb +29 -0
  71. data/lib/crowbar/client/command/role/list.rb +70 -0
  72. data/lib/crowbar/client/command/role/show.rb +70 -0
  73. data/lib/crowbar/client/command/virtual_ip.rb +29 -0
  74. data/lib/crowbar/client/command/virtual_ip/allocate.rb +50 -0
  75. data/lib/crowbar/client/command/virtual_ip/deallocate.rb +42 -0
  76. data/lib/crowbar/client/config.rb +178 -0
  77. data/lib/crowbar/client/filter.rb +33 -0
  78. data/lib/crowbar/client/filter/array.rb +29 -0
  79. data/lib/crowbar/client/filter/base.rb +41 -0
  80. data/lib/crowbar/client/filter/hash.rb +33 -0
  81. data/lib/crowbar/client/filter/subset.rb +45 -0
  82. data/lib/crowbar/client/formatter.rb +33 -0
  83. data/lib/crowbar/client/formatter/array.rb +49 -0
  84. data/lib/crowbar/client/formatter/base.rb +47 -0
  85. data/lib/crowbar/client/formatter/hash.rb +51 -0
  86. data/lib/crowbar/client/formatter/nested.rb +134 -0
  87. data/lib/crowbar/client/mixin.rb +30 -0
  88. data/lib/crowbar/client/mixin/barclamp.rb +41 -0
  89. data/lib/crowbar/client/mixin/filter.rb +33 -0
  90. data/lib/crowbar/client/mixin/format.rb +56 -0
  91. data/lib/crowbar/client/request.rb +57 -0
  92. data/lib/crowbar/client/request/barclamp.rb +26 -0
  93. data/lib/crowbar/client/request/barclamp/list.rb +35 -0
  94. data/lib/crowbar/client/request/base.rb +71 -0
  95. data/lib/crowbar/client/request/batch.rb +29 -0
  96. data/lib/crowbar/client/request/batch/build.rb +33 -0
  97. data/lib/crowbar/client/request/batch/export.rb +33 -0
  98. data/lib/crowbar/client/request/host_ip.rb +29 -0
  99. data/lib/crowbar/client/request/host_ip/allocate.rb +50 -0
  100. data/lib/crowbar/client/request/host_ip/deallocate.rb +48 -0
  101. data/lib/crowbar/client/request/interface.rb +29 -0
  102. data/lib/crowbar/client/request/interface/disable.rb +48 -0
  103. data/lib/crowbar/client/request/interface/enable.rb +48 -0
  104. data/lib/crowbar/client/request/node.rb +47 -0
  105. data/lib/crowbar/client/request/node/action.rb +39 -0
  106. data/lib/crowbar/client/request/node/delete.rb +38 -0
  107. data/lib/crowbar/client/request/node/list.rb +37 -0
  108. data/lib/crowbar/client/request/node/rename.rb +47 -0
  109. data/lib/crowbar/client/request/node/role.rb +47 -0
  110. data/lib/crowbar/client/request/node/show.rb +38 -0
  111. data/lib/crowbar/client/request/node/status.rb +36 -0
  112. data/lib/crowbar/client/request/node/transition.rb +48 -0
  113. data/lib/crowbar/client/request/party.rb +79 -0
  114. data/lib/crowbar/client/request/proposal.rb +47 -0
  115. data/lib/crowbar/client/request/proposal/commit.rb +40 -0
  116. data/lib/crowbar/client/request/proposal/create.rb +46 -0
  117. data/lib/crowbar/client/request/proposal/delete.rb +39 -0
  118. data/lib/crowbar/client/request/proposal/dequeue.rb +40 -0
  119. data/lib/crowbar/client/request/proposal/edit.rb +47 -0
  120. data/lib/crowbar/client/request/proposal/list.rb +38 -0
  121. data/lib/crowbar/client/request/proposal/show.rb +39 -0
  122. data/lib/crowbar/client/request/proposal/template.rb +39 -0
  123. data/lib/crowbar/client/request/repository.rb +38 -0
  124. data/lib/crowbar/client/request/repository/activate.rb +46 -0
  125. data/lib/crowbar/client/request/repository/activate_all.rb +37 -0
  126. data/lib/crowbar/client/request/repository/deactivate.rb +46 -0
  127. data/lib/crowbar/client/request/repository/deactivate_all.rb +37 -0
  128. data/lib/crowbar/client/request/repository/list.rb +36 -0
  129. data/lib/crowbar/client/request/reset.rb +29 -0
  130. data/lib/crowbar/client/request/reset/nodes.rb +33 -0
  131. data/lib/crowbar/client/request/reset/proposal.rb +33 -0
  132. data/lib/crowbar/client/request/role.rb +29 -0
  133. data/lib/crowbar/client/request/role/list.rb +38 -0
  134. data/lib/crowbar/client/request/role/show.rb +39 -0
  135. data/lib/crowbar/client/request/virtual_ip.rb +29 -0
  136. data/lib/crowbar/client/request/virtual_ip/allocate.rb +50 -0
  137. data/lib/crowbar/client/request/virtual_ip/deallocate.rb +48 -0
  138. data/lib/crowbar/client/util.rb +27 -0
  139. data/lib/crowbar/client/util/editor.rb +107 -0
  140. data/lib/crowbar/client/util/runner.rb +77 -0
  141. data/lib/crowbar/client/version.rb +33 -0
  142. data/spec/crowbar/client/app_spec.rb +21 -0
  143. data/spec/crowbar/client/command/barclamp/list_spec.rb +39 -0
  144. data/spec/crowbar/client/command/batch/build_spec.rb +39 -0
  145. data/spec/crowbar/client/command/batch/export_spec.rb +39 -0
  146. data/spec/crowbar/client/command/host_ip/allocate_spec.rb +39 -0
  147. data/spec/crowbar/client/command/host_ip/deallocate_spec.rb +39 -0
  148. data/spec/crowbar/client/command/interface/disable_spec.rb +39 -0
  149. data/spec/crowbar/client/command/interface/enable_spec.rb +39 -0
  150. data/spec/crowbar/client/command/node/allocate_spec.rb +39 -0
  151. data/spec/crowbar/client/command/node/delete_spec.rb +39 -0
  152. data/spec/crowbar/client/command/node/hardware_spec.rb +39 -0
  153. data/spec/crowbar/client/command/node/identify_spec.rb +39 -0
  154. data/spec/crowbar/client/command/node/list_spec.rb +39 -0
  155. data/spec/crowbar/client/command/node/powercycle_spec.rb +39 -0
  156. data/spec/crowbar/client/command/node/poweroff_spec.rb +39 -0
  157. data/spec/crowbar/client/command/node/poweron_spec.rb +39 -0
  158. data/spec/crowbar/client/command/node/reboot_spec.rb +39 -0
  159. data/spec/crowbar/client/command/node/reinstall_spec.rb +39 -0
  160. data/spec/crowbar/client/command/node/rename_spec.rb +39 -0
  161. data/spec/crowbar/client/command/node/reset_spec.rb +39 -0
  162. data/spec/crowbar/client/command/node/role_spec.rb +39 -0
  163. data/spec/crowbar/client/command/node/show_spec.rb +39 -0
  164. data/spec/crowbar/client/command/node/shutdown_spec.rb +39 -0
  165. data/spec/crowbar/client/command/node/status_spec.rb +39 -0
  166. data/spec/crowbar/client/command/node/transition_spec.rb +39 -0
  167. data/spec/crowbar/client/command/proposal/commit_spec.rb +39 -0
  168. data/spec/crowbar/client/command/proposal/create_spec.rb +61 -0
  169. data/spec/crowbar/client/command/proposal/delete_spec.rb +39 -0
  170. data/spec/crowbar/client/command/proposal/dequeue_spec.rb +39 -0
  171. data/spec/crowbar/client/command/proposal/edit_spec.rb +62 -0
  172. data/spec/crowbar/client/command/proposal/list_spec.rb +39 -0
  173. data/spec/crowbar/client/command/proposal/show_spec.rb +39 -0
  174. data/spec/crowbar/client/command/repository/activate_all_spec.rb +39 -0
  175. data/spec/crowbar/client/command/repository/activate_spec.rb +39 -0
  176. data/spec/crowbar/client/command/repository/deactivate_all_spec.rb +39 -0
  177. data/spec/crowbar/client/command/repository/deactivate_spec.rb +39 -0
  178. data/spec/crowbar/client/command/repository/list_spec.rb +39 -0
  179. data/spec/crowbar/client/command/reset/nodes_spec.rb +39 -0
  180. data/spec/crowbar/client/command/reset/proposal_spec.rb +39 -0
  181. data/spec/crowbar/client/command/role/list_spec.rb +39 -0
  182. data/spec/crowbar/client/command/role/show_spec.rb +39 -0
  183. data/spec/crowbar/client/command/virtual_ip/allocate_spec.rb +39 -0
  184. data/spec/crowbar/client/command/virtual_ip/deallocate_spec.rb +39 -0
  185. data/spec/crowbar/client/filter/array_spec.rb +65 -0
  186. data/spec/crowbar/client/filter/hash_spec.rb +65 -0
  187. data/spec/crowbar/client/filter/subset_spec.rb +77 -0
  188. data/spec/crowbar/client/formatter/array_spec.rb +102 -0
  189. data/spec/crowbar/client/formatter/hash_spec.rb +108 -0
  190. data/spec/crowbar/client/formatter/nested_spec.rb +106 -0
  191. data/spec/crowbar/client/request/barclamp/list_spec.rb +50 -0
  192. data/spec/crowbar/client/request/batch/build_spec.rb +64 -0
  193. data/spec/crowbar/client/request/batch/export_spec.rb +64 -0
  194. data/spec/crowbar/client/request/host_ip/allocate_spec.rb +61 -0
  195. data/spec/crowbar/client/request/host_ip/deallocate_spec.rb +57 -0
  196. data/spec/crowbar/client/request/interface/disable_spec.rb +57 -0
  197. data/spec/crowbar/client/request/interface/enable_spec.rb +57 -0
  198. data/spec/crowbar/client/request/node/action_spec.rb +53 -0
  199. data/spec/crowbar/client/request/node/delete_spec.rb +52 -0
  200. data/spec/crowbar/client/request/node/list_spec.rb +50 -0
  201. data/spec/crowbar/client/request/node/rename_spec.rb +55 -0
  202. data/spec/crowbar/client/request/node/role_spec.rb +55 -0
  203. data/spec/crowbar/client/request/node/show_spec.rb +52 -0
  204. data/spec/crowbar/client/request/node/status_spec.rb +50 -0
  205. data/spec/crowbar/client/request/node/transition_spec.rb +56 -0
  206. data/spec/crowbar/client/request/party_spec.rb +24 -0
  207. data/spec/crowbar/client/request/proposal/commit_spec.rb +53 -0
  208. data/spec/crowbar/client/request/proposal/create_spec.rb +56 -0
  209. data/spec/crowbar/client/request/proposal/delete_spec.rb +53 -0
  210. data/spec/crowbar/client/request/proposal/dequeue_spec.rb +53 -0
  211. data/spec/crowbar/client/request/proposal/edit_spec.rb +56 -0
  212. data/spec/crowbar/client/request/proposal/list_spec.rb +52 -0
  213. data/spec/crowbar/client/request/proposal/show_spec.rb +53 -0
  214. data/spec/crowbar/client/request/proposal/template_spec.rb +52 -0
  215. data/spec/crowbar/client/request/repository/activate_all_spec.rb +50 -0
  216. data/spec/crowbar/client/request/repository/activate_spec.rb +56 -0
  217. data/spec/crowbar/client/request/repository/deactivate_all_spec.rb +50 -0
  218. data/spec/crowbar/client/request/repository/deactivate_spec.rb +56 -0
  219. data/spec/crowbar/client/request/repository/list_spec.rb +50 -0
  220. data/spec/crowbar/client/request/reset/nodes_spec.rb +55 -0
  221. data/spec/crowbar/client/request/reset/proposal_spec.rb +55 -0
  222. data/spec/crowbar/client/request/role/list_spec.rb +52 -0
  223. data/spec/crowbar/client/request/role/show_spec.rb +53 -0
  224. data/spec/crowbar/client/request/virtual_ip/allocate_spec.rb +61 -0
  225. data/spec/crowbar/client/request/virtual_ip/deallocate_spec.rb +57 -0
  226. data/spec/crowbar/client/util/editor_spec.rb +108 -0
  227. data/spec/crowbar/client/util/runner_spec.rb +24 -0
  228. data/spec/crowbar/client_spec.rb +21 -0
  229. data/spec/spec_helper.rb +55 -0
  230. data/spec/support/command_context.rb +37 -0
  231. data/spec/support/request_examples.rb +55 -0
  232. metadata +549 -0
@@ -0,0 +1,77 @@
1
+ #
2
+ # Copyright 2015, SUSE Linux GmbH
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Crowbar
18
+ module Client
19
+ module App
20
+ class Barclamp < Base
21
+ desc "list",
22
+ "List available barclamps"
23
+
24
+ long_desc <<-LONGDESC
25
+ `list` will print out a list of the available barclamps on
26
+ the target cloud. You can display the list in different output
27
+ formats and you can filter the list by any search criteria.
28
+
29
+ With --format <format> option you can choose an output format
30
+ with the available options table, json or plain.
31
+
32
+ With --filter <filter> option you can limit the result of
33
+ printed out elements. You can use any substring that is part
34
+ of the found elements.
35
+ LONGDESC
36
+
37
+ method_option :format,
38
+ type: :string,
39
+ default: "table",
40
+ banner: "<format>",
41
+ desc: "Format of the output, valid formats are table, json or plain"
42
+
43
+ class_option :table,
44
+ type: :boolean,
45
+ default: false,
46
+ aliases: [],
47
+ desc: "Format output as table, a shortcut for --format table option"
48
+
49
+ class_option :json,
50
+ type: :boolean,
51
+ default: false,
52
+ aliases: [],
53
+ desc: "Format output as table, a shortcut for --format table option"
54
+
55
+ class_option :plain,
56
+ type: :boolean,
57
+ default: false,
58
+ aliases: [],
59
+ desc: "Format output as table, a shortcut for --format table option"
60
+
61
+ method_option :filter,
62
+ type: :string,
63
+ default: nil,
64
+ banner: "<filter>",
65
+ desc: "Filter by criteria, display only data that contains filter"
66
+
67
+ def list
68
+ Command::Barclamp::List.new(
69
+ *command_params
70
+ ).execute
71
+ rescue SimpleCatchableError => e
72
+ err e.message, 1
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,97 @@
1
+ #
2
+ # Copyright 2015, SUSE Linux GmbH
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require "thor"
18
+ require "easy_diff"
19
+
20
+ module Crowbar
21
+ module Client
22
+ module App
23
+ class Base < Thor
24
+ def initialize(args = [], local_options = {}, config = {})
25
+ super
26
+
27
+ Config.configure(
28
+ options.slice(
29
+ :config,
30
+ :alias,
31
+ :username,
32
+ :password,
33
+ :server,
34
+ :timeout,
35
+ :anonymous,
36
+ :debug
37
+ )
38
+ )
39
+ end
40
+
41
+ no_commands do
42
+ def say(message)
43
+ $stdout.puts message
44
+ end
45
+
46
+ def err(message, exit_code = nil)
47
+ $stderr.puts message
48
+ exit(exit_code) unless exit_code.nil?
49
+ end
50
+
51
+ def config_parse(path, section)
52
+ ini = Hashie::Mash.new(
53
+ IniFile.load(
54
+ config_detect(path)
55
+ ).to_h
56
+ )
57
+
58
+ if ini[section]
59
+ ini[section]
60
+ else
61
+ Hashie::Mash.new
62
+ end
63
+ rescue
64
+ Hashie::Mash.new
65
+ end
66
+
67
+ def config_detect(path)
68
+ if path.nil?
69
+ config_paths.detect do |temp|
70
+ File.exist? temp
71
+ end
72
+ else
73
+ path
74
+ end
75
+ end
76
+
77
+ def config_paths
78
+ [
79
+ "#{ENV["HOME"]}/.crowbarrc",
80
+ "/etc/crowbarrc"
81
+ ]
82
+ end
83
+
84
+ def command_params(args = {})
85
+ [
86
+ $stdin,
87
+ $stdout,
88
+ $stderr,
89
+ options,
90
+ args
91
+ ]
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,100 @@
1
+ #
2
+ # Copyright 2015, SUSE Linux GmbH
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Crowbar
18
+ module Client
19
+ module App
20
+ class Batch < Base
21
+ desc "build FILE",
22
+ "Build proposals from file or stdin"
23
+
24
+ long_desc <<-LONGDESC
25
+ `build FILE` will create/edit/commit proposals defined in
26
+ an YAML format. You can directly provide a path to a file or
27
+ just pipe the content from stdin. To pipe the content from
28
+ stdin you should just write a `-` instead of a specific
29
+ filename.
30
+
31
+ With --include <barclamp[.proposal]> option you can process
32
+ only a specific part from the provided YAML file structure.
33
+
34
+ With --exclude <barclamp[.proposal]> option you exclude
35
+ specific parts from the provided YAML file structure to be
36
+ processed.
37
+ LONGDESC
38
+
39
+ method_option :include,
40
+ type: :string,
41
+ default: nil,
42
+ banner: "<barclamp[.proposal]>",
43
+ desc: "Include a specific barclamp or proposal for processing"
44
+
45
+ method_option :exclude,
46
+ type: :string,
47
+ default: nil,
48
+ banner: "<barclamp[.proposal]>",
49
+ desc: "Exclude a specific barclamp or proposal for processing"
50
+
51
+ def build(file)
52
+ Command::Batch::Build.new(
53
+ *command_params(
54
+ file: file
55
+ )
56
+ ).execute
57
+ rescue SimpleCatchableError => e
58
+ err e.message, 1
59
+ end
60
+
61
+ desc "export PROPOSAL [PROPOSAL]",
62
+ "Export proposals to stdout"
63
+
64
+ long_desc <<-LONGDESC
65
+ `export PROPOSAL [PROPOSAL]` will collect the informations
66
+ for the provided proposals and print it out to stdout in a
67
+ YAML format that can be used to build again.
68
+
69
+ With --include <barclamp[.proposal]> option you can export
70
+ only a specific part from the existing proposals.
71
+
72
+ With --exclude <barclamp[.proposal]> option you exclude
73
+ specific parts from the existing proposals to be exported.
74
+ LONGDESC
75
+
76
+ method_option :include,
77
+ type: :string,
78
+ default: nil,
79
+ banner: "<barclamp[.proposal]>",
80
+ desc: "Include a specific barclamp or proposal for export"
81
+
82
+ method_option :exclude,
83
+ type: :string,
84
+ default: nil,
85
+ banner: "<barclamp[.proposal]>",
86
+ desc: "Exclude a specific barclamp or proposal for export"
87
+
88
+ def export(*proposals)
89
+ Command::Batch::Export.new(
90
+ *command_params(
91
+ proposals: proposals
92
+ )
93
+ ).execute
94
+ rescue SimpleCatchableError => e
95
+ err e.message, 1
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,121 @@
1
+ #
2
+ # Copyright 2015, SUSE Linux GmbH
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Crowbar
18
+ module Client
19
+ module App
20
+ class Entry < Base
21
+ map [
22
+ "--version",
23
+ "-v"
24
+ ] => :version
25
+
26
+ class_option :config,
27
+ type: :string,
28
+ default: nil,
29
+ aliases: ["-c"],
30
+ desc: "Path to a configuration file"
31
+
32
+ class_option :alias,
33
+ type: :string,
34
+ default: "default",
35
+ aliases: ["-a"],
36
+ desc: "Alias for a config section"
37
+
38
+ class_option :username,
39
+ type: :string,
40
+ default: "crowbar",
41
+ aliases: ["-U"],
42
+ desc: "Specify username for connection"
43
+
44
+ class_option :password,
45
+ type: :string,
46
+ default: "crowbar",
47
+ aliases: ["-P"],
48
+ desc: "Specify password for connection"
49
+
50
+ class_option :server,
51
+ type: :string,
52
+ default: "http://127.0.0.1:80",
53
+ aliases: ["-s"],
54
+ desc: "Specify server for connection"
55
+
56
+ class_option :timeout,
57
+ type: :numeric,
58
+ default: 60,
59
+ aliases: ["-t"],
60
+ desc: "Specify timeout for connection"
61
+
62
+ class_option :anonymous,
63
+ type: :boolean,
64
+ default: false,
65
+ aliases: ["-a"],
66
+ desc: "Skip API user authentication"
67
+
68
+ class_option :debug,
69
+ type: :boolean,
70
+ default: false,
71
+ aliases: ["-d"],
72
+ desc: "Output more debug information"
73
+
74
+ desc "version",
75
+ "Display the current version of the client"
76
+
77
+ long_desc <<-LONGDESC
78
+ `version` will print out the version of the currently used
79
+ crowbar-client, this is some usefull information if you try
80
+ to debug some issue with the current implementation.
81
+ LONGDESC
82
+
83
+ def version
84
+ say "crowbar-client v#{Crowbar::Client::Version}"
85
+ end
86
+
87
+ desc "barclamp [COMMANDS]",
88
+ "Barclamp specific commands, call without params for help"
89
+ subcommand "barclamp", Crowbar::Client::App::Barclamp
90
+
91
+ desc "batch [COMMANDS]",
92
+ "Batch specific commands, call without params for help"
93
+ subcommand "batch", Crowbar::Client::App::Batch
94
+
95
+ desc "network [COMMANDS]",
96
+ "Network specific commands, call without params for help"
97
+ subcommand "network", Crowbar::Client::App::Network
98
+
99
+ desc "node [COMMANDS]",
100
+ "Node specific commands, call without params for help"
101
+ subcommand "node", Crowbar::Client::App::Node
102
+
103
+ desc "proposal [COMMANDS]",
104
+ "Proposal specific commands, call without params for help"
105
+ subcommand "proposal", Crowbar::Client::App::Proposal
106
+
107
+ desc "repository [COMMANDS]",
108
+ "Repository specific commands, call without params for help"
109
+ subcommand "repository", Crowbar::Client::App::Repository
110
+
111
+ desc "reset [COMMANDS]",
112
+ "Reset specific commands, call without params for help"
113
+ subcommand "reset", Crowbar::Client::App::Reset
114
+
115
+ desc "role [COMMANDS]",
116
+ "Role specific commands, call without params for help"
117
+ subcommand "role", Crowbar::Client::App::Role
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,65 @@
1
+ #
2
+ # Copyright 2015, SUSE Linux GmbH
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Crowbar
18
+ module Client
19
+ module App
20
+ class HostIP < Base
21
+ desc "allocate PROPOSAL NODE NETWORK RANGE [SUGGESTION]",
22
+ "Allocate a host IP address"
23
+
24
+ long_desc <<-LONGDESC
25
+ `allocate PROPOSAL NODE NETWORK RANGE [SUGGESTION]` will
26
+ try to allocate a host IP address for the specified node.
27
+ LONGDESC
28
+
29
+ def allocate(proposal, node, network, range, suggestion = nil)
30
+ Command::VirtualIp::Allocate.new(
31
+ *command_params(
32
+ proposal: proposal,
33
+ node: node,
34
+ network: network,
35
+ range: range,
36
+ suggestion: suggestion
37
+ )
38
+ ).execute
39
+ rescue SimpleCatchableError => e
40
+ err e.message, 1
41
+ end
42
+
43
+ desc "deallocate PROPOSAL NODE NETWORK",
44
+ "Deallocate a host IP address"
45
+
46
+ long_desc <<-LONGDESC
47
+ `deallocate PROPOSAL NODE NETWORK` will try to deallocate
48
+ a host IP address for the specified node.
49
+ LONGDESC
50
+
51
+ def deallocate(proposal, node, network)
52
+ Command::VirtualIp::Allocate.new(
53
+ *command_params(
54
+ proposal: proposal,
55
+ node: node,
56
+ network: network
57
+ )
58
+ ).execute
59
+ rescue SimpleCatchableError => e
60
+ err e.message, 1
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end