crowbar-client 3.0.1 → 3.1.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 (51) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +7 -0
  3. data/lib/crowbar/client/app.rb +3 -0
  4. data/lib/crowbar/client/app/entry.rb +4 -0
  5. data/lib/crowbar/client/app/upgrade.rb +280 -0
  6. data/lib/crowbar/client/command.rb +3 -0
  7. data/lib/crowbar/client/command/upgrade.rb +50 -0
  8. data/lib/crowbar/client/command/upgrade/backup.rb +45 -0
  9. data/lib/crowbar/client/command/upgrade/crowbar.rb +45 -0
  10. data/lib/crowbar/client/command/upgrade/node.rb +45 -0
  11. data/lib/crowbar/client/command/upgrade/prechecks.rb +61 -0
  12. data/lib/crowbar/client/command/upgrade/prepare.rb +45 -0
  13. data/lib/crowbar/client/command/upgrade/repocheck.rb +61 -0
  14. data/lib/crowbar/client/command/upgrade/services.rb +45 -0
  15. data/lib/crowbar/client/command/upgrade/status.rb +61 -0
  16. data/lib/crowbar/client/config.rb +2 -4
  17. data/lib/crowbar/client/request.rb +3 -0
  18. data/lib/crowbar/client/request/upgrade.rb +50 -0
  19. data/lib/crowbar/client/request/upgrade/backup.rb +83 -0
  20. data/lib/crowbar/client/request/upgrade/crowbar.rb +63 -0
  21. data/lib/crowbar/client/request/upgrade/node.rb +75 -0
  22. data/lib/crowbar/client/request/upgrade/prechecks.rb +63 -0
  23. data/lib/crowbar/client/request/upgrade/prepare.rb +63 -0
  24. data/lib/crowbar/client/request/upgrade/repocheck.rb +72 -0
  25. data/lib/crowbar/client/request/upgrade/services.rb +63 -0
  26. data/lib/crowbar/client/request/upgrade/status.rb +62 -0
  27. data/lib/crowbar/client/version.rb +2 -2
  28. data/spec/crowbar/client/command/upgrade/backup_spec.rb +34 -0
  29. data/spec/crowbar/client/command/upgrade/crowbar_spec.rb +31 -0
  30. data/spec/crowbar/client/command/upgrade/node_spec.rb +32 -0
  31. data/spec/crowbar/client/command/upgrade/prechecks_spec.rb +31 -0
  32. data/spec/crowbar/client/command/upgrade/prepare_spec.rb +31 -0
  33. data/spec/crowbar/client/command/upgrade/repocheck_spec.rb +34 -0
  34. data/spec/crowbar/client/command/upgrade/services_spec.rb +31 -0
  35. data/spec/crowbar/client/command/upgrade/status_spec.rb +31 -0
  36. data/spec/crowbar/client/request/backup/create_spec.rb +4 -0
  37. data/spec/crowbar/client/request/backup/delete_spec.rb +4 -0
  38. data/spec/crowbar/client/request/backup/download_spec.rb +4 -0
  39. data/spec/crowbar/client/request/backup/list_spec.rb +4 -0
  40. data/spec/crowbar/client/request/backup/restore_spec.rb +4 -0
  41. data/spec/crowbar/client/request/backup/upload_spec.rb +4 -0
  42. data/spec/crowbar/client/request/{party_spec.rb → rest_spec.rb} +3 -3
  43. data/spec/crowbar/client/request/upgrade/backup_spec.rb +53 -0
  44. data/spec/crowbar/client/request/upgrade/crowbar_spec.rb +53 -0
  45. data/spec/crowbar/client/request/upgrade/node_spec.rb +55 -0
  46. data/spec/crowbar/client/request/upgrade/prechecks_spec.rb +53 -0
  47. data/spec/crowbar/client/request/upgrade/prepare_spec.rb +53 -0
  48. data/spec/crowbar/client/request/upgrade/repocheck_spec.rb +56 -0
  49. data/spec/crowbar/client/request/upgrade/services_spec.rb +53 -0
  50. data/spec/crowbar/client/request/upgrade/status_spec.rb +53 -0
  51. metadata +55 -4
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright 2016, 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 Upgrade
21
+ #
22
+ # Implementation for the upgrade crowbar command
23
+ #
24
+ class Crowbar < Base
25
+ def request
26
+ @request ||= Request::Upgrade::Crowbar.new(
27
+ args
28
+ )
29
+ end
30
+
31
+ def execute
32
+ request.process do |request|
33
+ case request.code
34
+ when 200
35
+ say "Triggered Crowbar operating system upgrade"
36
+ else
37
+ err request.parsed_response["error"]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,45 @@
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 Upgrade
21
+ #
22
+ # Implementation for the upgrade node command
23
+ #
24
+ class Node < Base
25
+ def request
26
+ @request ||= Request::Upgrade::Node.new(
27
+ args
28
+ )
29
+ end
30
+
31
+ def execute
32
+ request.process do |request|
33
+ case request.code
34
+ when 200
35
+ say "Successfully triggered node upgrade on #{args.id}"
36
+ else
37
+ err request.parsed_response["error"]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,61 @@
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 Upgrade
21
+ #
22
+ # Implementation for the upgrade status command
23
+ #
24
+ class Prechecks < Base
25
+ include Mixin::Format
26
+ include Mixin::Filter
27
+
28
+ def request
29
+ @request ||= Request::Upgrade::Prechecks.new(
30
+ args
31
+ )
32
+ end
33
+
34
+ def execute
35
+ request.process do |request|
36
+ case request.code
37
+ when 200
38
+ formatter = Formatter::Nested.new(
39
+ format: provide_format,
40
+ headings: ["Check", "Successful"],
41
+ values: Filter::Subset.new(
42
+ filter: provide_filter,
43
+ values: request.parsed_response
44
+ ).result
45
+ )
46
+
47
+ if formatter.empty?
48
+ err "No checks"
49
+ else
50
+ say formatter.result
51
+ end
52
+ else
53
+ err request.parsed_response["error"]
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright 2016, 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 Upgrade
21
+ #
22
+ # Implementation for the upgrade prepare command
23
+ #
24
+ class Prepare < Base
25
+ def request
26
+ @request ||= Request::Upgrade::Prepare.new(
27
+ args
28
+ )
29
+ end
30
+
31
+ def execute
32
+ request.process do |request|
33
+ case request.code
34
+ when 200
35
+ say "Setting nodes to upgrade state"
36
+ else
37
+ err request.parsed_response["error"]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,61 @@
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 Upgrade
21
+ #
22
+ # Implementation for the upgrade repocheck command
23
+ #
24
+ class Repocheck < Base
25
+ include Mixin::Format
26
+ include Mixin::Filter
27
+
28
+ def request
29
+ @request ||= Request::Upgrade::Repocheck.new(
30
+ args
31
+ )
32
+ end
33
+
34
+ def execute
35
+ request.process do |request|
36
+ case request.code
37
+ when 200
38
+ formatter = Formatter::Nested.new(
39
+ format: provide_format,
40
+ headings: ["Status", "Value"],
41
+ values: Filter::Subset.new(
42
+ filter: provide_filter,
43
+ values: request.parsed_response
44
+ ).result
45
+ )
46
+
47
+ if formatter.empty?
48
+ err "No repochecks"
49
+ else
50
+ say formatter.result
51
+ end
52
+ else
53
+ err request.parsed_response["error"]
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright 2016, 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 Upgrade
21
+ #
22
+ # Implementation for the upgrade services command
23
+ #
24
+ class Services < Base
25
+ def request
26
+ @request ||= Request::Upgrade::Services.new(
27
+ args
28
+ )
29
+ end
30
+
31
+ def execute
32
+ request.process do |request|
33
+ case request.code
34
+ when 200
35
+ say "Stopping related services on all nodes"
36
+ else
37
+ err request.parsed_response["error"]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,61 @@
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 Upgrade
21
+ #
22
+ # Implementation for the upgrade status command
23
+ #
24
+ class Status < Base
25
+ include Mixin::Format
26
+ include Mixin::Filter
27
+
28
+ def request
29
+ @request ||= Request::Upgrade::Status.new(
30
+ args
31
+ )
32
+ end
33
+
34
+ def execute
35
+ request.process do |request|
36
+ case request.code
37
+ when 200
38
+ formatter = Formatter::Nested.new(
39
+ format: provide_format,
40
+ headings: ["Status", "Value"],
41
+ values: Filter::Subset.new(
42
+ filter: provide_filter,
43
+ values: request.parsed_response
44
+ ).result
45
+ )
46
+
47
+ if formatter.empty?
48
+ err "No status"
49
+ else
50
+ say formatter.result
51
+ end
52
+ else
53
+ err request.parsed_response["error"]
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -162,11 +162,9 @@ module Crowbar
162
162
  #
