hammer_cli_foreman 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of hammer_cli_foreman might be problematic. Click here for more details.

Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -0
  3. data/doc/host_create.md +190 -0
  4. data/lib/hammer_cli_foreman.rb +1 -0
  5. data/lib/hammer_cli_foreman/commands.rb +21 -7
  6. data/lib/hammer_cli_foreman/common_parameter.rb +12 -18
  7. data/lib/hammer_cli_foreman/domain.rb +8 -6
  8. data/lib/hammer_cli_foreman/environment.rb +10 -0
  9. data/lib/hammer_cli_foreman/exception_handler.rb +11 -1
  10. data/lib/hammer_cli_foreman/exceptions.rb +9 -0
  11. data/lib/hammer_cli_foreman/host.rb +107 -16
  12. data/lib/hammer_cli_foreman/hostgroup.rb +10 -0
  13. data/lib/hammer_cli_foreman/puppet_class.rb +10 -1
  14. data/lib/hammer_cli_foreman/resource_supported_test.rb +3 -3
  15. data/lib/hammer_cli_foreman/smart_class_parameter.rb +110 -0
  16. data/lib/hammer_cli_foreman/version.rb +1 -1
  17. data/test/unit/apipie_resource_mock.rb +88 -0
  18. data/test/unit/architecture_test.rb +91 -0
  19. data/test/unit/common_parameter_test.rb +77 -0
  20. data/test/unit/compute_resource_test.rb +94 -0
  21. data/test/unit/domain_test.rb +130 -0
  22. data/test/unit/environment_test.rb +110 -0
  23. data/test/unit/exception_handler_test.rb +48 -0
  24. data/test/unit/fact_test.rb +31 -0
  25. data/test/unit/helpers/command.rb +69 -0
  26. data/test/unit/helpers/resource_disabled.rb +24 -0
  27. data/test/unit/host_test.rb +315 -0
  28. data/test/unit/hostgroup_test.rb +145 -0
  29. data/test/unit/image_test.rb +136 -0
  30. data/test/unit/location_test.rb +109 -0
  31. data/test/unit/media_test.rb +106 -0
  32. data/test/unit/model_test.rb +98 -0
  33. data/test/unit/operating_system_test.rb +151 -0
  34. data/test/unit/organization_test.rb +109 -0
  35. data/test/unit/output/formatters_test.rb +19 -0
  36. data/test/unit/partition_table_test.rb +143 -0
  37. data/test/unit/puppet_class_test.rb +71 -0
  38. data/test/unit/report_test.rb +64 -0
  39. data/test/unit/smart_class_parameter_test.rb +77 -0
  40. data/test/unit/smart_proxy_test.rb +102 -0
  41. data/test/unit/subnet_test.rb +95 -0
  42. data/test/unit/template_test.rb +141 -0
  43. data/test/unit/test_helper.rb +27 -0
  44. data/test/unit/test_output_adapter.rb +19 -0
  45. data/test/unit/user_test.rb +92 -0
  46. metadata +107 -29
