function get_ami_deployment_image_rootdevice_identifier($id) { global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_ADMIN; global $event; $rootdevice_identifier_array = array(); $image = new image(); $image_id_list = $image->get_ids(); foreach ($image_id_list as $id => $ikey) { $image_tmp = new image(); $image_tmp->get_instance_by_id($id); if ($image_tmp->type === "ami-deployment") { $rootdevice_identifier_array[] = array("value" => $image_tmp->rootdevice, "label" => $image_tmp->name); } } return $rootdevice_identifier_array; }
function get_response() { $response = $this->response; $form = $response->get_form($this->actions_name, 'edit'); $id = $this->response->html->request()->get('image_id'); $submit = $form->get_elements('submit'); $submit->handler = 'onclick="wait();"'; $form->add($submit, 'submit'); $submit = $form->get_elements('cancel'); $submit->handler = 'onclick="cancel();"'; $form->add($submit, 'cancel'); $image = $this->openqrm->image(); $image->get_instance_by_id($id); $storage = $this->openqrm->storage(); $storage->get_instance_by_id($image->storageid); $deployment = $this->openqrm->deployment(); $deployment->get_instance_by_id($storage->type); $storage_resource = $this->openqrm->resource(); $storage_resource->get_instance_by_id($storage->resource_id); // making the deployment parameters plugg-able $rootdevice_identifier_hook = $this->openqrm->get('basedir') . "/web/boot-service/image." . $deployment->type . ".php"; if (file_exists($rootdevice_identifier_hook)) { require_once "{$rootdevice_identifier_hook}"; // run function returning rootdevice array $get_rootfs_transfer_methods_function = "get_" . $deployment->type . "_rootfs_transfer_methods"; $get_rootfs_transfer_methods_function = str_replace("-", "_", $get_rootfs_transfer_methods_function); $rootfs_transfer_methods = $get_rootfs_transfer_methods_function(); $get_rootfs_set_password_method_function = "get_" . $deployment->type . "_rootfs_set_password_method"; $get_rootfs_set_password_method_function = str_replace("-", "_", $get_rootfs_set_password_method_function); $rootfs_set_password_method = $get_rootfs_set_password_method_function(); $get_rootfs_local_deployment_enabled_function = "get_" . $deployment->type . "_local_deployment_enabled"; $get_rootfs_local_deployment_enabled_function = str_replace("-", "_", $get_rootfs_local_deployment_enabled_function); $rootfs_local_deployment_enabled = $get_rootfs_local_deployment_enabled_function(); } else { $rootfs_transfer_methods = false; $rootfs_set_password_method = false; $rootfs_local_deployment_enabled = false; } // making the local deployment parameter plugg-able $local_deployment_methods_input = ""; if ($rootfs_local_deployment_enabled) { $local_deployment_methods_arr[] = array("value" => "", "label" => ""); $local_deployment = new deployment(); $deployment_id_arr = $local_deployment->get_deployment_ids(); foreach ($deployment_id_arr as $deployment_id) { $local_deployment->get_instance_by_id($deployment_id['deployment_id']); $local_deployment_templates_identifier_hook = $this->openqrm->get('basedir') . "/web/boot-service/template." . $local_deployment->type . ".php"; if (file_exists($local_deployment_templates_identifier_hook)) { require_once "{$local_deployment_templates_identifier_hook}"; $deployment_function = "get_" . "{$local_deployment->type}" . "_methods"; $deployment_function = str_replace("-", "_", $deployment_function); $local_deployment_methods_arr[] = $deployment_function(); } } } // in case the deployment method provides the rootfs-transfer options $nfs_image_identifier_array = array(); if ($rootfs_transfer_methods) { // prepare the install-from and transfer-to selects $nfs_image_identifier_array[] = array("value" => "", "label" => ""); $nfs_image = new image(); $image_arr = $nfs_image->get_ids(); foreach ($image_arr as $id) { $i_id = $id['image_id']; $timage = new image(); $timage->get_instance_by_id($i_id); if (strstr($timage->type, "nfs")) { $timage_name = $timage->name; $nfs_image_identifier_array[] = array("value" => "{$i_id}", "label" => "{$timage_name}"); } } } $html = new htmlobject_div(); $html->text = '<a href="../../plugins/' . $deployment->storagetype . '/' . $deployment->storagetype . '-about.php" target="_blank" class="doculink">' . $deployment->description . '</a>'; $html->id = 'htmlobject_image_type'; $storage_deploy_box = new htmlobject_box(); $storage_deploy_box->id = 'htmlobject_box_image_deploy'; $storage_deploy_box->css = 'htmlobject_box'; $storage_deploy_box->label = 'Deployment'; $storage_deploy_box->content = $html; $html = new htmlobject_div(); $html->text = $deployment->storagedescription; $html->id = 'htmlobject_storage_type'; $storage_type_box = new htmlobject_box(); $storage_type_box->id = 'htmlobject_box_storage_type'; $storage_type_box->css = 'htmlobject_box'; $storage_type_box->label = 'Storage'; $storage_type_box->content = $html; #$storage_resource->id / $html = new htmlobject_div(); $html->text = "{$storage_resource->ip}"; $html->id = 'htmlobject_storage_resource'; $storage_resource_box = new htmlobject_box(); $storage_resource_box->id = 'htmlobject_box_storage_resource'; $storage_resource_box->css = 'htmlobject_box'; $storage_resource_box->label = 'Resource'; $storage_resource_box->content = $html; // in case the deployment type allows to set the password in the image if ($rootfs_set_password_method) { $d['image_password']['label'] = $this->lang['form_image_password']; $d['image_password']['required'] = false; $d['image_password']['object']['type'] = 'htmlobject_input'; $d['image_password']['object']['attrib']['id'] = 'pass_1'; $d['image_password']['object']['attrib']['type'] = 'password'; $d['image_password']['object']['attrib']['name'] = 'image_password'; $d['image_password_2']['label'] = $this->lang['form_image_password_repeat']; $d['image_password_2']['required'] = false; $d['image_password_2']['object']['type'] = 'htmlobject_input'; $d['image_password_2']['object']['attrib']['id'] = 'pass_2'; $d['image_password_2']['object']['attrib']['type'] = 'password'; $d['image_password_2']['object']['attrib']['name'] = 'image_password_2'; } else { $d['image_password'] = ''; $d['image_password_2'] = ''; } if ($rootfs_transfer_methods) { $d['install_from_local']['label'] = $this->lang['form_install_from_local']; $d['install_from_local']['required'] = false; $d['install_from_local']['object']['type'] = 'htmlobject_input'; $d['install_from_local']['object']['attrib']['id'] = 'install_from_local'; $d['install_from_local']['object']['attrib']['name'] = 'install_from_local'; $d['transfer_to_local']['label'] = $this->lang['form_transfer_to_local']; $d['transfer_to_local']['required'] = false; $d['transfer_to_local']['object']['type'] = 'htmlobject_input'; $d['transfer_to_local']['object']['attrib']['id'] = 'transfer_to_local'; $d['transfer_to_local']['object']['attrib']['name'] = 'transfer_to_local'; $d['install_from_nfs']['label'] = $this->lang['form_install_from_nfs']; $d['install_from_nfs']['required'] = false; $d['install_from_nfs']['object']['type'] = 'htmlobject_select'; $d['install_from_nfs']['object']['attrib']['index'] = array('value', 'label'); $d['install_from_nfs']['object']['attrib']['id'] = 'install_from_nfs'; $d['install_from_nfs']['object']['attrib']['name'] = 'install_from_nfs'; $d['install_from_nfs']['object']['attrib']['options'] = $nfs_image_identifier_array; $d['transfer_to_nfs']['label'] = $this->lang['form_transfer_to_nfs']; $d['transfer_to_nfs']['required'] = false; $d['transfer_to_nfs']['object']['type'] = 'htmlobject_select'; $d['transfer_to_nfs']['object']['attrib']['index'] = array('value', 'label'); $d['transfer_to_nfs']['object']['attrib']['id'] = 'transfer_to_nfs'; $d['transfer_to_nfs']['object']['attrib']['name'] = 'transfer_to_nfs'; $d['transfer_to_nfs']['object']['attrib']['options'] = $nfs_image_identifier_array; } else { $d['install_from_local'] = ''; $d['transfer_to_local'] = ''; $d['install_from_nfs'] = ''; $d['transfer_to_nfs'] = ''; } if ($rootfs_local_deployment_enabled) { $d['install_from_template']['label'] = $this->lang['form_install_from_template']; $d['install_from_template']['required'] = false; $d['install_from_template']['object']['type'] = 'htmlobject_select'; $d['install_from_template']['object']['attrib']['index'] = array('value', 'label'); $d['install_from_template']['object']['attrib']['id'] = 'install_from_template'; $d['install_from_template']['object']['attrib']['name'] = 'install_from_template'; $d['install_from_template']['object']['attrib']['options'] = $local_deployment_methods_arr; } else { $d['install_from_template'] = ''; } $image_version_arr[] = array("value" => "Linux", "label" => "Linux"); $image_version_arr[] = array("value" => "Windows", "label" => "Windows"); $image_version_arr[] = array("value" => "Other", "label" => "Other"); $d['image_version']['label'] = $this->lang['form_image_version']; $d['image_version']['required'] = false; $d['image_version']['object']['type'] = 'htmlobject_select'; $d['image_version']['object']['attrib']['index'] = array('value', 'label'); $d['image_version']['object']['attrib']['id'] = 'image_version'; $d['image_version']['object']['attrib']['name'] = 'image_version'; $d['image_version']['object']['attrib']['options'] = $image_version_arr; $d['image_version']['object']['attrib']['selected'] = array($image->version); $d['image_comment']['label'] = $this->lang['form_comment']; $d['image_comment']['object']['type'] = 'htmlobject_textarea'; $d['image_comment']['object']['attrib']['id'] = 'comment'; $d['image_comment']['object']['attrib']['name'] = 'image_comment'; $d['image_comment']['object']['attrib']['value'] = $image->comment; $form->add($d); $response->form = $form; return $response; }
function get_response() { $size_select_arr = array(); $availability_zones_select_arr = array(); $security_group_select_arr = array(); $subnet_select_arr = array(); $keypair_select_arr = array(); // get the datastore and vswitchlist for the selects if (file_exists($this->statfile)) { $lines = explode("\n", file_get_contents($this->statfile)); if (count($lines) >= 1) { foreach ($lines as $line) { if ($line !== '') { $line = explode('@', $line); switch ($line[0]) { case 'SIZES': $size_select_arr[] = array($line[1], $line[1]); break; case 'KEYPAIR': $keypair_select_arr[] = array($line[1], $line[1]); break; case 'GROUP': $security_group_select_arr[] = array($line[1], $line[1]); break; case 'ZONES': $availability_zones_select_arr[] = array($line[1], $line[1]); break; case 'SUBNET': $subnet_select_arr[] = array($line[1], $line[2] . " (" . $line[3] . ")"); break; } } } } } if ($this->hc->account_type == 'aws' || $this->hc->account_type == 'euca') { $instance_types[] = array("t1.micro", "t1.micro"); $instance_types[] = array("m1.small", "m1.small"); $instance_types[] = array("m1.medium", "m1.medium"); $instance_types[] = array("m1.large", "m1.large"); $instance_types[] = array("m1.xlarge", "m1.xlarge"); $instance_types[] = array("m3.xlarge", "m3.xlarge"); $instance_types[] = array("m3.2xlarge", "m3.2xlarge"); $instance_types[] = array("c1.medium", "c1.medium"); $instance_types[] = array("c1.xlarge", "c1.xlarge"); $instance_types[] = array("m2.xlarge", "m2.xlarge"); $instance_types[] = array("m2.2xlarge", "m2.2xlarge"); $instance_types[] = array("m2.4xlarge", "m2.4xlarge"); $instance_types[] = array("cr1.8xlarge", "cr1.8xlarge"); $instance_types[] = array("hi1.4xlarge", "hi1.4xlarge"); $instance_types[] = array("hs1.8xlarge", "hs1.8xlarge"); $instance_types[] = array("cc1.4xlarge", "cc1.4xlarge"); $instance_types[] = array("cc2.8xlarge", "cc2.8xlarge"); $instance_types[] = array("cg1.4xlarge", "cg1.4xlarge"); $instance_type_selected = "t1.micro"; } if ($this->hc->account_type == 'lc-openstack') { $instance_types = $size_select_arr; $instance_type_selected = "m1.nano"; } // AMIs $ami_select_arr = array(); $image = new image(); $image_id_list = $image->get_ids(); foreach ($image_id_list as $id => $ikey) { $image_tmp = new image(); $image_tmp->get_instance_by_id($ikey['image_id']); if ($image_tmp->type === "ami-deployment") { $ami_select_arr[] = array($image_tmp->id, $image_tmp->comment); } } $response = $this->response; $form = $response->get_form($this->actions_name, 'add'); $submit = $form->get_elements('submit'); $submit->handler = 'onclick="wait();"'; $form->add($submit, 'submit'); $submit = $form->get_elements('cancel'); $submit->handler = 'onclick="cancel();"'; $form->add($submit, 'cancel'); if ($this->hc->account_type == 'lc-openstack') { $d['name']['label'] = $this->lang['form_name']; $d['name']['required'] = false; $d['name']['validate']['regex'] = '/^[a-z0-9._:\\/-]+$/i'; $d['name']['validate']['errormsg'] = sprintf($this->lang['error_name'], 'a-z0-9._:\\/-'); $d['name']['object']['type'] = 'htmlobject_input'; $d['name']['object']['attrib']['id'] = 'name'; $d['name']['object']['attrib']['name'] = 'name'; $d['name']['object']['attrib']['type'] = 'text'; $d['name']['object']['attrib']['value'] = ''; $d['name']['object']['attrib']['maxlength'] = 255; } if ($this->hc->account_type == 'aws' || $this->hc->account_type == 'euca') { $d['name'] = ''; } $d['instance_type']['label'] = $this->lang['form_instance_type']; $d['instance_type']['required'] = true; $d['instance_type']['object']['type'] = 'htmlobject_select'; $d['instance_type']['object']['attrib']['name'] = 'type'; $d['instance_type']['object']['attrib']['index'] = array(0, 1); $d['instance_type']['object']['attrib']['options'] = $instance_types; $d['instance_type']['object']['attrib']['selected'] = array($instance_type_selected); $d['ami']['label'] = $this->lang['form_ami']; $d['ami']['required'] = true; $d['ami']['object']['type'] = 'htmlobject_select'; $d['ami']['object']['attrib']['name'] = 'ami_image_id'; $d['ami']['object']['attrib']['index'] = array(0, 1); $d['ami']['object']['attrib']['options'] = $ami_select_arr; $a = $this->response->html->a(); $a->label = $this->lang['form_add_volume']; $a->handler = 'onclick="wait();"'; $a->css = 'add'; $a->href = 'index.php?plugin=hybrid-cloud&controller=hybrid-cloud-ami&hybrid_cloud_id=' . $this->id; $d['add_image'] = $a->get_string(); if ($this->hc->account_type == 'aws' || $this->hc->account_type == 'euca') { $d['availability_zone']['label'] = $this->lang['form_availability_zone']; $d['availability_zone']['required'] = true; $d['availability_zone']['object']['type'] = 'htmlobject_select'; $d['availability_zone']['object']['attrib']['name'] = 'availability_zone'; $d['availability_zone']['object']['attrib']['index'] = array(0, 1); $d['availability_zone']['object']['attrib']['options'] = $availability_zones_select_arr; } if ($this->hc->account_type == 'lc-openstack') { $d['availability_zone'] = ''; } if ($this->hc->account_type == 'aws') { $d['group'] = ''; $d['subnet']['label'] = $this->lang['form_subnet']; $d['subnet']['required'] = true; $d['subnet']['object']['type'] = 'htmlobject_select'; $d['subnet']['object']['attrib']['name'] = 'subnet'; $d['subnet']['object']['attrib']['index'] = array(0, 1); $d['subnet']['object']['attrib']['options'] = $subnet_select_arr; } else { $d['subnet'] = ''; $d['group']['label'] = $this->lang['form_security_group']; $d['group']['required'] = true; $d['group']['object']['type'] = 'htmlobject_select'; $d['group']['object']['attrib']['name'] = 'group'; $d['group']['object']['attrib']['index'] = array(0, 1); $d['group']['object']['attrib']['options'] = $security_group_select_arr; $d['group']['object']['attrib']['selected'] = array('default'); } $d['keypair']['label'] = $this->lang['form_keypair']; $d['keypair']['required'] = true; $d['keypair']['object']['type'] = 'htmlobject_select'; $d['keypair']['object']['attrib']['name'] = 'keypair'; $d['keypair']['object']['attrib']['index'] = array(0, 1); $d['keypair']['object']['attrib']['options'] = $keypair_select_arr; $d['custom_script']['label'] = $this->lang['form_custom_script']; $d['custom_script']['required'] = false; $d['custom_script']['validate']['regex'] = '/^[a-z0-9._:\\/-]+$/i'; $d['custom_script']['validate']['errormsg'] = sprintf($this->lang['error_name'], 'a-z0-9._:\\/-'); $d['custom_script']['object']['type'] = 'htmlobject_input'; $d['custom_script']['object']['attrib']['id'] = 'custom_script'; $d['custom_script']['object']['attrib']['name'] = 'custom_script'; $d['custom_script']['object']['attrib']['type'] = 'text'; $d['custom_script']['object']['attrib']['value'] = ''; $d['custom_script']['object']['attrib']['title'] = $this->lang['form_custom_script_title']; $d['custom_script']['object']['attrib']['maxlength'] = 255; $form->add($d); $response->form = $form; return $response; }
function get_response() { $OPENQRM_SERVER_BASE_DIR = $this->openqrm->get('basedir'); $response = $this->response; $form = $response->get_form($this->actions_name, 'add'); $cpus[] = array("1", "1 CPU"); $cpus[] = array("2", "2 CPUs"); $cpus[] = array("4", "4 CPUs"); $cpus[] = array("8", "8 CPUs"); $cpus[] = array("16", "16 CPUs"); $ram[] = array("256", "256 MB"); $ram[] = array("512", "512 MB"); $ram[] = array("1024", "1 GB"); $ram[] = array("2048", "2 GB"); $ram[] = array("4096", "4 GB"); $ram[] = array("8192", "8 GB"); $ram[] = array("16384", "16 GB"); $ram[] = array("32768", "32 GB"); $ram[] = array("65536", "64 GB"); $nics[] = array("virtio", $this->lang['form_net_virtio']); $nics[] = array("e1000", $this->lang['form_net_e1000']); $nics[] = array("rtl8139", $this->lang['form_net_rtl8139']); $keymaps[] = array("de", "de"); $keymaps[] = array("en-us", "en-us"); $keymaps[] = array("es", "es"); $keymaps[] = array("fr", "fr"); $keymaps[] = array("it", "it"); $keymaps[] = array("ja", "ja"); $keymaps[] = array("nl", "nl"); $keymaps[] = array("ru", "ru"); $keymaps[] = array("none", "none"); $disk_interfaces[] = array("virtio", "Virtio"); $disk_interfaces[] = array("ide", "IDE"); $swap_select_arr[] = array('1024', '1 GB'); $swap_select_arr[] = array('2048', '2 GB'); $swap_select_arr[] = array('4096', '4 GB'); // if we come from the wizard suggest the server name $vm_name_suggestion = ''; if (isset($this->user->wizard_name) && $this->user->wizard_name === 'appliance' && $this->user->wizard_step == 2) { $appliance = new appliance(); $appliance->get_instance_by_id($this->user->wizard_id); $vm_name_suggestion = $appliance->name; } // get a list of existing kvm localboot images to select $existing_image_arr = array(); $image = new image(); $image_image_id_ar = $image->get_ids_by_type('kvm-lvm-deployment'); foreach ($image_image_id_ar as $iid_ar) { $image_id = $iid_ar['image_id']; $image->get_instance_by_id($image_id); $existing_image_arr[] = array($image->id, $image->name); } $image_image_id_ar = $image->get_ids_by_type('kvm-bf-deployment'); foreach ($image_image_id_ar as $iid_ar) { $image_id = $iid_ar['image_id']; $image->get_instance_by_id($image_id); $existing_image_arr[] = array($image->id, $image->name); } $image_image_id_ar = $image->get_ids_by_type('kvm-gluster-deployment'); foreach ($image_image_id_ar as $iid_ar) { $image_id = $iid_ar['image_id']; $image->get_instance_by_id($image_id); $existing_image_arr[] = array($image->id, $image->name); } $existing_image_arr[] = array('', ''); // get a list of network-deployment images for netboot vms $existing_netboot_image_arr = array(); $existing_netboot_image_id_ar = $image->get_ids(); foreach ($existing_netboot_image_id_ar as $iid_ar) { $image_id = $iid_ar['image_id']; $image->get_instance_by_id($image_id); if ($image->is_network_deployment()) { $existing_netboot_image_arr[] = array($image->id, $image->name); } } $existing_netboot_image_arr[] = array('', ''); $file = $OPENQRM_SERVER_BASE_DIR . '/plugins/kvm/web/kvm-stat/' . $this->resource->id . '.bridge_config'; $data = openqrm_parse_conf($file); $bridges = array(); $bridge_list = $data['OPENQRM_KVM_BRIDGES']; $bridge_list = rtrim($bridge_list, ":"); $bridge_array = explode(':', $bridge_list); // handle no bridge error if (isset($bridge_array[0]) && $bridge_array[0] !== '') { foreach ($bridge_array as $b) { $bridges[] = array($b, $b); } $submit = $form->get_elements('submit'); $submit->handler = 'onclick="wait();"'; $form->add($submit, 'submit'); $submit = $form->get_elements('cancel'); $submit->handler = 'onclick="cancel();"'; $form->add($submit, 'cancel'); $d['name']['label'] = $this->lang['form_name']; $d['name']['required'] = true; $d['name']['validate']['regex'] = '/^[a-z0-9._]+$/i'; $d['name']['validate']['errormsg'] = sprintf($this->lang['error_name'], 'a-z0-9._'); $d['name']['object']['type'] = 'htmlobject_input'; $d['name']['object']['attrib']['name'] = 'name'; $d['name']['object']['attrib']['id'] = 'name'; $d['name']['object']['attrib']['type'] = 'text'; $d['name']['object']['attrib']['css'] = 'namegen'; $d['name']['object']['attrib']['customattribs'] = 'data-prefix="kvm" data-length="6"'; $d['name']['object']['attrib']['value'] = $vm_name_suggestion; $d['name']['object']['attrib']['maxlength'] = 50; $d['cpus']['label'] = $this->lang['form_cpus']; $d['cpus']['required'] = true; $d['cpus']['object']['type'] = 'htmlobject_select'; $d['cpus']['object']['attrib']['name'] = 'cpus'; $d['cpus']['object']['attrib']['index'] = array(0, 1); $d['cpus']['object']['attrib']['options'] = $cpus; $d['memory']['label'] = $this->lang['form_memory']; $d['memory']['required'] = true; $d['memory']['object']['type'] = 'htmlobject_select'; $d['memory']['object']['attrib']['name'] = 'memory'; $d['memory']['object']['attrib']['index'] = array(0, 1); $d['memory']['object']['attrib']['options'] = $ram; $d['memory']['object']['attrib']['selected'] = array(512); $vmtype = $this->response->html->request()->get('vmtype'); if ($vmtype === 'kvm-vm-net') { $d['netboot_image']['label'] = $this->lang['form_existing_disk']; $d['netboot_image']['object']['type'] = 'htmlobject_select'; $d['netboot_image']['object']['attrib']['index'] = array(0, 1); $d['netboot_image']['object']['attrib']['id'] = 'netboot_image'; $d['netboot_image']['object']['attrib']['name'] = 'netboot_image'; $d['netboot_image']['object']['attrib']['options'] = $existing_netboot_image_arr; $d['netboot_image']['object']['attrib']['selected'] = array(''); $d['disk_interface'] = ""; $d['localboot_image'] = ""; $d['cdrom_iso_path'] = ""; $d['cdrom_button'] = ""; } else { $d['localboot_image']['label'] = $this->lang['form_existing_disk']; $d['localboot_image']['object']['type'] = 'htmlobject_select'; $d['localboot_image']['object']['attrib']['index'] = array(0, 1); $d['localboot_image']['object']['attrib']['id'] = 'localboot_image'; $d['localboot_image']['object']['attrib']['name'] = 'localboot_image'; $d['localboot_image']['object']['attrib']['options'] = $existing_image_arr; $d['localboot_image']['object']['attrib']['selected'] = array(''); $d['disk_interface']['label'] = $this->lang['form_disk_interface']; $d['disk_interface']['required'] = true; $d['disk_interface']['object']['type'] = 'htmlobject_select'; $d['disk_interface']['object']['attrib']['name'] = 'disk_interface'; $d['disk_interface']['object']['attrib']['id'] = 'disk_interface'; $d['disk_interface']['object']['attrib']['index'] = array(0, 1); $d['disk_interface']['object']['attrib']['options'] = $disk_interfaces; $d['cdrom_iso_path']['label'] = $this->lang['form_cdrom']; $d['cdrom_iso_path']['object']['type'] = 'htmlobject_input'; $d['cdrom_iso_path']['object']['attrib']['type'] = 'text'; $d['cdrom_iso_path']['object']['attrib']['id'] = 'cdrom'; $d['cdrom_iso_path']['object']['attrib']['name'] = 'cdrom'; $d['cdrom_button']['static'] = true; $d['cdrom_button']['object']['type'] = 'htmlobject_input'; $d['cdrom_button']['object']['attrib']['type'] = 'button'; $d['cdrom_button']['object']['attrib']['name'] = 'cdrom_button'; $d['cdrom_button']['object']['attrib']['id'] = 'cdrom_button'; $d['cdrom_button']['object']['attrib']['css'] = 'browse-button'; $d['cdrom_button']['object']['attrib']['handler'] = 'onclick="filepicker.init(\'cdrom\'); return false;"'; $d['cdrom_button']['object']['attrib']['style'] = "display:none;"; $d['cdrom_button']['object']['attrib']['value'] = $this->lang['lang_browse']; $d['netboot_image'] = ""; } $mac = ''; if (isset($this->resource)) { $this->resource->generate_mac(); $mac = $this->resource->mac; } $d['net0']['label'] = $this->lang['lang_net_0']; $d['net0']['object']['type'] = 'htmlobject_input'; $d['net0']['object']['attrib']['type'] = 'checkbox'; $d['net0']['object']['attrib']['id'] = 'net0'; $d['net0']['object']['attrib']['name'] = 'net0'; $d['net0']['object']['attrib']['value'] = 'enabled'; $d['net0']['object']['attrib']['checked'] = true; $d['net0']['object']['attrib']['disabled'] = true; $d['mac']['label'] = $this->lang['form_mac']; $d['mac']['required'] = true; $d['mac']['object']['type'] = 'htmlobject_input'; $d['mac']['object']['attrib']['name'] = 'mac'; $d['mac']['object']['attrib']['type'] = 'text'; $d['mac']['object']['attrib']['value'] = $mac; $d['mac']['object']['attrib']['maxlength'] = 50; $d['bridge']['label'] = $this->lang['form_bridge']; $d['bridge']['required'] = true; $d['bridge']['object']['type'] = 'htmlobject_select'; $d['bridge']['object']['attrib']['name'] = 'bridge'; $d['bridge']['object']['attrib']['index'] = array(0, 1); $d['bridge']['object']['attrib']['options'] = $bridges; $d['nic']['label'] = $this->lang['form_netdevice']; $d['nic']['required'] = true; $d['nic']['object']['type'] = 'htmlobject_select'; $d['nic']['object']['attrib']['name'] = 'nic'; $d['nic']['object']['attrib']['index'] = array(0, 1); $d['nic']['object']['attrib']['options'] = $nics; // net 1 if (isset($this->resource)) { $this->resource->generate_mac(); $mac = $this->resource->mac; } $d['net1']['label'] = $this->lang['lang_net_1']; $d['net1']['object']['type'] = 'htmlobject_input'; $d['net1']['object']['attrib']['type'] = 'checkbox'; $d['net1']['object']['attrib']['id'] = 'net1'; $d['net1']['object']['attrib']['name'] = 'net1'; $d['net1']['object']['attrib']['value'] = 'enabled'; $d['net1']['object']['attrib']['handler'] = 'onchange="nettoggle(this);"'; $d['mac1']['label'] = $this->lang['form_mac']; $d['mac1']['object']['type'] = 'htmlobject_input'; $d['mac1']['object']['attrib']['name'] = 'mac1'; $d['mac1']['object']['attrib']['type'] = 'text'; $d['mac1']['object']['attrib']['value'] = $mac; $d['mac1']['object']['attrib']['maxlength'] = 50; $d['bridge1']['label'] = $this->lang['form_bridge']; $d['bridge1']['object']['type'] = 'htmlobject_select'; $d['bridge1']['object']['attrib']['name'] = 'bridge1'; $d['bridge1']['object']['attrib']['index'] = array(0, 1); $d['bridge1']['object']['attrib']['options'] = $bridges; $d['nic1']['label'] = $this->lang['form_netdevice']; $d['nic1']['object']['type'] = 'htmlobject_select'; $d['nic1']['object']['attrib']['name'] = 'nic1'; $d['nic1']['object']['attrib']['index'] = array(0, 1); $d['nic1']['object']['attrib']['options'] = $nics; // net 2 if (isset($this->resource)) { $this->resource->generate_mac(); $mac = $this->resource->mac; } $d['net2']['label'] = $this->lang['lang_net_2']; $d['net2']['object']['type'] = 'htmlobject_input'; $d['net2']['object']['attrib']['type'] = 'checkbox'; $d['net2']['object']['attrib']['id'] = 'net2'; $d['net2']['object']['attrib']['name'] = 'net2'; $d['net2']['object']['attrib']['value'] = 'enabled'; $d['net2']['object']['attrib']['handler'] = 'onchange="nettoggle(this);"'; $d['mac2']['label'] = $this->lang['form_mac']; $d['mac2']['object']['type'] = 'htmlobject_input'; $d['mac2']['object']['attrib']['name'] = 'mac2'; $d['mac2']['object']['attrib']['type'] = 'text'; $d['mac2']['object']['attrib']['value'] = $mac; $d['mac2']['object']['attrib']['maxlength'] = 50; $d['bridge2']['label'] = $this->lang['form_bridge']; $d['bridge2']['object']['type'] = 'htmlobject_select'; $d['bridge2']['object']['attrib']['name'] = 'bridge2'; $d['bridge2']['object']['attrib']['index'] = array(0, 1); $d['bridge2']['object']['attrib']['options'] = $bridges; $d['nic2']['label'] = $this->lang['form_netdevice']; $d['nic2']['object']['type'] = 'htmlobject_select'; $d['nic2']['object']['attrib']['name'] = 'nic2'; $d['nic2']['object']['attrib']['index'] = array(0, 1); $d['nic2']['object']['attrib']['options'] = $nics; // net 3 if (isset($this->resource)) { $this->resource->generate_mac(); $mac = $this->resource->mac; } $d['net3']['label'] = $this->lang['lang_net_3']; $d['net3']['object']['type'] = 'htmlobject_input'; $d['net3']['object']['attrib']['type'] = 'checkbox'; $d['net3']['object']['attrib']['id'] = 'net3'; $d['net3']['object']['attrib']['name'] = 'net3'; $d['net3']['object']['attrib']['value'] = 'enabled'; $d['net3']['object']['attrib']['handler'] = 'onchange="nettoggle(this);"'; $d['mac3']['label'] = $this->lang['form_mac']; $d['mac3']['object']['type'] = 'htmlobject_input'; $d['mac3']['object']['attrib']['name'] = 'mac3'; $d['mac3']['object']['attrib']['type'] = 'text'; $d['mac3']['object']['attrib']['value'] = $mac; $d['mac3']['object']['attrib']['maxlength'] = 50; $d['bridge3']['label'] = $this->lang['form_bridge']; $d['bridge3']['object']['type'] = 'htmlobject_select'; $d['bridge3']['object']['attrib']['name'] = 'bridge3'; $d['bridge3']['object']['attrib']['index'] = array(0, 1); $d['bridge3']['object']['attrib']['options'] = $bridges; $d['nic3']['label'] = $this->lang['form_netdevice']; $d['nic3']['object']['type'] = 'htmlobject_select'; $d['nic3']['object']['attrib']['name'] = 'nic3'; $d['nic3']['object']['attrib']['index'] = array(0, 1); $d['nic3']['object']['attrib']['options'] = $nics; // net 4 if (isset($this->resource)) { $this->resource->generate_mac(); $mac = $this->resource->mac; } $d['net4']['label'] = $this->lang['lang_net_4']; $d['net4']['object']['type'] = 'htmlobject_input'; $d['net4']['object']['attrib']['type'] = 'checkbox'; $d['net4']['object']['attrib']['name'] = 'net4'; $d['net4']['object']['attrib']['id'] = 'net4'; $d['net4']['object']['attrib']['value'] = 'enabled'; $d['net4']['object']['attrib']['handler'] = 'onchange="nettoggle(this);"'; $d['mac4']['label'] = $this->lang['form_mac']; $d['mac4']['object']['type'] = 'htmlobject_input'; $d['mac4']['object']['attrib']['name'] = 'mac4'; $d['mac4']['object']['attrib']['type'] = 'text'; $d['mac4']['object']['attrib']['value'] = $mac; $d['mac4']['object']['attrib']['maxlength'] = 50; $d['bridge4']['label'] = $this->lang['form_bridge']; $d['bridge4']['object']['type'] = 'htmlobject_select'; $d['bridge4']['object']['attrib']['name'] = 'bridge4'; $d['bridge4']['object']['attrib']['index'] = array(0, 1); $d['bridge4']['object']['attrib']['options'] = $bridges; $d['nic4']['label'] = $this->lang['form_netdevice']; $d['nic4']['object']['type'] = 'htmlobject_select'; $d['nic4']['object']['attrib']['name'] = 'nic4'; $d['nic4']['object']['attrib']['index'] = array(0, 1); $d['nic4']['object']['attrib']['options'] = $nics; // boot from $d['boot_cd'] = ''; $d['boot_iso'] = ''; $d['boot_iso_path'] = ''; $d['boot_local'] = ''; $d['browse_button'] = ''; if ($vmtype !== 'kvm-vm-net') { $d['boot_cd']['label'] = $this->lang['form_boot_cd']; $d['boot_cd']['object']['type'] = 'htmlobject_input'; $d['boot_cd']['object']['attrib']['type'] = 'radio'; $d['boot_cd']['object']['attrib']['name'] = 'boot'; $d['boot_cd']['object']['attrib']['value'] = 'cdrom'; $d['boot_iso']['label'] = $this->lang['form_boot_iso']; $d['boot_iso']['object']['type'] = 'htmlobject_input'; $d['boot_iso']['object']['attrib']['type'] = 'radio'; $d['boot_iso']['object']['attrib']['id'] = 'boot_iso'; $d['boot_iso']['object']['attrib']['name'] = 'boot'; $d['boot_iso']['object']['attrib']['value'] = 'iso'; $d['boot_iso_path']['label'] = $this->lang['form_iso_path']; $d['boot_iso_path']['object']['type'] = 'htmlobject_input'; $d['boot_iso_path']['object']['attrib']['type'] = 'text'; $d['boot_iso_path']['object']['attrib']['id'] = 'iso_path'; $d['boot_iso_path']['object']['attrib']['name'] = 'iso_path'; $d['boot_local']['label'] = $this->lang['form_boot_local']; $d['boot_local']['object']['type'] = 'htmlobject_input'; $d['boot_local']['object']['attrib']['type'] = 'radio'; $d['boot_local']['object']['attrib']['name'] = 'boot'; $d['boot_local']['object']['attrib']['value'] = 'local'; $d['boot_local']['object']['attrib']['checked'] = true; $d['browse_button']['static'] = true; $d['browse_button']['object']['type'] = 'htmlobject_input'; $d['browse_button']['object']['attrib']['type'] = 'button'; $d['browse_button']['object']['attrib']['name'] = 'browse_button'; $d['browse_button']['object']['attrib']['id'] = 'browsebutton'; $d['browse_button']['object']['attrib']['css'] = 'browse-button'; $d['browse_button']['object']['attrib']['handler'] = 'onclick="filepicker.init(\'iso_path\'); return false;"'; $d['browse_button']['object']['attrib']['style'] = "display:none;"; $d['browse_button']['object']['attrib']['value'] = $this->lang['lang_browse']; } $d['boot_net']['label'] = $this->lang['form_boot_net']; $d['boot_net']['object']['type'] = 'htmlobject_input'; $d['boot_net']['object']['attrib']['type'] = 'radio'; $d['boot_net']['object']['attrib']['name'] = 'boot'; $d['boot_net']['object']['attrib']['value'] = 'network'; if ($vmtype === 'kvm-vm-net') { $d['boot_net']['object']['attrib']['checked'] = true; } $d['vnc']['label'] = $this->lang['form_vnc']; $d['vnc']['required'] = true; $d['vnc']['object']['type'] = 'htmlobject_input'; $d['vnc']['object']['attrib']['name'] = 'vnc'; $d['vnc']['object']['attrib']['id'] = 'vnc'; $d['vnc']['object']['attrib']['type'] = 'password'; $d['vnc']['object']['attrib']['value'] = ''; $d['vnc']['object']['attrib']['maxlength'] = 50; $d['vnc_1']['label'] = $this->lang['form_vnc_repeat']; $d['vnc_1']['required'] = true; $d['vnc_1']['object']['type'] = 'htmlobject_input'; $d['vnc_1']['object']['attrib']['name'] = 'vnc_1'; $d['vnc_1']['object']['attrib']['id'] = 'vnc_1'; $d['vnc_1']['object']['attrib']['value'] = ''; $d['vnc_1']['object']['attrib']['type'] = 'password'; $d['vnc_1']['object']['attrib']['maxlength'] = 50; $d['vnc_keymap']['label'] = $this->lang['form_vnc_keymap']; $d['vnc_keymap']['object']['type'] = 'htmlobject_select'; $d['vnc_keymap']['object']['attrib']['name'] = 'vnc_keymap'; $d['vnc_keymap']['object']['attrib']['index'] = array(0, 1); $d['vnc_keymap']['object']['attrib']['options'] = $keymaps; $form->add($d); $response->form = $form; } else { $response->msg = $this->lang['error_no_bridge']; $response->form = $form; } return $response; }