crowbar-client 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/lib/crowbar/client.rb +6 -0
  4. data/lib/crowbar/client/app.rb +3 -0
  5. data/lib/crowbar/client/app/barclamp.rb +2 -2
  6. data/lib/crowbar/client/app/base.rb +24 -1
  7. data/lib/crowbar/client/app/batch.rb +4 -4
  8. data/lib/crowbar/client/app/entry.rb +4 -0
  9. data/lib/crowbar/client/app/host_ip.rb +4 -4
  10. data/lib/crowbar/client/app/installer.rb +103 -0
  11. data/lib/crowbar/client/app/interface.rb +4 -4
  12. data/lib/crowbar/client/app/node.rb +34 -34
  13. data/lib/crowbar/client/app/proposal.rb +14 -14
  14. data/lib/crowbar/client/app/repository.rb +10 -10
  15. data/lib/crowbar/client/app/reset.rb +4 -4
  16. data/lib/crowbar/client/app/role.rb +4 -4
  17. data/lib/crowbar/client/app/server.rb +2 -2
  18. data/lib/crowbar/client/app/virtual_ip.rb +4 -4
  19. data/lib/crowbar/client/command.rb +3 -0
  20. data/lib/crowbar/client/command/installer.rb +29 -0
  21. data/lib/crowbar/client/command/installer/start.rb +50 -0
  22. data/lib/crowbar/client/command/installer/status.rb +68 -0
  23. data/lib/crowbar/client/command/proposal/create.rb +19 -5
  24. data/lib/crowbar/client/command/proposal/edit.rb +19 -5
  25. data/lib/crowbar/client/request.rb +3 -0
  26. data/lib/crowbar/client/request/base.rb +12 -0
  27. data/lib/crowbar/client/request/installer.rb +29 -0
  28. data/lib/crowbar/client/request/installer/start.rb +44 -0
  29. data/lib/crowbar/client/request/installer/status.rb +36 -0
  30. data/lib/crowbar/client/version.rb +1 -1
  31. data/spec/crowbar/client/command/installer/start_spec.rb +40 -0
  32. data/spec/crowbar/client/command/installer/status_spec.rb +39 -0
  33. data/spec/crowbar/client/request/installer/start_spec.rb +55 -0
  34. data/spec/crowbar/client/request/installer/status_spec.rb +65 -0
  35. data/spec/support/request_examples.rb +4 -0
  36. metadata +84 -69
@@ -72,8 +72,8 @@ module Crowbar
72
72
  barclamp: barclamp
73
73
  )
74
74
  ).execute
75
- rescue SimpleCatchableError => e
76
- err e.message, 1
75
+ rescue => e
76
+ catch_errors(e)
77
77
  end
78
78
 
79
79
  desc "show BARCLAMP PROPOSAL",
@@ -134,8 +134,8 @@ module Crowbar
134
134
  proposal: proposal
135
135
  )
136
136
  ).execute
137
- rescue SimpleCatchableError => e
138
- err e.message, 1
137
+ rescue => e
138
+ catch_errors(e)
139
139
  end
140
140
 
141
141
  desc "create BARCLAMP PROPOSAL",
@@ -184,8 +184,8 @@ module Crowbar
184
184
  proposal: proposal
185
185
  )
186
186
  ).execute
187
- rescue SimpleCatchableError => e
188
- err e.message, 1
187
+ rescue => e
188
+ catch_errors(e)
189
189
  end
190
190
 
191
191
  desc "edit BARCLAMP PROPOSAL",
@@ -234,8 +234,8 @@ module Crowbar
234
234
  proposal: proposal
235
235
  )
236
236
  ).execute
237
- rescue SimpleCatchableError => e
238
- err e.message, 1
237
+ rescue => e
238
+ catch_errors(e)
239
239
  end
240
240
 
241
241
  desc "delete BARCLAMP PROPOSAL",
@@ -253,8 +253,8 @@ module Crowbar
253
253
  proposal: proposal
254
254
  )
255
255
  ).execute
256
- rescue SimpleCatchableError => e
257
- err e.message, 1
256
+ rescue => e
257
+ catch_errors(e)
258
258
  end
259
259
 
260
260
  desc "dequeue BARCLAMP PROPOSAL",
@@ -272,8 +272,8 @@ module Crowbar
272
272
  proposal: proposal
273
273
  )
274
274
  ).execute
