function action() { $msg = ''; $event = new event(); $server = new openqrm_server(); $plugin = new plugin(); $identifier = $this->response->html->request()->get($this->identifier_name); $enabled = $plugin->enabled(); if ($identifier !== '') { foreach ($identifier as $id) { if (in_array($id, $enabled)) { $return = $server->send_command("openqrm_server_plugin_command {$id} start"); if ($return === true) { if ($this->__check($id)) { $msg .= sprintf($this->lang['msg'], $id) . '<br>'; } else { $msg .= sprintf($this->lang['error_timeout'], $id) . '<br>'; } } else { $msg .= sprintf($this->lang['error_start'], $id) . '<br>'; } } } } $this->response->redirect($this->response->get_url($this->actions_name, 'select', $this->message_param, $msg)); }
function action() { $msg = ''; $event = new event(); $server = new openqrm_server(); $plugin = new plugin(); $identifier = $this->response->html->request()->get($this->identifier_name); $enabled = $plugin->enabled(); if ($identifier !== '') { foreach ($identifier as $id) { if (in_array($id, $enabled)) { $error = false; // check dependencies foreach ($enabled as $v) { if ($v !== $id) { $tmp = $plugin->get_dependencies($v); if ($tmp !== '' && isset($tmp['dependencies']) && $tmp['dependencies'] !== '') { if (strpos($tmp['dependencies'], $id) !== false) { $msg .= sprintf($this->lang['error_dependencies'], $id, $v) . '<br>'; $error = true; } } } } // handle plugin type if ($error === false) { $tmp = $plugin->get_config($id); switch ($tmp['type']) { case 'storage': $storage = new storage(); $types = $storage->get_storage_types(); $deployment = new deployment(); $dep = $deployment->get_id_by_storagetype($id); foreach ($dep as $val) { if (in_array($val['value'], $types)) { $msg .= sprintf($this->lang['error_in_use'], $id) . '<br>'; $error = true; } } break; } } if ($error === false) { $return = $server->send_command("openqrm_server_plugin_command " . $id . " uninstall " . $GLOBALS['OPENQRM_ADMIN']->name . ' ' . $GLOBALS['OPENQRM_ADMIN']->password); if ($return === true) { if ($this->__check($id)) { $msg .= sprintf($this->lang['msg'], $id) . '<br>'; } else { $msg .= sprintf($this->lang['error_timeout'], $id) . '<br>'; } } else { $msg .= sprintf($this->lang['error_disable'], $id) . '<br>'; } } } } } $this->response->redirect($this->response->get_url($this->actions_name, 'select', $this->message_param, $msg)); }
function get_application_list() { $application_list = array(); $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { $plugin_cloud_application_hook = $this->webdir . "/plugins/" . $plugin_name . "/openqrm-" . $plugin_name . "-cloud-application-hook.php"; if (file_exists($plugin_cloud_application_hook)) { $this->event->log("get_application_list", $_SERVER['REQUEST_TIME'], 5, "cloudapplication.class.php", "Found plugin " . $plugin_name . " providing a Cloud-application hook.", "", "", 0, 0, 0); require_once $plugin_cloud_application_hook; $application_function = "openqrm_" . "{$plugin_name}" . "_get_cloud_applications"; $application_function = str_replace("-", "_", $application_function); $application_array = $application_function(); foreach ($application_array as $index => $app) { $application_list[] .= $app; } } } return $application_list; }
$appliance_fields["appliance_cpumodel"] = $app_resource_remove_check->cpumodel; $appliance_fields["appliance_memtotal"] = $app_resource_remove_check->memtotal; $appliance_fields["appliance_swaptotal"] = $app_resource_remove_check->swaptotal; $appliance_fields["appliance_nics"] = $app_resource_remove_check->nics; $appliance_fields["appliance_capabilities"] = $app_resource_remove_check->capabilities; $appliance_fields["appliance_cluster"] = $app_resource_remove_check->cluster; $appliance_fields["appliance_ssi"] = $app_resource_remove_check->ssi; $appliance_fields["appliance_resources"] = $app_resource_remove_check->resources; $appliance_fields["appliance_highavailable"] = $app_resource_remove_check->highavailable; $appliance_fields["appliance_virtual"] = $app_resource_remove_check->virtual; $appliance_fields["appliance_virtualization"] = $app_resource_remove_check->virtualization; $appliance_fields["appliance_virtualization_host"] = $app_resource_remove_check->virtualization_host; $appliance_fields["appliance_comment"] = $app_resource_remove_check->comment; $appliance_fields["appliance_event"] = $app_resource_remove_check->event; $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { $plugin_start_appliance_hook = "{$RootDir}/plugins/{$plugin_name}/openqrm-{$plugin_name}-appliance-hook.php"; if (file_exists($plugin_start_appliance_hook)) { $event->log("remove", $_SERVER['REQUEST_TIME'], 5, "local-server-action", "Found plugin {$plugin_name} handling add-appliance event.", "", "", 0, 0, $app_resource_remove_check->resources); require_once "{$plugin_start_appliance_hook}"; $appliance_function = "openqrm_" . "{$plugin_name}" . "_appliance"; $appliance_function = str_replace("-", "_", $appliance_function); // stop $appliance_function("stop", $appliance_fields); // remove $appliance_function("remove", $appliance_fields); } } // remove appliance $appliance->remove($appliance_id);
function edit() { $resource_icon_default = "/img/resource.png"; $storage_icon = "/plugins/kvm/img/plugin.png"; //$state_icon = $this->openqrm->get('baseurl')."/img/".$this->resource->state.".png"; if ($this->file->exists($this->openqrm->get('webdir') . $storage_icon)) { $resource_icon_default = $storage_icon; } $resource_icon_default = $this->openqrm->get('baseurl') . $resource_icon_default; // check if we have a plugin implementing the remote console $remote_console = false; $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { //$plugin_remote_console_running = $this->openqrm->get('webdir')."/plugins/".$plugin_name."/.running"; $plugin_remote_console_hook = $this->openqrm->get('webdir') . "/plugins/" . $plugin_name . "/openqrm-" . $plugin_name . "-remote-console-hook.php"; if ($this->file->exists($plugin_remote_console_hook)) { require_once "{$plugin_remote_console_hook}"; $link_function = str_replace("-", "_", "openqrm_" . "{$plugin_name}" . "_remote_console"); if (function_exists($link_function)) { $remote_functions[] = $link_function; $remote_console = true; } } } // prepare list of all Host resource id for the migration select // we need a select with the ids/ips from all resources which // are used by appliances with kvm capabilities $kvm_hosts = array(); $appliance_list = new appliance(); $appliance_list_array = $appliance_list->get_list(); foreach ($appliance_list_array as $index => $app) { $appliance_kvm_host_check = new appliance(); $appliance_kvm_host_check->get_instance_by_id($app["value"]); // only active appliances if (!strcmp($appliance_kvm_host_check->state, "active") || $appliance_kvm_host_check->resources == 0) { $virtualization = new virtualization(); $virtualization->get_instance_by_id($appliance_kvm_host_check->virtualization); if (!strcmp($virtualization->type, "kvm") && !strstr($virtualization->type, "kvm-vm")) { $kvm_host_resource = new resource(); $kvm_host_resource->get_instance_by_id($appliance_kvm_host_check->resources); // exclude source host #if ($kvm_host_resource->id == $this->resource->id) { # continue; #} // only active appliances if (!strcmp($kvm_host_resource->state, "active")) { $migration_select_label = "Res. " . $kvm_host_resource->id . "/" . $kvm_host_resource->ip; $kvm_hosts[] = array("value" => $kvm_host_resource->id, "label" => $migration_select_label); } } } } $d['state'] = '<span class="pill ' . $this->resource->state . '">' . $this->resource->state . '</span>'; $d['resource'] = $this->resource->id . ' / ' . $this->resource->ip; $d['name'] = $this->appliance->name; $d['id'] = $this->appliance->id; $a = $this->response->html->a(); $a->label = $this->lang['action_add_local_vm']; $a->css = 'add'; $a->handler = 'onclick="wait();"'; $a->href = $this->response->get_url($this->actions_name, "add") . '&vmtype=kvm-vm-local'; $d['add_local_vm'] = $a->get_string(); $a = $this->response->html->a(); $a->label = $this->lang['action_add_network_vm']; $a->css = 'add'; $a->handler = 'onclick="wait();"'; $a->href = $this->response->get_url($this->actions_name, "add") . '&vmtype=kvm-vm-net'; $d['add_network_vm'] = $a->get_string(); $body = array(); $identifier_disabled = array(); $file = $this->statfile; if ($this->file->exists($file)) { $lines = explode("\n", $this->file->get_contents($file)); if (count($lines) >= 1) { $i = 0; foreach ($lines as $line) { if ($line !== '') { $line = explode('@', $line); $state = $line[0]; $name = $line[1]; $mac = $line[2]; $resource = new resource(); $resource->get_instance_by_mac($mac); if ($resource->vhostid != $this->resource->id) { continue; } $res_virtualization = new virtualization(); $res_virtualization->get_instance_by_id($resource->vtype); $update = ''; $a = $this->response->html->a(); $a->title = $this->lang['action_update']; $a->label = $this->lang['action_update']; $a->handler = 'onclick="wait();"'; $a->css = 'edit'; $a->href = $this->response->get_url($this->actions_name, "update") . '&vm=' . $name . '&vmtype=' . $res_virtualization->type; $update_link = $a->get_string(); $clone = ''; $a = $this->response->html->a(); $a->title = $this->lang['action_clone']; $a->label = $this->lang['action_clone']; $a->handler = 'onclick="wait();"'; $a->css = 'clone'; $a->href = $this->response->get_url($this->actions_name, "clone") . '&vm=' . $name . '&mac=' . $mac; $clone_link = $a->get_string(); if ($res_virtualization->type == 'kvm-vm-local') { if ($state === '0' && $resource->image === 'idle') { $update = $update_link; $clone = $clone_link; } } if ($res_virtualization->type == 'kvm-vm-net') { if ($state !== '2' && $resource->image === 'idle') { $update = $update_link; $clone = $clone_link; } } $migrate = ''; $a = $this->response->html->a(); $a->title = $this->lang['action_migrate']; $a->label = $this->lang['action_migrate']; $a->handler = 'onclick="wait();"'; $a->css = 'migrate'; $a->href = $this->response->get_url($this->actions_name, "migrate") . '&vm=' . $name . '&mac=' . $mac; if (count($kvm_hosts) >= 1 && $state === '1') { $migrate = $a->get_string(); } $data = '<b>' . $this->lang['table_id'] . '</b>: ' . $resource->id . '<br>'; $data .= '<b>' . $this->lang['table_name'] . '</b>: ' . $name . '<br>'; $data .= '<b>' . $this->lang['table_type'] . '</b>: ' . $res_virtualization->name . '<br>'; $data .= '<b>' . $this->lang['table_ip'] . '</b>: ' . $resource->ip . '<br>'; $data .= '<b>' . $this->lang['table_mac'] . '</b>: ' . $mac . '<br>'; $data .= '<b>' . $this->lang['table_vnc'] . '</b>: ' . $line[5] . '<br>'; $data .= '<b>' . $this->lang['table_cpu'] . '</b>: ' . $line[3] . '<br>'; $data .= '<b>' . $this->lang['table_ram'] . '</b>: ' . $line[4] . '<br>'; $data .= '<b>' . $this->lang['table_nics'] . '</b>: ' . $resource->nics; $appliance = new appliance(); $appliance->get_instance_by_virtualization_and_resource($resource->vtype, $resource->id); $server = array(); $server[0] = ''; $server[1] = '1000000000000000000000000'; if ($appliance->id !== '') { $kernel = new kernel(); $kernel->get_instance_by_id($appliance->kernelid); $image = new image(); $image->get_instance_by_id($appliance->imageid); $storage = new storage(); $storage->get_instance_by_id($image->storageid); $s = '<b>' . $this->lang['table_appliance'] . '</b>: ' . $appliance->id . '<br>'; $s .= '<b>' . $this->lang['table_name'] . '</b>: ' . $appliance->name . '<br>'; $s .= '<b>' . $this->lang['table_kernel'] . '</b>: ' . $kernel->name . '<br>'; $s .= '<b>' . $this->lang['table_image'] . '</b>: ' . $image->name . '<br>'; $s .= '<b>' . $this->lang['table_storage'] . '</b>: ' . $storage->name . '<br>'; $server[0] = $s; $server[1] = $appliance->id; } $console = ''; if ($state === '2') { $t = $this->response->html->template($this->openqrm->get('webdir') . '/js/openqrm-progressbar.js'); $identifier_disabled[] = $name; // progressbar $t->add(uniqid('b'), 'id'); $t->add($this->openqrm->get('baseurl') . '/api.php?action=plugin&plugin=kvm&controller=kvm-vm&kvm_vm_action=progress&name=' . $name . '.vm_migration_progress', 'url'); $t->add($this->lang['action_migrate_in_progress'], 'lang_in_progress'); $t->add($this->lang['action_migrate_finished'], 'lang_finished'); $console = $t->get_string(); } else { if ($remote_console === true && $resource->imageid !== 1 && $state === '1') { foreach ($remote_functions as $function) { $a = $function($resource->id); if (is_object($a)) { $console .= $a->get_string(); } } } } $state = array(); $state[0] = '<span class="pill idle">idle</span>'; $state[1] = 'i'; if ($line[0] === '1' && $resource->image !== 'idle') { $state[0] = '<span class="pill active">active</span>'; $state[1] = 'a'; } if ($res_virtualization->type == 'kvm-vm-net' && $line[0] === '0') { $state[0] = '<span class="pill off">off</span>'; $state[1] = 'o'; } $action = ''; if (!in_array($name, $identifier_disabled)) { $action = $update . $clone . $migrate; } $body[$i] = array('state' => $state[0], 'state_s' => $state[1], 'name' => $name, 'id' => $resource->id, 'mac' => $mac, 'cpu' => $line[3], 'ram' => $line[4], 'ip' => $resource->ip, 'vnc' => $line[5], 'data' => $data, 'appliance' => $server[0], 'appliance_s' => $server[1], 'plugins' => $console, 'action' => $action); } $i++; } } } $h['state']['title'] = $this->lang['table_state']; $h['state']['sortable'] = false; $h['state_s']['title'] = $this->lang['table_state']; $h['state_s']['sortable'] = true; $h['state_s']['hidden'] = true; $h['id']['title'] = $this->lang['table_id']; $h['id']['hidden'] = true; $h['name']['title'] = $this->lang['table_name']; $h['name']['hidden'] = true; $h['ip']['title'] = $this->lang['table_ip']; $h['ip']['hidden'] = true; $h['mac']['title'] = $this->lang['table_mac']; $h['mac']['hidden'] = true; $h['vnc']['title'] = $this->lang['table_vnc']; $h['vnc']['hidden'] = true; $h['cpu']['title'] = $this->lang['table_cpu']; $h['cpu']['hidden'] = true; $h['ram']['title'] = $this->lang['table_ram']; $h['ram']['hidden'] = true; $h['nics']['title'] = $this->lang['table_nics']; $h['nics']['hidden'] = true; $h['data']['title'] = ' '; $h['data']['sortable'] = false; $h['appliance']['title'] = ' '; $h['appliance']['sortable'] = false; $h['appliance_s']['title'] = $this->lang['table_appliance']; $h['appliance_s']['sortable'] = true; $h['appliance_s']['hidden'] = true; $h['plugins']['title'] = ' '; $h['plugins']['sortable'] = false; $h['action']['title'] = ' '; $h['action']['sortable'] = false; $table = $this->response->html->tablebuilder('kvm_vm_edit', $this->response->get_array($this->actions_name, 'edit')); $table->sort = 'name'; $table->limit = 10; $table->offset = 0; $table->order = 'ASC'; $table->max = count($body); $table->autosort = true; $table->sort_link = false; $table->id = 'Tabelle'; $table->css = 'htmlobject_table'; $table->border = 1; $table->cellspacing = 0; $table->cellpadding = 3; $table->form_action = $this->response->html->thisfile; $table->head = $h; $table->body = $body; $table->identifier = 'name'; $table->identifier_name = $this->identifier_name; $table->identifier_disabled = $identifier_disabled; $table->actions_name = $this->actions_name; $table->actions = array(array('start' => $this->lang['action_start']), array('stop' => $this->lang['action_stop']), array('reboot' => $this->lang['action_reboot']), array('remove' => $this->lang['action_remove'])); $d['table'] = $table->get_string(); return $d; }
function trigger_event_hook($action, $id) { // add event hook for plugins $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { $plugin_event_hook = $this->RootDir . "/plugins/" . $plugin_name . "/openqrm-" . $plugin_name . "-event-hook.php"; if (file_exists($plugin_event_hook)) { require_once "{$plugin_event_hook}"; $event_hook_function = "openqrm_" . "{$plugin_name}" . "_event"; $event_hook_function = str_replace("-", "_", $event_hook_function); $event_hook_function($action, $id); } } }
function stop() { $response = ''; $vms = $this->response->html->request()->get($this->identifier_name); if ($vms !== '') { $appliance_id = $this->response->html->request()->get('appliance_id'); $appliance = new appliance(); $resource = new resource(); $errors = array(); $message = array(); foreach ($vms as $key => $vm) { $appliance->get_instance_by_id($appliance_id); $resource->get_instance_by_id($appliance->resources); $file = $this->openqrm->get('basedir') . '/plugins/kvm/web/kvm-stat/' . $resource->id . '.vm_list'; $command = $this->openqrm->get('basedir') . '/plugins/kvm/bin/openqrm-kvm-vm stop -n ' . $vm; $command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password; $command .= ' --openqrm-ui-user ' . $this->user->name; $command .= ' --openqrm-cmd-mode background'; $resource->send_command($resource->ip, $command); $message[] = sprintf($this->lang['msg_stoped'], $vm); $file = $this->openqrm->get('basedir') . '/plugins/kvm/web/kvm-stat/' . $resource->id . '.vm_list'; if ($this->file->exists($file)) { $lines = explode("\n", $this->file->get_contents($file)); foreach ($lines as $line) { if ($line !== '') { $line = explode('@', $line); if ($line[1] === $vm) { $tmp = explode(':', $line[5]); $server = $tmp[0]; $port = $tmp[1]; $mac = $line[2]; $resource->get_instance_by_mac($mac); $rid = $resource->id; } } $event = new event(); $plugin = new plugin(); $enabled = $plugin->enabled(); foreach ($enabled as $index => $name) { $running = $this->openqrm->get('webdir') . '/plugins/' . $name . '/.running'; $hook = $this->openqrm->get('webdir') . '/plugins/' . $name . '/openqrm-' . $name . '-remote-console-hook.php'; if (file_exists($hook)) { if (file_exists($running)) { $event->log("console", $_SERVER['REQUEST_TIME'], 5, "kvm-vm.console.class.php", 'Found plugin ' . $name . ' providing a remote console.', "", "", 0, 0, $resource->id); require_once $hook; $console_function = 'openqrm_' . $name . '_disable_remote_console'; $console_function = str_replace("-", "_", $console_function); $console_function($server, $port, $rid, $mac, $vm); } } } } } } if (count($errors) === 0) { $response = join('<br>', $message); } else { $msg = array_merge($errors, $message); $response = join('<br>', $msg); } } else { $response = ''; } return $response; }
function select() { $icon_started = $this->lang['action_stop']; $icon_stopped = $this->lang['action_start']; $icon_enabled = $this->lang['action_disable']; $icon_disabled = $this->lang['action_enable']; $plugin = new plugin(); $plugins_available = $plugin->available(); $plugins_enabled = $plugin->enabled(); $plugins_started = $plugin->started(); $h = array(); $h['name']['title'] = $this->lang['table_name']; $h['type']['title'] = ' '; $h['type']['sortable'] = ' '; $h['type_n']['title'] = $this->lang['table_type']; $h['type_n']['hidden'] = true; $h['description']['title'] = $this->lang['table_description']; $h['description']['sortable'] = false; $h['configure']['title'] = " "; $h['configure']['sortable'] = false; $h['enabled']['title'] = " "; $h['enabled']['sortable'] = false; $h['enabled_n']['title'] = $this->lang['table_enabled']; $h['enabled_n']['hidden'] = true; $h['started']['title'] = " "; $h['started']['sortable'] = false; $h['started_n']['title'] = $this->lang['table_started']; $h['started_n']['hidden'] = true; $table = $this->response->html->tablebuilder('plugins', $this->response->get_array($this->actions_name, 'select')); $table->max = count($plugins_available); $table->sort = 'name'; $table->limit = 0; $table->order = 'ASC'; $table->init(); $tps = $table->get_params(); $tp = ''; foreach ($tps['plugins'] as $k => $v) { $tp .= '&plugins[' . $k . ']=' . $v; } $RootDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/'; $thisfile = $this->response->html->thisfile; $b = array(); $plugtype = array(); $i = 0; $openqrm_version = $this->openqrm->get('config', 'SERVER_VERSION'); foreach ($plugins_available as $index => $plugin_name) { $tmp = $plugin->get_config($plugin_name); $plugin_description = $tmp['description']; $plugin_type = $tmp['type']; $plugtype[] = $plugin_type; $plugin_version = $tmp['version']; $plugin_major = substr($plugin_version, 0, strpos($plugin_version, '.')); $plugin_minor = substr($plugin_version, strpos($plugin_version, '.') + 1); $plugin_minor = substr($plugin_minor, 0, strpos($plugin_minor, '.')); $plugin_base_version = $plugin_major . "." . $plugin_minor; if (!strlen($this->response->html->request()->get('plugin_filter')) || strstr($this->response->html->request()->get('plugin_filter'), $plugin_type)) { // $b[$i] = array(); // plugin version mismatch if ($openqrm_version != $plugin_base_version) { $b[$i]['name'] = $plugin_name; $b[$i]['type'] = '<span class="pill ' . strtolower($plugin_type) . '">' . $plugin_type . '</span>'; $b[$i]['type_n'] = $plugin_type; $b[$i]['description'] = $plugin_description; $b[$i]['enabled'] = $this->lang['version_mismatch']; $b[$i]['enabled_n'] = 'b'; $b[$i]['started'] = ' '; $b[$i]['started_n'] = 'c'; $b[$i]['configure'] = ''; } else { // plugin not enabled! if (!in_array($plugin_name, $plugins_enabled)) { $a = $this->response->html->a(); $a->label = $icon_disabled; $a->href = $this->response->get_url($this->actions_name, "enable"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; // anchor $a->name = $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = 'enable'; $a->title = sprintf($this->lang['title_enable'], $plugin_name); $b[$i]['name'] = $plugin_name; $b[$i]['type'] = '<span class="pill ' . strtolower($plugin_type) . '">' . $plugin_type . '</span>'; $b[$i]['type_n'] = $plugin_type; $b[$i]['description'] = $plugin_description; $b[$i]['enabled'] = $a->get_string(); $b[$i]['enabled_n'] = 'b'; $b[$i]['started'] = ' '; $b[$i]['started_n'] = 'c'; } else { $plugin_icon_path = "{$RootDir}/plugins/{$plugin_name}/img/plugin.png"; $plugin_icon = "/openqrm/base/plugins/{$plugin_name}/img/plugin.png"; $plugin_icon_default = "/openqrm/base/plugins/aa_plugins/img/plugin.png"; if ($this->file->exists($plugin_icon_path)) { $plugin_icon_default = $plugin_icon; } $a = $this->response->html->a(); $a->label = $icon_enabled; $a->href = $this->response->get_url($this->actions_name, "disable"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; // anchor $a->name = $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = !in_array($plugin_name, $plugins_started) ? 'disable' : 'disable disabled'; $a->title = sprintf($this->lang['title_disable'], $plugin_name); $b[$i]['name'] = $plugin_name; $b[$i]['type'] = '<span class="pill ' . strtolower($plugin_type) . '">' . $plugin_type . '</span>'; $b[$i]['type_n'] = $plugin_type; $b[$i]['description'] = $plugin_description; $b[$i]['enabled'] = $a->get_string(); $b[$i]['enabled_n'] = 'a'; // started ? if (!in_array($plugin_name, $plugins_started)) { $a = $this->response->html->a(); $a->label = $icon_stopped; $a->href = $this->response->get_url($this->actions_name, "start"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = 'start'; $a->title = sprintf($this->lang['title_start'], $plugin_name); $b[$i]['started'] = $a->get_string(); $b[$i]['started_n'] = 'b'; } else { $a = $this->response->html->a(); $a->label = $icon_started; $a->href = $this->response->get_url($this->actions_name, "stop"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = 'stop'; $a->title = sprintf($this->lang['title_stop'], $plugin_name); $b[$i]['started'] = $a->get_string(); $b[$i]['started_n'] = 'a'; } } // configure button $b[$i]['configure'] = ''; if (isset($tmp['configurable'])) { $a = $this->response->html->a(); $a->label = $this->lang['action_configure']; $a->href = $this->response->get_url($this->actions_name, "configure"); $a->href .= '&' . $this->identifier_name . '=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->handler = 'onclick="wait();"'; $a->css = 'manage'; $a->title = sprintf($this->lang['title_configure'], $plugin_name); $b[$i]['configure'] = $a->get_string(); } } $i++; } } $plugs = array(); $plugs[] = array('', ''); $plugtype = array_unique($plugtype); natcasesort($plugtype); foreach ($plugtype as $p) { $plugs[] = array($p, ucfirst($p)); } $select = $this->response->html->select(); $select->add($plugs, array(0, 1)); $select->name = 'plugin_filter'; $select->handler = 'onchange="wait();this.form.submit();return false;"'; $select->selected = array($this->response->html->request()->get('plugin_filter')); $box = $this->response->html->box(); $box->add($select); $box->id = 'plugins_filter'; $box->css = 'htmlobject_box'; $box->label = $this->lang['lang_filter']; $table->id = 'Tabelle'; $table->tr_handler = array(); $table->css = 'htmlobject_table'; $table->border = 1; $table->cellspacing = 0; $table->cellpadding = 3; $table->autosort = true; $table->sort_link = false; $table->add_headrow($box->get_string()); $table->head = $h; $table->body = $b; $table->max = count($b); $table->form_action = $this->response->html->thisfile; /* $table->actions_name = $this->actions_name; $table->actions = array( array('enable' => $this->lang['action_enable']), array('disable' => $this->lang['action_disable']), array('start' => $this->lang['action_start']), array('stop' => $this->lang['action_stop']) ); $table->identifier = 'name'; $table->identifier_name = $this->identifier_name; */ return $table; }
function check_permission($object = null, $bool = false) { $controller = get_class($object); $action = $this->response->html->request()->get($object->actions_name); $user = $this->openqrm->user(); if (is_array($action)) { $action = key($action); } if (!$user->isAdmin() && $controller !== 'datacenter_controller' && $controller !== 'user_controller' && $controller !== 'documentation_controller' && strripos($controller, 'about') === false && substr($action, 0, 4) !== 'load') { // check for plugin implementing the role hook $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { $plugin_role_hook = $this->openqrm->get('webdir') . "/plugins/" . $plugin_name . "/openqrm-" . $plugin_name . "-role-hook.class.php"; if (file_exists($plugin_role_hook)) { require_once $plugin_role_hook; $plugin_role_hook_class = "openqrm-" . $plugin_name . "-role-hook"; $plugin_role_hook_class = str_replace("-", "_", $plugin_role_hook_class); $plugin_role_hook_method = $plugin_name . "-check_permission"; $plugin_role_hook_method = str_replace("-", "_", $plugin_role_hook_method); $plugin_role_hook = new $plugin_role_hook_class($this->openqrm, $object); return $plugin_role_hook->{$plugin_role_hook_method}($bool); } } // no plugin implemented the role hook, go on with basic role permission check // is_not_admin -> tab menu with global error permission msg $response = $object->response; $html = $response->html; // handle empty action if ($action === '') { // try select as first action if (method_exists($object, 'select')) { $action = 'select'; } else { // pick first method as action $m = get_class_methods($object); foreach ($m as $a) { if (!in_array($a, array('api', 'action')) && strpos($a, '__') === false && strripos($a, 'reload') === false) { $action = $a; break; } } } } if ($bool === true) { return false; } else { $controller = str_replace('_controller', '', get_class($object)); $controller = str_replace('aa_', '', $controller); $t = $html->template($this->openqrm->get('webdir') . '/tpl/permission_denied.tpl.php'); $t->add($action, 'action'); $t->add($controller, 'controller'); $t->add($this->openqrm->get('baseurl'), 'baseurl'); $content['label'] = 'Permissions'; $content['value'] = $t; $content['target'] = $html->thisfile; $content['request'] = $response->get_array($object->actions_name, ''); $content['onclick'] = false; $content['active'] = true; $tab = $html->tabmenu('permissions'); $tab->css = 'htmlobject_tabs'; $tab->add(array($content)); return $tab; } } else { if ($bool === true) { return true; } else { return $object->action(); } } }
function check_all_states() { global $RESOURCE_INFO_TABLE; global $RESOURCE_TIME_OUT; global $RootDir; global $event; $resource_list = array(); $db = openqrm_get_db_connection(); $rs = $db->Execute("select resource_id, resource_lastgood, resource_state from {$RESOURCE_INFO_TABLE}"); if (!$rs) { $event->log("check_all_states", $_SERVER['REQUEST_TIME'], 2, "resource.class.php", $db->ErrorMsg(), "", "", 0, 0, 0); } else { while (!$rs->EOF) { $resource_id = $rs->fields['resource_id']; $resource_lastgood = $rs->fields['resource_lastgood']; $resource_state = $rs->fields['resource_state']; $check_time = $_SERVER['REQUEST_TIME']; // get the HA-timeout per resource from the capabilites $custom_resource_ha_timeout = ""; $resource_hat = new resource(); $resource_hat->get_instance_by_id($resource_id); $custom_resource_ha_timeout = $resource_hat->get_resource_capabilities("HAT"); if (strlen($custom_resource_ha_timeout)) { $RESOURCE_TIME_OUT = $custom_resource_ha_timeout; } // resolve errors for all active resources if ("{$resource_state}" == "active" && $resource_id != 0) { if ($check_time - $resource_lastgood < $RESOURCE_TIME_OUT) { // resolve error event $event->resolve_by_resource("check_all_states", $resource_id); } } // check for statistics (errors) for all resources which are not offline // exclude manual added resources from the check ! if ("{$resource_state}" != "off" && "{$resource_lastgood}" != "-1") { if ($check_time - $resource_lastgood > $RESOURCE_TIME_OUT) { $resource_fields = array(); $resource_fields["resource_state"] = "error"; $resource_error = new resource(); $resource_error->update_info($resource_id, $resource_fields); // log error event $event->log("check_all_states", $_SERVER['REQUEST_TIME'], 1, "resource.class.php", "Resource {$resource_id} is in error state", "", "", 0, 0, $resource_id); // check for plugin which may want to handle the error event $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { $plugin_ha_hook = "{$RootDir}/plugins/{$plugin_name}/openqrm-{$plugin_name}-ha-hook.php"; if (file_exists($plugin_ha_hook)) { $event->log("check_all_states", $_SERVER['REQUEST_TIME'], 1, "resource.class.php", "Found {$plugin_name} handling the resource error.", "", "", 0, 0, $resource_id); require_once "{$plugin_ha_hook}"; $ha_function = "openqrm_" . "{$plugin_name}" . "_ha_hook"; $ha_function = str_replace("-", "_", $ha_function); $ha_function($resource_id); } } } } $rs->MoveNext(); } } }
function stop() { global $event; global $RootDir; $resource = new resource(); $resource->get_instance_by_id($this->resources); $resource->assign($resource->id, "1", "default", "1", "idle"); // update stoptime + state $now = $_SERVER['REQUEST_TIME']; $appliance_fields = array(); $appliance_fields['appliance_stoptime'] = $now; $appliance_fields['appliance_state'] = 'stopped'; $this->update($this->id, $appliance_fields); // update resource state to transition $resource_fields = array(); $resource_fields["resource_state"] = "transition"; $resource_fields["resource_event"] = "reboot"; $resource->update_info($resource->id, $resource_fields); // stop appliance hook // fill in the rest of the appliance info in the array for the plugin hook $appliance_fields["appliance_id"] = $this->id; $appliance_fields["appliance_name"] = $this->name; $appliance_fields["appliance_kernelid"] = $this->kernelid; $appliance_fields["appliance_imageid"] = $this->imageid; $appliance_fields["appliance_cpunumber"] = $this->cpunumber; $appliance_fields["appliance_cpuspeed"] = $this->cpuspeed; $appliance_fields["appliance_cpumodel"] = $this->cpumodel; $appliance_fields["appliance_memtotal"] = $this->memtotal; $appliance_fields["appliance_swaptotal"] = $this->swaptotal; $appliance_fields["appliance_nics"] = $this->nics; $appliance_fields["appliance_capabilities"] = $this->capabilities; $appliance_fields["appliance_cluster"] = $this->cluster; $appliance_fields["appliance_ssi"] = $this->ssi; $appliance_fields["appliance_resources"] = $this->resources; $appliance_fields["appliance_highavailable"] = $this->highavailable; $appliance_fields["appliance_virtual"] = $this->virtual; $appliance_fields["appliance_virtualization"] = $this->virtualization; $appliance_fields["appliance_virtualization_host"] = $this->virtualization_host; $appliance_fields["appliance_comment"] = $this->comment; $appliance_fields["appliance_wizard"] = $this->wizard; $appliance_fields["appliance_event"] = $this->event; // stop the hook $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { $plugin_stop_appliance_hook = "{$RootDir}/plugins/{$plugin_name}/openqrm-{$plugin_name}-appliance-hook.php"; if (file_exists($plugin_stop_appliance_hook)) { $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "appliance.class.php", "Found plugin {$plugin_name} handling stop-appliance event.", "", "", 0, 0, $this->resources); require_once "{$plugin_stop_appliance_hook}"; $appliance_function = "openqrm_" . "{$plugin_name}" . "_appliance"; $appliance_function = str_replace("-", "_", $appliance_function); $appliance_function("stop", $appliance_fields); } } // delay a bit to make sure all appliance hooks have been executed or at least arrived in the queue sleep(2); $resource->send_command("{$resource->ip}", "reboot"); // storage authentication hook $image = new image(); $image->get_instance_by_id($this->imageid); $deployment = new deployment(); $deployment->get_instance_by_type($image->type); $deployment_type = $deployment->type; $deployment_plugin_name = $deployment->storagetype; $storage_auth_hook = "{$RootDir}/plugins/{$deployment_plugin_name}/openqrm-{$deployment_type}-auth-hook.php"; if (file_exists($storage_auth_hook)) { $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "appliance.class.php", "Found deployment type {$deployment_type} handling the stop auth hook.", "", "", 0, 0, $this->resources); require_once "{$storage_auth_hook}"; storage_auth_function("stop", $this->id); } // set image to deactive $image->set_active(0); }
function remove() { $response = $this->get_response(); $vms = $response->html->request()->get($this->identifier_name); $form = $response->form; if ($vms !== '') { $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'); $i = 0; foreach ($vms as $ex) { $d['param_f' . $i]['label'] = $ex; $d['param_f' . $i]['object']['type'] = 'htmlobject_input'; $d['param_f' . $i]['object']['attrib']['type'] = 'checkbox'; $d['param_f' . $i]['object']['attrib']['name'] = $this->identifier_name . '[' . $i . ']'; $d['param_f' . $i]['object']['attrib']['value'] = $ex; $d['param_f' . $i]['object']['attrib']['checked'] = true; $i++; } $form->add($d); if (!$form->get_errors() && $response->submit()) { $appliance_id = $this->response->html->request()->get('appliance_id'); $appliance = new appliance(); $resource = new resource(); $errors = array(); $message = array(); foreach ($vms as $key => $vm) { $appliance->get_instance_by_id($appliance_id); $resource->get_instance_by_id($appliance->resources); $file = $this->openqrm->get('basedir') . '/plugins/kvm/web/kvm-stat/' . $resource->id . '.vm_list'; if ($this->file->exists($file)) { $lines = explode("\n", $this->file->get_contents($file)); if (count($lines) >= 1) { foreach ($lines as $line) { if ($line !== '') { $line = explode('@', $line); if ($vm === $line[1]) { $kvm = new resource(); $kvm->get_instance_by_mac($line[2]); // check if it is still in use $appliances_using_resource = $appliance->get_ids_per_resource($kvm->id); if (count($appliances_using_resource) > 0) { $appliances_using_resource_str = implode(",", $appliances_using_resource[0]); $errors[] = sprintf($this->lang['msg_vm_resource_still_in_use'], $vm, $kvm->id, $appliances_using_resource_str); } else { $kvm->remove($kvm->id, $line[2]); $command = $this->openqrm->get('basedir') . '/plugins/kvm/bin/openqrm-kvm-vm delete -n ' . $vm; $command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password; $command .= ' --openqrm-ui-user ' . $this->user->name; $command .= ' --openqrm-cmd-mode background'; $resource->send_command($resource->ip, $command); $form->remove($this->identifier_name . '[' . $key . ']'); $message[] = sprintf($this->lang['msg_removed'], $vm); // stop remote console $tmp = explode(':', $line[5]); $server = $tmp[0]; $port = $tmp[1]; $mac = $line[2]; $rid = $kvm->id; $event = new event(); $plugin = new plugin(); $enabled = $plugin->enabled(); foreach ($enabled as $index => $name) { $running = $this->openqrm->get('webdir') . '/plugins/' . $name . '/.running'; $hook = $this->openqrm->get('webdir') . '/plugins/' . $name . '/openqrm-' . $name . '-remote-console-hook.php'; if (file_exists($hook)) { if (file_exists($running)) { $event->log("console", $_SERVER['REQUEST_TIME'], 5, "kvm-storge-vm.remove.class.php", 'Stopping ' . $name . ' remote console.', "", "", 0, 0, $kvm->id); require_once $hook; $console_function = 'openqrm_' . $name . '_disable_remote_console'; $console_function = str_replace("-", "_", $console_function); $console_function($server, $port, $rid, $mac, $vm); } } } } } } } } } } if (count($errors) === 0) { $response->msg = join('<br>', $message); } else { $msg = array_merge($errors, $message); $response->error = join('<br>', $msg); } } } else { $response->msg = ''; } return $response; }
function select() { $d = array(); $h = array(); $h['appliance_state']['title'] = $this->lang['table_state']; $h['appliance_id']['title'] = $this->lang['table_id']; $h['appliance_id']['hidden'] = true; $h['appliance_name']['title'] = $this->lang['table_name']; $h['appliance_name']['hidden'] = true; $h['appliance_values']['title'] = ' '; $h['appliance_values']['sortable'] = false; $h['appliance_comment']['title'] = ' '; $h['appliance_comment']['sortable'] = false; $h['appliance_virtualization']['title'] = 'Type'; $h['appliance_virtualization']['sortable'] = true; $h['appliance_virtualization']['hidden'] = true; $h['appliance_edit']['sortable'] = false; $appliance = new appliance(); $params = $this->response->get_array($this->actions_name, 'select'); $b = array(); // unset unnecessary params unset($params['resource_type_filter']); unset($params['resource_filter']); unset($params['appliance[sort]']); unset($params['appliance[order]']); unset($params['appliance[limit]']); unset($params['appliance[offset]']); $table = $this->response->html->tablebuilder('appliance', $params); $table->offset = 0; $table->sort = 'appliance_id'; $table->limit = 20; $table->order = 'ASC'; $table->max = $appliance->get_count(); $table->init(); // handle table params #$tps = $table->get_params(); $tp = ''; #foreach($tps['appliance'] as $k => $v) { # $tp .= '&appliance['.$k.']='.$v; #} $resource_filter = null; if ($this->response->html->request()->get('resource_filter') !== '') { $resource = $this->openqrm->resource(); $resource_filter = array(); $ar = $resource->find_resource($this->response->html->request()->get('resource_filter')); if (count($ar) > 0) { foreach ($ar as $k => $v) { $resource_filter[] = $v['resource_id']; } } } $disabled = array(); $appliances = $appliance->display_overview(0, 10000, $table->sort, $table->order); foreach ($appliances as $index => $appliance_db) { $appliance = new appliance(); $appliance->get_instance_by_id($appliance_db["appliance_id"]); $resource = new resource(); $resource->get_instance_by_id($appliance->resources); $appliance_resources = $appliance_db["appliance_resources"]; $kernel = new kernel(); $kernel->get_instance_by_id($appliance_db["appliance_kernelid"]); $image = new image(); $image->get_instance_by_id($appliance_db["appliance_imageid"]); $virtualization = new virtualization(); $virtualization->get_instance_by_id($appliance_db["appliance_virtualization"]); $appliance_virtualization_name = $virtualization->name; $virtualization_plugin_name = $virtualization->get_plugin_name(); $resource_is_local_server = false; if ($this->response->html->request()->get('resource_type_filter') === '' || $this->response->html->request()->get('resource_type_filter') == $resource->vtype) { // Skip all resources not in $resource_filter if (isset($resource_filter)) { if (!in_array($resource->id, $resource_filter)) { continue; } } if ($appliance_resources >= 0) { // an appliance with a pre-selected resource $resource->get_instance_by_id($appliance_resources); $resource_state_icon = '<span class="pill ' . $resource->state . '">' . $resource->state . '</span>'; // idle ? if ("{$resource->imageid}" == "1" && "{$resource->state}" == "active") { $resource_state_icon = '<span class="pill idle">idle</span>'; } // link to resource list $virtualization_vm_action_name = $virtualization->name; if (strstr($resource->capabilities, "TYPE=local-server")) { $resource_is_local_server = true; } $appliance_resources_str = ''; if (strpos($virtualization->type, "-vm")) { $host_resource = new resource(); $host_resource->get_instance_by_id($resource->vhostid); $host_virtualization = new virtualization(); $host_virtualization_name = $virtualization->get_plugin_name(); $host_virtualization->get_instance_by_type($host_virtualization_name); $host_appliance = new appliance(); $host_appliance->get_instance_by_virtualization_and_resource($host_virtualization->id, $resource->vhostid); $link = '?base=appliance&appliance_action=load_select'; $link .= '&aplugin=' . $virtualization_plugin_name; $link .= '&acontroller=' . $virtualization_plugin_name . '-vm'; $link .= '&' . $virtualization_plugin_name . '_vm_action=update'; $link .= '&appliance_id=' . $host_appliance->id; $link .= '&vm=' . $resource->hostname; $appliance_resources_str = '<a href="' . $this->response->html->thisfile . $link . '" onclick="wait();">' . $resource->hostname . '</a> ' . $resource_state_icon; } else { $appliance_resources_str = $resource->hostname . ' ' . $resource_state_icon; } } else { // an appliance with resource auto-select enabled $appliance_resources_str = "auto-select"; } // active or inactive $resource_icon_default = "/openqrm/base/img/appliance.png"; $active_state_icon = '<span class="pill active">active</span>'; $inactive_state_icon = '<span class="pill inactive">incative</span>'; if ($appliance->stoptime == 0 || $appliance_resources == 0) { $state_icon = $active_state_icon; } else { $state_icon = $inactive_state_icon; } // link to image edit if ($image->id > 0) { $link = '?base=image'; $link .= '&image_action=edit'; $link .= '&image_id=' . $image->id; $image_edit_link = '<a href="' . $this->response->html->thisfile . $link . '" onclick="wait();">' . $image->name . '</a>'; } else { $image_edit_link = $image->name; } // release resource $release_resource = ''; if ($appliance->stoptime == 0 || $appliance_resources == 0) { $release_resource = ''; } else { if ($appliance->resources != -1) { $a = $this->response->html->a(); $a->label = $this->lang['action_release']; $a->title = $this->lang['resource_release']; $a->css = 'enable'; $a->href = $this->response->get_url($this->actions_name, 'release') . '&appliance_id=' . $appliance->id . '' . $tp; $release_resource = $a->get_string(); } } $str = '<strong>' . $this->lang['table_id'] . ':</strong> ' . $appliance_db["appliance_id"] . '<br> <strong>' . $this->lang['table_name'] . ':</strong> ' . $appliance_db["appliance_name"] . '<br> <strong>Type:</strong> ' . $appliance_virtualization_name . '<br> <strong>Kernel:</strong> ' . $kernel->name . '<br> <strong>Image:</strong> ' . $image_edit_link . '<br> <strong>Resource:</strong> ' . $appliance_resources_str . '<br> <strong>IP:</strong> ' . $resource->ip; if (strpos($virtualization->type, "-vm") && isset($resource->vhostid) && $resource->vhostid != '') { $happliance = new appliance(); $hresource = $happliance->get_ids_per_resource($resource->vhostid); if (isset($hresource[0]['appliance_id'])) { $happliance->get_instance_by_id($hresource[0]['appliance_id']); $link = '?base=appliance'; $link .= '&appliance_action=edit'; $link .= '&appliance_id=' . $happliance->id; $href = '<a href="' . $this->response->html->thisfile . $link . '" onclick="wait();">' . $happliance->name . '</a>'; $str .= '<br><strong>Host:</strong> ' . $href; } } // appliance edit $a = $this->response->html->a(); $a->title = $this->lang['action_edit']; $a->label = $this->lang['action_edit']; $a->handler = 'onclick="wait();"'; $a->css = 'edit'; $a->href = $this->response->get_url($this->actions_name, 'edit') . '&appliance_id=' . $appliance->id . '' . $tp; $strEdit = $a->get_string(); // appliance start $strStart = ''; if ($appliance_resources !== '0') { $a = $this->response->html->a(); $a->handler = 'onclick="wait();"'; if ($appliance->stoptime == 0) { $a->title = $this->lang['action_stop']; $a->label = $this->lang['action_stop']; $a->css = 'disable'; $a->href = $this->response->get_url($this->actions_name, 'stop') . '&' . $this->identifier_name . '[]=' . $appliance->id . '' . $tp; } else { $a->title = $this->lang['action_start']; $a->label = $this->lang['action_start']; $a->css = 'enable'; $a->href = $this->response->get_url($this->actions_name, 'start') . '&' . $this->identifier_name . '[]=' . $appliance->id . '' . $tp; } $strStart = $a->get_string(); } // build the plugin link section $appliance_link_section = ''; // add link to continue if appliance has unfinished wizard $disabled = array(); if (isset($appliance->wizard) && strpos($appliance->wizard, 'wizard') !== false) { $params = explode(',', $appliance->wizard); $wizard_step = explode('=', $params[0]); $wizard_user = explode('=', $params[1]); if ($wizard_user[1] === $this->user->name) { // continue button $a = $this->response->html->a(); $a->title = $this->lang['action_continue']; $a->label = $this->lang['action_continue']; $a->handler = 'onclick="wait();"'; $a->css = 'badge continue'; $a->href = $this->response->get_url($this->actions_name, $wizard_step[1]) . '&appliance_wizard_id=' . $appliance->id . '' . $tp; $appliance_comment = $a->get_string(); } else { $appliance_comment = sprintf($this->lang['appliance_create_in_progress'], $wizard_user[1]); } // disable all buttons $disabled[] = $appliance->id; $strEdit = ''; $strStart = ''; $strStop = ''; $release_resource = ''; } else { $plugin = new plugin(); $enabled_plugins = $plugin->enabled(); foreach ($enabled_plugins as $index => $plugin_name) { $plugin_appliance_link_section_hook = $this->openqrm->get('webdir') . "/plugins/" . $plugin_name . "/openqrm-" . $plugin_name . "-appliance-link-hook.php"; if (file_exists($plugin_appliance_link_section_hook)) { require_once "{$plugin_appliance_link_section_hook}"; $appliance_get_link_function = str_replace("-", "_", "get_" . "{$plugin_name}" . "_appliance_link"); if (function_exists($appliance_get_link_function)) { $p = $plugin->get_config($plugin_name); $alink = $appliance_get_link_function($appliance->id); if (is_object($alink)) { // $alink->handler = $alink->handler.' onclick="wait();"'; $alink->css = 'enable'; $alink->title = preg_replace('~(.*?)<a.*>(.*?)</a>(.*?)~i', '$1$2$3', $p['description']); $alink = $alink->get_string(); } $appliance_link_section .= $alink; } } } if ($appliance_db["appliance_comment"] !== '') { $appliance_comment = $appliance_db["appliance_comment"]; $appliance_comment .= "<hr>"; $appliance_comment .= $appliance_link_section; } else { $appliance_comment = $appliance_link_section; } } $b[] = array('appliance_state' => $state_icon, 'appliance_id' => $appliance_db["appliance_id"], 'appliance_name' => $appliance_db["appliance_name"], 'appliance_values' => $str, 'appliance_comment' => $appliance_comment, 'appliance_virtualization' => $appliance_db["appliance_virtualization"], 'appliance_edit' => $strEdit . '' . $strStart . '' . $release_resource); } } // Filter $virtulization_types = new virtualization(); $list = $virtulization_types->get_list(); $filter = array(); $filter[] = array('', ''); foreach ($list as $l) { $filter[] = array($l['label'], $l['value']); } asort($filter); $select = $this->response->html->select(); $select->add($filter, array(1, 0)); $select->name = 'resource_type_filter'; $select->handler = 'onchange="wait();this.form.submit();return false;"'; $select->selected = array($this->response->html->request()->get('resource_type_filter')); $box1 = $this->response->html->box(); $box1->add($select); $box1->id = 'resource_type_filter'; $box1->css = 'htmlobject_box'; $box1->label = $this->lang['lang_type_filter']; // Resource Filter $input = $this->response->html->input(); $input->name = 'resource_filter'; $input->value = $this->response->html->request()->get('resource_filter'); $input->title = $this->lang['lang_filter_title']; $box2 = $this->response->html->box(); $box2->add($input); $box2->id = 'resource_filter'; $box2->css = 'htmlobject_box'; $box2->label = $this->lang['lang_filter']; $add = $this->response->html->a(); $add->title = $this->lang['action_add']; $add->label = $this->lang['action_add']; $add->handler = 'onclick="wait();"'; $add->css = 'add'; $add->href = $this->response->get_url($this->actions_name, "step1") . '' . $tp; $table->id = 'Tabelle'; $table->css = 'htmlobject_table'; $table->border = 1; $table->cellspacing = 0; $table->cellpadding = 3; $table->autosort = true; $table->sort_link = false; $table->max = count($b); $table->head = $h; $table->body = $b; #$table->form_action = $this->response->html->thisfile; $table->actions_name = $this->actions_name; $table->actions = array(array('start' => $this->lang['action_start']), array('stop' => $this->lang['action_stop']), array('remove' => $this->lang['action_remove'])); $table->identifier = 'appliance_id'; $table->identifier_name = $this->identifier_name; $table->identifier_disabled = $disabled; #$table->limit_select = array( # array("value" => 10, "text" => 10), # array("value" => 20, "text" => 20), # array("value" => 30, "text" => 30), # array("value" => 50, "text" => 50), # array("value" => 100, "text" => 100), #); $d['form'] = $this->response->get_form($this->actions_name, 'select', false)->get_elements(); $d['add'] = $add->get_string(); $d['table'] = $table; $d['resource_type_filter'] = $box1->get_string(); $d['resource_filter'] = $box2->get_string(); return $d; }