summaryrefslogtreecommitdiffstats
path: root/webui_templates/system_edit.tmpl
blob: f282ef4ed46d8140f67eef371caf41ef525691c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
#extends cobbler.webui.master

#block body

###
### here's a list of all the NIC fields we use
###
### FIXME: add gateway, subnet, and any other missing fields

#set $fields = [ "macaddress", "ipaddress", "hostname", "dhcptag", "virtbridge", "subnet", "gateway"]


<script language="javascript">

function delete_interface(num)
{
    #for $field in $fields
    document.getElementById("${field}-intf" + num).value = "";
    #end for
    toggleRowVisibility("id" + num);
}

#if $system
function disablename(value)
{
    document.getElementById("name").disabled=value;
    if (value) {
        document.getElementById("name").value = "$system.name";
    }
}
#else
function get_random_mac()
{
    xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", "$base_url/random_mac", true);
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var mac_field = document.getElementById("macaddress")
            var result = xmlHttp.responseText;
            if (result.charAt(2) == ':' && result.charAt(5) == ':') {
                mac_field.value = result;
            }
        }
    };
    xmlHttp.send(null);
}
#end if
</script>

## 
##   determine a bit about what interfaces should be shown and which should not.
##

#set $all_interfaces = [ "intf0", "intf1", "intf2", "intf3", "intf4", "intf5", "intf6", "intf7" ]
#if $system
    #set $interfaces = $system.interfaces.keys()
    #set $defined_interfaces = []
    #for $potential in $all_interfaces
        #if $potential in $interfaces
            #set $rc = $defined_interfaces.append($potential)
        #end if
    #end for
#else
    #set $interfaces = [ "intf0", "intf1", "intf2", "intf3", "intf4", "intf5", "intf6", "intf7" ]
    #set $defined_interfaces = [ "intf0" ]
#end if


### 
### now generate the onload function.
###

<script language="javascript">

function page_onload() {

    onLoadStuff(2);
    hideAllRows();
    #set counter = 0
    #for $interface in $all_interfaces
        #if $interface in $defined_interfaces
            toggleRowVisibility("id${counter}");
        #end if
        #set $counter = $counter+1
    #end for

}
</script>