275
- rescue SimpleCatchableError => e
276
- err e.message, 1
275
+ rescue => e
276
+ catch_errors(e)
277
277
  end
278
278
 
279
279
  desc "commit BARCLAMP PROPOSAL",
@@ -291,8 +291,8 @@ module Crowbar
291
291
  proposal: proposal
292
292
  )
293
293
  ).execute
294
- rescue SimpleCatchableError => e
295
- err e.message, 1
294
+ rescue => e
295
+ catch_errors(e)
296
296
  end
297
297
  end
298
298
  end
@@ -70,8 +70,8 @@ module Crowbar
70
70
  Command::Repository::List.new(
71
71
  *command_params
72
72
  ).execute
73
- rescue SimpleCatchableError => e
74
- err e.message, 1
73
+ rescue => e
74
+ catch_errors(e)
75
75
  end
76
76
 
77
77
  desc "activate PLATFORM REPO",
@@ -89,8 +89,8 @@ module Crowbar
89
89
  repo: repo
90
90
  )
91
91
  ).execute
92
- rescue SimpleCatchableError => e
93
- err e.message, 1
92
+ rescue => e
93
+ catch_errors(e)
94
94
  end
95
95
 
96
96
  desc "activate-all",
@@ -105,8 +105,8 @@ module Crowbar
105
105
  Command::Repository::ActivateAll.new(
106
106
  *command_params
107
107
  ).execute
108
- rescue SimpleCatchableError => e
109
- err e.message, 1
108
+ rescue => e
109
+ catch_errors(e)
110
110
  end
111
111
 
112
112
  desc "deactivate PLATFORM REPO",
@@ -124,8 +124,8 @@ module Crowbar
124
124
  repo: repo
125
125
  )
126
126
  ).execute
127
- rescue SimpleCatchableError => e
128
- err e.message, 1
127
+ rescue => e
128
+ catch_errors(e)
129
129
  end
130
130
 
131
131
  desc "deactivate-all",
@@ -140,8 +140,8 @@ module Crowbar
140
140
  Command::Repository::DeactivateAll.new(
141
141
  *command_params
142
142
  ).execute
143
- rescue SimpleCatchableError => e
144
- err e.message, 1
143
+ rescue => e
144
+ catch_errors(e)
145
145
  end
146
146
  end
147
147
  end
@@ -33,8 +33,8 @@ module Crowbar
33
33
  proposal: proposal
34
34
  )
35
35
  ).execute
36
- rescue SimpleCatchableError => e
37
- err e.message, 1
36
+ rescue => e
37
+ catch_errors(e)
38
38
  end
39
39
 
40
40
  desc "nodes",
@@ -49,8 +49,8 @@ module Crowbar
49
49
  Command::Reset::Nodes.new(
50
50
  *command_params
51
51
  ).execute
52
- rescue SimpleCatchableError => e
53
- err e.message, 1
52
+ rescue => e
53
+ catch_errors(e)
54
54
  end
55
55
  end
56
56
  end
@@ -72,8 +72,8 @@ module Crowbar
72
72
  barclamp: barclamp
73
73
  )
74
74
  ).execute
75
- rescue SimpleCatchableError => e
76
- err e.message, 1
75
+ rescue => e
76
+ catch_errors(e)
77
77
  end
78
78
 
79
79
  desc "show BARCLAMP ROLE",
@@ -131,8 +131,8 @@ module Crowbar
131
131
  role: role
132
132
  )
133
133
  ).execute
134
- rescue SimpleCatchableError => e
135
- err e.message, 1
134
+ rescue => e
135
+ catch_errors(e)
136
136
  end
137
137
  end
138
138
  end
@@ -32,8 +32,8 @@ module Crowbar
32
32
  barclamp: barclamp
33
33
  )
34
34
  ).execute
35
- rescue SimpleCatchableError => e
36
- err e.message, 1
35
+ rescue => e
36
+ catch_errors(e)
37
37
  end
38
38
  end
39
39
  end
@@ -36,8 +36,8 @@ module Crowbar
36
36
  suggestion: suggestion
37
37
  )
38
38
  ).execute
39
- rescue SimpleCatchableError => e
40
- err e.message, 1
39
+ rescue => e
40
+ catch_errors(e)
41
41
  end
42
42
 
43
43
  desc "deallocate PROPOSAL SERVICE NETWORK",
@@ -56,8 +56,8 @@ module Crowbar
56
56
  network: network
57
57
  )
