hammer_cli_foreman 0.0.11 → 0.0.12
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.
Potentially problematic release.
This version of hammer_cli_foreman might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/hammer_cli_foreman/architecture.rb +5 -9
- data/lib/hammer_cli_foreman/commands.rb +55 -0
- data/lib/hammer_cli_foreman/common_parameter.rb +2 -4
- data/lib/hammer_cli_foreman/compute_resource.rb +10 -14
- data/lib/hammer_cli_foreman/domain.rb +16 -17
- data/lib/hammer_cli_foreman/environment.rb +6 -10
- data/lib/hammer_cli_foreman/fact.rb +6 -8
- data/lib/hammer_cli_foreman/host.rb +59 -60
- data/lib/hammer_cli_foreman/hostgroup.rb +17 -16
- data/lib/hammer_cli_foreman/image.rb +11 -17
- data/lib/hammer_cli_foreman/location.rb +4 -8
- data/lib/hammer_cli_foreman/media.rb +7 -29
- data/lib/hammer_cli_foreman/model.rb +7 -11
- data/lib/hammer_cli_foreman/operating_system.rb +25 -22
- data/lib/hammer_cli_foreman/organization.rb +4 -8
- data/lib/hammer_cli_foreman/output/formatters.rb +3 -2
- data/lib/hammer_cli_foreman/parameter.rb +8 -9
- data/lib/hammer_cli_foreman/partition_table.rb +6 -10
- data/lib/hammer_cli_foreman/puppet_class.rb +12 -13
- data/lib/hammer_cli_foreman/report.rb +43 -47
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +6 -7
- data/lib/hammer_cli_foreman/smart_proxy.rb +11 -17
- data/lib/hammer_cli_foreman/subnet.rb +17 -21
- data/lib/hammer_cli_foreman/template.rb +27 -32
- data/lib/hammer_cli_foreman/user.rb +19 -27
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/test/unit/commands_test.rb +79 -0
- data/test/unit/output/formatters_test.rb +10 -0
- data/test/unit/test_output_adapter.rb +6 -1
- metadata +7 -5
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
require 'hammer_cli'
|
3
|
+
|
4
|
+
|
5
|
+
describe HammerCLIForeman do
|
6
|
+
|
7
|
+
context "collection_to_common_format" do
|
8
|
+
|
9
|
+
let(:kind) { { "name" => "PXELinux", "id" => 1 } }
|
10
|
+
|
11
|
+
it "should convert old API format" do
|
12
|
+
old_format = [
|
13
|
+
{
|
14
|
+
"template_kind" => kind
|
15
|
+
}
|
16
|
+
]
|
17
|
+
|
18
|
+
set = HammerCLIForeman.collection_to_common_format(old_format)
|
19
|
+
set.must_be_kind_of HammerCLI::Output::RecordCollection
|
20
|
+
set.first.must_equal(kind)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should convert common API format" do
|
24
|
+
common_format = [ kind ]
|
25
|
+
|
26
|
+
set = HammerCLIForeman.collection_to_common_format(common_format)
|
27
|
+
set.must_be_kind_of HammerCLI::Output::RecordCollection
|
28
|
+
set.first.must_equal(kind)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should convert new API format" do
|
32
|
+
new_format = {
|
33
|
+
"total" => 1,
|
34
|
+
"subtotal" => 1,
|
35
|
+
"page" => 1,
|
36
|
+
"per_page" => 20,
|
37
|
+
"search" => nil,
|
38
|
+
"sort" => {
|
39
|
+
"by" => nil,
|
40
|
+
"order" => nil
|
41
|
+
},
|
42
|
+
"results" => [ kind ]
|
43
|
+
}
|
44
|
+
|
45
|
+
set = HammerCLIForeman.collection_to_common_format(new_format)
|
46
|
+
set.must_be_kind_of HammerCLI::Output::RecordCollection
|
47
|
+
set.first.must_equal(kind)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should rise error on unexpected format" do
|
51
|
+
proc { HammerCLIForeman.collection_to_common_format('unexpected') }.must_raise RuntimeError
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
context "record_to_common_format" do
|
58
|
+
|
59
|
+
let(:arch) { { "name" => "x86_64", "id" => 1 } }
|
60
|
+
|
61
|
+
it "should convert old API format" do
|
62
|
+
old_format = {
|
63
|
+
"architecture" => arch
|
64
|
+
}
|
65
|
+
|
66
|
+
rec = HammerCLIForeman.record_to_common_format(old_format)
|
67
|
+
rec.must_equal(arch)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should convert common API format" do
|
71
|
+
common_format = arch
|
72
|
+
|
73
|
+
rec = HammerCLIForeman.record_to_common_format(common_format)
|
74
|
+
rec.must_equal(arch)
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -9,6 +9,11 @@ describe HammerCLIForeman::Output::Formatters::OSNameFormatter do
|
|
9
9
|
formatter = HammerCLIForeman::Output::Formatters::OSNameFormatter.new
|
10
10
|
formatter.format({ :name => 'Fedora', :major => '19'}).must_equal 'Fedora 19'
|
11
11
|
end
|
12
|
+
|
13
|
+
it "recovers when os is nil" do
|
14
|
+
formatter = HammerCLIForeman::Output::Formatters::OSNameFormatter.new
|
15
|
+
formatter.format(nil).must_equal nil
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
describe HammerCLIForeman::Output::Formatters::ServerFormatter do
|
@@ -16,4 +21,9 @@ describe HammerCLIForeman::Output::Formatters::ServerFormatter do
|
|
16
21
|
formatter = HammerCLIForeman::Output::Formatters::ServerFormatter.new
|
17
22
|
formatter.format({ :name => 'Server', :url => "URL"}).must_equal 'Server (URL)'
|
18
23
|
end
|
24
|
+
|
25
|
+
it "recovers when server is nil" do
|
26
|
+
formatter = HammerCLIForeman::Output::Formatters::ServerFormatter.new
|
27
|
+
formatter.format(nil).must_equal nil
|
28
|
+
end
|
19
29
|
end
|
@@ -3,7 +3,12 @@ require 'hammer_cli/output/adapter/abstract'
|
|
3
3
|
|
4
4
|
class TestAdapter < HammerCLI::Output::Adapter::Abstract
|
5
5
|
|
6
|
-
def
|
6
|
+
def print_record(fields, record)
|
7
|
+
print_collection(fields, [record].flatten(1))
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def print_collection(fields, data)
|
7
12
|
@separator = '#'
|
8
13
|
puts @separator+fields.collect{|f| f.label.to_s}.join(@separator)+@separator
|
9
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_foreman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomáš Strachota
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hammer_cli
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.0.
|
20
|
+
version: 0.0.12
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.0.
|
27
|
+
version: 0.0.12
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: foreman_api
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/hammer_cli_foreman/version.rb
|
100
100
|
- test/unit/apipie_resource_mock.rb
|
101
101
|
- test/unit/architecture_test.rb
|
102
|
+
- test/unit/commands_test.rb
|
102
103
|
- test/unit/common_parameter_test.rb
|
103
104
|
- test/unit/compute_resource_test.rb
|
104
105
|
- test/unit/domain_test.rb
|
@@ -145,13 +146,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
146
|
version: '0'
|
146
147
|
requirements: []
|
147
148
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.0.
|
149
|
+
rubygems_version: 2.0.13
|
149
150
|
signing_key:
|
150
151
|
specification_version: 4
|
151
152
|
summary: Foreman commands for Hammer
|
152
153
|
test_files:
|
153
154
|
- test/unit/apipie_resource_mock.rb
|
154
155
|
- test/unit/architecture_test.rb
|
156
|
+
- test/unit/commands_test.rb
|
155
157
|
- test/unit/common_parameter_test.rb
|
156
158
|
- test/unit/compute_resource_test.rb
|
157
159
|
- test/unit/domain_test.rb
|