163
163
  def default_apiversion
164
164
  if ENV["CROWBAR_APIVERSION"].present?
165
- [
166
- 1.0, 2.0
167
- ].include? ENV["CROWBAR_APIVERSION"]
165
+ ENV["CROWBAR_APIVERSION"].to_f
168
166
  else
169
- 2.0
167
+ 1.0
170
168
  end
171
169
  end
172
170
 
@@ -59,6 +59,9 @@ module Crowbar
59
59
  autoload :Server,
60
60
  File.expand_path("../request/server", __FILE__)
61
61
 
62
+ autoload :Upgrade,
63
+ File.expand_path("../request/upgrade", __FILE__)
64
+
62
65
  autoload :VirtualIP,
63
66
  File.expand_path("../request/virtual_ip", __FILE__)
64
67
  end
@@ -0,0 +1,50 @@
1
+ #
2
+ # Copyright 2016, 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 Request
20
+ #
21
+ # Module for the upgrade request implementations
22
+ #
23
+ module Upgrade
24
+ autoload :Backup,
25
+ File.expand_path("../upgrade/backup", __FILE__)
26
+
27
+ autoload :Crowbar,
28
+ File.expand_path("../upgrade/crowbar", __FILE__)
29
+
30
+ autoload :Node,
31
+ File.expand_path("../upgrade/node", __FILE__)
32
+
33
+ autoload :Prechecks,
34
+ File.expand_path("../upgrade/prechecks", __FILE__)
35
+
36
+ autoload :Prepare,
37
+ File.expand_path("../upgrade/prepare", __FILE__)
38
+
39
+ autoload :Repocheck,
40
+ File.expand_path("../upgrade/repocheck", __FILE__)
41
+
42
+ autoload :Services,
43
+ File.expand_path("../upgrade/services", __FILE__)
44
+
45
+ autoload :Status,
46
+ File.expand_path("../upgrade/status", __FILE__)
47
+ end
48
+ end
49
+ end
50
+ end