58
58
  ).execute
59
- rescue SimpleCatchableError => e
60
- err e.message, 1
59
+ rescue => e
60
+ catch_errors(e)
61
61
  end
62
62
  end
63
63
  end
@@ -29,6 +29,9 @@ module Crowbar
29
29
  autoload :HostIP,
30
30
  File.expand_path("../command/host_ip", __FILE__)
31
31
 
32
+ autoload :Installer,
33
+ File.expand_path("../command/installer", __FILE__)
34
+
32
35
  autoload :Interface,
33
36
  File.expand_path("../command/interface", __FILE__)
34
37
 
@@ -0,0 +1,29 @@
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 Installer
21
+ autoload :Status,
22
+ File.expand_path("../installer/status", __FILE__)
23
+
24
+ autoload :Start,
25
+ File.expand_path("../installer/start", __FILE__)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,50 @@
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 Installer
21
+ class Start < Base
22
+ def request
23
+ @request ||= Request::Installer::Start.new(
24
+ args.easy_merge(
25
+ force: options.force
26
+ )
27
+ )
28
+ end
29
+
30
+ def execute
31
+ request.process do |request|
32
+ case request.code
33
+ when 200
34
+ say "Triggered installation process"
35
+ when 226
36
+ say "Crowbar already installing"
37
+ when 410
38
+ say "Installation is already done"
39
+ when 501
40
+ err "Platform is not supported"
41
+ else
42
+ err request.parsed_response["error"]
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ 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
+ module Crowbar
18
+ module Client
19
+ module Command
20
+ module Installer
21
+ class Status < Base
22
+ include Mixin::Format
23
+ include Mixin::Filter
24
+
25
+ def request
26
+ @request ||= Request::Installer::Status.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::Nested.new(
36
+ format: provide_format,
37
+ headings: ["Status", "Value"],
38
+ values: Filter::Subset.new(
39
+ filter: provide_filter,
40
+ values: content_from(request)
41
+ ).result
42
+ )
43
+
44
+ if formatter.empty?
45
+ err "No status"
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 content_from(request)
58
+ request.parsed_response.except(
59
+ "errorMsg",
60
+ "noticeMsg",
61
+ "successMsg"
62
+ )
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -66,9 +66,11 @@ module Crowbar
66
66
 
67
67
  def from_data
68
68
  json = begin
69
- JSON.load options[:data]
70
- rescue
71
- err "Invalid json data"
69
+ JSON.load(
70
+ options[:data]
71
+ )
72
+ rescue JSON::ParserError
73
+ err "Failed to parse JSON"
72
74
  end
73
75
 
74
76
  if options[:merge]
@@ -82,9 +84,21 @@ module Crowbar
82
84
 
83
85
  def from_file
84
86
  json = begin
85
- JSON.load options[:file]
87
+ file = File.read(
88
+ options[:file]
89
+ )
90
+
91
+ JSON.load(
92
+ file
93
+ )
94
+ rescue Errno::EACCES
95
+ err "Failed to access file"
96
+ rescue Errno::ENOENT
97
+ err "Failed to read file"
98
+ rescue JSON::ParserError
99
+ err "Failed to parse JSON"
86
100
  rescue
87
- err "Invalid json file"
101
+ err "Failed to process file"
88
102
  end
89
103
 
90
104
  if options[:merge]
@@ -65,9 +65,11 @@ module Crowbar
65
65
 
66
66
  def from_data
67
67
  json = begin
68
- JSON.load options[:data]
69
- rescue
70
- err "Invalid json data"
68
+ JSON.load(
69
+ options[:data]
70
+ )
71
+ rescue JSON::ParserError
72
+ err "Failed to parse JSON"
71
73
  end
72
74
 
73
75
  if options[:merge]
@@ -81,9 +83,21 @@ module Crowbar
81
83
 
82
84
  def from_file
83
85
  json = begin
84
- JSON.load options[:file]
86
+ file = File.read(
87
+ options[:file]
88
+ )
89
+
90
+ JSON.load(
91
+ file
92
+ )
93
+ rescue Errno::EACCES
94
+ err "Failed to access file"
95
+ rescue Errno::ENOENT
96
+ err "Failed to read file"
97
+ rescue JSON::ParserError
98
+ err "Failed to parse JSON"
85
99
  rescue
86
- err "Invalid json file"
100
+ err "Failed to process file"
87
101
  end
88
102
 
89
103
  if options[:merge]