<form method="post" action="$base_url/system_save">
<fieldset id="cform">
   
    #if $system
        <input type="hidden" name="new_or_edit" value="edit"/>
        <input type="hidden" name="oldname" value="$system.name"/>
    #else
        <input type="hidden" name="new_or_edit" value="new"/>
    #end if

    <legend>Edit a System</legend>

    ## FIXME: this ID doesn't make sense but it's there for the javascript
    <table border=0 id="channel-list">

    <tr id="id9000">
    <td>
    <label for="name">System Name</label>
    </td>
    <td>
    #if $system
    <input type="text" size="128" style="width: 150px;" name="name" id="name" disabled="true"
    #else
    <input type="text" size="128" style="width: 150px;" name="name" id="name"
    #end if
        #if $system
            value="$system.name"
        #end if
    />
    <p class="context-tip">Example: vanhalen</p>
    </td>
    </tr>

    #if $system
    <tr id="id9001">
    <td>
    <label for="mode">Edit Mode</label>
    </td>
    <td>
    <input type="radio" name="editmode" value="edit" checked onclick="javascript:disablename(true)">Edit
    <input type="radio" name="editmode" value="rename" onclick="javascript:disablename(false)">Rename + Edit
    <input type="radio" name="editmode" value="copy" onclick="javascript:disablename(false)">Copy + Edit
    <p class="context-tip">How do you want to modify this object?</p>
    </td>
    </tr>
    #end if

    <tr id="id9002">
    <td>
    <label for="profile">Profile</label>
    </td>
    <td>
    <select name="profile" id="profile">
        #for $profile in $profiles:
        <option name="$profile.name"
            #if $system and $system.profile == $profile.name
                    selected="1"
            #end if
        >$profile.name</option>
        #end for
    </select>
    <p class="context-tip">What profile should be installed on this system?</p>
    </td>
    </tr>

    <tr id="id9004">
    <td>
    <label for="kopts">Kernel Options</label>
    </td>
    <td>
    <input type="text" size="255" style="width: 150px;" name="kopts" id="kopts"
        #if $system
            value="$system.kernel_options"
        #end if
    /> 
    <p class="context-tip">Example: noipv6 magic=foo</p>
    </td>
    </tr>

    <tr id="id9005">
    <td>
    <label for="ksmeta">Kickstart Metadata</label>
    </td>
    <td>
    <input type="text" size="255" style="width: 150px;" name="ksmeta" id="ksmeta"
        #if $system
            value="$system.ks_meta"
        #end if
    />
    <p class="context-tip">Example: dog=fido gnome=yes</p>
    </td>
    </tr>

    <tr id="id9006">
    <td>
    <label for="netboot">Netboot Enabled</label>
    </td>
    <td>
    <input type="checkbox" name="netboot" id="netboot"
    #if not $system or $system.netboot_enabled is True
        checked="True"
    #end if
    >
    <p class="context-tip">Deselect to keep this system from PXE booting</p>
    </td>
    </tr>

    ## ====================================== start of looping through interfaces

    #set $counter = -1
    #for $interface in $all_interfaces
        #set $counter = $counter+1        

        ## ----------------------------------
        ## load up initial variable values
        ## ----------------------------------

        #if $system and $interface in $defined_interfaces
            #set $macaddress  = $system.interfaces[$interface]["mac_address"]
            #set $ipaddress   = $system.interfaces[$interface]["ip_address"]
            #set $hostname    = $system.interfaces[$interface]["hostname"]
            #set $dhcptag     = $system.interfaces[$interface]["dhcp_tag"]
            #set $virtbridge  = $system.interfaces[$interface]["virt_bridge"]
            #set $subnet      = $system.interfaces[$interface]["subnet"]
            #set $gateway     = $system.interfaces[$interface]["gateway"]
        #else
            #set $macaddress  = ""
            #set $ipaddress   = ""
            #set $hostname    = ""
            #set $dhcptag     = ""
            #set $virtbridge  = ""
            #set $subnet      = ""
            #set $gateway     = ""
        #end if

        ## ----------------------------------------
        ## render the toggle link to hide the interfaces not yet defined
        ## ----------------------------------------

        <tr class="listrow" id="1000${counter}">
        <td>
        <hr width="100%"/>
        </td>
        <td>
        <hr width="100%"/>
        </td>
        </tr>