@@ -0,0 +1,91 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
+
4
+
5
+ describe HammerCLIForeman::Architecture do
6
+
7
+ extend CommandTestHelper
8
+
9
+ before :each do
10
+ cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
+ end
12
+
13
+ context "ListCommand" do
14
+
15
+ let(:cmd) { HammerCLIForeman::Architecture::ListCommand.new("", ctx) }
16
+
17
+ context "parameters" do
18
+ it_should_accept "no arguments"
19
+ it_should_accept_search_params
20
+ end
21
+
22
+ context "output" do
23
+ let(:expected_record_count) { cmd.resource.call(:index)[0].length }
24
+
25
+ it_should_print_n_records
26
+ it_should_print_column "Name"
27
+ it_should_print_column "Id"
28
+ end
29
+
30
+ end
31
+
32
+
33
+ context "InfoCommand" do
34
+
35
+ let(:cmd) { HammerCLIForeman::Architecture::InfoCommand.new("", ctx) }
36
+
37
+ context "parameters" do
38
+ it_should_accept "id", ["--id=1"]
39
+ it_should_accept "name", ["--name=arch"]
40
+ it_should_fail_with "no arguments"
41
+ end
42
+
43
+ context "output" do
44
+ with_params ["--id=1"] do
45
+ it_should_print_n_records 1
46
+ it_should_print_column "Name"
47
+ it_should_print_column "Id"
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+
54
+ context "CreateCommand" do
55
+
56
+ let(:cmd) { HammerCLIForeman::Architecture::CreateCommand.new("", ctx) }
57
+
58
+ context "parameters" do
59
+ it_should_accept "name", ["--name=arch"]
60
+ it_should_fail_with "name missing", []
61
+ end
62
+
63
+ end
64
+
65
+
66
+ context "DeleteCommand" do
67
+
68
+ let(:cmd) { HammerCLIForeman::Architecture::DeleteCommand.new("", ctx) }
69
+
70
+ context "parameters" do
71
+ it_should_accept "name", ["--name=arch"]
72
+ it_should_accept "id", ["--id=1"]
73
+ it_should_fail_with "name or id missing", []
74
+ end
75
+
76
+ end
77
+
78
+
79
+ context "UpdateCommand" do
80
+
81
+ let(:cmd) { HammerCLIForeman::Architecture::UpdateCommand.new("", ctx) }
82
+
83
+ context "parameters" do
84
+ it_should_accept "name", ["--name=arch", "--new-name=arch2"]
85
+ it_should_accept "id", ["--id=1", "--new-name=arch2"]
86
+ it_should_fail_with "no params", []
87
+ it_should_fail_with "name or id missing", ["--new-name=arch2"]
88
+ end
89
+
90
+ end
91
+ end
@@ -0,0 +1,77 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
+
4
+
5
+ describe HammerCLIForeman::CommonParameter do
6
+
7
+ extend CommandTestHelper
8
+
9
+ let(:resource_mock) { ApipieResourceMock.new(cmd.class.resource.resource_class) }
10
+
11
+ before :each do
12
+ cmd.class.resource resource_mock
13
+ end
14
+
15
+ context "ListCommand" do
16
+
17
+ let(:cmd) { HammerCLIForeman::CommonParameter::ListCommand.new("", ctx) }
18
+
19
+ context "parameters" do
20
+ it_should_accept "no arguments"
21
+ it_should_accept_search_params
22
+ end
23
+
24
+ context "output" do
25
+ let(:expected_record_count) { cmd.resource.call(:index)[0].length }
26
+
27
+ it_should_print_n_records
28
+ it_should_print_columns ["Name", "Value"]
29
+ end
30
+
31
+ end
32
+
33
+
34
+ context "SetCommand" do
35
+
36
+ let(:cmd) { HammerCLIForeman::CommonParameter::SetCommand.new("", ctx) }
37
+ before :each do
38
+ resource_mock.stub_method(:index, [])
39
+ end
40
+
41
+ context "parameters" do
42
+ it_should_accept "name and value", ["--name=param", "--value=val"]
43
+ it_should_fail_with "name missing", ["--value=val"]
44
+ it_should_fail_with "value missing", ["--name=param"]
45
+ end
46
+
47
+ context "adding params" do
48
+ with_params ["--name=param", "--value=val"] do
49
+ it_should_call_action :create, {'common_parameter' => {'name' => 'param', 'value' => 'val'}, 'id' => 'param'}
50
+ end
51
+ end
52
+
53
+ context "updating params" do
54
+ before :each do
55
+ resource_mock.stub_method(:index, [{'common_parameter' => {'name' => 'param'}}])
56
+ end
57
+
58
+ with_params ["--name=param", "--value=val"] do
59
+ it_should_call_action :update, {'common_parameter' => {'name' => 'param', 'value' => 'val'}, 'id' => 'param'}
60
+ end
61
+ end
62
+
63
+ end
64
+
65
+
66
+ context "DeleteCommand" do
67
+
68
+ let(:cmd) { HammerCLIForeman::CommonParameter::DeleteCommand.new("", ctx) }
69
+
70
+ context "parameters" do
71
+ it_should_accept "name", ["--name=arch"]
72
+ it_should_fail_with "name missing", []
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -0,0 +1,94 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
+ require File.join(File.dirname(__FILE__), 'test_output_adapter')
4
+
5
+
6
+ describe HammerCLIForeman::ComputeResource do
7
+
8
+ extend CommandTestHelper
9
+
10
+ before :each do
11
+ cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
12
+ end
13
+
14
+ context "ListCommand" do
15
+
16
+ let(:cmd) { HammerCLIForeman::ComputeResource::ListCommand.new("", ctx) }
17
+
18
+ context "parameters" do
19
+ it_should_accept "no arguments"
20
+ it_should_accept_search_params
21
+ end
22
+
23
+ context "output" do
24
+ let(:expected_record_count) { cmd.resource.call(:index)[0].length }
25
+
26
+ it_should_print_n_records
27
+ it_should_print_columns ["Name", "Id", "Provider"]
28
+ end
29
+
30
+ end
31
+
32
+
33
+ context "InfoCommand" do
34
+
35
+ let(:cmd) { HammerCLIForeman::ComputeResource::InfoCommand.new("", ctx) }
36
+
37
+ context "parameters" do
38
+ it_should_accept "id", ["--id=1"]
39
+ it_should_accept "name", ["--name=arch"]
40
+ it_should_fail_with "no arguments"
41
+ end
42
+
43
+ context "output" do
44
+ with_params ["--id=1"] do
45
+ it_should_print_n_records 1
46
+ it_should_print_columns ["Name", "Id", "Provider", "Url"]
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+
53
+ context "CreateCommand" do
54
+
55
+ let(:cmd) { HammerCLIForeman::ComputeResource::CreateCommand.new("", ctx) }
56
+
57
+ context "parameters" do
58
+ it_should_accept "name, url, provider", ["--name=arch", "--url=http://some.org", "--provider=Libvirt"]
59
+ it_should_fail_with "name missing", ["--url=http://some.org", "--provider=Libvirt"]
60
+ it_should_fail_with "url missing", ["--name=arch", "--provider=Libvirt"]
61
+ it_should_fail_with "provider missing", ["--name=arch", "--url=http://some.org"]
62
+ end
63
+
64
+ end
65
+
66
+
67
+ context "DeleteCommand" do
68
+
69
+ let(:cmd) { HammerCLIForeman::ComputeResource::DeleteCommand.new("", ctx) }
70
+
71
+ context "parameters" do
72
+ it_should_accept "name", ["--name=arch"]
73
+ it_should_accept "id", ["--id=1"]
74
+ it_should_fail_with "name or id missing", []
75
+ end
76
+
77
+ end
78
+
79
+
80
+ context "UpdateCommand" do
81
+
82
+ let(:cmd) { HammerCLIForeman::ComputeResource::UpdateCommand.new("", ctx) }
83
+
84
+ context "parameters" do
85
+ it_should_accept "name", ["--name=arch", "--new-name=arch2"]
86
+ it_should_accept "id", ["--id=1", "--new-name=arch2"]
87
+ it_should_fail_with "no params", []
88
+ it_should_fail_with "name or id missing", ["--new-name=arch2"]
89
+ end
90
+
91
+ end
92
+
93
+
94
+ end
@@ -0,0 +1,130 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
+
4
+
5
+ describe HammerCLIForeman::Domain do
6
+
7
+ extend CommandTestHelper
8
+
9
+ before :each do
10
+ cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
+ end
12
+
13
+ context "ListCommand" do
14
+
15
+ let(:cmd) { HammerCLIForeman::Domain::ListCommand.new("", ctx) }
16
+
17
+ context "parameters" do
18
+ it_should_accept "no arguments"
19
+ it_should_accept_search_params
20
+ end
21
+
22
+ context "output" do
23
+ let(:expected_record_count) { cmd.resource.call(:index)[0].length }
24
+
25
+ it_should_print_n_records
26
+ it_should_print_columns ["Id", "Name"]
27
+ end
28
+
29
+ end
30
+
31
+
32
+ context "InfoCommand" do
33
+
34
+ let(:cmd) { HammerCLIForeman::Domain::InfoCommand.new("", ctx) }
35
+
36
+ before :each do
37
+ HammerCLIForeman::Parameter.stubs(:get_parameters).returns([])
38
+ end
39
+
40
+ context "parameters" do
41
+ it_should_accept "id", ["--id=1"]
42
+ it_should_accept "name", ["--name=arch"]
43
+ it_should_fail_with "no arguments"
44
+ end
45
+
46
+ context "output" do
47
+ with_params ["--id=1"] do
48
+ it_should_print_n_records 1
49
+ it_should_print_columns ["Id", "Name", "Created at", "Updated at"]
50
+ it_should_print_columns ["DNS Id", "Description"]
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+
57
+ context "CreateCommand" do
58
+
59
+ let(:cmd) { HammerCLIForeman::Domain::CreateCommand.new("", ctx) }
60
+
61
+ context "parameters" do
62
+ it_should_accept "name, fullname", ["--name=domain", "--description=full_domain_name"]
63
+ it_should_fail_with "name missing", ["--full-name=full_domain_name"]
64
+ end
65
+
66
+ end
67
+
68
+
69
+ context "DeleteCommand" do
70
+
71
+ let(:cmd) { HammerCLIForeman::Domain::DeleteCommand.new("", ctx) }
72
+
73
+ context "parameters" do
74
+ it_should_accept "name", ["--name=domain"]
75
+ it_should_accept "id", ["--id=1"]
76
+ it_should_fail_with "name or id missing", []
77
+ end
78
+
79
+ end
80
+
81
+
82
+ context "UpdateCommand" do
83
+
84
+ let(:cmd) { HammerCLIForeman::Domain::UpdateCommand.new("", ctx) }
85
+
86
+ context "parameters" do
87
+ it_should_accept "name", ["--name=domain", "--new-name=domain2", "--description=full_domain_name"]
88
+ it_should_accept "id", ["--id=1", "--new-name=domain2", "--description=full_domain_name"]
89
+ it_should_fail_with "no params", []
90
+ it_should_fail_with "name or id missing", ["--new-name=arch2", "--description=full_domain_name"]
91
+ end
92
+
93
+ end
94
+
95
+
96
+ context "SetParameterCommand" do
97
+
98
+ before :each do
99
+ resource_mock = ApipieResourceMock.new(cmd.class.resource.resource_class)
100
+ resource_mock.stub_method(:index, [])
101
+ cmd.class.resource resource_mock
102
+ end
103
+
104
+ let(:cmd) { HammerCLIForeman::Domain::SetParameterCommand.new("", ctx) }
105
+
106
+ context "parameters" do
107
+ it_should_accept "name, value and domain name", ["--name=name", "--value=val", "--domain-name=name"]
108
+ it_should_accept "name, value and domain id", ["--name=name", "--value=val", "--domain-id=id"]
109
+ it_should_fail_with "name missing", ["--value=val", "--domain-name=name"]
110
+ it_should_fail_with "value missing", ["--name=name", "--domain-name=name"]
111
+ it_should_fail_with "domain name or id missing", ["--name=name", "--value=val"]
112
+ end
113
+
114
+ end
115
+
116
+
117
+ context "DeleteParameterCommand" do
118
+
119
+ let(:cmd) { HammerCLIForeman::Domain::DeleteParameterCommand.new("", ctx) }
120
+
121
+ context "parameters" do
122
+ it_should_accept "name and domain name", ["--name=domain", "--domain-name=name"]
123
+ it_should_accept "name and domain id", ["--name=domain", "--domain-id=id"]
124
+ it_should_fail_with "name missing", ["--domain-name=name"]
125
+ it_should_fail_with "domain name or id missing", ["--name=name"]
126
+ end
127
+
128
+ end
129
+
130
+ end
@@ -0,0 +1,110 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
+
4
+
5
+ describe HammerCLIForeman::Environment do
6
+
7
+ extend CommandTestHelper
8
+
9
+ before :each do
10
+ cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
+ end
12
+
13
+ context "ListCommand" do
14
+
15
+ let(:cmd) { HammerCLIForeman::Environment::ListCommand.new("", ctx) }
16
+
17
+ context "parameters" do
18
+ it_should_accept "no arguments"
19
+ it_should_accept_search_params
20
+ end
21
+
22
+ context "output" do
23
+ let(:expected_record_count) { cmd.resource.call(:index)[0].length }
24
+
25
+ it_should_print_n_records
26
+ it_should_print_column "Name"
27
+ it_should_print_column "Id"
28
+ end
29
+
30
+ end
31
+
32
+
33
+ context "InfoCommand" do
34
+
35
+ let(:cmd) { HammerCLIForeman::Environment::InfoCommand.new("", ctx) }
36
+
37
+ context "parameters" do
38
+ it_should_accept "id", ["--id=1"]
39
+ it_should_accept "name", ["--name=env"]
40
+ it_should_fail_with "no arguments"
41
+ end
42
+
43
+ context "output" do
44
+ with_params ["--id=1"] do
45
+ it_should_print_n_records 1
46
+ it_should_print_column "Name"
47
+ it_should_print_column "Id"
48
+ it_should_print_column "Created at"
49
+ it_should_print_column "Updated at"
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+
56
+ context "CreateCommand" do
57
+
58
+ let(:cmd) { HammerCLIForeman::Environment::CreateCommand.new("", ctx) }
59
+
60
+ context "parameters" do
61
+ it_should_accept "name", ["--name=env"]
62
+ it_should_fail_with "name missing", []
63
+ end
64
+
65
+ end
66
+
67
+
68
+ context "DeleteCommand" do
69
+
70
+ let(:cmd) { HammerCLIForeman::Environment::DeleteCommand.new("", ctx) }
71
+
72
+ context "parameters" do
73
+ it_should_accept "name", ["--name=env"]
74
+ it_should_accept "id", ["--id=1"]
75
+ it_should_fail_with "name or id missing", []
76
+ end
77
+
78
+ end
79
+
80
+
81
+ context "UpdateCommand" do
82
+
83
+ let(:cmd) { HammerCLIForeman::Environment::UpdateCommand.new("", ctx) }
84
+
85
+ context "parameters" do
86
+ it_should_accept "name", ["--name=env", "--new-name=env2"]
87
+ it_should_accept "id", ["--id=1", "--new-name=env2"]
88
+ it_should_fail_with "no params", []
89
+ it_should_fail_with "name or id missing", ["--new-name=env2"]
90
+ end
91
+
92
+ end
93
+
94
+ context "SCParamsCommand" do
95
+
96
+ before :each do
97
+ cmd.class.resource ResourceMocks.smart_class_parameter
98
+ end
99
+
100
+ let(:cmd) { HammerCLIForeman::Environment::SCParamsCommand.new("", ctx) }
101
+
102
+ context "parameters" do
103
+ it_should_accept "name", ["--name=env"]
104
+ it_should_accept "id", ["--id=1"]
105
+ it_should_fail_with "name or id missing", []
106
+ end
107
+
108
+ end
109
+
110
+ end