1 <%doc>Copyright (C) 2009-2010 HDE, Inc.</%doc>
2 <%inherit file="../include/common.part" />
3 <%! from karesansui.lib.template import view_autounit %>
5 <script type="text/javascript">
7 function validates_guest(){
13 CHECK_EMPTY | CHECK_LENGTH | CHECK_ONLYSPACE,
16 MACHINE_NAME_MIN_LENGTH,
17 MACHINE_NAME_MAX_LENGTH
22 CHECK_LENGTH | CHECK_ONLYSPACE,
25 NOTE_TITLE_MIN_LENGTH,
39 var form_tmp = $("#tags").val();
40 var tags = $("#tags").val().split(",");
43 for (var idx in tags){
44 $("#tags").val(tags[idx]);
45 tag_check = check_string(
47 CHECK_LENGTH | CHECK_ONLYSPACE,
53 if(tag_check == false){
57 $("#tags").val(form_tmp);
58 check = check && tag_check;
63 CHECK_EMPTY | CHECK_LENGTH | CHECK_VALID | CHECK_ONLYSPACE,
71 CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
72 "${_('Memory Size (MB)')}",
78 CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
79 "${_('Disk Size (MB)')}",
83 boot_image = $("input:radio[name='boot_image']:checked").val();
84 if(boot_image == "kernel") {
85 check = check_startfile(
87 CHECK_EMPTY | CHECK_VALID,
88 "${_('Kernel Image')}"
90 check = check_startfile(
92 CHECK_EMPTY | CHECK_VALID,
93 "${_('Initrd Image')}"
96 check = check_startfile(
98 CHECK_EMPTY | CHECK_VALID,
103 check = check_number(
105 CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
106 "${_('VNC Port Number')}",
111 check = check_macaddr(
113 CHECK_EMPTY | CHECK_VALID,
114 "${_('MAC Address')}"
118 show_alert_msg("${_('Please input correct value.')}\n" + ERROR_MSG);
124 function setDefaultValue() {
125 hypervisor = $("#m_hypervisor").children(":selected").val();
126 if(hypervisor == 2) { /* kvm */
127 $("#boot_image_iso_html").css("display","block")
128 } else { /* not kvm as xen */
129 $("#boot_image_iso_html").css("display","none")
131 % for x in hypervisors.keys():
132 if("${hypervisors[x]}" == hypervisor) {
133 $("#vm_mac").val("${mac_address[x]}");
135 keymap_html = '<select id="keymap" name="keymap">'
136 % for y in keymaps[x]:
137 % if y == DEFAULT_KEYMAP:
138 keymap_html += '<option value="${y | h}" selected="selected">${y | h}</option>'
140 keymap_html += '<option value="${y | h}">${y | h}</option>'
143 keymap_html += '</select>';
144 $("#select_keymap_html").html(keymap_html);
146 phydev_html = '<select id="phydev" name="phydev">'
147 % for y in phydev[x]:
148 phydev_html += '<option value="${y | h}">${y | h}</option>'
150 phydev_html += '</select>';
151 $("#select_phydev_html").html(phydev_html);
153 virnet_html = '<select id="virnet" name="virnet">'
154 % for y in virnet[x]:
155 virnet_html += '<option value="${y | h}">${y | h}</option>'
157 virnet_html += '</select>'
158 $("#select_virnet_html").html(virnet_html)
162 boot_image = $("input:radio[name='boot_image']:checked").val();
163 if(boot_image == "kernel") {
164 $("#vm_kernel_require_str").css("display","");
165 $("#vm_initrd_require_str").css("display","");
166 $("#vm_iso_require_str").css("display","none");
167 $("#vm_kernel").attr("disabled", "");
168 $("#vm_initrd").attr("disabled", "");
169 $("#vm_iso").attr("disabled", "disabled");
171 $("#vm_kernel_require_str").css("display","none");
172 $("#vm_initrd_require_str").css("display","none");
173 $("#vm_iso_require_str").css("display","");
174 $("#vm_kernel").attr("disabled", "disabled");
175 $("#vm_initrd").attr("disabled", "disabled");
176 $("#vm_iso").attr("disabled", "");
181 function show_element(id,flag) {
189 $(document).ready(function(){
190 // TODO: ストレージプール毎に最大値等を設定する
191 set_simple_slider("#disk_slider", "#vm_disk_size", 0, ${int(pools_info['default']['available']) / (1024 * 1024)}, ${int(pools_info['default']['available']) / (1024 * 1024)});
192 $("#pool_dir").change(function(){
193 var pool_name = $('option:selected', this).val();
194 var disk_type = $('option:selected', this).parent('optgroup').attr('label');
195 if(disk_type == 'block'){
196 var parts = pool_name.split("_");
197 var vol_name = parts[1];
199 var vols_info = new Array();
200 % for pool_name in sorted(pools_vols_info.keys()):
201 % for vol_name in sorted(pools_vols_info[pool_name].keys()):
202 var vol_info = new Array();
203 vol_info['capacity'] = "${pools_vols_info[pool_name][vol_name]['capacity']}";
204 vols_info["${vol_name}"] = vol_info;
207 var disk_capacity = Math.floor(vols_info[vol_name]['capacity'] / (1024 * 1024));
208 $("#disk_size_box").hide();
209 $("#disk_type_value_box").html(disk_type);
210 $("#disk_available_box").hide();
211 $("#disk_capacity_value_box").html(disk_capacity);
212 $("#disk_format_box").hide();
213 } else { // type is 'dir' or 'fs'
214 var pools_info = new Array();
215 % for pool_name in pools_info.keys():
216 var pool_info = new Array();
217 pool_info['available'] = "${pools_info[pool_name]['available']}";
218 pool_info['capacity'] = "${pools_info[pool_name]['capacity']}";
219 pools_info["${pool_name}"] = pool_info
221 var disk_available = Math.floor(pools_info[pool_name]['available'] / (1024 * 1024));
222 var disk_capacity = Math.floor(pools_info[pool_name]['capacity'] / (1024 * 1024));
223 $("#disk_size_box").show();
224 set_simple_slider("#disk_slider", "#vm_disk_size", 0, disk_available, disk_available);
225 $("#disk_type_value_box").html(disk_type);
226 $("#disk_available_box").show();
227 $("#disk_available_value_box").html(disk_available);
228 $("#disk_capacity_value_box").html(disk_capacity);
229 $("#disk_format_box").show();
234 $("#pool_iscsi_list").tablesorter({
235 widgets: ['zebra', 'select'],
242 $("#mem_slider").slider({
246 slide: function(event, ui){
247 $("#vm_mem_size").val(ui.value);
251 $("#vm_mem_size").change(function(){
252 $("#mem_slider").slider("value",$(this).val());
256 "#input_guest_icon_form",
257 "${ctx.homepath}/icon",
258 function(){return true;}
262 "#input_guest_submit",
263 "${ctx.homepath}${ctx.path}",
264 "#input_guest :input",
269 $("tr[id*='pool_iscsi_row_']").each(function(){
270 $(this).one('click.once', function(){
271 var selc = $(this).attr("id").replace("pool_iscsi_row_", "").split("_");
273 var volume = selc[1];
275 $("#iscsi_pool").attr("value", pool);
276 $("#iscsi_volume").attr("value", volume);
282 helptip("#guest_name_help",
283 "${_('Guest Name')}",
284 "${_('Name of the guest. This will be used in Karesansui control panel. Any letters, including spaces and symbols are allowed.')}");
286 helptip("#guest_domain_name_help",
287 "${_('Domain Name')}",
288 "${_(r'VM domain name of the guest. This will be used to distinguish each guests in VM, so it should be unique between all guests (This is NOT a DNS \"domain\"). Alphabets and some symbols are allowed.')}");
290 helptip("#guest_icon_help",
291 "${_('Guest Icon')}",
292 "${_('Icon image to be used in Karesansui control panel. Choose the file and click upload button.')}");
294 helptip("#guest_memory_help",
295 "${_('Memory Size')}",
296 "${_('The amount of RAM for the guest to use (in mega-bytes).')}");
299 // ストレージとは 1系でいうディスクをさします。
301 // 利用するストレージを設定します。\nストレージ追加\n新規にストレージを作成します。\n\niSCSIストレージ利用\nネットワークストレージを利用します。\n
302 helptip("#disk_layout_help",
303 "${_('Storage Type')}",
304 "${_(r'Create New Disk Image: Create a new storage image. \n\nUse iSCSI: Use iSCSI networked storage.\n')}");
308 // ストレージプールを選択してください。ストレージプールは、ストレージプール画面から操作することができます。
309 helptip("#guest_disk_storage_name_help",
310 "${_('Storage Pool To Use')}",
311 "${_(r'Select the storage pool to use. You can manupulate storage pools in \"Storage Pool\" tab.')}");
315 // そのストレージプールの空き容量です。(MB)
316 helptip("#guest_disk_storage_available_help",
318 "${_('Available space in the storage pool.(MB)')}");
321 // ストレージプールの総容量です。(MB)
322 helptip("#guest_disk_storage_capacity_help",
324 "${_('Total capacity of the storage pool. (MB)')}");
328 // ゲストOSのストレージ容量を設定します。(MB)
329 helptip("#guest_disk_storage_help",
330 "${_('Disk Size (MB)')}",
331 "${_('Set the storage capacity of the guest OS. (MB)')}");
336 raw: もっともシンプルなイメージ形式です。(簡単に他のシステムで利用できる利点があります。)
337 vmdk : VMwareのバージョン3と4に対応するイメージ形式です。
338 cow: User Mode Linux利用されるイメージ形式です。
339 qcow: 古いQemuでサポートされているイメージ形式です。(互換性の維持で残されています。)
340 qcow2 : Qemuがサポートする最も一般的なイメージ形式です。
342 raw: This is the simplest image format. (Benefits available in other file systems easily.)
343 vmdk: VMware image format corresponding to the version 3 and 4.
344 cow: User Mode Linux is used image format.
345 qcow: Qemu is an older image formats are supported. (We have left in place to maintain compatibility.)
346 qcow2: Qemu is the most common image formats supported.
349 helptip("#guest_disk_os_image_type_help",
350 "${_('Image Type')}",
351 "${_(r'raw: The simplest image format. High interoperability with other systems.\nvmdk: Format which is used in VMWare 3 or 4.\ncow: Format used in User Mode Linux.\nqcow: Format used in old versions of Qemu. Left for compatibility.\nqcow2: The most common image format supported by Qemu.\n')}");
355 // ストレージプールの種別です。ネットワークストレージ及びストレージプールの画面で設定を行うことができます。
356 helptip("#guest_iscsi_storage_pool_type_help",
357 "${_('Storage Pool Type')}",
358 "${_('The type of storage pool. You can set this in networked storage tab and storage pool tab.')}");
362 // ストレージプールの名前です。ストレージプールの設定はストレージプール画面から行うことができます。
363 helptip("#guest_iscsi_storage_pool_help",
364 "${_('Storage Pool Name')}",
365 "${_('The name of the storage. Storage pool settings are available in storage pool tab.')}");
369 // ストレージプール内で実際に使われるボリューム名です。
370 helptip("#guest_iscsi_storage_volume_name_help",
371 "${_('Storage Volume Name')}",
372 "${_('Volume name actually used in the storage pool.')}");
376 // デバイスの制御方法を設定します。準仮想化デバイスとして動作するvirtio(KVM)/xen(Xen)を推奨します。
377 helptip("#guest_bus_type_help",
379 "${_('Set the device controlling method. We recommend virtio (KVM) / xen (Xen), which allows device to act as a para-virtualized device.')}");
384 helptip("#device_display_bootup_vnc_keymap_help",
385 "${_('VNC Keymap')}",
386 "${_('Keymap of the keyboard to use with VNC.')}");
388 helptip("#guest_disk_help",
390 "${_('Size of the disk of the guest (MB)')}");
392 helptip("#guest_kernel_help",
393 "${_('Kernel Image')}",
394 "${_('Kernel image for the guest. Specify FTP/HTTP URL, or a valid absolute file path.')}");
396 helptip("#guest_initrd_help",
397 "${_('Initrd Image')}",
398 "${_('The initrd (bootup RAM disk) image for the guest. Specify FTP/HTTP URL, or a valid absolute file path.')}");
400 helptip("#guest_iso_help",
402 "${_('The ISO 9660 CD-ROM/DVD-ROM image for the guest. Specify a valid absolute file path.')}");
404 helptip("#guest_vnc_port_help",
405 "${_('VNC Port Number')}",
406 "${_('(Auto-recommended value displayed below.) TCP port number to access the guest with VNC. Numbers greater than 5900 are allowed. Unique number between all guests are recommended.')}");
408 helptip("#guest_interface_type_help",
409 "${_('Interface Type')}",
410 "${_(r'Type of the virtual network interface connection. Choose \"Physical Device\" to connect directly to the physical network, or \"Virtual Network\" to connect guest to the virtual network (which are in \"Network\" tab of the host). ')}");
412 helptip("#guest_mac_address_help",
413 "${_('MAC Address')}",
414 "${_('(Auto-recommended value displayed below.) MAC address of the guest in xx:xx:xx:xx:xx:xx format. Specify an address not used in the network.')}");
416 helptip("#guest_option_help",
417 "${_('Extra Kernel Options')}",
418 "${_('Kernel parameters to pass to the guest kernel on guest installation.')}");
420 helptip("#guest_tag_help",
422 "${_(r'Tag to add to the guest to be used in Karesansui control panel. Can be used to search guests using tags in the \"Guests\" panel. Separate tags with commas to specify two or more tags. Any letters, including spaces and symbols are allowed.')}");
427 <div id="input_guest">
428 <div class="grayout-head">
429 <span class="grayout-title">
430 <a href="#" id="server" class="path-a"><img src="${ctx.homepath}/static/images/settings-title.gif" alt="">${_('Create Guest')}</a>
432 <br style="clear: both;"/>
435 <div class="grayout-contents">
436 <div class="grayout-param">${_('Guest Name')}<span id="guest_name_help"/></div>
437 <div class="grayout-value grayout-form">
438 <input type="text" id="m_name" name="m_name" value="" size="40" maxlength="256" /><span class="require-text">${_('Require')}</span>
440 <div class="grayout-param">${_('Hypervisor')}</div>
441 <div class="grayout-value grayout-form">
442 <select id="m_hypervisor" name="m_hypervisor" onChange="javascript:setDefaultValue()">
443 % for x in hypervisors.keys():
444 <option value="${hypervisors[x]}">${_(x)}</option>
448 <div class="grayout-param">${_('Domain Name')}<span id="guest_domain_name_help"/></div>
449 <div class="grayout-value grayout-form">
450 <input type="text" id="domain_name" name="domain_name" value="" size="40" /><span class="require-text">${_('Require')}</span>
454 <div class="grayout-param">${_('Guest Icon')}<span id="guest_icon_help"/></div>
455 <div class="grayout-value grayout-form">
456 <form action="#" method="post" id="input_guest_icon_form" name="input_guest_icon_form">
457 <input type="file" id="multi_icon" name="multi_icon" size="40" />
458 <input type="hidden" id="icon_filename" name="icon_filename" value="" />
459 <a href="#" name="icon_upload_submit" id="icon_upload_submit" class="button" style="display: inline">
460 <span class="button-left"> </span><span class="button-right">${_('Upload')}</span>
462 <a href="#" name="icon_cancel_submit" id="icon_cancel_submit" class="button" style="display: inline">
463 <span class="button-left"> </span><span class="button-right">${_('Cancel')}</span>
468 <div class="grayout-param">${_('Memory Size (MB)')}<span id="guest_memory_help"/></div>
469 <div class="grayout-value grayout-form">
470 <div id="mem_slider"></div>
471 <input type="text" id="vm_mem_size" name="vm_mem_size" value="512" /><span class="require-text">${_('Require')}</span>
474 <div class="grayout-param">${_('Storage Type')}<span id="disk_layout_help"/></div>
475 <div class="grayout-value grayout-form">
476 <style type="text/css">
478 border: 1px solid #BCBCBC;
490 background:transparent url(${ctx.homepath}/static/images/kugiri-a.gif) repeat scroll 0 0;
496 table.detail-contents>tbody>tr>th{
498 background-color: #FFFFFF;
504 table.detail-contents>tbody>tr>td{
505 background-color: #FFFFFF;
508 ${_("Storage Pool Name")} :
509 <select id="pool_dir" name="pool_dir">
511 TODO: iscsiのストレージプールを表示させない。dir, fsのみ表示させる。
513 % for group_type in ['dir', 'fs', 'block']:
514 <optgroup label="${group_type}">
515 % for name in sorted(pools_info.keys()):
516 % if group_type == 'dir' and pools_info[name]['type'] == 'dir':
517 % if pools_info[name]['name'] == 'default':
518 <option value="${name}" selected>${name}</option>
520 <option value="${name}">${name}</option>
524 % if group_type == 'fs' and pools_info[name]['type'] == 'fs':
525 <option value="${name}">${name}</option>
528 % if group_type == 'block' and pools_info[name]['type'] == 'iscsi':
529 % for vol_name in sorted(pools_vols_info[name].keys()):
530 <option value="${name}_${vol_name}">${name}/${vol_name}</option>
537 <div class="grayout-detail">
538 <input type="hidden" id="iscsi_pool" name="iscsi_pool" value="" />
539 <input type="hidden" id="iscsi_volume" name="iscsi_volume" value="" />
540 <table class="detail-contents">
541 <tr id="disk_type_box">
542 <th>${_('Storage Pool Type')}</th>
543 <td class="detail-separator"><img src="${ctx.homepath}/static/images/table-space.gif" alt="" /></td>
544 <td id="disk_type_value_box">${pools_info['default']['type'] | h}</td>
546 <tr id="disk_size_box">
547 <th>${_('Disk Size (MB)')}</th>
548 <td class="detail-separator"><img src="${ctx.homepath}/static/images/table-space.gif" alt="" /></td>
549 <td id="disk_size_value_box">
550 <div id="disk_slider"></div>
551 <input type="text" id="vm_disk_size" name="vm_disk_size" value="0" /><span class="require-text">${_('Require')}</span>
554 <tr id="disk_available_box">
555 <th>${_('Available (MB)')}</th>
556 <td class="detail-separator"><img src="${ctx.homepath}/static/images/table-space.gif" alt="" /></td>
557 <td id="disk_available_value_box">${int(pools_info['default']['available']) / (1024 * 1024)}</td>
559 <tr id="disk_capacity_box">
560 <th>${_('Capacity (MB)')}</th>
561 <td class="detail-separator"><img src="${ctx.homepath}/static/images/table-space.gif" alt="" /></td>
562 <td id="disk_capacity_value_box">${int(pools_info['default']['capacity']) / (1024 * 1024)}</td>
564 <tr id="disk_format_box">
565 <th>${_('OS Image Type')}</th>
566 <td class="detail-separator"><img src="${ctx.homepath}/static/images/table-space.gif" alt="" /></td>
567 <td id="disk_format_value_box">
568 <select id="select_disk_format" name="disk_format">
569 % if "KVM" in hypervisors.keys():
570 % for x in DISK_QEMU_FORMAT.values():
572 <option value="${x}" selected>${x}</option>
574 <option value="${x}">${x}</option>
578 % for x in DISK_NON_QEMU_FORMAT.values():
579 <option value="${x}">${x}</option>
589 <div class="grayout-param">${_('Bus Type')}<span id="guest_bus_type_help"/></div>
590 <div class="grayout-value grayout-form">
591 <select name="bus_type">
592 % if "KVM" in hypervisors.keys():
593 % for x in bus_types:
595 <option value="${x}" selected>${x}</option>
597 <option value="${x}">${x}</option>
601 % for x in bus_types:
603 <option value="${x}" selected>${x}</option>
605 <option value="${x}">${x}</option>
612 <div class="grayout-param">${_('Boot Image')}<span id="guest_boot_image_help"/></div>
613 <div class="grayout-value grayout-form">
617 <input type="radio" name="boot_image" id="boot_image_kernel" value="kernel" checked onChange="javascript:setDefaultValue()"/>
622 <div class="grayout-value grayout-form" style="width:150px;">
623 ${_('Kernel Image')}<span id="guest_kernel_help"/>
626 <input type="text" id="vm_kernel" name="vm_kernel" value="" size="60" /><span class="require-text" id="vm_kernel_require_str">${_('Require')}</span>
630 <div class="grayout-value grayout-form" style="width:150px;">
631 ${_('Initrd Image')}<span id="guest_initrd_help"/>
634 <input type="text" id="vm_initrd" name="vm_initrd" value="" size="60" /><span class="require-text" id="vm_initrd_require_str">${_('Require')}</span>
643 <div id="boot_image_iso_html">
644 <div class="grayout-value grayout-form">
648 <input type="radio" name="boot_image" id="boot_image_iso" value="iso" onChange="javascript:setDefaultValue()"/>
653 <div class="grayout-value grayout-form" style="width:150px;">
654 ${_('ISO Image')}<span id="guest_iso_help"/>
657 <input type="text" id="vm_iso" name="vm_iso" value="/git/iso/CentOS-5.4-x86_64-bin-DVD.iso" size="60" /><span class="require-text" id="vm_iso_require_str">${_('Require')}</span>
667 <div class="grayout-param">${_('VNC Keymap')}<span id="device_display_bootup_vnc_keymap_help" /></div>
668 <div class="grayout-value grayout-form">
669 <div id="select_keymap_html"></div>
672 <div class="grayout-param">${_('VNC Port Number')}<span id="guest_vnc_port_help"/></div>
673 <div class="grayout-value grayout-form">
674 <input type="text" id="vm_vncport" name="vm_vncport" value="${vnc_port | h}" size="6" maxlength="5" /><span class="require-text">${_('Require')}</span>
677 <div class="grayout-param">${_('Interface Type')}<span id="guest_interface_type_help" /></div>
680 <div class="grayout-value grayout-form">
684 <input type="radio" name="nic_type" id="nic_type_phy" value="phydev" checked />
689 <div class="grayout-value grayout-form" style="width:150px;">
690 ${_('Physical Device')}<span id="guest_iso_help"/>
693 <div id="select_phydev_html"></div>
702 <input type="radio" name="nic_type" id="nic_type_vir" value="virnet" />
707 <div class="grayout-value grayout-form" style="width:150px;">
708 ${_('Virtual Network')}<span id="guest_iso_help"/>
711 <div id="select_virnet_html"></div>
721 <div class="grayout-param">${_('MAC Address')}<span id="guest_mac_address_help"/></div>
722 <div class="grayout-value grayout-form">
723 <input type="text" id="vm_mac" name="vm_mac" value="" size="20" maxlength="17" /><span class="require-text">${_('Require')}</span>
725 <div class="grayout-param">${_('Extra Kernel Options')}<span id="guest_option_help"/></div>
726 <div class="grayout-value grayout-form">
727 <input type="text" id="vm_extra" name="vm_extra" value="" size="40" />
729 <div class="grayout-param">${_('Notebook')}</div>
730 <div class="grayout-value grayout-form">
732 <input type="text" id="note_title" name="note_title" value="" size="40" maxlength="64" />
734 <textarea id="note_value" name="note_value" cols="50" rows="5"></textarea>
736 <div class="grayout-param">${_('Tag')}<span id="guest_tag_help"/></div>
737 <div class="grayout-value grayout-form">
738 <input type="text" id="tags" name="tags" value="" size="40" />
741 <div class="grayout-footer">
742 <a href="#" name="input_guest_submit" id="input_guest_submit" class="button">
743 <span class="button-left"> </span><span class="button-right">${_('Create')}</span>
745 <br style="clear: both;"/>
747 <br style="clear: both;"/>