crowbar-client 3.6.1 → 3.9.3
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 +33 -0
- data/lib/crowbar/client/app.rb +6 -0
- data/lib/crowbar/client/app/entry.rb +13 -0
- data/lib/crowbar/client/app/proposal.rb +20 -0
- data/lib/crowbar/client/app/restricted.rb +136 -0
- data/lib/crowbar/client/app/ses.rb +54 -0
- data/lib/crowbar/client/command.rb +6 -0
- data/lib/crowbar/client/command/base.rb +9 -0
- data/lib/crowbar/client/command/proposal/edit.rb +5 -1
- data/lib/crowbar/client/command/proposal/show.rb +7 -1
- data/lib/crowbar/client/command/restricted.rb +38 -0
- data/lib/crowbar/client/command/restricted/allocate.rb +51 -0
- data/lib/crowbar/client/command/restricted/ping.rb +45 -0
- data/lib/crowbar/client/command/restricted/show.rb +72 -0
- data/lib/crowbar/client/command/restricted/transition.rb +47 -0
- data/lib/crowbar/client/command/ses.rb +29 -0
- data/lib/crowbar/client/command/ses/upload.rb +60 -0
- data/lib/crowbar/client/command/upgrade/repocheck.rb +3 -1
- data/lib/crowbar/client/config.rb +24 -8
- data/lib/crowbar/client/request.rb +6 -0
- data/lib/crowbar/client/request/restricted.rb +38 -0
- data/lib/crowbar/client/request/restricted/allocate.rb +50 -0
- data/lib/crowbar/client/request/restricted/ping.rb +49 -0
- data/lib/crowbar/client/request/restricted/show.rb +50 -0
- data/lib/crowbar/client/request/restricted/transition.rb +63 -0
- data/lib/crowbar/client/request/ses.rb +29 -0
- data/lib/crowbar/client/request/ses/upload.rb +65 -0
- data/lib/crowbar/client/util.rb +3 -0
- data/lib/crowbar/client/util/apiversion.rb +2 -8
- data/lib/crowbar/client/util/osrelease.rb +37 -0
- data/lib/crowbar/client/version.rb +2 -2
- metadata +26 -10
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019, SUSE
|
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 Restricted
|
21
|
+
#
|
22
|
+
# Implementation for the restricted ping command
|
23
|
+
#
|
24
|
+
class Ping < Base
|
25
|
+
def request
|
26
|
+
@request ||= Request::Restricted::Ping.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 pinged the administration server"
|
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,72 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019, SUSE
|
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 Restricted
|
21
|
+
#
|
22
|
+
# Implementation for the restricted show command
|
23
|
+
#
|
24
|
+
class Show < Base
|
25
|
+
include Mixin::Format
|
26
|
+
include Mixin::Filter
|
27
|
+
|
28
|
+
def request
|
29
|
+
@request ||= Request::Restricted::Show.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
|
+
path: provide_filter,
|
41
|
+
headings: ["Key", "Value"],
|
42
|
+
values: Filter::Subset.new(
|
43
|
+
filter: provide_filter,
|
44
|
+
values: content_from(request)
|
45
|
+
).result
|
46
|
+
)
|
47
|
+
|
48
|
+
if formatter.empty?
|
49
|
+
err "No result"
|
50
|
+
elsif args.name == "help"
|
51
|
+
err "Node does not exist"
|
52
|
+
else
|
53
|
+
say formatter.result
|
54
|
+
end
|
55
|
+
when 404
|
56
|
+
err "Node does not exist"
|
57
|
+
else
|
58
|
+
err request.parsed_response["error"]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def content_from(request)
|
66
|
+
request.parsed_response
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019, SUSE
|
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 Restricted
|
21
|
+
#
|
22
|
+
# Implementation for the restricted transition command
|
23
|
+
#
|
24
|
+
class Transition < Base
|
25
|
+
def request
|
26
|
+
@request ||= Request::Restricted::Transition.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 transitioned to #{args.state}"
|
36
|
+
when 404
|
37
|
+
err "Node does not exist"
|
38
|
+
else
|
39
|
+
err request.parsed_response["error"]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019, SUSE
|
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
|
+
#
|
21
|
+
# Module for the SES command implementations
|
22
|
+
#
|
23
|
+
module Ses
|
24
|
+
autoload :Upload,
|
25
|
+
File.expand_path("../ses/upload", __FILE__)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright 2019, SUSE
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
|
16
|
+
module Crowbar
|
17
|
+
module Client
|
18
|
+
module Command
|
19
|
+
module Ses
|
20
|
+
#
|
21
|
+
# Implementation for the SES config upload command
|
22
|
+
#
|
23
|
+
class Upload < Base
|
24
|
+
def request
|
25
|
+
args.file =
|
26
|
+
case args.file
|
27
|
+
when "-"
|
28
|
+
stdin.to_io
|
29
|
+
when File
|
30
|
+
args.file
|
31
|
+
else
|
32
|
+
unless File.exist?(args.file)
|
33
|
+
err "File #{args.file} does not exist."
|
34
|
+
end
|
35
|
+
File.new(
|
36
|
+
args.file,
|
37
|
+
File::RDONLY
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
@request ||= Request::Ses::Upload.new(
|
42
|
+
args
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def execute
|
47
|
+
request.process do |request|
|
48
|
+
case request.code
|
49
|
+
when 200
|
50
|
+
say "Successfully uploaded SES configuration"
|
51
|
+
else
|
52
|
+
err request.parsed_response["error"]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -50,6 +50,8 @@ module Crowbar
|
|
50
50
|
bad_repos.each do |bad_repo|
|
51
51
|
hint = "Some repopositories are not available. " \
|
52
52
|
"Fix the problem and call the step again."
|
53
|
+
repos[bad_repo] = { repo: bad_repo, status: [], type: type } \
|
54
|
+
unless repos.key? bad_repo
|
53
55
|
repos[bad_repo][:status] << "#{error} (#{arch})"
|
54
56
|
end
|
55
57
|
end
|
@@ -100,7 +102,7 @@ module Crowbar
|
|
100
102
|
)
|
101
103
|
else
|
102
104
|
err "No such component '#{args.component}'. " \
|
103
|
-
"Only '
|
105
|
+
"Only 'crowbar' and 'nodes' are valid components."
|
104
106
|
end
|
105
107
|
end
|
106
108
|
end
|
@@ -61,6 +61,7 @@ module Crowbar
|
|
61
61
|
apiversion: default_apiversion,
|
62
62
|
experimental: default_experimental,
|
63
63
|
upgrade_versions: default_upgrade_versions,
|
64
|
+
cloud_version: default_cloud_version,
|
64
65
|
debug: default_debug
|
65
66
|
)
|
66
67
|
end
|
@@ -108,18 +109,33 @@ module Crowbar
|
|
108
109
|
return "7-to-8" if File.exist?("/var/lib/crowbar/upgrade/7-to-8-upgrade-running")
|
109
110
|
|
110
111
|
# if upgrade has not been started, check the system version
|
111
|
-
|
112
|
-
|
113
|
-
if File.exist?(os_release_file)
|
114
|
-
os_release = Hash[
|
115
|
-
File.open(os_release_file).read.scan(/(\S+)\s*=\s*"([^"]+)/)
|
116
|
-
]
|
117
|
-
return "6-to-7" if os_release["VERSION_ID"] == "12.1"
|
118
|
-
end
|
112
|
+
return "6-to-7" if default_cloud_version == "6"
|
119
113
|
|
120
114
|
"7-to-8"
|
121
115
|
end
|
122
116
|
|
117
|
+
#
|
118
|
+
# Define a default cloud version value
|
119
|
+
# It is detected based on OS release for local machine or set by user via ENV variable.
|
120
|
+
#
|
121
|
+
# @return [String] the default cloud version value
|
122
|
+
#
|
123
|
+
def default_cloud_version
|
124
|
+
return ENV["CROWBAR_CLOUD_VERSION"] if ENV["CROWBAR_CLOUD_VERSION"].present?
|
125
|
+
|
126
|
+
os_release = Crowbar::Client::Util::OsRelease.fields
|
127
|
+
case os_release["VERSION_ID"]
|
128
|
+
when "12.1"
|
129
|
+
"6"
|
130
|
+
when "12.2"
|
131
|
+
"7"
|
132
|
+
when "12.3"
|
133
|
+
"8"
|
134
|
+
else
|
135
|
+
"9"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
123
139
|
#
|
124
140
|
# Define a default alias value
|
125
141
|
#
|
@@ -59,9 +59,15 @@ module Crowbar
|
|
59
59
|
autoload :Rest,
|
60
60
|
File.expand_path("../request/rest", __FILE__)
|
61
61
|
|
62
|
+
autoload :Restricted,
|
63
|
+
File.expand_path("../request/restricted", __FILE__)
|
64
|
+
|
62
65
|
autoload :Role,
|
63
66
|
File.expand_path("../request/role", __FILE__)
|
64
67
|
|
68
|
+
autoload :Ses,
|
69
|
+
File.expand_path("../request/ses", __FILE__)
|
70
|
+
|
65
71
|
autoload :Server,
|
66
72
|
File.expand_path("../request/server", __FILE__)
|
67
73
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019, SUSE
|
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 Restricted request implementations
|
22
|
+
#
|
23
|
+
module Restricted
|
24
|
+
autoload :Allocate,
|
25
|
+
File.expand_path("../restricted/allocate", __FILE__)
|
26
|
+
|
27
|
+
autoload :Ping,
|
28
|
+
File.expand_path("../restricted/ping", __FILE__)
|
29
|
+
|
30
|
+
autoload :Show,
|
31
|
+
File.expand_path("../restricted/show", __FILE__)
|
32
|
+
|
33
|
+
autoload :Transition,
|
34
|
+
File.expand_path("../restricted/transition", __FILE__)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019, SUSE
|
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 Restricted
|
21
|
+
#
|
22
|
+
# Implementation for the restricted allocate request
|
23
|
+
#
|
24
|
+
class Allocate < Base
|
25
|
+
#
|
26
|
+
# HTTP method that gets used by the request
|
27
|
+
#
|
28
|
+
# @return [Symbol] the method for the request
|
29
|
+
#
|
30
|
+
def method
|
31
|
+
:post
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Path to the API endpoint for the request
|
36
|
+
#
|
37
|
+
# @return [String] path to the API endpoint
|
38
|
+
#
|
39
|
+
def url
|
40
|
+
[
|
41
|
+
"restricted",
|
42
|
+
"allocate",
|
43
|
+
attrs.name
|
44
|
+
].join("/")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2019, SUSE
|
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 Restricted
|
21
|
+
#
|
22
|
+
# Implementation for the restricted ping request
|
23
|
+
#
|
24
|
+
class Ping < Base
|
25
|
+
#
|
26
|
+
# HTTP method that gets used by the request
|
27
|
+
#
|
28
|
+
# @return [Symbol] the method for the request
|
29
|
+
#
|
30
|
+
def method
|
31
|
+
:get
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Path to the API endpoint for the request
|
36
|
+
#
|
37
|
+
# @return [String] path to the API endpoint
|
38
|
+
#
|
39
|
+
def url
|
40
|
+
[
|
41
|
+
"restricted",
|
42
|
+
"ping"
|
43
|
+
].join("/")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|