crowbar-client 1.0.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 +7 -0
- data/CHANGELOG.md +6 -0
- data/LICENSE +202 -0
- data/README.md +49 -0
- data/bin/crowbar +37 -0
- data/lib/crowbar-client.rb +17 -0
- data/lib/crowbar/client.rb +82 -0
- data/lib/crowbar/client/app.rb +60 -0
- data/lib/crowbar/client/app/barclamp.rb +77 -0
- data/lib/crowbar/client/app/base.rb +97 -0
- data/lib/crowbar/client/app/batch.rb +100 -0
- data/lib/crowbar/client/app/entry.rb +121 -0
- data/lib/crowbar/client/app/host_ip.rb +65 -0
- data/lib/crowbar/client/app/interface.rb +63 -0
- data/lib/crowbar/client/app/network.rb +35 -0
- data/lib/crowbar/client/app/node.rb +451 -0
- data/lib/crowbar/client/app/proposal.rb +300 -0
- data/lib/crowbar/client/app/repository.rb +149 -0
- data/lib/crowbar/client/app/reset.rb +58 -0
- data/lib/crowbar/client/app/role.rb +140 -0
- data/lib/crowbar/client/app/virtual_ip.rb +65 -0
- data/lib/crowbar/client/command.rb +54 -0
- data/lib/crowbar/client/command/barclamp.rb +26 -0
- data/lib/crowbar/client/command/barclamp/list.rb +64 -0
- data/lib/crowbar/client/command/base.rb +55 -0
- data/lib/crowbar/client/command/batch.rb +29 -0
- data/lib/crowbar/client/command/batch/build.rb +36 -0
- data/lib/crowbar/client/command/batch/export.rb +36 -0
- data/lib/crowbar/client/command/host_ip.rb +29 -0
- data/lib/crowbar/client/command/host_ip/allocate.rb +50 -0
- data/lib/crowbar/client/command/host_ip/deallocate.rb +42 -0
- data/lib/crowbar/client/command/interface.rb +29 -0
- data/lib/crowbar/client/command/interface/disable.rb +42 -0
- data/lib/crowbar/client/command/interface/enable.rb +50 -0
- data/lib/crowbar/client/command/node.rb +74 -0
- data/lib/crowbar/client/command/node/allocate.rb +48 -0
- data/lib/crowbar/client/command/node/delete.rb +44 -0
- data/lib/crowbar/client/command/node/hardware.rb +48 -0
- data/lib/crowbar/client/command/node/identify.rb +48 -0
- data/lib/crowbar/client/command/node/list.rb +71 -0
- data/lib/crowbar/client/command/node/powercycle.rb +48 -0
- data/lib/crowbar/client/command/node/poweroff.rb +48 -0
- data/lib/crowbar/client/command/node/poweron.rb +48 -0
- data/lib/crowbar/client/command/node/reboot.rb +48 -0
- data/lib/crowbar/client/command/node/reinstall.rb +48 -0
- data/lib/crowbar/client/command/node/rename.rb +44 -0
- data/lib/crowbar/client/command/node/reset.rb +48 -0
- data/lib/crowbar/client/command/node/role.rb +44 -0
- data/lib/crowbar/client/command/node/show.rb +67 -0
- data/lib/crowbar/client/command/node/shutdown.rb +48 -0
- data/lib/crowbar/client/command/node/status.rb +71 -0
- data/lib/crowbar/client/command/node/transition.rb +44 -0
- data/lib/crowbar/client/command/proposal.rb +44 -0
- data/lib/crowbar/client/command/proposal/commit.rb +50 -0
- data/lib/crowbar/client/command/proposal/create.rb +130 -0
- data/lib/crowbar/client/command/proposal/delete.rb +48 -0
- data/lib/crowbar/client/command/proposal/dequeue.rb +48 -0
- data/lib/crowbar/client/command/proposal/edit.rb +129 -0
- data/lib/crowbar/client/command/proposal/list.rb +68 -0
- data/lib/crowbar/client/command/proposal/show.rb +71 -0
- data/lib/crowbar/client/command/repository.rb +38 -0
- data/lib/crowbar/client/command/repository/activate.rb +44 -0
- data/lib/crowbar/client/command/repository/activate_all.rb +42 -0
- data/lib/crowbar/client/command/repository/deactivate.rb +44 -0
- data/lib/crowbar/client/command/repository/deactivate_all.rb +42 -0
- data/lib/crowbar/client/command/repository/list.rb +71 -0
- data/lib/crowbar/client/command/reset.rb +29 -0
- data/lib/crowbar/client/command/reset/nodes.rb +36 -0
- data/lib/crowbar/client/command/reset/proposal.rb +36 -0
- data/lib/crowbar/client/command/role.rb +29 -0
- data/lib/crowbar/client/command/role/list.rb +70 -0
- data/lib/crowbar/client/command/role/show.rb +70 -0
- data/lib/crowbar/client/command/virtual_ip.rb +29 -0
- data/lib/crowbar/client/command/virtual_ip/allocate.rb +50 -0
- data/lib/crowbar/client/command/virtual_ip/deallocate.rb +42 -0
- data/lib/crowbar/client/config.rb +178 -0
- data/lib/crowbar/client/filter.rb +33 -0
- data/lib/crowbar/client/filter/array.rb +29 -0
- data/lib/crowbar/client/filter/base.rb +41 -0
- data/lib/crowbar/client/filter/hash.rb +33 -0
- data/lib/crowbar/client/filter/subset.rb +45 -0
- data/lib/crowbar/client/formatter.rb +33 -0
- data/lib/crowbar/client/formatter/array.rb +49 -0
- data/lib/crowbar/client/formatter/base.rb +47 -0
- data/lib/crowbar/client/formatter/hash.rb +51 -0
- data/lib/crowbar/client/formatter/nested.rb +134 -0
- data/lib/crowbar/client/mixin.rb +30 -0
- data/lib/crowbar/client/mixin/barclamp.rb +41 -0
- data/lib/crowbar/client/mixin/filter.rb +33 -0
- data/lib/crowbar/client/mixin/format.rb +56 -0
- data/lib/crowbar/client/request.rb +57 -0
- data/lib/crowbar/client/request/barclamp.rb +26 -0
- data/lib/crowbar/client/request/barclamp/list.rb +35 -0
- data/lib/crowbar/client/request/base.rb +71 -0
- data/lib/crowbar/client/request/batch.rb +29 -0
- data/lib/crowbar/client/request/batch/build.rb +33 -0
- data/lib/crowbar/client/request/batch/export.rb +33 -0
- data/lib/crowbar/client/request/host_ip.rb +29 -0
- data/lib/crowbar/client/request/host_ip/allocate.rb +50 -0
- data/lib/crowbar/client/request/host_ip/deallocate.rb +48 -0
- data/lib/crowbar/client/request/interface.rb +29 -0
- data/lib/crowbar/client/request/interface/disable.rb +48 -0
- data/lib/crowbar/client/request/interface/enable.rb +48 -0
- data/lib/crowbar/client/request/node.rb +47 -0
- data/lib/crowbar/client/request/node/action.rb +39 -0
- data/lib/crowbar/client/request/node/delete.rb +38 -0
- data/lib/crowbar/client/request/node/list.rb +37 -0
- data/lib/crowbar/client/request/node/rename.rb +47 -0
- data/lib/crowbar/client/request/node/role.rb +47 -0
- data/lib/crowbar/client/request/node/show.rb +38 -0
- data/lib/crowbar/client/request/node/status.rb +36 -0
- data/lib/crowbar/client/request/node/transition.rb +48 -0
- data/lib/crowbar/client/request/party.rb +79 -0
- data/lib/crowbar/client/request/proposal.rb +47 -0
- data/lib/crowbar/client/request/proposal/commit.rb +40 -0
- data/lib/crowbar/client/request/proposal/create.rb +46 -0
- data/lib/crowbar/client/request/proposal/delete.rb +39 -0
- data/lib/crowbar/client/request/proposal/dequeue.rb +40 -0
- data/lib/crowbar/client/request/proposal/edit.rb +47 -0
- data/lib/crowbar/client/request/proposal/list.rb +38 -0
- data/lib/crowbar/client/request/proposal/show.rb +39 -0
- data/lib/crowbar/client/request/proposal/template.rb +39 -0
- data/lib/crowbar/client/request/repository.rb +38 -0
- data/lib/crowbar/client/request/repository/activate.rb +46 -0
- data/lib/crowbar/client/request/repository/activate_all.rb +37 -0
- data/lib/crowbar/client/request/repository/deactivate.rb +46 -0
- data/lib/crowbar/client/request/repository/deactivate_all.rb +37 -0
- data/lib/crowbar/client/request/repository/list.rb +36 -0
- data/lib/crowbar/client/request/reset.rb +29 -0
- data/lib/crowbar/client/request/reset/nodes.rb +33 -0
- data/lib/crowbar/client/request/reset/proposal.rb +33 -0
- data/lib/crowbar/client/request/role.rb +29 -0
- data/lib/crowbar/client/request/role/list.rb +38 -0
- data/lib/crowbar/client/request/role/show.rb +39 -0
- data/lib/crowbar/client/request/virtual_ip.rb +29 -0
- data/lib/crowbar/client/request/virtual_ip/allocate.rb +50 -0
- data/lib/crowbar/client/request/virtual_ip/deallocate.rb +48 -0
- data/lib/crowbar/client/util.rb +27 -0
- data/lib/crowbar/client/util/editor.rb +107 -0
- data/lib/crowbar/client/util/runner.rb +77 -0
- data/lib/crowbar/client/version.rb +33 -0
- data/spec/crowbar/client/app_spec.rb +21 -0
- data/spec/crowbar/client/command/barclamp/list_spec.rb +39 -0
- data/spec/crowbar/client/command/batch/build_spec.rb +39 -0
- data/spec/crowbar/client/command/batch/export_spec.rb +39 -0
- data/spec/crowbar/client/command/host_ip/allocate_spec.rb +39 -0
- data/spec/crowbar/client/command/host_ip/deallocate_spec.rb +39 -0
- data/spec/crowbar/client/command/interface/disable_spec.rb +39 -0
- data/spec/crowbar/client/command/interface/enable_spec.rb +39 -0
- data/spec/crowbar/client/command/node/allocate_spec.rb +39 -0
- data/spec/crowbar/client/command/node/delete_spec.rb +39 -0
- data/spec/crowbar/client/command/node/hardware_spec.rb +39 -0
- data/spec/crowbar/client/command/node/identify_spec.rb +39 -0
- data/spec/crowbar/client/command/node/list_spec.rb +39 -0
- data/spec/crowbar/client/command/node/powercycle_spec.rb +39 -0
- data/spec/crowbar/client/command/node/poweroff_spec.rb +39 -0
- data/spec/crowbar/client/command/node/poweron_spec.rb +39 -0
- data/spec/crowbar/client/command/node/reboot_spec.rb +39 -0
- data/spec/crowbar/client/command/node/reinstall_spec.rb +39 -0
- data/spec/crowbar/client/command/node/rename_spec.rb +39 -0
- data/spec/crowbar/client/command/node/reset_spec.rb +39 -0
- data/spec/crowbar/client/command/node/role_spec.rb +39 -0
- data/spec/crowbar/client/command/node/show_spec.rb +39 -0
- data/spec/crowbar/client/command/node/shutdown_spec.rb +39 -0
- data/spec/crowbar/client/command/node/status_spec.rb +39 -0
- data/spec/crowbar/client/command/node/transition_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/commit_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/create_spec.rb +61 -0
- data/spec/crowbar/client/command/proposal/delete_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/dequeue_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/edit_spec.rb +62 -0
- data/spec/crowbar/client/command/proposal/list_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/show_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/activate_all_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/activate_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/deactivate_all_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/deactivate_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/list_spec.rb +39 -0
- data/spec/crowbar/client/command/reset/nodes_spec.rb +39 -0
- data/spec/crowbar/client/command/reset/proposal_spec.rb +39 -0
- data/spec/crowbar/client/command/role/list_spec.rb +39 -0
- data/spec/crowbar/client/command/role/show_spec.rb +39 -0
- data/spec/crowbar/client/command/virtual_ip/allocate_spec.rb +39 -0
- data/spec/crowbar/client/command/virtual_ip/deallocate_spec.rb +39 -0
- data/spec/crowbar/client/filter/array_spec.rb +65 -0
- data/spec/crowbar/client/filter/hash_spec.rb +65 -0
- data/spec/crowbar/client/filter/subset_spec.rb +77 -0
- data/spec/crowbar/client/formatter/array_spec.rb +102 -0
- data/spec/crowbar/client/formatter/hash_spec.rb +108 -0
- data/spec/crowbar/client/formatter/nested_spec.rb +106 -0
- data/spec/crowbar/client/request/barclamp/list_spec.rb +50 -0
- data/spec/crowbar/client/request/batch/build_spec.rb +64 -0
- data/spec/crowbar/client/request/batch/export_spec.rb +64 -0
- data/spec/crowbar/client/request/host_ip/allocate_spec.rb +61 -0
- data/spec/crowbar/client/request/host_ip/deallocate_spec.rb +57 -0
- data/spec/crowbar/client/request/interface/disable_spec.rb +57 -0
- data/spec/crowbar/client/request/interface/enable_spec.rb +57 -0
- data/spec/crowbar/client/request/node/action_spec.rb +53 -0
- data/spec/crowbar/client/request/node/delete_spec.rb +52 -0
- data/spec/crowbar/client/request/node/list_spec.rb +50 -0
- data/spec/crowbar/client/request/node/rename_spec.rb +55 -0
- data/spec/crowbar/client/request/node/role_spec.rb +55 -0
- data/spec/crowbar/client/request/node/show_spec.rb +52 -0
- data/spec/crowbar/client/request/node/status_spec.rb +50 -0
- data/spec/crowbar/client/request/node/transition_spec.rb +56 -0
- data/spec/crowbar/client/request/party_spec.rb +24 -0
- data/spec/crowbar/client/request/proposal/commit_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/create_spec.rb +56 -0
- data/spec/crowbar/client/request/proposal/delete_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/dequeue_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/edit_spec.rb +56 -0
- data/spec/crowbar/client/request/proposal/list_spec.rb +52 -0
- data/spec/crowbar/client/request/proposal/show_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/template_spec.rb +52 -0
- data/spec/crowbar/client/request/repository/activate_all_spec.rb +50 -0
- data/spec/crowbar/client/request/repository/activate_spec.rb +56 -0
- data/spec/crowbar/client/request/repository/deactivate_all_spec.rb +50 -0
- data/spec/crowbar/client/request/repository/deactivate_spec.rb +56 -0
- data/spec/crowbar/client/request/repository/list_spec.rb +50 -0
- data/spec/crowbar/client/request/reset/nodes_spec.rb +55 -0
- data/spec/crowbar/client/request/reset/proposal_spec.rb +55 -0
- data/spec/crowbar/client/request/role/list_spec.rb +52 -0
- data/spec/crowbar/client/request/role/show_spec.rb +53 -0
- data/spec/crowbar/client/request/virtual_ip/allocate_spec.rb +61 -0
- data/spec/crowbar/client/request/virtual_ip/deallocate_spec.rb +57 -0
- data/spec/crowbar/client/util/editor_spec.rb +108 -0
- data/spec/crowbar/client/util/runner_spec.rb +24 -0
- data/spec/crowbar/client_spec.rb +21 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/support/command_context.rb +37 -0
- data/spec/support/request_examples.rb +55 -0
- metadata +549 -0
|
@@ -0,0 +1,48 @@
|
|
|
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 "easy_diff"
|
|
18
|
+
|
|
19
|
+
module Crowbar
|
|
20
|
+
module Client
|
|
21
|
+
module Command
|
|
22
|
+
module Node
|
|
23
|
+
class Reset < Base
|
|
24
|
+
def request
|
|
25
|
+
@request ||= Request::Node::Action.new(
|
|
26
|
+
args.easy_merge(
|
|
27
|
+
action: :shutdown
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def execute
|
|
33
|
+
request.process do |request|
|
|
34
|
+
case request.code
|
|
35
|
+
when 200
|
|
36
|
+
say "Successfully triggered reset for #{args.name}"
|
|
37
|
+
when 404
|
|
38
|
+
err "Node does not exist"
|
|
39
|
+
else
|
|
40
|
+
err request.parsed_response["error"]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
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 Role < Base
|
|
22
|
+
def request
|
|
23
|
+
@request ||= Request::Node::Role.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 role for #{args.name}"
|
|
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
|
|
@@ -0,0 +1,67 @@
|
|
|
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 Show < Base
|
|
22
|
+
include Mixin::Format
|
|
23
|
+
include Mixin::Filter
|
|
24
|
+
|
|
25
|
+
def request
|
|
26
|
+
@request ||= Request::Node::Show.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
|
+
path: provide_filter,
|
|
38
|
+
headings: ["Key", "Value"],
|
|
39
|
+
values: Filter::Subset.new(
|
|
40
|
+
filter: provide_filter,
|
|
41
|
+
values: content_from(request)
|
|
42
|
+
).result
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
if formatter.empty?
|
|
46
|
+
err "No result"
|
|
47
|
+
else
|
|
48
|
+
say formatter.result
|
|
49
|
+
end
|
|
50
|
+
when 404
|
|
51
|
+
err "Node does not exist"
|
|
52
|
+
else
|
|
53
|
+
err request.parsed_response["error"]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
protected
|
|
59
|
+
|
|
60
|
+
def content_from(request)
|
|
61
|
+
request.parsed_response
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
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 "easy_diff"
|
|
18
|
+
|
|
19
|
+
module Crowbar
|
|
20
|
+
module Client
|
|
21
|
+
module Command
|
|
22
|
+
module Node
|
|
23
|
+
class Shutdown < Base
|
|
24
|
+
def request
|
|
25
|
+
@request ||= Request::Node::Action.new(
|
|
26
|
+
args.easy_merge(
|
|
27
|
+
action: :shutdown
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def execute
|
|
33
|
+
request.process do |request|
|
|
34
|
+
case request.code
|
|
35
|
+
when 200
|
|
36
|
+
say "Successfully triggered shutdown for #{args.name}"
|
|
37
|
+
when 404
|
|
38
|
+
err "Node does not exist"
|
|
39
|
+
else
|
|
40
|
+
err request.parsed_response["error"]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
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 Status < Base
|
|
22
|
+
include Mixin::Format
|
|
23
|
+
include Mixin::Filter
|
|
24
|
+
|
|
25
|
+
def request
|
|
26
|
+
@request ||= Request::Node::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::Hash.new(
|
|
36
|
+
format: provide_format,
|
|
37
|
+
headings: ["Name", "Alias"],
|
|
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 nodes"
|
|
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
|
+
[].tap do |row|
|
|
59
|
+
request.parsed_response["nodes"].each do |name, value|
|
|
60
|
+
row.push(
|
|
61
|
+
name: name,
|
|
62
|
+
status: value["status"]
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
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 Transition < Base
|
|
22
|
+
def request
|
|
23
|
+
@request ||= Request::Node::Transition.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 transitioned to #{args.state}"
|
|
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
|
|
@@ -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 Proposal
|
|
21
|
+
autoload :Commit,
|
|
22
|
+
File.expand_path("../proposal/commit", __FILE__)
|
|
23
|
+
|
|
24
|
+
autoload :Create,
|
|
25
|
+
File.expand_path("../proposal/create", __FILE__)
|
|
26
|
+
|
|
27
|
+
autoload :Delete,
|
|
28
|
+
File.expand_path("../proposal/delete", __FILE__)
|
|
29
|
+
|
|
30
|
+
autoload :Dequeue,
|
|
31
|
+
File.expand_path("../proposal/dequeue", __FILE__)
|
|
32
|
+
|
|
33
|
+
autoload :Edit,
|
|
34
|
+
File.expand_path("../proposal/edit", __FILE__)
|
|
35
|
+
|
|
36
|
+
autoload :List,
|
|
37
|
+
File.expand_path("../proposal/list", __FILE__)
|
|
38
|
+
|
|
39
|
+
autoload :Show,
|
|
40
|
+
File.expand_path("../proposal/show", __FILE__)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
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 Proposal
|
|
21
|
+
class Commit < Base
|
|
22
|
+
include Mixin::Barclamp
|
|
23
|
+
|
|
24
|
+
def request
|
|
25
|
+
@request ||= Request::Proposal::Commit.new(
|
|
26
|
+
args
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def execute
|
|
31
|
+
validate_barclamp! args.barclamp
|
|
32
|
+
|
|
33
|
+
request.process do |request|
|
|
34
|
+
case request.code
|
|
35
|
+
when 200
|
|
36
|
+
say "Successfully commited #{args.proposal} proposal"
|
|
37
|
+
when 202
|
|
38
|
+
say "Successfully queued #{args.proposal} proposal"
|
|
39
|
+
when 404
|
|
40
|
+
say "Proposal does not exist"
|
|
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,130 @@
|
|
|
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 "json"
|
|
18
|
+
require "easy_diff"
|
|
19
|
+
|
|
20
|
+
module Crowbar
|
|
21
|
+
module Client
|
|
22
|
+
module Command
|
|
23
|
+
module Proposal
|
|
24
|
+
class Create < Base
|
|
25
|
+
include Mixin::Barclamp
|
|
26
|
+
|
|
27
|
+
def request
|
|
28
|
+
@request ||= Request::Proposal::Create.new(
|
|
29
|
+
args.easy_merge(
|
|
30
|
+
payload: payload_content
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def execute
|
|
36
|
+
validate_barclamp! args.barclamp
|
|
37
|
+
|
|
38
|
+
request.process do |request|
|
|
39
|
+
case request.code
|
|
40
|
+
when 200
|
|
41
|
+
say "Successfully created #{args.proposal} proposal"
|
|
42
|
+
else
|
|
43
|
+
err request.parsed_response["error"]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
protected
|
|
49
|
+
|
|
50
|
+
def proposal_preload
|
|
51
|
+
result = Request::Proposal::Template.new(
|
|
52
|
+
barclamp: args.barclamp
|
|
53
|
+
).process
|
|
54
|
+
|
|
55
|
+
case result.code
|
|
56
|
+
when 200
|
|
57
|
+
result.parsed_response.easy_merge(
|
|
58
|
+
"id" => args.proposal
|
|
59
|
+
)
|
|
60
|
+
when 404
|
|
61
|
+
err "Failed to preload template"
|
|
62
|
+
else
|
|
63
|
+
err result.parsed_response["error"]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def from_data
|
|
68
|
+
json = begin
|
|
69
|
+
JSON.load options[:data]
|
|
70
|
+
rescue
|
|
71
|
+
err "Invalid json data"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if options[:merge]
|
|
75
|
+
proposal_preload.easy_merge(
|
|
76
|
+
json
|
|
77
|
+
)
|
|
78
|
+
else
|
|
79
|
+
json
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def from_file
|
|
84
|
+
json = begin
|
|
85
|
+
JSON.load options[:file]
|
|
86
|
+
rescue
|
|
87
|
+
err "Invalid json file"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
if options[:merge]
|
|
91
|
+
proposal_preload.easy_merge(
|
|
92
|
+
json
|
|
93
|
+
)
|
|
94
|
+
else
|
|
95
|
+
json
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def from_editor
|
|
100
|
+
editor = Util::Editor.new content: proposal_preload
|
|
101
|
+
editor.edit!
|
|
102
|
+
|
|
103
|
+
editor.result
|
|
104
|
+
rescue EditorAbortError => e
|
|
105
|
+
err e.message
|
|
106
|
+
rescue EditorStartupError => e
|
|
107
|
+
err e.message
|
|
108
|
+
rescue InvalidJsonError => e
|
|
109
|
+
err e.message
|
|
110
|
+
rescue SimpleCatchableError => e
|
|
111
|
+
err e.message
|
|
112
|
+
rescue
|
|
113
|
+
err "Editing content failed"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def payload_content
|
|
117
|
+
case
|
|
118
|
+
when options[:data]
|
|
119
|
+
from_data
|
|
120
|
+
when options[:file]
|
|
121
|
+
from_file
|
|
122
|
+
else
|
|
123
|
+
from_editor
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|