crowbar-client 2.2.1 → 2.3.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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/lib/crowbar/client/app/backup.rb +148 -0
  4. data/lib/crowbar/client/app/entry.rb +4 -4
  5. data/lib/crowbar/client/app/node.rb +26 -13
  6. data/lib/crowbar/client/app/proposal.rb +59 -0
  7. data/lib/crowbar/client/app.rb +3 -3
  8. data/lib/crowbar/client/command/{reset/proposal.rb → backup/create.rb} +9 -3
  9. data/lib/crowbar/client/command/backup/delete.rb +42 -0
  10. data/lib/crowbar/client/command/backup/download.rb +68 -0
  11. data/lib/crowbar/client/command/backup/list.rb +76 -0
  12. data/lib/crowbar/client/command/{reset/nodes.rb → backup/upload.rb} +9 -4
  13. data/lib/crowbar/client/command/{reset.rb → backup.rb} +14 -5
  14. data/lib/crowbar/client/command/node/group.rb +44 -0
  15. data/lib/crowbar/client/command/node/list.rb +37 -16
  16. data/lib/crowbar/client/command/node.rb +3 -0
  17. data/lib/crowbar/client/command/proposal/reset.rb +48 -0
  18. data/lib/crowbar/client/command/proposal.rb +3 -0
  19. data/lib/crowbar/client/command.rb +3 -3
  20. data/lib/crowbar/client/config.rb +5 -5
  21. data/lib/crowbar/client/mixin/barclamp.rb +1 -4
  22. data/lib/crowbar/client/request/backup/create.rb +46 -0
  23. data/lib/crowbar/client/request/{reset/proposal.rb → backup/delete.rb} +8 -4
  24. data/lib/crowbar/client/request/backup/download.rb +47 -0
  25. data/lib/crowbar/client/request/{reset/nodes.rb → backup/list.rb} +6 -3
  26. data/lib/crowbar/client/request/backup/upload.rb +48 -0
  27. data/lib/crowbar/client/request/backup.rb +38 -0
  28. data/lib/crowbar/client/request/base.rb +4 -4
  29. data/lib/crowbar/client/request/node/group.rb +39 -0
  30. data/lib/crowbar/client/request/node.rb +3 -0
  31. data/lib/crowbar/client/request/party.rb +2 -2
  32. data/lib/crowbar/client/request/proposal/reset.rb +40 -0
  33. data/lib/crowbar/client/request/proposal.rb +3 -0
  34. data/lib/crowbar/client/request.rb +3 -3
  35. data/lib/crowbar/client/version.rb +2 -2
  36. data/spec/crowbar/client/command/backup/create_spec.rb +42 -0
  37. data/spec/crowbar/client/command/backup/delete_spec.rb +41 -0
  38. data/spec/crowbar/client/command/backup/download_spec.rb +40 -0
  39. data/spec/crowbar/client/command/{reset/nodes_spec.rb → backup/list_spec.rb} +3 -3
  40. data/spec/crowbar/client/command/backup/upload_spec.rb +40 -0
  41. data/spec/crowbar/client/command/{reset/proposal_spec.rb → node/group_spec.rb} +3 -3
  42. data/spec/crowbar/client/command/proposal/create_spec.rb +3 -7
  43. data/spec/crowbar/client/command/proposal/edit_spec.rb +4 -8
  44. data/spec/crowbar/client/command/proposal/reset_spec.rb +39 -0
  45. data/spec/crowbar/client/request/{reset/proposal_spec.rb → backup/create_spec.rb} +37 -36
  46. data/spec/crowbar/client/request/{reset/nodes_spec.rb → backup/delete_spec.rb} +34 -36
  47. data/spec/crowbar/client/request/backup/download_spec.rb +53 -0
  48. data/spec/crowbar/client/request/backup/list_spec.rb +52 -0
  49. data/spec/crowbar/client/request/backup/upload_spec.rb +55 -0
  50. data/spec/crowbar/client/request/barclamp/list_spec.rb +1 -1
  51. data/spec/crowbar/client/request/batch/build_spec.rb +1 -1
  52. data/spec/crowbar/client/request/batch/export_spec.rb +1 -1
  53. data/spec/crowbar/client/request/host_ip/allocate_spec.rb +1 -1
  54. data/spec/crowbar/client/request/host_ip/deallocate_spec.rb +1 -1
  55. data/spec/crowbar/client/request/installer/start_spec.rb +1 -1
  56. data/spec/crowbar/client/request/installer/status_spec.rb +1 -1
  57. data/spec/crowbar/client/request/interface/disable_spec.rb +1 -1
  58. data/spec/crowbar/client/request/interface/enable_spec.rb +1 -1
  59. data/spec/crowbar/client/request/node/action_spec.rb +1 -1
  60. data/spec/crowbar/client/request/node/delete_spec.rb +1 -1
  61. data/spec/crowbar/client/request/node/group_spec.rb +53 -0
  62. data/spec/crowbar/client/request/node/list_spec.rb +1 -1
  63. data/spec/crowbar/client/request/node/rename_spec.rb +1 -1
  64. data/spec/crowbar/client/request/node/role_spec.rb +1 -1
  65. data/spec/crowbar/client/request/node/show_spec.rb +1 -1
  66. data/spec/crowbar/client/request/node/status_spec.rb +1 -1
  67. data/spec/crowbar/client/request/node/transition_spec.rb +1 -1
  68. data/spec/crowbar/client/request/proposal/commit_spec.rb +1 -1
  69. data/spec/crowbar/client/request/proposal/create_spec.rb +34 -36
  70. data/spec/crowbar/client/request/proposal/delete_spec.rb +1 -1
  71. data/spec/crowbar/client/request/proposal/dequeue_spec.rb +1 -1
  72. data/spec/crowbar/client/request/proposal/edit_spec.rb +34 -36
  73. data/spec/crowbar/client/request/proposal/list_spec.rb +1 -1
  74. data/spec/crowbar/client/request/proposal/reset_spec.rb +53 -0
  75. data/spec/crowbar/client/request/proposal/show_spec.rb +1 -1
  76. data/spec/crowbar/client/request/proposal/template_spec.rb +1 -1
  77. data/spec/crowbar/client/request/repository/activate_all_spec.rb +1 -1
  78. data/spec/crowbar/client/request/repository/activate_spec.rb +1 -1
  79. data/spec/crowbar/client/request/repository/deactivate_all_spec.rb +1 -1
  80. data/spec/crowbar/client/request/repository/deactivate_spec.rb +1 -1
  81. data/spec/crowbar/client/request/repository/list_spec.rb +1 -1
  82. data/spec/crowbar/client/request/role/list_spec.rb +1 -1
  83. data/spec/crowbar/client/request/role/show_spec.rb +1 -1
  84. data/spec/crowbar/client/request/server/api_spec.rb +1 -1
  85. data/spec/crowbar/client/request/virtual_ip/allocate_spec.rb +1 -1
  86. data/spec/crowbar/client/request/virtual_ip/deallocate_spec.rb +1 -1
  87. data/spec/fixtures/upload.tgz +0 -0
  88. data/spec/spec_helper.rb +2 -0
  89. data/{lib/crowbar/client/request/reset.rb → spec/support/helper_methods.rb} +10 -11
  90. data/spec/support/request_examples.rb +31 -12
  91. metadata +130 -96
  92. data/lib/crowbar/client/app/reset.rb +0 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4da88aa4d847eb33fd49059ba13a36ba19c37375
