Ejemplo n.º 1
0
 function __construct($openqrm, $response)
 {
     $this->response = $response;
     $this->openqrm = $openqrm;
     $this->file = $this->openqrm->file();
     $this->openqrm = $openqrm;
     $this->user = $openqrm->user();
     $storage_id = $this->response->html->request()->get('storage_id');
     $storage = new storage();
     $resource = new resource();
     $deployment = new deployment();
     $this->storage = $storage->get_instance_by_id($storage_id);
     $this->resource = $resource->get_instance_by_id($storage->resource_id);
     $this->deployment = $deployment->get_instance_by_id($storage->type);
     $this->response->add('storage_id', $storage_id);
 }
Ejemplo n.º 2
0
function get_kvm_lvm_deployment_image_rootdevice_identifier($kvm_lvm_id)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_ADMIN;
    global $event;
    // place for the storage stat files
    $StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/kvm/storage';
    $rootdevice_identifier_array = array();
    $storage = new storage();
    $storage->get_instance_by_id($kvm_lvm_id);
    // get deployment type
    $deployment = new deployment();
    $deployment->get_instance_by_id($storage->type);
    // get storage resource
    $storage_resource = new resource();
    $storage_resource->get_instance_by_id($storage->resource_id);
    $storage_resource_id = $storage_resource->id;
    $ident_file = $StorageDir . "/" . $storage_resource_id . ".lv.kvm-lvm-deployment.ident";
    if (file_exists($ident_file)) {
        unlink($ident_file);
    }
    // send command
    $resource_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm post_identifier -u " . $OPENQRM_ADMIN->name . " -p " . $OPENQRM_ADMIN->password . " -t " . $deployment->type;
    $storage_resource->send_command($storage_resource->ip, $resource_command);
    if (!kvm_lvm_deployment_wait_for_identfile($ident_file)) {
        $event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.kvm-lvm-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0);
        return;
    }
    $fcontent = file($ident_file);
    foreach ($fcontent as $lun_info) {
        $tpos = strpos($lun_info, ":");
        $timage_name = trim(substr($lun_info, 0, $tpos));
        $troot_device = trim(substr($lun_info, $tpos + 1));
        $rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}");
    }
    return $rootdevice_identifier_array;
}
Ejemplo n.º 3
0
                if (!strlen($image_fields["image_storageid"])) {
                    $image_fields["image_storageid"] = $id;
                }
                continue;
            }
            break;
    }
}
$event->log("{$image_command}", $_SERVER['REQUEST_TIME'], 5, "image-action", "Processing image {$image_command} on Image {$image_name}", "", "", 0, 0, 0);
switch ($image_command) {
    case 'new_image':
        $image = new image();
        $image_fields["image_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
        # switch deployment_id to deyployment_type
        $deployment_switch = new deployment();
        $deployment_switch->get_instance_by_id($image_type);
        $image_fields["image_type"] = $deployment_switch->type;
        // unquote
        $image_deployment_parameter = $image_fields["image_deployment_parameter"];
        $image_fields["image_deployment_parameter"] = stripslashes($image_deployment_parameter);
        $image->add($image_fields);
        break;
    case 'update_image':
        $image = new image();
        if (!strlen($image_fields["image_isshared"])) {
            $image_fields["image_isshared"] = "0";
        }
        // unquote
        $image_deployment_parameter = $image_fields["image_deployment_parameter"];
        $image_fields["image_deployment_parameter"] = stripslashes($image_deployment_parameter);
        $image->update($image_id, $image_fields);
Ejemplo n.º 4
0
 }
 // find the most loaded storage
 $in_store_table = 0;
 arsort($store_load_array, true);
 $sorted_store_load_array_ids = array_keys($store_load_array);
 foreach ($sorted_store_load_array_ids as $ml_store_id) {
     $l_store = new storage();
     $l_store->get_instance_by_id($ml_store_id);
     if ($in_store_table < $max_show_storage) {
         // get resource load
         $l_res = new resource();
         $l_res->get_instance_by_id($l_store->resource_id);
         $l_store_load = $l_res->load;
         // get storage type
         $deployment = new deployment();
         $deployment->get_instance_by_id($l_store->type);
         // fill in array body
         $arBody[] = array('storage_icon' => "<img widht='16' height='16' src='/openqrm/base/img/active.png'>", 'storage_id' => $l_store->id, 'storage_name' => $l_store->name, 'storage_resource' => $l_store->resource_id, 'storage_type' => $deployment->storagedescription, 'storage_load' => $l_store_load);
         $in_store_table++;
     } else {
         break;
     }
 }
 $table->id = 'Tabelle';
 $table->css = 'htmlobject_table';
 $table->border = 1;
 $table->cellspacing = 0;
 $table->cellpadding = 3;
 $table->sort = '';
 $table->head = $arHead;
 $table->body = $arBody;
Ejemplo n.º 5
0
 function send_command($resource_ip, $resource_command, $command_timeout = NULL)
 {
     global $OPENQRM_EXEC_PORT;
     global $OPENQRM_SERVER_BASE_DIR;
     global $OPENQRM_EXECUTION_LAYER;
     global $event;
     global $RootDir;
     // here we assume that we are the resource
     // plugin hook in case a resource gets rebooted or halted
     switch ($resource_command) {
         case 'reboot':
             // start the hook
             $plugin = new plugin();
             $enabled_plugins = $plugin->enabled();
             foreach ($enabled_plugins as $index => $plugin_name) {
                 $plugin_start_resource_hook = "{$RootDir}/plugins/{$plugin_name}/openqrm-{$plugin_name}-resource-hook.php";
                 if (file_exists($plugin_start_resource_hook)) {
                     $event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found plugin {$plugin_name} handling start-resource event.", "", "", 0, 0, $this->id);
                     // prepare resource_fields array
                     $resource_fields = array();
                     $resource_fields = $this->get_fields($this->id);
                     // include the plugin function file and run it
                     require_once "{$plugin_start_resource_hook}";
                     $resource_function = "openqrm_" . "{$plugin_name}" . "_resource";
                     $resource_function = str_replace("-", "_", $resource_function);
                     $resource_function("start", $resource_fields);
                 }
             }
             // here we check if the resource is virtual or a host and if
             // the virtualization plugin wants to reboot it via the host
             $virtualization = new virtualization();
             $virtualization->get_instance_by_id($this->vtype);
             $virtualization_plugin_name = $virtualization->get_plugin_name();
             $plugin_resource_virtual_command_hook_vm_type = "{$RootDir}/plugins/{$virtualization_plugin_name}/openqrm-{$virtualization_plugin_name}-resource-virtual-command-hook.php";
             // we also give the deployment type a chance to implement virtual commands
             $deployment_plugin_name = '';
             if ($this->imageid != 1) {
                 $image = new image();
                 $image->get_instance_by_id($this->imageid);
                 $storage = new storage();
                 $storage->get_instance_by_id($image->storageid);
                 $deployment = new deployment();
                 $deployment->get_instance_by_id($storage->type);
                 $deployment_plugin_name = $deployment->storagetype;
             }
             $plugin_resource_virtual_command_hook = '';
             $plugin_resource_virtual_command_hook_image_type = "{$RootDir}/plugins/{$deployment_plugin_name}/openqrm-{$deployment_plugin_name}-resource-virtual-command-hook.php";
             //            $plugin_resource_virtual_command_hook_image_type = "$RootDir/plugins/sanboot-storage/openqrm-sanboot-storage-resource-virtual-command-hook.php";
             if (file_exists($plugin_resource_virtual_command_hook_vm_type)) {
                 $event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found virtualization {$virtualization_plugin_name} managing virtual command.", "", "", 0, 0, $this->id);
                 $plugin_resource_virtual_command_hook = $plugin_resource_virtual_command_hook_vm_type;
             } else {
                 if (file_exists($plugin_resource_virtual_command_hook_image_type)) {
                     // check if IMAGE_VIRTUAL_RESOURCE_COMMAND=true
                     $event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found deploymetn {$deployment_plugin_name} managing virtual command.", "", "", 0, 0, $this->id);
                     $image = new image();
                     $image->get_instance_by_id($this->imageid);
                     $virtual_command_enabled = $image->get_deployment_parameter("IMAGE_VIRTUAL_RESOURCE_COMMAND");
                     if (!strcmp($virtual_command_enabled, "true")) {
                         $event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found IMAGE_VIRTUAL_RESOURCE_COMMAND enabled, using virtual command.", "", "", 0, 0, $this->id);
                         $plugin_resource_virtual_command_hook = $plugin_resource_virtual_command_hook_image_type;
                         $virtualization_plugin_name = $deployment_plugin_name;
                     } else {
                         $event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found IMAGE_VIRTUAL_RESOURCE_COMMAND disabled, using regular command.", "", "", 0, 0, $this->id);
                     }
                 }
             }
             if (strlen($plugin_resource_virtual_command_hook)) {
                 $event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found plugin {$virtualization_plugin_name} virtually handling the reboot command.", "", "", 0, 0, $this->id);
                 // prepare resource_fields array
                 $resource_fields = array();
                 $resource_fields = $this->get_fields($this->id);
                 // include the plugin function file and run it
                 require_once "{$plugin_resource_virtual_command_hook}";
                 $resource_function = "openqrm_" . "{$virtualization_plugin_name}" . "_resource_virtual_command";
                 $resource_function = str_replace("-", "_", $resource_function);
                 $resource_function("reboot", $resource_fields);
                 // the virtual reboot function can only be
                 // implemented by a single plugin depending on the
                 // resource type. So we return after that and
                 // do not try to reboot the resource via its ip
                 return;
             }
             break;
         case 'halt':
             // stop hook
             $plugin = new plugin();
             $enabled_plugins = $plugin->enabled();
             foreach ($enabled_plugins as $index => $plugin_name) {
                 $plugin_start_resource_hook = "{$RootDir}/plugins/{$plugin_name}/openqrm-{$plugin_name}-resource-hook.php";
                 if (file_exists($plugin_start_resource_hook)) {
                     $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found plugin {$plugin_name} handling start-resource event.", "", "", 0, 0, $this->id);
                     // prepare resource_fields array
                     $resource_fields = array();
                     $resource_fields = $this->get_fields($this->id);
                     // include the plugin function file and run it
                     require_once "{$plugin_start_resource_hook}";
                     $resource_function = "openqrm_" . "{$plugin_name}" . "_resource";
                     $resource_function = str_replace("-", "_", $resource_function);
                     $resource_function("stop", $resource_fields);
                 }
             }
             // here we check if the resource is virtual or a host and if
             // the virtualization plugin wants to reboot it via the host
             $virtualization = new virtualization();
             $virtualization->get_instance_by_id($this->vtype);
             $virtualization_plugin_name = $virtualization->get_plugin_name();
             $plugin_resource_virtual_command_hook_vm_type = "{$RootDir}/plugins/{$virtualization_plugin_name}/openqrm-{$virtualization_plugin_name}-resource-virtual-command-hook.php";
             // we also give the deployment type a chance to implement virtual commands
             $deployment_plugin_name = '';
             if ($this->imageid != 1) {
                 $image = new image();
                 $image->get_instance_by_id($this->imageid);
                 $storage = new storage();
                 $storage->get_instance_by_id($image->storageid);
                 $deployment = new deployment();
                 $deployment->get_instance_by_id($storage->type);
                 $deployment_plugin_name = $deployment->storagetype;
             }
             $plugin_resource_virtual_command_hook = '';
             $plugin_resource_virtual_command_hook_image_type = "{$RootDir}/plugins/{$deployment_plugin_name}/openqrm-{$deployment_plugin_name}-resource-virtual-command-hook.php";
             if (file_exists($plugin_resource_virtual_command_hook_vm_type)) {
                 $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found virtualization {$virtualization_plugin_name} managing virtual command.", "", "", 0, 0, $this->id);
                 $plugin_resource_virtual_command_hook = $plugin_resource_virtual_command_hook_vm_type;
             } else {
                 if (file_exists($plugin_resource_virtual_command_hook_image_type)) {
                     // check if IMAGE_VIRTUAL_RESOURCE_COMMAND=true
                     $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found deploymetn {$deployment_plugin_name} managing virtual command.", "", "", 0, 0, $this->id);
                     $image = new image();
                     $image->get_instance_by_id($this->imageid);
                     $virtual_command_enabled = $image->get_deployment_parameter("IMAGE_VIRTUAL_RESOURCE_COMMAND");
                     if (!strcmp($virtual_command_enabled, "true")) {
                         $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found IMAGE_VIRTUAL_RESOURCE_COMMAND enabled, using virtual command.", "", "", 0, 0, $this->id);
                         $plugin_resource_virtual_command_hook = $plugin_resource_virtual_command_hook_image_type;
                         $virtualization_plugin_name = $deployment_plugin_name;
                     } else {
                         $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found IMAGE_VIRTUAL_RESOURCE_COMMAND disabled, using regular command.", "", "", 0, 0, $this->id);
                     }
                 }
             }
             if (strlen($plugin_resource_virtual_command_hook)) {
                 $event->log("stop", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Found plugin {$virtualization_plugin_name} virtually handling the reboot command.", "", "", 0, 0, $this->id);
                 // prepare resource_fields array
                 $resource_fields = array();
                 $resource_fields = $this->get_fields($this->id);
                 // include the plugin function file and run it
                 require_once "{$plugin_resource_virtual_command_hook}";
                 $resource_function = "openqrm_" . "{$virtualization_plugin_name}" . "_resource_virtual_command";
                 $resource_function = str_replace("-", "_", $resource_function);
                 $resource_function("halt", $resource_fields);
                 // the virtual halt function can only be
                 // implemented by a single plugin depending on the
                 // resource type. So we return after that and
                 // do not try to halt the resource via its ip
                 return;
             }
             break;
     }
     // check which execution layer to use
     switch ($OPENQRM_EXECUTION_LAYER) {
         case 'dropbear':
             // generate a random token for the cmd
             $cmd_token = md5(uniqid(rand(), true));
             // custom timeout ?
             if (!is_null($command_timeout)) {
                 $cmd_token .= "." . $command_timeout;
             }
             $final_resource_command = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/sbin/openqrm-exec -i {$resource_ip} -t {$cmd_token} -c \"{$resource_command}\"";
             //$event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Running : $final_resource_command", "", "", 0, 0, 0);
             shell_exec($final_resource_command);
             break;
         case 'openqrm-execd':
             $fp = fsockopen($resource_ip, $OPENQRM_EXEC_PORT, $errno, $errstr, 30);
             if (!$fp) {
                 $event->log("send_command", $_SERVER['REQUEST_TIME'], 2, "resource.class.php", "Could not send the command to resource {$resource_ip}", "", "", 0, 0, 0);
                 $event->log("send_command", $_SERVER['REQUEST_TIME'], 2, "resource.class.php", "{$errstr} ({$errno})", "", "", 0, 0, 0);
             } else {
                 // $event->log("start", $_SERVER['REQUEST_TIME'], 5, "resource.class.php", "Running : $resource_command", "", "", 0, 0, $resource->id);
                 fputs($fp, "{$resource_command}");
                 fclose($fp);
             }
             break;
     }
 }
Ejemplo n.º 6
0
 function get_response()
 {
     $response = $this->response;
     $form = $response->get_form($this->actions_name, 'install2');
     $id = $this->response->html->request()->get('image_id');
     $install_server = $this->response->html->request()->get('install_server');
     $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 = new image();
     $image->get_instance_by_id($id);
     $storage = new storage();
     $storage->get_instance_by_id($install_server);
     $deployment = new deployment();
     $deployment->get_instance_by_id($storage->type);
     // require template-deployment file
     $local_deployment_templates_identifier_hook = $this->openqrm->get('basedir') . "/web/boot-service/template." . $deployment->type . ".php";
     if ($this->file->exists($local_deployment_templates_identifier_hook)) {
         require_once "{$local_deployment_templates_identifier_hook}";
         $get_deployment_templates_function = "get_" . "{$deployment->type}" . "_templates";
         $get_deployment_templates_function = str_replace("-", "_", $get_deployment_templates_function);
         $local_deployment_templates_arr = $get_deployment_templates_function($install_server);
         // get additional optional local-deployment parameters from the template hook
         $get_additional_parameters_function = "get_" . "{$deployment->type}" . "_additional_parameters";
         $get_additional_parameters_function = str_replace("-", "_", $get_additional_parameters_function);
         $additional_local_deployment_parameter = $get_additional_parameters_function();
     }
     // persistent deployment ?
     $local_deployment_persistent_arr = array();
     $local_deployment_persistent_arr[] = array("value" => "0", "label" => "First boot");
     $local_deployment_persistent_arr[] = array("value" => "1", "label" => "Persistent");
     $d['template']['label'] = $this->lang['form_install_template'];
     $d['template']['required'] = false;
     $d['template']['object']['type'] = 'htmlobject_select';
     $d['template']['object']['attrib']['index'] = array('value', 'label');
     $d['template']['object']['attrib']['id'] = 'template';
     $d['template']['object']['attrib']['name'] = 'template';
     $d['template']['object']['attrib']['options'] = $local_deployment_templates_arr;
     $d['persistent']['label'] = $this->lang['form_install_persistent'];
     $d['persistent']['required'] = false;
     $d['persistent']['object']['type'] = 'htmlobject_select';
     $d['persistent']['object']['attrib']['index'] = array('value', 'label');
     $d['persistent']['object']['attrib']['id'] = 'persistent';
     $d['persistent']['object']['attrib']['name'] = 'persistent';
     $d['persistent']['object']['attrib']['options'] = $local_deployment_persistent_arr;
     $n = 1;
     foreach ($additional_local_deployment_parameter as $paramters) {
         if (!isset($paramters['label'])) {
             continue;
         }
         $d['parameter' . $n]['label'] = $paramters['label'];
         $d['parameter' . $n]['required'] = false;
         $d['parameter' . $n]['object']['type'] = 'htmlobject_input';
         $d['parameter' . $n]['object']['attrib']['id'] = 'parameter' . $n;
         $d['parameter' . $n]['object']['attrib']['name'] = 'parameter' . $n;
         $n++;
     }
     for ($j = $n; $j <= 4; $j++) {
         $d['parameter' . $j] = '';
     }
     $form->add($d);
     $response->form = $form;
     return $response;
 }
function openqrm_hybrid_cloud_cloud_product($cmd, $cloud_hook_config)
{
    global $event;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RootDir;
    $openqrm_server = new openqrm_server();
    $event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Handling " . $cmd . " event", "", "", 0, 0, 0);
    switch ($cmd) {
        case "add":
            $event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Handling cloud-product " . $cmd . " event", "", "", 0, 0, 0);
            // create resource products
            $db = openqrm_get_db_connection();
            $image = new image();
            $checked_virtualization_plugins = array();
            $virtualization = new virtualization();
            $virtualization_id_ar = $virtualization->get_list();
            unset($virtualization_id_ar[0]);
            foreach ($virtualization_id_ar as $key => $value) {
                $next_sort_id = 0;
                $id = $value['value'];
                $virtualization->get_instance_by_id($id);
                $pos = strpos($virtualization->type, 'hybrid-cloud-vm-');
                if ($pos !== false) {
                    $event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Adding " . $virtualization->type . " as cloud-product", "", "", 0, 0, 0);
                    $cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
                    $create_resource_cloudselector_config = "insert into cloud_selector (id, type, sort_id, quantity, price, name, description, state) VALUES (" . $cloud_product_id . ", 'resource', " . $next_sort_id . ", '" . $virtualization->id . "', 1, '" . $virtualization->type . "', '" . $virtualization->name . "', 1);";
                    $recordSet = $db->Execute($create_resource_cloudselector_config);
                    $next_sort_id++;
                    // add all existing images for this virtualization type to private images
                    $virtualization_plugin_name = $virtualization->get_plugin_name();
                    if (!in_array($virtualization_plugin_name, $checked_virtualization_plugins)) {
                        $checked_virtualization_plugins[] = $virtualization_plugin_name;
                        $deployment = new deployment();
                        $deployment_id_ar = $deployment->get_id_by_storagetype($virtualization_plugin_name);
                        foreach ($deployment_id_ar as $key => $value) {
                            $did = $value['value'];
                            $deployment->get_instance_by_id($did);
                            $image_id_deployment_ar = $image->get_ids_by_type($deployment->type);
                            foreach ($image_id_deployment_ar as $iid_ar) {
                                // add to private images
                                $image_id = $iid_ar['image_id'];
                                $event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Adding Image " . $image_id . " as private image", "", "", 0, 0, 0);
                                $cloud_pr_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
                                $create_private_image_config = "insert into cloud_private_image (co_id, co_image_id, co_cu_id, co_clone_on_deploy, co_state) VALUES (" . $cloud_pr_id . ", " . $image_id . ", 0, 1, 1);";
                                $recordSet = $db->Execute($create_private_image_config);
                            }
                        }
                    }
                }
            }
            // add host to admin resource pool
            $admin_project_id = $cloud_hook_config['cloud_admin_procect'];
            $virtualization->get_instance_by_type('hybrid-cloud');
            $appliance = new appliance();
            $appliance_id_ar = $appliance->get_ids_per_virtualization($virtualization->id);
            foreach ($appliance_id_ar as $key => $value) {
                $appliance_id = $value['appliance_id'];
                $appliance->get_instance_by_id($appliance_id);
                $cloud_respool_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
                $create_default_resource_pool_config = "insert into cloud_respool(rp_id, rp_resource_id, rp_cg_id) values (" . $cloud_respool_id . ", " . $appliance->resources . ", " . $admin_project_id . ");";
                $recordSet = $db->Execute($create_default_resource_pool_config);
            }
            break;
        case "remove":
            $cloud_product_class = $RootDir . "/plugins/cloud/class/cloudselector.class.php";
            if (file_exists($cloud_product_class)) {
                require_once $cloud_product_class;
                $cloud_selector = new cloudselector();
                $virtualization = new virtualization();
                $virtualization->get_instance_by_type('hybrid-cloud-vm-local');
                $event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Removing resource type " . $virtualization->type . " from cloud-products", "", "", 0, 0, 0);
                $cloud_selector->remove_by_quantity($virtualization->id);
            }
            break;
    }
}
Ejemplo n.º 8
0
 function duplicate()
 {
     $response = $this->get_response();
     $form = $response->form;
     if (!$form->get_errors() && $this->response->submit()) {
         $storage_id = $this->response->html->request()->get('storage_id');
         $storage = new storage();
         $resource = new resource();
         $deployment = new deployment();
         $storage->get_instance_by_id($storage_id);
         $resource->get_instance_by_id($storage->resource_id);
         $deployment->get_instance_by_id($storage->type);
         $name = $form->get_request('name');
         $command = $this->openqrm->get('basedir') . '/plugins/nfs-storage/bin/openqrm-nfs-storage clone';
         $command .= ' -n ' . $this->volume;
         $command .= ' -s ' . $name;
         $command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
         $command .= ' --openqrm-ui-user ' . $this->user->name;
         $command .= ' --openqrm-cmd-mode background';
         $statfile = $this->openqrm->get('basedir') . '/plugins/nfs-storage/web/storage/' . $storage->resource_id . '.nfs.stat';
         $origin_volume_path = '';
         $volume_path = "";
         if (file_exists($statfile)) {
             $lines = explode("\n", file_get_contents($statfile));
             if (count($lines) >= 1) {
                 foreach ($lines as $line) {
                     if ($line !== '') {
                         $line = explode('@', $line);
                         $check = basename($line[1]);
                         if ($name === $check) {
                             $error = sprintf($this->lang['error_exists'], $name);
                         }
                         if ($this->volume === $check) {
                             $origin_volume_path = $line[1];
                         }
                     }
                 }
             }
         }
         if (!strlen($origin_volume_path)) {
             $error = sprintf($this->lang['msg_clone_failed'], $name);
         } else {
             $export_path = dirname($origin_volume_path);
             $volume_path = $export_path . '/' . $name;
         }
         if (isset($error)) {
             $response->error = $error;
         } else {
             $file = $this->openqrm->get('basedir') . '/plugins/nfs-storage/web/storage/' . $resource->id . '.nfs.' . $name . '.sync_progress';
             if ($this->file->exists($file)) {
                 $this->file->remove($file);
             }
             $resource->send_command($resource->ip, $command);
             while (!$this->file->exists($file)) {
                 usleep(10000);
                 // sleep 10ms to unload the CPU
                 clearstatcache();
             }
             $tables = $this->openqrm->get('table');
             $image_fields = array();
             $image_fields["image_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
             $image_fields['image_name'] = $name;
             $image_fields['image_type'] = $deployment->type;
             $image_fields['image_rootfstype'] = 'nfs';
             $image_fields['image_storageid'] = $storage->id;
             $image_fields['image_comment'] = "Image Object for volume {$name}";
             $image_fields['image_rootdevice'] = $volume_path;
             $image = new image();
             $image->add($image_fields);
             $response->msg = sprintf($this->lang['msg_cloned'], $this->volume, $name);
             // save image id in response for the wizard
             $response->image_id = $image_fields["image_id"];
         }
     }
     return $response;
 }
Ejemplo n.º 9
0
 function remove()
 {
     $response = $this->get_response();
     $lvols = $response->html->request()->get($this->identifier_name);
     $form = $response->form;
     if ($lvols !== '') {
         $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 ($lvols 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()) {
             $name = $this->openqrm->admin()->name;
             $pass = $this->openqrm->admin()->password;
             $storage = new storage();
             $resource = new resource();
             $deployment = new deployment();
             $storage->get_instance_by_id($this->response->html->request()->get('storage_id'));
             $resource->get_instance_by_id($storage->resource_id);
             $deployment->get_instance_by_id($storage->type);
             $errors = array();
             $message = array();
             foreach ($lvols as $key => $lvol) {
                 // check if an appliance is still using the volume as an image
                 $image = new image();
                 $image->get_instance_by_name($lvol);
                 // check if it is still in use
                 $appliance = new appliance();
                 $appliances_using_resource = $appliance->get_ids_per_image($image->id);
                 if (count($appliances_using_resource) > 0) {
                     $appliances_using_resource_str = implode(",", $appliances_using_resource[0]);
                     $errors[] = sprintf($this->lang['msg_vm_image_still_in_use'], $lvol, $image->id, $appliances_using_resource_str);
                 } else {
                     $command = $this->openqrm->get('basedir') . '/plugins/kvm/bin/openqrm-kvm remove';
                     $command .= ' -n ' . $lvol;
                     $command .= ' -v ' . $this->volgroup;
                     $command .= ' -t ' . $deployment->type;
                     $command .= ' -u ' . $name . ' -p ' . $pass;
                     $command .= ' --openqrm-ui-user ' . $this->user->name;
                     $command .= ' --openqrm-cmd-mode background';
                     $file = $this->openqrm->get('basedir') . '/plugins/kvm/web/storage/' . $resource->id . '.' . $this->volgroup . '.lv.stat';
                     if ($this->file->exists($file)) {
                         $this->file->remove($file);
                     }
                     $resource->send_command($resource->ip, $command);
                     while (!$this->file->exists($file)) {
                         usleep(10000);
                         // sleep 10ms to unload the CPU
                         clearstatcache();
                     }
                     $form->remove($this->identifier_name . '[' . $key . ']');
                     $message[] = sprintf($this->lang['msg_removed'], $lvol);
                     // remove the image of the volume
                     $image->remove_by_name($lvol);
                 }
             }
             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;
 }
Ejemplo n.º 10
0
 function duplicate()
 {
     $response = $this->get_response();
     $form = $response->form;
     if (!$form->get_errors() && $this->response->submit()) {
         $storage_id = $this->response->html->request()->get('storage_id');
         $storage = new storage();
         $resource = new resource();
         $deployment = new deployment();
         $storage->get_instance_by_id($storage_id);
         $resource->get_instance_by_id($storage->resource_id);
         $deployment->get_instance_by_id($storage->type);
         $name = $form->get_request('name');
         // check if volume / image name is aleady existing
         $image_check = new image();
         $image_check->get_instance_by_name($name);
         if (isset($image_check->id) && $image_check->id > 0) {
             $error = sprintf($this->lang['error_image_exists'], $name);
         }
         $linuxcoe_volume = new linuxcoe_volume();
         $linuxcoe_volume->get_instance_by_name($name);
         if (isset($linuxcoe_volume->id) && $linuxcoe_volume->id > 0) {
             $error = sprintf($this->lang['error_exists'], $name);
         }
         if (isset($error)) {
             $response->error = $error;
         } else {
             // add volume
             $linuxcoe_volume->get_instance_by_name($this->volume);
             $volume_fields = array();
             $volume_fields["linuxcoe_volume_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
             $volume_fields['linuxcoe_volume_name'] = $name;
             $volume_fields['linuxcoe_volume_root'] = $linuxcoe_volume->root;
             $volume_fields['linuxcoe_volume_description'] = $linuxcoe_volume->description;
             $linuxcoe_volume->add($volume_fields);
             // add image
             $tables = $this->openqrm->get('table');
             $image_fields = array();
             $image_fields["image_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
             $image_fields['image_name'] = $name;
             $image_fields['image_type'] = $deployment->type;
             $image_fields['image_rootfstype'] = 'local';
             $image_fields['image_storageid'] = $storage->id;
             $image_fields['image_comment'] = "Image Object for volume {$name}";
             $image_fields['image_rootdevice'] = 'local';
             $image = new image();
             $image->add($image_fields);
             $response->msg = sprintf($this->lang['msg_cloned'], $this->volume, $name);
             // save image id in response for the wizard
             $response->image_id = $image_fields["image_id"];
         }
     }
     return $response;
 }
function create_private_kvm_lvm_deployment($cloud_image_id, $private_disk, $private_image_name)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $cloudimage = new cloudimage();
    $cloudimage->get_instance_by_id($cloud_image_id);
    $event->log("create_private_kvm_lvm_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-cloud-hook.php", "Creating private image " . $cloudimage->image_id . " on storage.", "", "", 0, 0, 0);
    // get image
    $image = new image();
    $image->get_instance_by_id($cloudimage->image_id);
    $image_id = $image->id;
    $image_name = $image->name;
    $image_type = $image->type;
    $image_version = $image->version;
    $image_rootdevice = $image->rootdevice;
    $image_rootfstype = $image->rootfstype;
    $imageid = $image->storageid;
    $image_isshared = $image->isshared;
    $image_comment = $image->comment;
    $image_capabilities = $image->capabilities;
    $image_deployment_parameter = $image->deployment_parameter;
    // get image storage
    $storage = new storage();
    $storage->get_instance_by_id($imageid);
    $storage_resource_id = $storage->resource_id;
    // get deployment type
    $deployment = new deployment();
    $deployment->get_instance_by_id($storage->type);
    // get storage resource
    $resource = new resource();
    $resource->get_instance_by_id($storage_resource_id);
    $resource_id = $resource->id;
    $resource_ip = $resource->ip;
    // create an admin user to post when cloning has finished
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    // parse the volume group info in the identifier
    $volume_group_location = dirname($image_rootdevice);
    $volume_group = basename($volume_group_location);
    $image_location_name = basename($image_rootdevice);
    // For kvm vms we assume that the image is located on the vm-host
    // so we send the auth command to the vm-host instead of the image storage.
    // This enables using a SAN backend with dedicated volumes per vm-host which all
    // contain all "golden-images" which are used for snapshotting.
    // We do this to overcome the current lvm limitation of not supporting cluster-wide snapshots
    //
    // Still we need to send the remove command to the storage resource since the
    // create-phase automatically adapted the image->storageid, we cannot use the vm-resource here
    // because cloudimage->resource_id will be set to -1 when the cloudapp is in paused/resize/private state
    //
    if ($cloudimage->resource_id > 0) {
        // try to get the vm resource
        $vm_resource = new resource();
        $vm_resource->get_instance_by_id($cloudimage->resource_id);
        // get the lxc host
        $vm_host_resource = new resource();
        $vm_host_resource->get_instance_by_id($vm_resource->vhostid);
        // san backend ?
        if ($vm_host_resource->id != $resource->id) {
            $event->log("create_private_kvm_lvm_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-cloud-hook.php", "Image " . $image_id . " IS NOT available on this kvm host, " . $resource->id . " not equal " . $vm_host_resource->id . " !! Assuming SAN Backend", "", "", 0, 0, 0);
        } else {
            $event->log("create_private_kvm_lvm_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-cloud-hook.php", "Image " . $image_id . " IS available on this kvm host, " . $resource->id . " equal " . $vm_host_resource->id . ".", "", "", 0, 0, 0);
        }
    }
    $image_resize_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm clone -n " . $image_location_name . " -s " . $private_image_name . " -v " . $volume_group . " -m " . $private_disk . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " -t " . $deployment->type . " --openqrm-cmd-mode background";
    $event->log("create_private_kvm_lvm_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-lvm-deployment-cloud-hook.php", "Running : {$image_resize_cmd}", "", "", 0, 0, 0);
    $resource->send_command($resource_ip, $image_resize_cmd);
    // set the storage specific image root_device parameter
    $new_rootdevice = str_replace($image_location_name, $private_image_name, $image->rootdevice);
    return $new_rootdevice;
}
Ejemplo n.º 12
0
 function select()
 {
     $d = array();
     $h = array();
     $h['storage_state']['title'] = $this->lang['table_state'];
     $h['storage_state']['sortable'] = false;
     $h['storage_id']['title'] = $this->lang['table_id'];
     $h['storage_id']['hidden'] = true;
     $h['storage_name']['title'] = $this->lang['table_name'];
     $h['storage_name']['hidden'] = true;
     $h['storage_resource_id']['title'] = $this->lang['table_resource'];
     $h['storage_resource_id']['hidden'] = true;
     $h['storage_type']['title'] = $this->lang['table_type'];
     $h['storage_type']['hidden'] = true;
     $h['data']['title'] = '&#160;';
     $h['data']['sortable'] = false;
     $h['storage_comment']['title'] = '&#160;';
     $h['storage_comment']['sortable'] = false;
     $h['storage_edit']['title'] = '&#160;';
     $h['storage_edit']['sortable'] = false;
     $storage = new storage();
     $params = $this->response->get_array($this->actions_name, 'select');
     $b = array();
     unset($params['storage_filter']);
     $table = $this->response->html->tablebuilder('storage', $params);
     $table->offset = 0;
     $table->sort = 'storage_id';
     $table->limit = 20;
     $table->order = 'ASC';
     $table->max = $storage->get_count();
     $table->init();
     $storages = $storage->display_overview(0, 10000, $table->sort, $table->order);
     // handle table params
     $tps = $table->get_params();
     $tp = '';
     foreach ($tps['storage'] as $k => $v) {
         $tp .= '&storage[' . $k . ']=' . $v;
     }
     $i = 0;
     $deployment = new deployment();
     foreach ($storages as $key => $value) {
         $storage = new storage();
         $storage->get_instance_by_id($value["storage_id"]);
         $resource = new resource();
         $resource->get_instance_by_id($storage->resource_id);
         $deployment = new deployment();
         $deployment->get_instance_by_id($storage->type);
         $resource_icon_default = "/img/resource.png";
         $storage_icon = '/plugins/' . $deployment->storagetype . '/img/plugin.png';
         $state_icon = '<span class="pill ' . $resource->state . '">' . $resource->state . '</span>';
         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;
         $data = '<b>' . $this->lang['table_id'] . ':</b> ' . $value["storage_id"] . '<br>';
         $data .= '<b>' . $this->lang['table_name'] . ':</b> ' . $value["storage_name"] . '<br>';
         $data .= '<b>' . $this->lang['table_resource'] . ':</b> ' . $resource->id . ' / ' . $resource->ip . '<br>';
         $data .= '<b>' . $this->lang['table_type'] . ':</b> ' . $deployment->storagetype . '<br>';
         $data .= '<b>' . $this->lang['table_deployment'] . ':</b> ' . $deployment->storagedescription;
         $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") . '&storage_id=' . $storage->id . '' . $tp;
         $edit = $a->get_string();
         #$url  = $this->openqrm->get('baseurl').'/index.php?plugin='.$deployment->storagetype.'&'.str_replace('-', '_',$deployment->storagetype).'_action=edit&storage_id='.$value["storage_id"];
         $url = $this->response->get_url($this->actions_name, 'load') . '&splugin=' . $deployment->storagetype . '&' . str_replace('-', '_', $deployment->storagetype) . '_action=edit&storage_id=' . $value["storage_id"];
         if ($deployment->storagetype === 'equallogic-storage' || $deployment->storagetype === 'netapp-storage' || $deployment->storagetype === 'vbox') {
             $url = $this->openqrm->get('baseurl') . '/index.php?plugin=' . $deployment->storagetype . '&currenttab=tab0&action=select&identifier[]=' . $storage->id;
         }
         $a = $this->response->html->a();
         $a->title = $this->lang['action_mgmt'];
         $a->label = $this->lang['action_mgmt'];
         $a->handler = 'onclick="wait();"';
         $a->css = 'manage';
         $a->href = $url;
         // no mgmt for local-server resources
         if (strstr($storage->capabilities, "TYPE=local-server")) {
             $mgmt = '&#160;';
         } else {
             $mgmt = $a->get_string();
         }
         if ($this->response->html->request()->get('storage_filter') === '' || strstr($this->response->html->request()->get('storage_filter'), $deployment->storagetype)) {
             $b[] = array('storage_state' => $state_icon, 'storage_id' => $value["storage_id"], 'storage_name' => $value["storage_name"], 'storage_type' => '', 'storage_resource_id' => "", 'data' => $data, 'storage_comment' => $value["storage_comment"], 'storage_edit' => $edit . $mgmt);
         }
         $i++;
     }
     $list = $deployment->get_storagetype_list();
     $filter = array();
     $filter[] = array('', '');
     foreach ($list as $l) {
         $filter[] = array($l['value'], ucfirst($l['label']));
     }
     asort($filter);
     $select = $this->response->html->select();
     $select->add($filter, array(0, 1));
     $select->name = 'storage_filter';
     $select->handler = 'onchange="wait();this.form.submit();return false;"';
     $select->selected = array($this->response->html->request()->get('storage_filter'));
     $box = $this->response->html->box();
     $box->add($select);
     $box->id = 'storages_filter';
     $box->css = 'htmlobject_box';
     $box->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, "add") . '' . $tp;
     $table->id = 'Tabelle';
     $table->css = 'htmlobject_table';
     $table->border = 1;
     $table->cellspacing = 0;
     $table->cellpadding = 3;
     $table->autosort = false;
     $table->sort_link = false;
     $table->head = $h;
     $table->body = $b;
     $table->max = count($b);
     $table->actions_name = $this->actions_name;
     $table->actions = array(array('remove' => $this->lang['action_remove']));
     $table->identifier = 'storage_id';
     $table->identifier_name = $this->identifier_name;
     $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['filter'] = $box->get_string();
     $d['table'] = $table;
     return $d;
 }
 function action()
 {
     $response = $this->removevg();
     $deployment = new deployment();
     $deployment->get_instance_by_id($this->storage->type);
     if (isset($response->error)) {
         $_REQUEST[$this->message_param] = $response->error;
     }
     if (isset($response->msg)) {
         $this->response->redirect($this->response->get_url($this->actions_name, 'edit', $this->message_param, $response->msg));
     }
     $data['confirm_text'] = sprintf($this->lang['confirm_text'], $this->response->html->request()->get('volgroup'));
     $data['plugin'] = $deployment->storagetype;
     $data['label'] = sprintf($this->lang['label'], $this->storage->name);
     $data['baseurl'] = $this->openqrm->get('baseurl');
     $data['thisfile'] = $response->html->thisfile;
     $t = $response->html->template($this->tpldir . '/device-manager-removevg.tpl.php');
     $t->add($response->form);
     $t->add($data);
     $t->group_elements(array('param_' => 'form'));
     return $t;
 }
Ejemplo n.º 14
0
 function init()
 {
     $storage_id = $this->response->html->request()->get('storage_id');
     if ($storage_id === '') {
         return false;
     }
     // set ENV
     $deployment = new deployment();
     $storage = new storage();
     $resource = new resource();
     $storage->get_instance_by_id($storage_id);
     $resource->get_instance_by_id($storage->resource_id);
     $deployment->get_instance_by_id($storage->type);
     $this->resource = $resource;
     $this->storage = $storage;
     $this->deployment = $deployment;
 }
Ejemplo n.º 15
0
 function snap()
 {
     $response = $this->get_response();
     $form = $response->form;
     if (!$form->get_errors() && $this->response->submit()) {
         if ($form->get_request('size') > $this->max) {
             $form->set_error('size', sprintf($this->lang['error_size_exeeded'], number_format($this->max, 0, '', '')));
         }
         if (!$form->get_errors()) {
             $storage_id = $this->response->html->request()->get('storage_id');
             $storage = new storage();
             $resource = new resource();
             $deployment = new deployment();
             $storage->get_instance_by_id($storage_id);
             $resource->get_instance_by_id($storage->resource_id);
             $deployment->get_instance_by_id($storage->type);
             $name = $form->get_request('name');
             $command = $this->openqrm->get('basedir') . '/plugins/lvm-storage/bin/openqrm-lvm-storage snap';
             $command .= ' -t ' . $this->deployment->type;
             $command .= ' -v ' . $this->volgroup;
             $command .= ' -n ' . $this->lvol;
             $command .= ' -m ' . $form->get_request('size');
             $command .= ' -s ' . $name;
             $command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
             $command .= ' --openqrm-ui-user ' . $this->user->name;
             $command .= ' --openqrm-cmd-mode background';
             if ($this->deployment->type === 'lvm-iscsi-deployment') {
                 $image = new image();
                 $command .= ' -i ' . $image->generatePassword(12);
             }
             $statfile = $this->openqrm->get('basedir') . '/plugins/lvm-storage/web/storage/' . $this->resource->id . '.' . $this->volgroup . '.lv.stat';
             if (file_exists($statfile)) {
                 $lines = explode("\n", file_get_contents($statfile));
                 if (count($lines) >= 1) {
                     foreach ($lines as $line) {
                         if ($line !== '') {
                             $line = explode('@', $line);
                             $check = $line[1];
                             if ($name === $check) {
                                 $error = sprintf($this->lang['error_exists'], $name);
                             }
                         }
                     }
                 }
             }
             if (isset($error)) {
                 $response->error = $error;
             } else {
                 if (file_exists($statfile)) {
                     unlink($statfile);
                 }
                 $this->resource->send_command($this->resource->ip, $command);
                 while (!file_exists($statfile)) {
                     usleep(10000);
                     // sleep 10ms to unload the CPU
                     clearstatcache();
                 }
                 switch ($this->deployment->type) {
                     case 'lvm-aoe-deployment':
                         // for lvm-aoe deployment we need to get the shelf + slot from get_root_identifiert
                         $ident_file = $this->openqrm->get('basedir') . '/plugins/lvm-storage/web/storage/' . $this->resource->id . '.lv.lvm-aoe-deployment.ident';
                         $get_ident_command = $this->openqrm->get('basedir') . '/plugins/lvm-storage/bin/openqrm-lvm-storage post_identifier';
                         $get_ident_command .= ' -t ' . $this->deployment->type . ' -v ' . $this->volgroup;
                         $get_ident_command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
                         $ident_file = $this->openqrm->get('basedir') . '/plugins/lvm-storage/web/storage/' . $this->resource->id . '.lv.lvm-aoe-deployment.ident';
                         if (file_exists($ident_file)) {
                             unlink($ident_file);
                         }
                         $this->resource->send_command($this->resource->ip, $get_ident_command);
                         while (!file_exists($ident_file)) {
                             usleep(10000);
                             // sleep 10ms to unload the CPU
                             clearstatcache();
                         }
                         $ident_lines = explode("\n", file_get_contents($ident_file));
                         if (count($ident_lines) >= 1) {
                             foreach ($ident_lines as $ident_line) {
                                 if ($ident_line !== '') {
                                     $ident_line = explode(',', $ident_line);
                                     $ident_root_path = explode(':', $ident_line[1]);
                                     $ident_check = $ident_root_path[1];
                                     if ($name === $ident_check) {
                                         $volume_path = $ident_line[1];
                                         $rootfstype = 'ext3';
                                         break;
                                     }
                                 }
                             }
                         }
                         break;
                     case 'lvm-nfs-deployment':
                         $volume_path = '/' . $this->volgroup . '/' . $name;
                         $rootfstype = 'nfs';
                         break;
                     case 'lvm-iscsi-deployment':
                         $volume_path = $this->volgroup . ':/dev/' . $name . '/1';
                         $rootfstype = 'ext3';
                         break;
                 }
                 $tables = $this->openqrm->get('table');
                 $image_fields = array();
                 $image_fields["image_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
                 $image_fields['image_name'] = $name;
                 $image_fields['image_type'] = $deployment->type;
                 $image_fields['image_rootfstype'] = $rootfstype;
                 $image_fields['image_storageid'] = $storage->id;
                 $image_fields['image_comment'] = "Image Object for volume {$name}";
                 $image_fields['image_rootdevice'] = $volume_path;
                 $image = new image();
                 $image->add($image_fields);
                 $response->msg = sprintf($this->lang['msg_snaped'], $this->lvol, $name);
                 // save image id in response for the wizard
                 $response->image_id = $image_fields["image_id"];
             }
         }
     }
     return $response;
 }
function create_private_kvm_gluster_deployment($cloud_image_id, $private_disk, $private_image_name)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $cloudimage = new cloudimage();
    $cloudimage->get_instance_by_id($cloud_image_id);
    $event->log("create_private_kvm_gluster_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-gluster-deployment-cloud-hook.php", "Creating private image " . $cloudimage->image_id . " on storage.", "", "", 0, 0, 0);
    // get image
    $image = new image();
    $image->get_instance_by_id($cloudimage->image_id);
    $image_id = $image->id;
    $image_name = $image->name;
    $image_type = $image->type;
    $image_version = $image->version;
    $image_rootdevice = $image->rootdevice;
    $image_rootfstype = $image->rootfstype;
    $imageid = $image->storageid;
    $image_isshared = $image->isshared;
    $image_comment = $image->comment;
    $image_capabilities = $image->capabilities;
    $image_deployment_parameter = $image->deployment_parameter;
    // get image storage
    $storage = new storage();
    $storage->get_instance_by_id($imageid);
    $storage_resource_id = $storage->resource_id;
    // get deployment type
    $deployment = new deployment();
    $deployment->get_instance_by_id($storage->type);
    // get storage resource
    $resource = new resource();
    $resource->get_instance_by_id($storage_resource_id);
    $resource_id = $resource->id;
    $resource_ip = $resource->ip;
    // create an admin user to post when cloning has finished
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    $gluster_uri_arr = parse_url($image_rootdevice);
    // origin image volume name
    $origin_volume_name = basename($gluster_uri_arr['path']);
    // location of the volume (path)
    $image_location_name = str_replace('/', '', dirname($gluster_uri_arr['path']));
    $image_clone_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm clone -n " . $origin_volume_name . " -s " . $private_image_name . " -v " . $image_location_name . " -m " . $private_disk . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " -t " . $deployment->type . " --openqrm-cmd-mode background";
    $event->log("create_private_kvm_gluster_deployment", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-gluster-deployment-cloud-hook.php", "Running : {$image_resize_cmd}", "", "", 0, 0, 0);
    $resource->send_command($resource->ip, $image_clone_cmd);
    // set the storage specific image root_device parameter
    $new_rootdevice = "gluster:" . $resource->ip . "//" . $image_location_name . "/" . $private_image_name;
    return $new_rootdevice;
}
Ejemplo n.º 17
0
 function select()
 {
     // set ENV
     $deployment = new deployment();
     $storage = new storage();
     $resource = new resource();
     $deployment->get_instance_by_type("linuxcoe-deployment");
     $table = $this->response->html->tablebuilder('linuxcoe_select', $this->response->get_array($this->actions_name, 'select'));
     $table->sort = 'storage_id';
     $table->limit = 10;
     $table->offset = 0;
     $table->order = 'ASC';
     $table->max = $storage->get_count_per_type($deployment->id);
     $table->autosort = false;
     $table->sort_link = false;
     $table->init();
     $storages = $storage->display_overview_per_type($deployment->id, $table->offset, $table->limit, $table->sort, $table->order);
     if (count($storages) >= 1) {
         foreach ($storages as $k => $v) {
             $storage->get_instance_by_id($v["storage_id"]);
             $resource->get_instance_by_id($storage->resource_id);
             $deployment->get_instance_by_id($storage->type);
             $resource_icon_default = "/img/resource.png";
             $storage_icon = "/plugins/linuxcoe/img/plugin.png";
             $state_icon = $this->openqrm->get('baseurl') . "/img/" . $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;
             $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") . '&storage_id=' . $storage->id;
             $data = '<b>' . $this->lang['table_recource'] . ':</b> ' . $resource->id . ' / ' . $resource->ip . '<br>';
             $data .= '<b>' . $this->lang['table_type'] . ':</b> ' . $deployment->type . '<br>';
             $data .= '<b>' . $this->lang['table_deployment'] . ':</b> ' . $deployment->storagedescription . '<br>';
             $b[] = array('state' => '<img width="24" height="24" src="' . $state_icon . '" alt="State">', 'icon' => '<img width="24" height="24" src="' . $resource_icon_default . '" alt="Icon">', 'storage_id' => $storage->id, 'storage_name' => $storage->name, 'storage_resource_id' => $storage->resource_id, 'storage_data' => $data, 'storage_comment' => '', 'storage_edit' => $a->get_string());
         }
         $h = array();
         $h['state'] = array();
         $h['state']['title'] = '&#160;';
         $h['state']['sortable'] = false;
         $h['icon'] = array();
         $h['icon']['title'] = '&#160;';
         $h['icon']['sortable'] = false;
         $h['storage_id'] = array();
         $h['storage_id']['title'] = $this->lang['table_id'];
         $h['storage_name'] = array();
         $h['storage_name']['title'] = $this->lang['table_name'];
         $h['storage_resource_id'] = array();
         $h['storage_resource_id']['title'] = $this->lang['table_recource'];
         $h['storage_resource_id']['hidden'] = true;
         $h['storage_data'] = array();
         $h['storage_data']['title'] = '&#160;';
         $h['storage_data']['sortable'] = false;
         $h['storage_comment'] = array();
         $h['storage_comment']['title'] = '&#160;';
         $h['storage_comment']['sortable'] = false;
         $h['storage_edit'] = array();
         $h['storage_edit']['title'] = '&#160;';
         $h['storage_edit']['sortable'] = 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 = $b;
         $table->limit_select = array(array("value" => 10, "text" => 10), array("value" => 20, "text" => 20), array("value" => 30, "text" => 30), array("value" => 40, "text" => 40), array("value" => 50, "text" => 50));
         return $table->get_string();
     } else {
         $a = $this->response->html->a();
         $a->title = $this->lang['new_storage'];
         $a->label = $this->lang['new_storage'];
         $a->handler = 'onclick="wait();"';
         $a->css = 'add';
         $a->href = $this->response->html->thisfile . '?base=storage&storage_action=add';
         $box = $this->response->html->div();
         $box->id = 'Tabelle';
         $box->css = 'htmlobject_box';
         $content = $this->lang['error_no_storage'] . '<br><br>';
         $content .= $a->get_string();
         $box->add($content);
         return $box->get_string();
     }
 }
Ejemplo n.º 18
0
 function init()
 {
     $storage_id = $this->response->html->request()->get('storage_id');
     if ($storage_id === '') {
         return false;
     }
     // set ENV
     $deployment = new deployment();
     $storage = new storage();
     $resource = new resource();
     $storage->get_instance_by_id($storage_id);
     $resource->get_instance_by_id($storage->resource_id);
     $deployment->get_instance_by_id($storage->type);
     $this->resource = $resource;
     $this->storage = $storage;
     $this->deployment = $deployment;
     if (!$this->file->exists($this->openqrm->get('basedir') . '/plugins/nfs-storage/web/storage/' . $resource->id . '.nfs.stat.manual')) {
         $this->statfile = $this->openqrm->get('basedir') . '/plugins/nfs-storage/web/storage/' . $resource->id . '.nfs.stat';
     } else {
         $this->response->redirect($this->response->get_url($this->actions_name, 'manual', $this->message_param, $this->lang['manual_configured']));
     }
 }
Ejemplo n.º 19
0
 function init()
 {
     $storage_id = $this->response->html->request()->get('storage_id');
     if ($storage_id === '') {
         return false;
     }
     // set ENV
     $deployment = new deployment();
     $storage = new storage();
     $resource = new resource();
     $storage->get_instance_by_id($storage_id);
     $resource->get_instance_by_id($storage->resource_id);
     $deployment->get_instance_by_id($storage->type);
     $this->resource = $resource;
     $this->storage = $storage;
     $this->deployment = $deployment;
     $this->response->add('storage_id', $storage_id);
     $this->response->add('volgroup', $this->volgroup);
     $this->statfile = $this->openqrm->get('basedir') . '/plugins/lvm-storage/web/storage/' . $resource->id . '.' . $this->volgroup . '.lv.stat';
 }
Ejemplo n.º 20
0
 function select()
 {
     // set ENV
     $deployment = new deployment();
     $storage = new storage();
     $resource = new resource();
     $type = $this->response->html->request()->get('storage_type');
     if ($type === '') {
         $type = 'lvm-lvm-deployment';
     }
     $deployment->get_instance_by_type($type);
     $storages = $storage->display_overview(0, $storage->get_count(), 'storage_id', 'ASC');
     if (count($storages) >= 1) {
         foreach ($storages as $k => $v) {
             $storage->get_instance_by_id($v["storage_id"]);
             $resource->get_instance_by_id($storage->resource_id);
             $deployment->get_instance_by_id($storage->type);
             if ($deployment->storagetype === 'lvm-storage') {
                 $resource_icon_default = "/img/resource.png";
                 $storage_icon = "/plugins/lvm-storage/img/plugin.png";
                 $state_icon = '<span class="pill">' . $resource->state . '</span>';
                 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;
                 $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") . '&storage_id=' . $storage->id;
                 $data = '<strong>' . $this->lang['table_recource'] . ':</strong> ' . $resource->id . ' / ' . $resource->ip . '<br>';
                 $data .= '<strong>' . $this->lang['table_type'] . ':</strong> <span class="pill">' . $deployment->storagetype . '</span><br>';
                 $data .= '<strong>' . $this->lang['table_deployment'] . ':</strong> ' . $deployment->storagedescription . '<br>';
                 $b[] = array('state' => $state_icon, 'storage_id' => $storage->id, 'name' => $storage->name, 'storage_resource_id' => $storage->resource_id, 'deployment' => $deployment->storagedescription, 'storage_data' => $data, 'storage_comment' => '', 'edit' => $a->get_string());
             }
         }
         if (isset($b) && is_array($b) && count($b) >= 1) {
             $h = array();
             $h['state'] = array();
             $h['state']['title'] = '&#160;';
             $h['state']['sortable'] = false;
             /*
             				$h['icon'] = array();
             				$h['icon']['title'] ='&#160;';
             				$h['icon']['sortable'] = false;
             */
             $h['storage_id'] = array();
             $h['storage_id']['title'] = $this->lang['table_id'];
             $h['name'] = array();
             $h['name']['title'] = $this->lang['table_name'];
             $h['storage_resource_id'] = array();
             $h['storage_resource_id']['title'] = $this->lang['table_recource'];
             $h['storage_resource_id']['hidden'] = true;
             $h['storage_data'] = array();
             $h['storage_data']['title'] = '&#160;';
             $h['storage_data']['sortable'] = false;
             $h['deployment'] = array();
             $h['deployment']['title'] = $this->lang['table_deployment'];
             $h['deployment']['hidden'] = true;
             $h['storage_comment'] = array();
             $h['storage_comment']['title'] = '&#160;';
             $h['storage_comment']['sortable'] = false;
             $h['edit'] = array();
             $h['edit']['title'] = '&#160;';
             $h['edit']['sortable'] = false;
             $table = $this->response->html->tablebuilder('lvm', $this->response->get_array($this->actions_name, 'select'));
             $table->sort = 'storage_id';
             $table->limit = 10;
             $table->order = 'ASC';
             $table->max = count($b);
             $table->autosort = false;
             $table->sort_link = false;
             $table->autosort = true;
             $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 = $b;
             return $table->get_string();
         } else {
             $a = $this->response->html->a();
             $a->title = $this->lang['new_storage'];
             $a->label = $this->lang['new_storage'];
             $a->handler = 'onclick="wait();"';
             $a->css = 'add';
             $a->href = $this->response->html->thisfile . '?base=storage&storage_action=add';
             $box = $this->response->html->div();
             $box->id = 'Tabelle';
             $box->css = 'htmlobject_box';
             $content = $this->lang['error_no_storage'] . '<br><br>';
             $content .= $a->get_string();
             $box->add($content);
             return $box->get_string();
         }
     } else {
         $a = $this->response->html->a();
         $a->title = $this->lang['new_storage'];
         $a->label = $this->lang['new_storage'];
         $a->handler = 'onclick="wait();"';
         $a->css = 'add';
         $a->href = $this->response->html->thisfile . '?base=storage&storage_action=add';
         $box = $this->response->html->div();
         $box->id = 'Tabelle';
         $box->css = 'htmlobject_box';
         $content = $this->lang['error_no_storage'] . '<br><br>';
         $content .= $a->get_string();
         $box->add($content);
         return $box->get_string();
     }
 }
Ejemplo n.º 21
0
 function action()
 {
     $deployment = new deployment();
     $deployment_id_array = $deployment->get_deployment_ids();
     $info = '<div class="infotext">' . $this->lang['info'] . '</div>';
     $storage_link_section = '';
     if (isset($this->appliance)) {
         $resource = new resource();
         $resource->get_instance_by_id($this->appliance->resources);
         $virtualization = new virtualization();
         $virtualization->get_instance_by_id($resource->vtype);
         #$resourceinfo  = '<b>Server:</b> '.$this->appliance->id.' / '.$this->appliance->name.'<br>';
         $info = '<b>Resource:</b> ' . $resource->id . ' / ' . $resource->ip . ' ' . $resource->hostname . ' - ' . $virtualization->name . '<br><br>' . $info;
         foreach ($deployment_id_array as $id) {
             $new_image_link = '';
             $deployment->get_instance_by_id($id['deployment_id']);
             if ($deployment->storagetype != 'none' && $deployment->storagetype != 'local-server') {
                 if (strstr($resource->capabilities, "TYPE=local-server")) {
                     // disable - local-server already has an image and cannot be re-deployed with a differenet one
                     continue;
                 } else {
                     if (strstr($virtualization->type, "-vm-local")) {
                         // get virt plugin name, check if deployment->storagetype == virt plugin name
                         if ($deployment->storagetype === $virtualization->get_plugin_name()) {
                             $new_image_link = $this->response->get_url($this->actions_name, 'load') . '&iplugin=' . $deployment->storagetype;
                         }
                     } else {
                         if (strstr($virtualization->type, "-vm-net")) {
                             // find with image-deployment type hook if deployment is network-deployment
                             $is_network_deployment = false;
                             $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}";
                                 $image_is_network_deployment_function = "get_" . $deployment->type . "_is_network_deployment";
                                 $image_is_network_deployment_function = str_replace("-", "_", $image_is_network_deployment_function);
                                 if ($image_is_network_deployment_function()) {
                                     $new_image_link = $this->response->get_url($this->actions_name, 'load') . '&iplugin=' . $deployment->storagetype;
                                 }
                             }
                         } else {
                             // $new_image_link = "/openqrm/base/index.php?plugin=".$deployment->storagetype;
                             // same as vm-net
                             // all network deployment types
                         }
                     }
                 }
                 if ($new_image_link !== '') {
                     $storage_link_section .= "<a href='" . $new_image_link . "' style='text-decoration: none'><img title='" . sprintf($this->lang['create_image'], $deployment->description) . "' alt='" . sprintf($this->lang['create_image'], $deployment->description) . "' src='/openqrm/base/plugins/" . $deployment->storagetype . "/img/plugin.png' border=0> " . $deployment->description . "</a><br>";
                 }
             }
         }
     } else {
         foreach ($deployment_id_array as $deployment_id) {
             $deployment->get_instance_by_id($deployment_id['deployment_id']);
             if ($deployment->storagetype != 'none' && $deployment->storagetype != 'local-server') {
                 #$new_image_link = "/openqrm/base/index.php?plugin=".$deployment->storagetype;
                 $new_image_link = $this->response->get_url($this->actions_name, 'load') . '&iplugin=' . $deployment->storagetype;
                 switch ($deployment->storagetype) {
                     case 'coraid-storage':
                     case 'equallogic-storage':
                     case 'netapp-storage':
                         $new_image_link = "/openqrm/base/index.php?iframe=/openqrm/base/plugins/" . $deployment->storagetype . "/" . $deployment->storagetype . "-manager.php";
                         break;
                 }
                 $storage_link_section .= "<a href='" . $new_image_link . "' style='text-decoration: none'><img title='" . sprintf($this->lang['create_image'], $deployment->description) . "' alt='" . sprintf($this->lang['create_image'], $deployment->description) . "' src='/openqrm/base/plugins/" . $deployment->storagetype . "/img/plugin.png' border=0> " . $deployment->description . "</a><br>";
             }
         }
     }
     if (!strlen($storage_link_section)) {
         $storage_link_section = $this->lang['start_storage_plugin'];
     }
     $t = $this->response->html->template($this->tpldir . '/image-add.tpl.php');
     $t->add($storage_link_section, 'image_new');
     $t->add($this->lang['label'], 'label');
     $t->add($this->lang['title'], 'title');
     $t->add($this->openqrm->get('baseurl'), 'baseurl');
     $t->add($this->lang['please_wait'], 'please_wait');
     $t->add($this->lang['canceled'], 'canceled');
     $t->add($this->prefix_tab, 'prefix_tab');
     $t->add($info, 'info');
     $t->group_elements(array('param_' => 'form'));
     return $t;
 }
Ejemplo n.º 22
0
 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 storage_auth_deployment_stop($image_id)
{
    global $event;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    $image = new image();
    $image->get_instance_by_id($image_id);
    $image_name = $image->name;
    $image_rootdevice = $image->rootdevice;
    $storage = new storage();
    $storage->get_instance_by_id($image->storageid);
    $storage_resource = new resource();
    $storage_resource->get_instance_by_id($storage->resource_id);
    $storage_ip = $storage_resource->ip;
    $deployment = new deployment();
    $deployment->get_instance_by_type($image->type);
    $deployment_type = $deployment->type;
    $deployment_plugin_name = $deployment->storagetype;
    // just for sending the commands
    $resource = new resource();
    // get install deployment params
    $install_from_nfs_param = trim($image->get_deployment_parameter("IMAGE_INSTALL_FROM_NFS"));
    if (strlen($install_from_nfs_param)) {
        // storage -> resource -> auth
        $ip_storage_id = $deployment->parse_deployment_parameter("id", $install_from_nfs_param);
        $ip_storage_ip = $deployment->parse_deployment_parameter("ip", $install_from_nfs_param);
        $ip_image_rootdevice = $deployment->parse_deployment_parameter("path", $install_from_nfs_param);
        $ip_storage = new storage();
        $ip_storage->get_instance_by_id($ip_storage_id);
        $ip_storage_resource = new resource();
        $ip_storage_resource->get_instance_by_id($ip_storage->resource_id);
        $op_storage_ip = $ip_storage_resource->ip;
        $ip_deployment = new deployment();
        $ip_deployment->get_instance_by_id($ip_storage->type);
        $ip_deployment_type = $ip_deployment->type;
        $ip_deployment_plugin_name = $ip_deployment->storagetype;
        $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-lvm-nfs-deployment-auth-hook.php", "Install-from-NFS: Authenticating {$resource_ip} on storage id {$ip_storage_id}:{$ip_storage_ip}:{$ip_image_rootdevice}", "", "", 0, 0, $resource_id);
        $auth_install_from_nfs_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $ip_deployment_plugin_name . "/bin/openqrm-" . $ip_deployment_plugin_name . " auth -r " . $ip_image_rootdevice . " -i " . $OPENQRM_SERVER_IP_ADDRESS . " -t " . $ip_deployment_type . " --openqrm-cmd-mode background";
        $resource->send_command($ip_storage_ip, $auth_install_from_nfs_start_cmd);
    }
    // get transfer deployment params
    $transfer_from_nfs_param = trim($image->get_deployment_parameter("IMAGE_TRANSFER_TO_NFS"));
    if (strlen($transfer_from_nfs_param)) {
        // storage -> resource -> auth
        $tp_storage_id = $deployment->parse_deployment_parameter("id", $transfer_from_nfs_param);
        $tp_storage_ip = $deployment->parse_deployment_parameter("ip", $transfer_from_nfs_param);
        $tp_image_rootdevice = $deployment->parse_deployment_parameter("path", $transfer_from_nfs_param);
        $tp_storage = new storage();
        $tp_storage->get_instance_by_id($tp_storage_id);
        $tp_storage_resource = new resource();
        $tp_storage_resource->get_instance_by_id($tp_storage->resource_id);
        $op_storage_ip = $tp_storage_resource->ip;
        $tp_deployment = new deployment();
        $tp_deployment->get_instance_by_id($tp_storage->type);
        $tp_deployment_type = $tp_deployment->type;
        $tp_deployment_plugin_name = $tp_deployment->storagetype;
        $event->log("storage_auth_function", $_SERVER['REQUEST_TIME'], 5, "openqrm-lvm-nfs-deployment-auth-hook.php", "Install-from-NFS: Authenticating {$resource_ip} on storage id {$tp_storage_id}:{$tp_storage_ip}:{$tp_image_rootdevice}", "", "", 0, 0, $resource_id);
        $auth_install_from_nfs_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $tp_deployment_plugin_name . "/bin/openqrm-" . $tp_deployment_plugin_name . " auth -r " . $tp_image_rootdevice . " -i " . $OPENQRM_SERVER_IP_ADDRESS . " -t " . $tp_deployment_type . " --openqrm-cmd-mode background";
        $resource->send_command($tp_storage_ip, $auth_install_from_nfs_start_cmd);
    }
}
Ejemplo n.º 24
0
 function get_response()
 {
     $response = $this->response;
     $form = $response->get_form($this->actions_name, 'step3');
     $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);
     }
     $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');
     // prepare image list according to the resource capabilities + vtype
     $image = new image();
     $list = $image->get_list();
     unset($list[0]);
     unset($list[1]);
     $images = array();
     // openQRM
     if ($resource->id == 0) {
         $images[] = array(0, 'Local openQRM Installation');
         // local-server integrated resource
     } else {
         if (strstr($resource->capabilities, "TYPE=local-server")) {
             $local_image = new image();
             $local_image->get_instance_by_id($resource->imageid);
             $images[] = array($local_image->id, 'Local OS Installation');
             // local-deployment VMs
         } else {
             if (strstr($virtualization->type, "-vm-local")) {
                 $virtualization_plugin_name = $virtualization->get_plugin_name();
                 $deployment = new deployment();
                 $deployment_id_arr = $deployment->get_deployment_ids();
                 $possible_deployment_types_arr = '';
                 foreach ($deployment_id_arr as $deployment_id_db) {
                     $deployment_id = $deployment_id_db['deployment_id'];
                     $deployment->get_instance_by_id($deployment_id);
                     if ($deployment->storagetype === $virtualization_plugin_name) {
                         $possible_deployment_types_arr[] = $deployment->type;
                     }
                 }
                 // filter image list with only the images from the VM deployment type
                 foreach ($list as $value) {
                     $image_id = $value['value'];
                     $image->get_instance_by_id($image_id);
                     // is image active ? then do not show it here
                     if ($image->isactive == 1) {
                         continue;
                     }
                     if (!in_array($image->type, $possible_deployment_types_arr)) {
                         continue;
                     }
                     // filter local-server images
                     $images[] = array($image_id, $image->id . ' / ' . $image->name . ' (' . $image->type . ')');
                 }
                 // network-deployment - show only network-boot images
             } else {
                 if (strstr($virtualization->type, "-vm-net")) {
                     foreach ($list as $value) {
                         $image_id = $value['value'];
                         $image->get_instance_by_id($image_id);
                         // is image active ? then do not show it here
                         if ($image->isactive == 1) {
                             continue;
                         }
                         // filter local-server images
                         if (strstr($image->capabilities, "TYPE=local-server")) {
                             continue;
                         }
                         $is_network_deployment = false;
                         if ($image->is_network_deployment() === true) {
                             $is_network_deployment = true;
                         }
                         if ($is_network_deployment) {
                             $images[] = array($image_id, $image->id . ' / ' . $image->name . ' (' . $image->type . ')');
                         }
                     }
                     // network deployment - physical systems - show only network-boot images
                 } else {
                     foreach ($list as $value) {
                         $image_id = $value['value'];
                         $image->get_instance_by_id($image_id);
                         // is image active ? then do not show it here
                         if ($image->isactive == 1) {
                             continue;
                         }
                         // filter local-server images
                         if (strstr($image->capabilities, "TYPE=local-server")) {
                             continue;
                         }
                         $is_network_deployment = false;
                         if ($image->is_network_deployment() === true) {
                             $is_network_deployment = true;
                         }
                         if ($is_network_deployment) {
                             $images[] = array($image_id, $image->id . ' / ' . $image->name . ' (' . $image->type . ')');
                         }
                     }
                 }
             }
         }
     }
     // handle appliance is new or edited
     $selected = $this->response->html->request()->get('image_id');
     if ($selected === '' && isset($this->appliance->imageid)) {
         $selected = $this->appliance->imageid;
     }
     $d['image']['label'] = $this->lang['form_image'];
     $d['image']['required'] = true;
     $d['image']['object']['type'] = 'htmlobject_select';
     $d['image']['object']['attrib']['index'] = array(0, 1);
     $d['image']['object']['attrib']['id'] = 'image';
     $d['image']['object']['attrib']['name'] = 'image';
     $d['image']['object']['attrib']['options'] = $images;
     $d['image']['object']['attrib']['selected'] = array($selected);
     $d['image_edit'] = '';
     if ($this->appliance->resources != 0) {
         $d['image_edit']['label'] = $this->lang['form_image_edit'];
         $d['image_edit']['object']['type'] = 'htmlobject_input';
         $d['image_edit']['object']['attrib']['type'] = 'checkbox';
         $d['image_edit']['object']['attrib']['id'] = 'image_edit';
         $d['image_edit']['object']['attrib']['name'] = 'image_edit';
         $d['image_edit']['object']['attrib']['checked'] = true;
     }
     $form->add($d);
     $response->form = $form;
     return $response;
 }
Ejemplo n.º 25
0
 function __reload($mode)
 {
     $OPENQRM_SERVER_BASE_DIR = $this->openqrm->get('basedir');
     $storage_id = $this->response->html->request()->get('storage_id');
     $volgroup = $this->response->html->request()->get('volgroup');
     $storage = new storage();
     $resource = new resource();
     $deployment = new deployment();
     $storage->get_instance_by_id($storage_id);
     $resource->get_instance_by_id($storage->resource_id);
     $deployment->get_instance_by_id($storage->type);
     $command = '';
     $file = '';
     // reload volume group
     if ($mode === 'vg') {
         $file = $OPENQRM_SERVER_BASE_DIR . '/plugins/kvm/web/storage/' . $resource->id . '.vg.stat';
         $command .= $OPENQRM_SERVER_BASE_DIR . '/plugins/kvm/bin/openqrm-kvm post_vg -t ' . $deployment->type;
     }
     // reload logical volumes
     if ($mode === 'lv') {
         $file = $OPENQRM_SERVER_BASE_DIR . '/plugins/kvm/web/storage/' . $resource->id . '.' . $volgroup . '.lv.stat';
         $command .= $OPENQRM_SERVER_BASE_DIR . '/plugins/kvm/bin/openqrm-kvm post_lv';
         $command .= ' -v ' . $volgroup . ' -t ' . $deployment->type;
     }
     $command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
     $command .= ' --openqrm-ui-user ' . $this->user->name;
     $command .= ' --openqrm-cmd-mode background';
     if ($this->file->exists($file)) {
         $this->file->remove($file);
     }
     $resource->send_command($resource->ip, $command);
     while (!$this->file->exists($file)) {
         usleep(10000);
         // sleep 10ms to unload the CPU
         clearstatcache();
     }
     return true;
 }
Ejemplo n.º 26
0
 function select()
 {
     $d = array();
     $h = array();
     $h['image_isactive']['title'] = $this->lang['table_isactive'];
     $h['image_id']['title'] = $this->lang['table_id'];
     $h['image_id']['hidden'] = true;
     $h['image_name']['title'] = $this->lang['table_name'];
     $h['image_name']['hidden'] = true;
     $h['image_type']['title'] = $this->lang['table_deployment'];
     $h['image_type']['hidden'] = true;
     $h['image_rootdevice']['title'] = $this->lang['table_root'];
     $h['image_rootdevice']['hidden'] = true;
     $h['image_version']['title'] = $this->lang['table_version'];
     $h['image_version']['hidden'] = true;
     $h['image_capabilities']['title'] = $this->lang['table_capabilities'];
     $h['image_capabilities']['hidden'] = true;
     $h['image_data']['title'] = '&#160;';
     $h['image_data']['sortable'] = false;
     $h['image_comment']['title'] = '&#160;';
     $h['image_comment']['sortable'] = false;
     $h['image_edit']['title'] = '&#160;';
     $h['image_edit']['sortable'] = false;
     $image = new image();
     $params = $this->response->get_array($this->actions_name, 'select');
     $b = array();
     // unset unnecessary params
     unset($params['image[sort]']);
     unset($params['image[order]']);
     unset($params['image[limit]']);
     unset($params['image[offset]']);
     unset($params['image_filter']);
     $table = $this->response->html->tablebuilder('image', $params);
     $table->offset = 0;
     $table->sort = 'image_id';
     $table->limit = 20;
     $table->order = 'ASC';
     $table->max = $image->get_count();
     $table->init();
     // handle table params
     $tps = $table->get_params();
     $tp = '';
     foreach ($tps['image'] as $k => $v) {
         $tp .= '&image[' . $k . ']=' . $v;
     }
     $image_arr = $image->display_overview(0, 10000, $table->sort, $table->order);
     $image_icon = "/openqrm/base/img/image.png";
     foreach ($image_arr as $index => $image_db) {
         if ($this->response->html->request()->get('image_filter') === '' || $this->response->html->request()->get('image_filter') == $image_db["image_type"]) {
             // prepare the values for the array
             $image = new image();
             $image->get_instance_by_id($image_db["image_id"]);
             // 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') . '&image_id=' . $image->id . '' . $tp;
             $image_edit = $a->get_string();
             // force remove
             $a = $this->response->html->a();
             $a->title = $this->lang['action_remove'];
             $a->label = $this->lang['action_remove'];
             $a->css = 'remove';
             $a->href = $this->response->get_url($this->actions_name, 'remove') . '&image_identifier=' . $image->id . '' . $tp;
             $image_remove = $a->get_string();
             $image_actions = $image_edit;
             // set the active icon
             $isactive_icon = '<span class="pill inactive">' . $this->lang['lang_inactive'] . '</span>';
             if ($image_db["image_isactive"] == 1) {
                 $isactive_icon = '<span class="pill active">' . $this->lang['lang_active'] . '</span>';
             } else {
                 $image_actions .= $image_remove;
             }
             // infos
             $storage = new storage();
             $storage->get_instance_by_id($image_db['image_storageid']);
             $deployment = new deployment();
             $deployment->get_instance_by_id($storage->type);
             $link = $storage->name;
             if ($deployment->storagetype !== 'local-server') {
                 $a = $this->response->html->a();
                 $a->label = $storage->name;
                 $a->handler = 'onclick="wait();"';
                 $a->href = $this->response->html->thisfile . '?plugin=' . $deployment->storagetype . '&' . str_replace('-', '_', $deployment->storagetype) . '_action=edit&storage_id=' . $storage->id;
                 $link = $a->get_string();
             }
             $data = '<div class="data">';
             $data .= '<b>' . $this->lang['table_id'] . '</b>: ' . $image_db["image_id"] . '<br>';
             $data .= '<b>' . $this->lang['table_name'] . '</b>: ' . $image_db["image_name"] . '<br>';
             $data .= '<b>' . $this->lang['table_deployment'] . '</b>: ' . $image_db["image_type"] . '<br>';
             $data .= '<b>' . $this->lang['table_storage'] . '</b>: ' . $link . '<br>';
             if (isset($image_db["image_rootdevice"])) {
                 $root = str_replace($image_db["image_name"], '', $image_db["image_rootdevice"]);
                 // vmware
                 $root = str_replace(':/.vmdk', '', $root);
                 $data .= '<b>' . $this->lang['table_root'] . '</b>: ' . $root . '<br>';
             }
             if (isset($image_db["image_version"])) {
                 $data .= '<b>' . $this->lang['table_version'] . '</b>: ' . $image_db["image_version"] . '<br>';
             }
             if (isset($image_db["image_capabilities"])) {
                 $data .= '<b>' . $this->lang['table_capabilities'] . '</b>: ' . $image_db["image_capabilities"];
             }
             $data .= '</div>';
             $b[] = array('image_isactive' => $isactive_icon, 'image_id' => $image_db["image_id"], 'image_name' => $image_db["image_name"], 'image_rootdevice' => $image_db["image_rootdevice"], 'image_version' => $image_db["image_version"], 'image_capabilities' => $image_db["image_capabilities"], 'image_data' => $data, 'image_comment' => $image_db["image_comment"], 'image_edit' => $image_actions);
         }
     }
     // Filter
     $types = $this->openqrm->deployment();
     $list = $types->get_list();
     $filter = array();
     foreach ($list as $l) {
         $filter[] = array($l['label']);
     }
     asort($filter);
     array_unshift($filter, array('', ''));
     $select = $this->response->html->select();
     $select->add($filter, array(0, 0));
     $select->name = 'image_filter';
     $select->handler = 'onchange="wait();this.form.submit();return false;"';
     $select->selected = array($this->response->html->request()->get('image_filter'));
     $box = $this->response->html->box();
     $box->add($select);
     $box->id = 'image_filter_box';
     $box->css = 'htmlobject_box';
     $box->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, "add") . '' . $tp;
     $table->id = 'Tabelle';
     $table->css = 'htmlobject_table';
     $table->border = 1;
     $table->cellspacing = 0;
     $table->cellpadding = 3;
     $table->autosort = false;
     $table->sort_link = false;
     if ($this->response->html->request()->get('image_filter') !== '') {
         $table->max = count($b);
     } else {
         $table->max = $image->get_count() - 2;
     }
     $table->head = $h;
     $table->body = $b;
     $table->form_action = $this->response->html->thisfile;
     $d['form'] = $this->response->get_form($this->actions_name, 'select', false)->get_elements();
     $d['add'] = $add->get_string();
     $d['table'] = $table;
     $d['filter'] = $box->get_string();
     return $d;
 }