function get_response() { $response = $this->response; $form = $response->get_form($this->actions_name, 'step4'); $resource = new resource(); $resource->get_instance_by_id($this->appliance->resources); // if not openQRM resource if ($resource->id != 0) { $virtualization = new virtualization(); $virtualization->get_instance_by_id($resource->vtype); } $image = new image(); $image->get_instance_by_id($this->appliance->imageid); $deployment = new deployment(); $deployment->get_instance_by_type($image->type); $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'); $kernel = new kernel(); $list = $kernel->get_list(); unset($list[0]); $kernels = array(); if ($resource->id == 0) { $kernels[] = array(0, 'openQRM'); } else { if (strstr($resource->capabilities, "TYPE=local-server")) { $local_kernel = new kernel(); $local_kernel->get_instance_by_name("resource" . $resource->id); $kernels[] = array($local_kernel->id, 'Local OS Installation'); // local-deployment VMs } else { if (strstr($virtualization->type, "-vm-local")) { $kernels[] = array(1, 'Local OS Installation'); // network-deployment - show only network-boot images } else { if (strstr($virtualization->type, "-vm-net")) { foreach ($list as $value) { $id = $value['value']; $kernel->get_instance_by_id($id); if (!strstr($kernel->capabilities, "TYPE=local-server")) { $kernels[] = array($id, $kernel->id . ' / ' . $kernel->name . ' (' . $kernel->version . ')'); } } // network deployment - physical systems - show only network-boot images } else { foreach ($list as $value) { $id = $value['value']; $kernel->get_instance_by_id($id); if (!strstr($kernel->capabilities, "TYPE=local-server")) { $kernels[] = array($id, $kernel->id . ' / ' . $kernel->name . ' (' . $kernel->version . ')'); } } } } } } $d['kernel']['label'] = $this->lang['form_kernel']; $d['kernel']['required'] = true; $d['kernel']['object']['type'] = 'htmlobject_select'; $d['kernel']['object']['attrib']['index'] = array(0, 1); $d['kernel']['object']['attrib']['id'] = 'kernel'; $d['kernel']['object']['attrib']['name'] = 'kernel'; $d['kernel']['object']['attrib']['options'] = $kernels; $form->add($d); $response->form = $form; return $response; }
function KernelGetList($method_parameters) { global $event; $parameter_array = explode(',', $method_parameters); $mode = $parameter_array[0]; $username = $parameter_array[1]; $password = $parameter_array[2]; // check all user input for ($i = 0; $i <= 2; $i++) { if (!$this->check_param($parameter_array[$i])) { $event->log("cloudsoap->KernelGetList", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Not allowing user-intput with special-characters : {$parameter_array[$i]}", "", "", 0, 0, 0); return; } } // check parameter count $parameter_count = count($parameter_array); if ($parameter_count != 3) { $event->log("cloudsoap->KernelGetList", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Wrong parameter count {$parameter_count} ! Exiting.", "", "", 0, 0, 0); return; } // check authentication if (!$this->check_user($mode, $username, $password)) { $event->log("cloudsoap->KernelGetList", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "User authentication failed (mode {$mode})", "", "", 0, 0, 0); return; } $event->log("cloudsoap->KernelGetList", $_SERVER['REQUEST_TIME'], 5, "cloud-soap-server.php", "Providing list of available kernels", "", "", 0, 0, 0); $kernel = new kernel(); $kernel_list = $kernel->get_list(); $kernel_name_list = array(); foreach ($kernel_list as $kernels) { // check cloudselector // ####### start of cloudselector case ####### // if cloudselector is enabled check if products exist $cloudselector = new cloudselector(); $cc_conf = new cloudconfig(); $cloud_selector_enabled = $cc_conf->get_value(22); // cloudselector if (!strcmp($cloud_selector_enabled, "true")) { // kernel $kernel_name = $kernels['label']; $cs_kernel = new kernel(); $cs_kernel->get_instance_by_name($kernel_name); if ($cloudselector->product_exists_enabled("kernel", $cs_kernel->id)) { $kernel_name_list[] = $kernels['label']; } } else { $kernel_name_list[] = $kernels['label']; } } if (strcmp($cloud_selector_enabled, "true")) { // remove openqrm kernel array_splice($kernel_name_list, 0, 1); } return $kernel_name_list; }
$cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0")); $create_default_cloudselector_config = "insert into cloud_selector VALUES (" . $cloud_product_id . ",'network',1,'2',2,'2','2 Network Cards',1);"; $recordSet = $db->Execute($create_default_cloudselector_config); $cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0")); $create_default_cloudselector_config = "insert into cloud_selector VALUES (" . $cloud_product_id . ",'network',2,'3',3,'3','3 Network Cards',1);"; $recordSet = $db->Execute($create_default_cloudselector_config); $cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0")); $create_default_cloudselector_config = "insert into cloud_selector VALUES (" . $cloud_product_id . ",'network',3,'4',4,'4','4 Network Cards',1);"; $recordSet = $db->Execute($create_default_cloudselector_config); $cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0")); $create_default_cloudselector_config = "insert into cloud_selector VALUES (" . $cloud_product_id . ",'quantity',0,'1',1,'1','1 CloudAppliance',1);"; $recordSet = $db->Execute($create_default_cloudselector_config); // create kernel products $next_sort_id = 0; $kernel = new kernel(); $kernel_id_ar = $kernel->get_list(); unset($kernel_id_ar[0]); foreach ($kernel_id_ar as $key => $value) { $id = $value['value']; $kernel->get_instance_by_id($id); $pos = strpos($kernel->name, 'resource'); if ($pos === false) { $cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0")); $create_kernel_cloudselector_config = "insert into cloud_selector (id, type, sort_id, quantity, price, name, description, state) VALUES (" . $cloud_product_id . ", 'kernel', " . $next_sort_id . ", '" . $kernel->id . "', 1, '" . $kernel->name . "', '" . $kernel->version . "', 1);"; $recordSet = $db->Execute($create_kernel_cloudselector_config); $next_sort_id++; } } // create default projects $cloud_hook_config = array(); $cloud_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));