4
- data.tar.gz: 01281b07c8e373c9d0291ddb3ced3985ea12f7f1
3
+ metadata.gz: 196e25c8ac9b8112656985164751b9a51b732178
4
+ data.tar.gz: 3d281cb6d8561bc51f78d9aae02517b714761d0f
5
5
  SHA512:
6
- metadata.gz: ab8363e15f75d69f3b1e7eacbf2a32d5aa7ed0549f217565bb4ba20e6e4487f987b67eba00f4c7b22b3431d620eaaeff36250b721a28ba6a78b5a5b63938b00f
7
- data.tar.gz: bacc1907cc82f75edec29d2a1b036dff5d16a8e882926675985cc755fd2974d794d1edb33705182957cbb36eb8703ca474571c39d6b9ce6cdcaf8b56b31babd5
6
+ metadata.gz: ba6e3e297bd4a9d22c6c737c040101af78dbf2b1c70b9ee70eddb377f72e844b3759e098dcbd646998ebababb04d9c6070d666048b95eb6bdcfa58387c99fefe
7
+ data.tar.gz: 8572d1bb1472e8a57133bd94731205783011803fb5902ef8f0947591350f6197b2bd19fc1237defeec06c6a455d6352e58a2c4d9f2c85976a9b20424d0b8dfd6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.3.0](https://github.com/crowbar/crowbar-client/releases/tag/v2.3.0) - 2015-01-15
4
+
5
+ * BREAKING
6
+ * Dropped --no-aliases option from node list subcommand (@tboerger)
7
+ * Dropped --no-names option from node list subcommand (@tboerger)
8
+ * ENHANCEMENT
9
+ * Added more columns to node list subcommand (@tboerger)
10
+ * Order node list subcommand output alphabetically now (@tboerger)
11
+ * Added subcommand to reset a proposal state through the API (@tboerger)
12
+ * Added subcommand to interact with the backup API (@tboerger)
13
+ * Added subcommand to set the group of a node (@tboerger)
14
+
3
15
  ## [2.2.1](https://github.com/crowbar/crowbar-client/releases/tag/v2.2.1) - 2015-12-15
4
16
 
5
17
  * BUGFIX
@@ -0,0 +1,148 @@
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 Backup < Base
21
+ desc "list",
22
+ "List existing backups"
23
+
24
+ long_desc <<-LONGDESC
25
+ `list` will print out a list of existing backups on the admin
26
+ node. 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. You can also
31
+ use the shortcut options --table, --json or --plain.
32
+
33
+ With --filter <filter> option you can limit the result of
34
+ printed out elements. You can use any substring that is part
35
+ of the found elements.
36
+ LONGDESC
37
+
38
+ method_option :format,
39
+ type: :string,
40
+ default: "table",
41
+ banner: "<format>",
42
+ desc: "Format of the output, valid formats are table, json or plain"
43
+
44
+ method_option :table,
45
+ type: :boolean,
46
+ default: false,
47
+ aliases: [],
48
+ desc: "Format output as table, a shortcut for --format table option"
49
+
50
+ method_option :json,
51
+ type: :boolean,
52
+ default: false,
53
+ aliases: [],
54
+ desc: "Format output as table, a shortcut for --format table option"
55
+
56
+ method_option :plain,
57
+ type: :boolean,
58
+ default: false,
59
+ aliases: [],
60
+ desc: "Format output as table, a shortcut for --format table option"
61
+
62
+ method_option :filter,
63
+ type: :string,
64
+ default: nil,
65
+ banner: "<filter>",
66
+ desc: "Filter by criteria, display only data that contains filter"
67
+
68
+ def list
69
+ Command::Backup::List.new(
70
+ *command_params
71
+ ).execute
72
+ rescue => e
73
+ catch_errors(e)
74
+ end
75
+
76
+ desc "create",
77
+ "Create a new backup"
78
+
79
+ long_desc <<-LONGDESC
80
+ `create NAME` will create a new backup on the Administration Server.
81
+ LONGDESC
82
+
83
+ def create(name)
84
+ Command::Backup::Create.new(
85
+ *command_params(
86
+ backup: name
87
+ )
88
+ ).execute
89
+ rescue => e
90
+ catch_errors(e)
91
+ end
92
+
93
+ desc "download",
94
+ "Download a backup"
95
+
96
+ long_desc <<-LONGDESC
97
+ `download ID` will download a backup from the Administration Server.
98
+ LONGDESC
99
+
100
+ def download(id)
101
+ Command::Backup::Download.new(
102
+ *command_params(
103
+ id: id
104
+ )
105
+ ).execute
106
+ rescue => e
107
+ catch_errors(e)
108
+ end
109
+
110
+ desc "upload",
111
+ "Upload a backup"
112
+
113
+ long_desc <<-LONGDESC
114
+ `upload FILE` will upload a backup to the Administration Server.
115
+ LONGDESC
116
+
117
+ def upload(file)
118
+ Command::Backup::Upload.new(
119
+ *command_params(
120
+ file: File.new(
121
+ file
122
+ )
123
+ )
124
+ ).execute
125
+ rescue => e
126
+ catch_errors(e)
127
+ end
128
+
129
+ desc "delete",
130
+ "Delete a backup"
131
+
132
+ long_desc <<-LONGDESC
133
+ `delete ID` will delete a backup from the Administration Server.
134
+ LONGDESC
135
+
136
+ def delete(id)
137
+ Command::Backup::Delete.new(
138
+ *command_params(
139
+ id: id
140
+ )
141
+ ).execute
142
+ rescue => e
143
+ catch_errors(e)
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -78,6 +78,10 @@ module Crowbar
78
78
  say "crowbar-client v#{Crowbar::Client::Version}"
79
79
  end
80
80
 
81
+ desc "backup [COMMANDS]",
82
+ "Backup specific commands, call without params for help"
83
+ subcommand "backup", Crowbar::Client::App::Backup
84
+
81
85
  desc "barclamp [COMMANDS]",
82
86
  "Barclamp specific commands, call without params for help"
83
87
  subcommand "barclamp", Crowbar::Client::App::Barclamp
@@ -102,10 +106,6 @@ module Crowbar
102
106
  "Repository specific commands, call without params for help"
103
107
  subcommand "repository", Crowbar::Client::App::Repository
104
108
 
105
- desc "reset [COMMANDS]",
106
- "Reset specific commands, call without params for help"
107
- subcommand "reset", Crowbar::Client::App::Reset
108
-
109
109
  desc "role [COMMANDS]",
110
110
  "Role specific commands, call without params for help"
111
111
  subcommand "role", Crowbar::Client::App::Role
@@ -101,11 +101,9 @@ module Crowbar
101
101
  printed out elements. You can use any substring that is part
102
102
  of the found elements.
103
103
 
104
- With --no-aliases switch you can disable the output of the node
105
- aliases, per default the listing will display them.
106
-
107
- With --no-names switch you can disable the output of the node
108
- names, per default the listing will display them.
104
+ With --no-meta switch you can disable the additional information
105
+ and just get a list of names and aliases for further scripting
106
+ where you don't care about the other columns.
109
107
  LONGDESC
110
108
 
111
109
  method_option :format,
@@ -138,17 +136,11 @@ module Crowbar
138
136
  banner: "<filter>",
139
137
  desc: "Filter by criteria, display only data that contains filter"
140
138
 
141
- method_option :aliases,
142
- type: :boolean,
143
- default: true,
144
- aliases: [],
145
- desc: "Show or hide the aliases for the available nodes within listing"
146
-
147
- method_option :names,
139
+ method_option :meta,
148
140
  type: :boolean,
149
141
  default: true,
150
142
  aliases: [],
151
- desc: "Show or hide the names for the available nodes within listing"
143
+ desc: "Show or hide the additional meta info like group and status"
152
144
 
153
145
  def list
154
146
  Command::Node::List.new(
@@ -455,6 +447,27 @@ module Crowbar
455
447
  catch_errors(e)
456
448
  end
457
449
 
450
+ desc "group NAME_OR_ALIAS GROUP",
451
+ "Assign another group to a node"
452
+
453
+ long_desc <<-LONGDESC
454
+ `group NAME_OR_ALIAS GROUP` will try to assign the specified
455
+ node to a different group. If you want to guess a group
456
+ automatically you can provide the group "automatic", then you
457
+ will get the new name as a response.
458
+ LONGDESC
459
+
460
+ def group(name, value)
461
+ Command::Node::Group.new(
462
+ *command_params(
463
+ name: name,
464
+ value: value
465
+ )
466
+ ).execute
467
+ rescue => e
468
+ catch_errors(e)
469
+ end
470
+
458
471
  desc "transition NAME_OR_ALIAS STATE",
459
472
  "Transition a node to a specific state"
460
473
 
@@ -294,6 +294,65 @@ module Crowbar
294
294
  rescue => e
295
295
  catch_errors(e)
296
296
  end
297
+
298
+ desc "reset BARCLAMP [PROPOSAL]",
299
+ "Reset a proposal for specific barclamp"
300
+
301
+ long_desc <<-LONGDESC
302
+ `reset BARCLAMP [PROPOSAL]` will try to reset the state
303
+ for the specified barclamp. If you don't provide a proposal
304
+ the client will select the default proposal. The usage of
305
+ this command is unsupported, unless you have been specifically
306
+ told to run it as part of a support request!
307
+
308
+ With --yes option you can force the reset without any further
309
+ question, this skips the otherwise required confirmation.
310
+ LONGDESC
311
+
312
+ method_option :yes,
313
+ type: :boolean,
314
+ default: false,
315
+ aliases: [],
316
+ desc: "Force the reset without any confirmation message"
317
+
318
+ def reset(barclamp, proposal = "default")
319
+ unless accepts_reset?
320
+ say "Canceled reset"
321
+ return
322
+ end
323
+
324
+ Command::Proposal::Reset.new(
325
+ *command_params(
326
+ barclamp: barclamp,
327
+ proposal: proposal
328
+ )
329
+ ).execute
330
+ rescue => e
331
+ catch_errors(e)
332
+ end
333
+
334
+ no_commands do
335
+ def accepts_reset?
336
+ return true if options[:yes]
337
+
338
+ question = <<-QUESTION.strip_heredoc
339
+ Usage of this command is unsupported, unless you have been
340
+ specifically told to run it as part of a support request!
341
+ Are you sure you want to proceed?
342
+ QUESTION
343
+
344
+ answer = ask(
345
+ question,
346
+ :red,
347
+ limited_to: [
348
+ "yes",
349
+ "no"
350
+ ]
351
+ )
352
+
353
+ answer == "yes"
354
+ end
355
+ end
297
356
  end
298
357
  end
299
358
  end
@@ -17,6 +17,9 @@
17
17
  module Crowbar
18
18
  module Client
19
19
  module App
20
+ autoload :Backup,
21
+ File.expand_path("../app/backup", __FILE__)
22
+
20
23
  autoload :Barclamp,
21
24
  File.expand_path("../app/barclamp", __FILE__)
22
25
 
@@ -50,9 +53,6 @@ module Crowbar
50
53
  autoload :Repository,
51
54
  File.expand_path("../app/repository", __FILE__)
52
55
 
53
- autoload :Reset,
54
- File.expand_path("../app/reset", __FILE__)
55
-
56
56
  autoload :Role,
57
57
  File.expand_path("../app/role", __FILE__)
58
58
 
@@ -17,16 +17,22 @@
17
17
  module Crowbar
18
18
  module Client
19
19
  module Command
20
- module Reset
21
- class Proposal < Base
20
+ module Backup
21
+ class Create < Base
22
22
  def request
23
- @request ||= Request::Reset::Proposal.new(
23
+ @request ||= Request::Backup::Create.new(
24
24
  args
25
25
  )
26
26
  end
27
27
 
28
28
  def execute
29
29
  request.process do |request|
30
+ case request.code
31
+ when 200
32
+ say "Successfully created the backup"
33
+ else
34
+ err request.parsed_response["error"]
35
+ end
30
36
  end
31
37
  end
32
38
  end
@@ -0,0 +1,42 @@
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 Command
20
+ module Backup
21
+ class Delete < Base
22
+ def request
23
+ @request ||= Request::Backup::Delete.new(
24
+ args
25
+ )
26
+ end
27
+
28
+ def execute
29
+ request.process do |request|
30
+ case request.code
31
+ when 200
32
+ say "Successfully deleted the backup"
33
+ else
34
+ err request.parsed_response["error"]
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,68 @@
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 "httparty"
18
+
19
+ module Crowbar
20
+ module Client
21
+ module Command
22
+ module Backup
23
+ class Download < Base
24
+ def request
25
+ @request ||= Request::Backup::Download.new(
26
+ args
27
+ )
28
+ end
29
+
30
+ def execute
31
+ request.process do |request|
32
+ case request.code
33
+ when 200
34
+ if write(request.body)
35
+ say "Successfully downloaded backup to #{path}"
36
+ else
37
+ say "Failed to download backup to #{path}"
38
+ end
39
+ else
40
+ err request.parsed_response["error"]
41
+ end
42
+ end
43
+ end
44
+
45
+ protected
46
+
47
+ def write(body)
48
+ path.open("wb") do |f|
49
+ f.binmode
50
+ f.write body
51
+
52
+ true
53
+ end
54
+ rescue
55
+ false
56
+ end
57
+
58
+ def path
59
+ filename = Request::Backup::List.new.process do |p|
60
+ p.parsed_response.select { |s| s["id"] == args.id.to_i }
61
+ end.first["name"]
62
+ Pathname.new("#{filename}.tar.gz")
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,76 @@
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 Command
20
+ module Backup
21
+ class List < Base
22
+ include Mixin::Format
23
+ include Mixin::Filter
24
+
25
+ def request
26
+ @request ||= Request::Backup::List.new(
27
+ args
28
+ )
29
+ end
30
+
31
+ def execute
32
+ request.process do |request|
33
+ case request.code
34
+ when 200
35
+ formatter = Formatter::Hash.new(
36
+ format: provide_format,
37
+ headings: headings,
38
+ values: Filter::Hash.new(
39
+ filter: provide_filter,
40
+ values: content_from(request)
41
+ ).result
42
+ )
43
+
44
+ if formatter.empty?
45
+ err "No backups"
46
+ else
47
+ say formatter.result
48
+ end
49
+ else
50
+ err request.parsed_response["error"]
51
+ end
52
+ end
53
+ end
54
+
55
+ protected
56
+
57
+ def headings
58
+ ["Id", "Name", "Created", "Size", "Version"]
59
+ end
60
+
61
+ def content_from(request)
62
+ request.parsed_response.map do |row|
63
+ row.slice(
64
+ "id",
65
+ "name",
66
+ "created_at",
67
+ "size",
68
+ "version"
69
+ )
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,4 +1,3 @@
1
- #
2
1
  # Copyright 2015, SUSE Linux GmbH
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,16 +16,22 @@
17
16
  module Crowbar
18
17
  module Client
19
18
  module Command
20
- module Reset
21
- class Nodes < Base
19
+ module Backup
20
+ class Upload < Base
22
21
  def request
23
- @request ||= Request::Reset::Nodes.new(
22
+ @request ||= Request::Backup::Upload.new(
24
23
  args
25
24
  )
26
25
  end
27
26
 
28
27
  def execute
29
28
  request.process do |request|
29
+ case request.code
30
+ when 200
31
+ say "Successfully uploaded backup"
32
+ else
33
+ err request.parsed_response["error"]
34
+ end
30
35
  end
31
36
  end
32
37
  end
@@ -17,12 +17,21 @@
17
17
  module Crowbar
18
18
  module Client
19
19
  module Command
20
- module Reset
21
- autoload :Nodes,
22
- File.expand_path("../reset/nodes", __FILE__)
20
+ module Backup
21
+ autoload :Create,
22
+ File.expand_path("../backup/create", __FILE__)
23
23
 
24
- autoload :Proposal,
25
- File.expand_path("../reset/proposal", __FILE__)
24
+ autoload :Delete,
25
+ File.expand_path("../backup/delete", __FILE__)
26
+
27
+ autoload :Download,
28
+ File.expand_path("../backup/download", __FILE__)
29
+
30
+ autoload :List,
31
+ File.expand_path("../backup/list", __FILE__)
32
+
33
+ autoload :Upload,
34
+ File.expand_path("../backup/upload", __FILE__)
26
35
  end
27
36
  end
28
37
  end
@@ -0,0 +1,44 @@
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 Command
20
+ module Node
21
+ class Group < Base
22
+ def request
23
+ @request ||= Request::Node::Group.new(
24
+ args
25
+ )
26
+ end
27
+
28
+ def execute
29
+ request.process do |request|
30
+ case request.code
31
+ when 200
32
+ say "Successfully updated group to #{request.parsed_response["group"]}"
33
+ when 404
34
+ err "Node does not exist"
35
+ else
36
+ err request.parsed_response["error"]
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end