foreman-katello-engine 0.0.1 → 0.0.2
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.
- data/README.md +23 -5
- data/app/views/activation_keys/_host_tab_pane.html.erb +54 -23
- data/foreman-katello-engine.gemspec +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
Katello
|
2
|
-
|
1
|
+
Foreman Katello Rails Engine
|
2
|
+
============================
|
3
3
|
|
4
4
|
Bringing Katello specific code into Foreman.
|
5
5
|
|
@@ -18,13 +18,13 @@ How it works?
|
|
18
18
|
|
19
19
|
The gem modifies some of the Foreman functionality to play nice with
|
20
20
|
Katello managed infrastructure. Often, just the HTML forms are
|
21
|
-
slightly modified, leveraging the Foreman data
|
22
|
-
entities.
|
21
|
+
slightly modified using a `deface` gem, leveraging the Foreman data
|
22
|
+
model to model Katello entities.
|
23
23
|
|
24
24
|
Modified functionality
|
25
25
|
----------------------
|
26
26
|
|
27
|
-
|
27
|
+
### Host Group forms
|
28
28
|
|
29
29
|
New tab 'Katello' is added to the host groups form, exposing a select
|
30
30
|
box for katello environment and activation keys.
|
@@ -54,6 +54,24 @@ The activation keys are autocompleted for better user experience and
|
|
54
54
|
the list of products for each used activation key is displayed at the
|
55
55
|
bottom of the Katello tab.
|
56
56
|
|
57
|
+
### Katello-friendly provisioning
|
58
|
+
|
59
|
+
To register a provisioned system to katello a new provisioning
|
60
|
+
template snippet needs to be crated, lets call it katello:
|
61
|
+
|
62
|
+
```
|
63
|
+
<% if @host.params['kt_activation_keys'] %>
|
64
|
+
rpm -ivh "http://katello.example.com/pub/candlepin-cert-consumer-katello.example.com-1.0-1.noarch.rpm"
|
65
|
+
subscription-manager register --org "<%= @host.params['kt_org'] %>" --activationkey "<%= @host.params['kt_activation_keys'] %>"
|
66
|
+
<% end %>
|
67
|
+
```
|
68
|
+
|
69
|
+
and reference it from the kickstart template:
|
70
|
+
|
71
|
+
```
|
72
|
+
<%= snippets "katello" %>
|
73
|
+
```
|
74
|
+
|
57
75
|
Current status
|
58
76
|
--------------
|
59
77
|
|
@@ -7,11 +7,11 @@ $(function() {
|
|
7
7
|
'"katello-and-friends": ["Katello", "Pulp", "Candlepin", "Foreman"],' +
|
8
8
|
'"headpin-and-friends": ["Headpin", "Thumbslug", "Candlepin"] }');
|
9
9
|
|
10
|
-
function
|
10
|
+
function ktFindParamContainer(name){
|
11
11
|
var ret;
|
12
12
|
$("div#parameters div.control-group input[ type = 'text']").each(function () {
|
13
13
|
element = $(this);
|
14
|
-
if(element.val() ==
|
14
|
+
if(element.val() == name) {
|
15
15
|
ret = element.parent();
|
16
16
|
return false;
|
17
17
|
}
|
@@ -25,6 +25,21 @@ $(function() {
|
|
25
25
|
});
|
26
26
|
}
|
27
27
|
|
28
|
+
function ktParseOrgName(frOrgName) {
|
29
|
+
return frOrgName.match(/^kt-\[(.*)\]\[(.*)\]$/);
|
30
|
+
}
|
31
|
+
|
32
|
+
function ktHideParams() {
|
33
|
+
var paramsToHide = [ktFindParamContainer(KT_AK_LABEL),
|
34
|
+
ktFindParamContainer('kt_org'),
|
35
|
+
ktFindParamContainer('kt_env')];
|
36
|
+
$.each(paramsToHide, function (i, paramContainer) {
|
37
|
+
if(paramContainer) {
|
38
|
+
paramContainer.hide();
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
28
43
|
function ktOrganizationsToKtEnv() {
|
29
44
|
var ktOrgs = [], ktOrgsToEnvs = [], selectedEnvId;
|
30
45
|
var ktEnvironmentSelect = $("#kt_environment_id");
|
@@ -32,7 +47,7 @@ $(function() {
|
|
32
47
|
var input = $(label).find("input[ type = 'checkbox' ]");
|
33
48
|
var frOrgName = $(label).text().trim();
|
34
49
|
var frOrgId = input.val();
|
35
|
-
var match = frOrgName
|
50
|
+
var match = ktParseOrgName(frOrgName);
|
36
51
|
if(match) {
|
37
52
|
if(input.attr('checked')) {
|
38
53
|
selectedEnvId = frOrgId;
|
@@ -67,6 +82,36 @@ $(function() {
|
|
67
82
|
|
68
83
|
}
|
69
84
|
|
85
|
+
function ktSelectedOrgAndEnv() {
|
86
|
+
var selectedEnvId = $("#kt_environment_id").val();
|
87
|
+
var orgCheckbox = $("#organizations label.organization input[ type = 'checkbox' ][ value = '" + selectedEnvId + "' ]");
|
88
|
+
if(orgCheckbox) {
|
89
|
+
return ktParseOrgName(orgCheckbox.parent().text().trim());
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
function ktSetParam(name, value) {
|
94
|
+
var paramContainer = ktFindParamContainer(name);
|
95
|
+
if(value) {
|
96
|
+
if(! paramContainer) { // we create the param for kt_activation_keys
|
97
|
+
$("div#parameters a.btn-success").click();
|
98
|
+
paramContainer = $("div#parameters div.control-group").last();
|
99
|
+
paramContainer.find("input").val(name);
|
100
|
+
}
|
101
|
+
paramContainer.find("textarea").val(value);
|
102
|
+
} else if(paramContainer) {
|
103
|
+
// we remove the param by setting destoy to 1
|
104
|
+
paramContainer.find("input[ type = 'hidden' ]").val(1);
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
function ktEnvToParam() {
|
110
|
+
var orgAndEnv = ktSelectedOrgAndEnv() || [];
|
111
|
+
ktSetParam('kt_org', orgAndEnv[1]);
|
112
|
+
ktSetParam('kt_env', orgAndEnv[2]);
|
113
|
+
}
|
114
|
+
|
70
115
|
function ktEnvToFrOrganizations() {
|
71
116
|
var selectedEnvId = $("#kt_environment_id").val();
|
72
117
|
$.each(ktOrganizations(), function (i, label) {
|
@@ -80,27 +125,15 @@ $(function() {
|
|
80
125
|
}
|
81
126
|
|
82
127
|
function ktParamToAkInput() {
|
83
|
-
var paramContainer =
|
128
|
+
var paramContainer = ktFindParamContainer(KT_AK_LABEL);
|
84
129
|
if(paramContainer) {
|
85
130
|
$("#kt_activation_keys").val(paramContainer.find("textarea").val());
|
86
|
-
paramContainer.hide();
|
87
131
|
}
|
88
132
|
}
|
89
133
|
|
90
134
|
function ktAkInputToParam() {
|
91
135
|
var ktActivationKeysValue = $("#kt_activation_keys").val().replace(/,\s*/g,",").replace(/,$/g,"");
|
92
|
-
|
93
|
-
if(ktActivationKeysValue) {
|
94
|
-
if(! paramContainer) { // we create the param for kt_activation_keys
|
95
|
-
$("div#parameters a.btn-success").click();
|
96
|
-
paramContainer = $("div#parameters div.control-group").last();
|
97
|
-
paramContainer.find("input").val(KT_AK_LABEL);
|
98
|
-
}
|
99
|
-
paramContainer.find("textarea").val(ktActivationKeysValue);
|
100
|
-
} else if(paramContainer) {
|
101
|
-
// we remove the param by setting destoy to 1
|
102
|
-
paramContainer.find("input[ type = 'hidden' ]").val(1);
|
103
|
-
}
|
136
|
+
ktSetParam(KT_AK_LABEL, ktActivationKeysValue);
|
104
137
|
}
|
105
138
|
|
106
139
|
function ktAkUpdateubscriptionsInfo() {
|
@@ -120,6 +153,7 @@ $(function() {
|
|
120
153
|
}
|
121
154
|
|
122
155
|
function ktOnLoad() {
|
156
|
+
ktHideParams();
|
123
157
|
ktParamToAkInput();
|
124
158
|
ktAkUpdateubscriptionsInfo();
|
125
159
|
ktOrganizationsToKtEnv();
|
@@ -127,6 +161,7 @@ $(function() {
|
|
127
161
|
|
128
162
|
function ktOnSubmit() {
|
129
163
|
ktAkInputToParam();
|
164
|
+
ktEnvToParam();
|
130
165
|
ktEnvToFrOrganizations();
|
131
166
|
}
|
132
167
|
|
@@ -168,18 +203,14 @@ $(function() {
|
|
168
203
|
$(this).autocomplete( "search" );
|
169
204
|
}});
|
170
205
|
|
171
|
-
$("#test").click(function () {
|
172
|
-
ktAkInputToParam();
|
173
|
-
});
|
174
|
-
|
175
206
|
});
|
176
207
|
|
177
208
|
<% end %>
|
178
209
|
<div class="tab-pane" id="katello">
|
179
|
-
<%= field(nil, "Katello Environment") do
|
210
|
+
<%= field(nil, "Katello Environment", :help_inline => "the names of Katello organization and environment will be available in templates as @host.params['kt_org'] and @host.params['kt_env']") do
|
180
211
|
select_tag(:kt_environment_id, [])
|
181
212
|
end %>
|
182
|
-
<%= field(nil, "Activation Keys", :help_inline => "comma separated values. The value will be available in templates as
|
213
|
+
<%= field(nil, "Activation Keys", :help_inline => "comma separated values. The value will be available in templates as @host.params['#{kt_ak_label}']") do
|
183
214
|
text_field_tag("kt_activation_keys", "", :style => 'width: 98%')
|
184
215
|
end %>
|
185
216
|
<div class="alert alert-info">
|