crowbar-client 2.3.0 → 2.4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/crowbar/client/app/backup.rb +87 -21
- data/lib/crowbar/client/app/base.rb +20 -0
- data/lib/crowbar/client/app/batch.rb +44 -31
- data/lib/crowbar/client/app/host_ip.rb +2 -0
- data/lib/crowbar/client/app/interface.rb +2 -0
- data/lib/crowbar/client/app/virtual_ip.rb +2 -0
- data/lib/crowbar/client/command/backup.rb +3 -0
- data/lib/crowbar/client/command/backup/delete.rb +2 -0
- data/lib/crowbar/client/command/backup/download.rb +21 -14
- data/lib/crowbar/client/command/backup/list.rb +6 -3
- data/lib/crowbar/client/command/backup/restore.rb +42 -0
- data/lib/crowbar/client/command/backup/upload.rb +13 -0
- data/lib/crowbar/client/command/base.rb +3 -0
- data/lib/crowbar/client/command/batch/build.rb +26 -0
- data/lib/crowbar/client/command/batch/export.rb +43 -0
- data/lib/crowbar/client/command/installer/start.rb +2 -0
- data/lib/crowbar/client/filter/hash.rb +1 -1
- data/lib/crowbar/client/request/backup.rb +3 -0
- data/lib/crowbar/client/request/backup/create.rb +1 -3
- data/lib/crowbar/client/request/backup/delete.rb +1 -1
- data/lib/crowbar/client/request/backup/download.rb +1 -1
- data/lib/crowbar/client/request/backup/restore.rb +38 -0
- data/lib/crowbar/client/request/backup/upload.rb +0 -2
- data/lib/crowbar/client/request/batch/build.rb +17 -2
- data/lib/crowbar/client/request/batch/export.rb +22 -2
- data/lib/crowbar/client/version.rb +1 -1
- data/spec/crowbar/client/command/backup/create_spec.rb +1 -3
- data/spec/crowbar/client/command/backup/delete_spec.rb +1 -2
- data/spec/crowbar/client/command/backup/download_spec.rb +1 -1
- data/spec/crowbar/client/command/backup/restore_spec.rb +40 -0
- data/spec/crowbar/client/command/backup/upload_spec.rb +4 -1
- data/spec/crowbar/client/command/batch/build_spec.rb +5 -1
- data/spec/crowbar/client/request/backup/create_spec.rb +2 -4
- data/spec/crowbar/client/request/backup/delete_spec.rb +2 -2
- data/spec/crowbar/client/request/backup/download_spec.rb +2 -2
- data/spec/crowbar/client/request/backup/list_spec.rb +2 -4
- data/spec/crowbar/client/request/backup/restore_spec.rb +52 -0
- data/spec/crowbar/client/request/batch/build_spec.rb +35 -44
- data/spec/crowbar/client/request/batch/export_spec.rb +33 -44
- data/spec/crowbar/client/request/proposal/create_spec.rb +2 -1
- data/spec/crowbar/client/request/proposal/edit_spec.rb +2 -1
- data/spec/fixtures/batch.yml +0 -0
- metadata +11 -3
@@ -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 Restore < Base
|
22
|
+
def request
|
23
|
+
@request ||= Request::Backup::Restore.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 triggered a restore"
|
33
|
+
else
|
34
|
+
err request.parsed_response["error"]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -19,6 +19,19 @@ module Crowbar
|
|
19
19
|
module Backup
|
20
20
|
class Upload < Base
|
21
21
|
def request
|
22
|
+
args.file =
|
23
|
+
case args.file
|
24
|
+
when "-"
|
25
|
+
stdin.to_io
|
26
|
+
when File
|
27
|
+
args.file
|
28
|
+
else
|
29
|
+
File.new(
|
30
|
+
args.file,
|
31
|
+
File::RDONLY
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
22
35
|
@request ||= Request::Backup::Upload.new(
|
23
36
|
args
|
24
37
|
)
|
@@ -15,11 +15,14 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
require "hashie"
|
18
|
+
require "active_support/number_helper"
|
18
19
|
|
19
20
|
module Crowbar
|
20
21
|
module Client
|
21
22
|
module Command
|
22
23
|
class Base
|
24
|
+
include ActiveSupport::NumberHelper
|
25
|
+
|
23
26
|
attr_accessor :stdin
|
24
27
|
attr_accessor :stdout
|
25
28
|
attr_accessor :stderr
|
@@ -14,12 +14,32 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require "easy_diff"
|
18
|
+
|
17
19
|
module Crowbar
|
18
20
|
module Client
|
19
21
|
module Command
|
20
22
|
module Batch
|
21
23
|
class Build < Base
|
22
24
|
def request
|
25
|
+
args.easy_merge!(
|
26
|
+
includes: options.includes,
|
27
|
+
excludes: options.excludes
|
28
|
+
)
|
29
|
+
|
30
|
+
args.file =
|
31
|
+
case args.file
|
32
|
+
when "-"
|
33
|
+
stdin.to_io
|
34
|
+
when File
|
35
|
+
args.file
|
36
|
+
else
|
37
|
+
File.new(
|
38
|
+
args.file,
|
39
|
+
File::RDONLY
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
23
43
|
@request ||= Request::Batch::Build.new(
|
24
44
|
args
|
25
45
|
)
|
@@ -27,6 +47,12 @@ module Crowbar
|
|
27
47
|
|
28
48
|
def execute
|
29
49
|
request.process do |request|
|
50
|
+
case request.code
|
51
|
+
when 200
|
52
|
+
say "Successfully built batch"
|
53
|
+
else
|
54
|
+
err request.body
|
55
|
+
end
|
30
56
|
end
|
31
57
|
end
|
32
58
|
end
|
@@ -14,12 +14,19 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require "easy_diff"
|
18
|
+
|
17
19
|
module Crowbar
|
18
20
|
module Client
|
19
21
|
module Command
|
20
22
|
module Batch
|
21
23
|
class Export < Base
|
22
24
|
def request
|
25
|
+
args.easy_merge!(
|
26
|
+
includes: options.includes,
|
27
|
+
excludes: options.excludes
|
28
|
+
)
|
29
|
+
|
23
30
|
@request ||= Request::Batch::Export.new(
|
24
31
|
args
|
25
32
|
)
|
@@ -27,8 +34,44 @@ module Crowbar
|
|
27
34
|
|
28
35
|
def execute
|
29
36
|
request.process do |request|
|
37
|
+
case request.code
|
38
|
+
when 200
|
39
|
+
if write(request.body)
|
40
|
+
say "Successfully exported batch"
|
41
|
+
else
|
42
|
+
err "Failed to export batch"
|
43
|
+
end
|
44
|
+
else
|
45
|
+
err request.parsed_response["error"]
|
46
|
+
end
|
30
47
|
end
|
31
48
|
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def write(body)
|
53
|
+
path.binmode
|
54
|
+
path.write body
|
55
|
+
|
56
|
+
true
|
57
|
+
rescue
|
58
|
+
false
|
59
|
+
end
|
60
|
+
|
61
|
+
def path
|
62
|
+
@path ||=
|
63
|
+
case args.file
|
64
|
+
when "-"
|
65
|
+
stdout.to_io
|
66
|
+
when File
|
67
|
+
args.file
|
68
|
+
else
|
69
|
+
File.new(
|
70
|
+
args.file,
|
71
|
+
File::CREAT | File::TRUNC | File::RDWR
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
32
75
|
end
|
33
76
|
end
|
34
77
|
end
|
@@ -0,0 +1,38 @@
|
|
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 Request
|
20
|
+
module Backup
|
21
|
+
class Restore < Base
|
22
|
+
def method
|
23
|
+
:post
|
24
|
+
end
|
25
|
+
|
26
|
+
def url
|
27
|
+
[
|
28
|
+
"utils",
|
29
|
+
"backups",
|
30
|
+
attrs.name,
|
31
|
+
"restore"
|
32
|
+
].join("/")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -19,12 +19,27 @@ module Crowbar
|
|
19
19
|
module Request
|
20
20
|
module Batch
|
21
21
|
class Build < Base
|
22
|
+
def params
|
23
|
+
{
|
24
|
+
headers: headers,
|
25
|
+
query: {
|
26
|
+
includes: attrs.includes,
|
27
|
+
excludes: attrs.excludes,
|
28
|
+
file: attrs.file
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
22
33
|
def method
|
23
|
-
:
|
34
|
+
:post
|
24
35
|
end
|
25
36
|
|
26
37
|
def url
|
27
|
-
[
|
38
|
+
[
|
39
|
+
"utils",
|
40
|
+
"batch",
|
41
|
+
"build"
|
42
|
+
].join("/")
|
28
43
|
end
|
29
44
|
end
|
30
45
|
end
|
@@ -14,17 +14,37 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require "easy_diff"
|
18
|
+
|
17
19
|
module Crowbar
|
18
20
|
module Client
|
19
21
|
module Request
|
20
22
|
module Batch
|
21
23
|
class Export < Base
|
24
|
+
def content
|
25
|
+
super.easy_merge!(
|
26
|
+
includes: attrs.includes,
|
27
|
+
excludes: attrs.excludes
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def headers
|
32
|
+
super.easy_merge!(
|
33
|
+
"Content-Type" => "application/octet-stream",
|
34
|
+
"Accept" => "application/octet-stream"
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
22
38
|
def method
|
23
|
-
:
|
39
|
+
:post
|
24
40
|
end
|
25
41
|
|
26
42
|
def url
|
27
|
-
[
|
43
|
+
[
|
44
|
+
"utils",
|
45
|
+
"batch",
|
46
|
+
"export"
|
47
|
+
].join("/")
|
28
48
|
end
|
29
49
|
end
|
30
50
|
end
|
@@ -0,0 +1,40 @@
|
|
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_relative "../../../../spec_helper"
|
18
|
+
|
19
|
+
describe "Crowbar::Client::Command::Backup::Restore" do
|
20
|
+
include_context "command_context"
|
21
|
+
|
22
|
+
subject do
|
23
|
+
::Crowbar::Client::Command::Backup::Restore.new(
|
24
|
+
stdin,
|
25
|
+
stdout,
|
26
|
+
stderr,
|
27
|
+
name: "test-backup"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should always return a request class" do
|
32
|
+
expect(subject.request).to(
|
33
|
+
be_a(
|
34
|
+
::Crowbar::Client::Request::Backup::Restore
|
35
|
+
)
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
pending
|
40
|
+
end
|