##
##<td><a onclick="toggleRowVisibility('id263');" style="cursor: pointer;"><img name="id263-image" src="/img/list-expand.gif" alt=""/></a><a href="/network/software/channels/details.pxt?cid=263">Red Hat Enterprise Linux (v. 5 for 32-bit x86)</a></td>
##

        <tr class="listrow" id="id${counter}">
        <td>
        Interface $interface.replace("intf","")
        </td>
        <td>
        <a onclick="toggleRowVisibility('id${counter}');" style="cursor: pointer;"><img name="id${counter}-image" src="/cobbler/webui/list-expand.png" alt=""/></A>
        </td>
        </tr>
        
        ## ----------------------------------------
        ## now show all of the interface fields which may or may not
        ## be hidden but are always there
        ## ----------------------------------------

        <tr class="listrow" id="child-id${counter}-0">
        <td>
        <label for="macaddress-$interface">MAC</label>
        </td>
        <td>
        <input type="text" size="64" style="width: 150px;" name="macaddress-$interface" id="macaddress-$interface"
               value="$macaddress"
        />
        #if not $system
            <a href="javascript: get_random_mac()" style="font-size: 0.8em;">random</a>   
        #end if
        <p class="context-tip">Example: AA:BB:CC:DD:EE:FF</p>
        </td>
        </tr>

        <tr class="listrow" id="child-id${counter}-1">
        <td>
        <label for="ipaddress-$interface">IP</label>
        </td>
        <td>
        <input type="text" size="64" style="width: 150px;" name="ipaddress-$interface" id="ipaddress-$interface"
                value="$ipaddress"
        />
        <p class="context-tip">Example: 192.168.10.15</p>
        </td>
        </tr>

        <tr class="listrow" id="child-id${counter}-3">
        <td>
        <label for="hostname-$interface">Hostname</label>
        </td>
        <td>
        <input type="text" size="255" style="width: 150px;" name="hostname-$interface" id="hostname-$interface"
                value="$hostname"
        />
        <p class="context-tip">Example: vanhalen.example.org</p>
        </td>
        </tr>

        <tr class="listrow" id="child-id${counter}-4">
        <td>
        <label for="dhcptag-$interface">DHCP Tag</label>
        </td>
        <td>
        <input type="text" size="128" style="width: 150px;" name="dhcptag-$interface" id="dhcptag-$interface"
               value="$dhcptag"
        />
        <p class="context-tip">Selects alternative subnets, see manpage or leave blank</p>
        </td>
        </tr>

        ## FIXME: add virt_bridge editing (like above)

        <tr class="listrow" id="child-id${counter}-5">
        <td>
        <label for="virtbridge-$interface">Virt Bridge</label>
        </td>
        <td>
        <input type="text" size="20" style="width: 150px;" name="virtbridge-$interface" id="virtbridge-$interface"
                value="$virtbridge"
        />
        <p class="context-tip">Example: 'xenbr0' or 'virbr0'.  Can be blank if set in profile or settings.</p>
        </td>
        </tr>

        ## FIXME: add subnet editing (like above)

        <tr class="listrow" id="child-id${counter}-6">
        <td>
        <label for="subnet-$interface">Subnet</label>
        </td>
        <td>
        <input type="text" size="64" style="width: 150px;" name="subnet-$interface" id="subnet-$interface"
                value="$subnet"
        />
        <p class="context-tip">Ex: "255.255.255.0".  For use in kickstart templates for static IPs.</p>
        </td>
        </tr>

        ## FIXME: add gateway editing (like above)

        <tr class="listrow" id="child-id${counter}-7">
        <td>
        <label for="gateway-$interface">Gateway</label>
        </td>
        <td>
        <input type="text" size="64" style="width: 150px;" name="gateway-$interface" id="gateway-$interface"
                value="$gateway"
        />
        <p class="context-tip">Ex: "192.168.1.11".  For use in kickstart templates for static IPs.</p>
        </td>
        </tr>

        #if $interface != "intf0"
            <tr class="listrow" id="child-id${counter}-8">
            <td>
            <label for="enabled-$interface">Remove</label>
            </td>
            <td>
            <input type="button" name="delete-$interface" value="remove" onclick="delete_interface($counter)">
            <p class="context-tip">Clicking this button removes the interface from the configuration.</p>
            </td>
            </tr>
        #end if


        ## FIXME: make the save function understand the new fieldname-$interface variables
        ##        only enable an interface for saving if one of it's fields is non-empty
        ## FIXME: delete checkboxes and accompanying API method.  No delete for intf0.

    #end for
    ## ====================================== end of looping through interfaces

    <tr class="listrow" id="id10000">
    <td>
    <hr width="95%"/>
    </td>
    <td>
    <hr width="95%"/>
    </td>
    </tr>

    #if $system
    <tr id="id10001">
    <td>
    <label for="delete">Delete</label>
    </td>
    <td>
       <input type="checkbox" name="delete1" value="delete1">Yes
       <input type="checkbox" name="delete2" value="delete2">Really
    <p class="context-tip">Check both buttons and click save to delete this object</p>
    </td>
    </tr>
    #end if

    <tr id="9008">
    <td>
    </td>
    <td>
    <input type="submit" name="submit" value="Save"/>
    <input type="reset" name="reset" value="Reset"/>
    </td>
    </tr>

    </table>

</fieldset>
</form>

#end block body