当前位置: 首页>>代码示例>>PHP>>正文


PHP storage::get_instance_by_id方法代码示例

本文整理汇总了PHP中storage::get_instance_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP storage::get_instance_by_id方法的具体用法?PHP storage::get_instance_by_id怎么用?PHP storage::get_instance_by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在storage的用法示例。


在下文中一共展示了storage::get_instance_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_lvm_iscsi_deployment_image_rootdevice_identifier

function get_lvm_iscsi_deployment_image_rootdevice_identifier($lvm_iscsi_storage_id)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_ADMIN;
    global $event;
    // place for the storage stat files
    $StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/lvm-storage/storage';
    $rootdevice_identifier_array = array();
    $storage = new storage();
    $storage->get_instance_by_id($lvm_iscsi_storage_id);
    $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.lvm-iscsi-deployment.ident";
    if (file_exists($ident_file)) {
        unlink($ident_file);
    }
    // send command
    $resource_command = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/lvm-storage/bin/openqrm-lvm-storage post_identifier -t lvm-iscsi-deployment -u {$OPENQRM_ADMIN->name} -p {$OPENQRM_ADMIN->password}";
    $storage_resource->send_command($storage_resource->ip, $resource_command);
    if (!lvm_iscsi_deployment_wait_for_identfile($ident_file)) {
        $event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.lvm-iscsi-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;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:33,代码来源:image.lvm-iscsi-deployment.php

示例2: storage

 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);
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:16,代码来源:iscsi-storage.image.class.php

示例3: storage

 function __construct($openqrm, $response)
 {
     $this->openqrm = $openqrm;
     $this->user = $this->openqrm->user();
     $this->rootdir = $this->openqrm->get('webdir');
     $this->response = $response;
     $this->file = $this->openqrm->file();
     $this->tpldir = $this->rootdir . '/plugins/device-manager/tpl';
     $id = $this->response->html->request()->get('storage_id');
     $this->response->add('storage_id', $id);
     $this->response->add('volgroup', $this->response->html->request()->get('volgroup'));
     $storage = new storage();
     $this->storage = $storage->get_instance_by_id($id);
     $resource = new resource();
     $this->resource = $resource->get_instance_by_id($this->storage->resource_id);
     $this->statfile = $this->openqrm->get('basedir') . '/plugins/device-manager/web/storage/' . $this->resource->id . '.device.stat';
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:17,代码来源:device-manager.removevg.class.php

示例4: get_nfs_deployment_image_rootdevice_identifier

function get_nfs_deployment_image_rootdevice_identifier($nfs_storage_id)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_ADMIN;
    global $event;
    // place for the storage stat files
    $StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/nfs-storage/storage';
    $rootdevice_identifier_array = array();
    $storage = new storage();
    $storage->get_instance_by_id($nfs_storage_id);
    $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}.nfs.ident";
    $statfile_manual = "{$StorageDir}/" . $storage_resource_id . ".nfs.stat.manual";
    // manual configured ?
    if (file_exists($statfile_manual)) {
        $fcontent = file($statfile_manual);
        foreach ($fcontent as $lun_info) {
            $troot_device = trim($lun_info);
            $rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$troot_device}");
        }
    } else {
        if (file_exists($ident_file)) {
            unlink($ident_file);
        }
        // send command
        $resource_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/nfs-storage/bin/openqrm-nfs-storage post_identifier -u " . $OPENQRM_ADMIN->name . " -p " . $OPENQRM_ADMIN->password . " --openqrm-cmd-mode background";
        $storage_resource->send_command($storage_resource->ip, $resource_command);
        if (!nfs_deployment_wait_for_identfile($ident_file)) {
            $event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.nfs-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;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:43,代码来源:image.nfs-deployment.php

示例5: get_kvm_lvm_deployment_image_rootdevice_identifier

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;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:37,代码来源:image.kvm-lvm-deployment.php

示例6: remove_nfs_deployment

function remove_nfs_deployment($cloud_image_id)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $event->log("remove_nfs_deployment", $_SERVER['REQUEST_TIME'], 5, "nfs-deployment-cloud-hook", "Removing image on storage", "", "", 0, 0, 0);
    $cloudimage = new cloudimage();
    $cloudimage->get_instance_by_id($cloud_image_id);
    // 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;
    $image_storageid = $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($image_storageid);
    $storage_resource_id = $storage->resource_id;
    // get storage resource
    $resource = new resource();
    $resource->get_instance_by_id($storage_resource_id);
    $resource_id = $resource->id;
    $resource_ip = $resource->ip;
    // nfs-storage
    $image_location_name = basename($image_rootdevice);
    $image_remove_clone_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/nfs-storage/bin/openqrm-nfs-storage remove -n " . $image_location_name . " --openqrm-cmd-mode background";
    $event->log("remove_nfs_deployment", $_SERVER['REQUEST_TIME'], 5, "nfs-deployment-cloud-hook", "Running : {$image_remove_clone_cmd}", "", "", 0, 0, 0);
    $resource->send_command($resource_ip, $image_remove_clone_cmd);
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:39,代码来源:openqrm-nfs-deployment-cloud-hook.php

示例7: create_private_kvm_gluster_deployment

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;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:51,代码来源:openqrm-kvm-gluster-deployment-cloud-hook.php

示例8: create

 function create($cu_id, $virtualization_type, $name, $mac, $additional_nics, $cpu, $memory, $disk, $timeout, $vncpassword, $source_image_id = null)
 {
     global $OPENQRM_SERVER_BASE_DIR;
     global $OPENQRM_SERVER_IP_ADDRESS;
     global $OPENQRM_EXEC_PORT;
     global $RESOURCE_INFO_TABLE;
     global $host_start_from_off_timeout;
     global $RootDir;
     $this->init($timeout);
     global $event;
     $vmware_mac_address_space = "00:50:56";
     $vtype = new virtualization();
     $vtype->get_instance_by_id($virtualization_type);
     $virtualization_plugin_name = $vtype->get_plugin_name();
     $event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Trying to create new VM type {$virtualization_type} ({$virtualization_plugin_name}) {$mac}/{$cpu}/{$memory}/{$disk}", "", "", 0, 0, 0);
     // here we need to find out if we have a virtualization host providing the type of VMs as requested
     // find out the host virtualization type via the plugin name
     $vhost_type = new virtualization();
     $vhost_type->get_instance_by_type($virtualization_plugin_name);
     $event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Trying to find a virtualization host from type {$vhost_type->type} {$vhost_type->name}", "", "", 0, 0, 0);
     // check if resource-pooling is enabled
     $cp_conf = new cloudconfig();
     $show_resource_pools = $cp_conf->get_value(25);
     // resource_pools enabled ?
     $vm_provision_delay = $cp_conf->get_value(40);
     // delay provisioning of VMs ?
     $vm_loadbalance_algorithm = $cp_conf->get_value(41);
     // which LB to select ?
     // for all in appliance list, find virtualization host appliances
     $appliance_tmp = new appliance();
     $appliance_id_list = $appliance_tmp->get_all_ids();
     $active_appliance_list = array();
     $active_appliance_resource_list = array();
     foreach ($appliance_id_list as $id_arr) {
         foreach ($id_arr as $id) {
             $appliance = new appliance();
             $appliance->get_instance_by_id($id);
             // active ?
             if ($appliance->stoptime == 0 || $appliance->resources == 0) {
                 if ($appliance->virtualization == $vhost_type->id) {
                     // we have found an active appliance from the right virtualization type
                     // Now we check that its resource is active and not in error
                     $cvm_resource = new resource();
                     $cvm_resource->get_instance_by_id($appliance->resources);
                     if (strcmp($cvm_resource->state, "active")) {
                         continue;
                     }
                     // here we check if there is still enough space
                     // to create the new VM -> max_vm setting per resource
                     $res_hostlimit = new cloudhostlimit();
                     $res_hostlimit->get_instance_by_resource($appliance->resources);
                     if (strlen($res_hostlimit->id)) {
                         if ($res_hostlimit->max_vms >= 0) {
                             $new_current_vms = $res_hostlimit->current_vms + 1;
                             if ($new_current_vms > $res_hostlimit->max_vms) {
                                 $event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Hostlimit max_vm is reached for resource {$appliance->resources}", "", "", 0, 0, $appliance->resources);
                                 continue;
                             }
                         }
                     }
                     // resource pooling enabled ?
                     if (strcmp($show_resource_pools, "true")) {
                         // disabled, add any appliance from the right virtualization type
                         $active_appliance_list[] .= $id;
                         $active_appliance_resource_list[] .= $appliance->resources;
                         //$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- resource pooling is disabled", "", "", 0, 0, 0);
                     } else {
                         //$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- resource pooling is enabled $appliance->resources", "", "", 0, 0, 0);
                         // resource pooling enabled, check to which user group the resource belongs to
                         $private_resource = new cloudrespool();
                         $private_resource->get_instance_by_resource($appliance->resources);
                         // is this resource configured in the resource pools ?
                         //$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- resource pool id $private_resource->id !", "", "", 0, 0, 0);
                         if (strlen($private_resource->id)) {
                             //$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- resource $appliance->resources is in a resource pool", "", "", 0, 0, 0);
                             // is it hidden ?
                             if ($private_resource->cg_id >= 0) {
                                 //$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- resource $appliance->resources is also configured in resource pool (not hidden)", "", "", 0, 0, 0);
                                 $cloud_user = new clouduser();
                                 $cloud_user->get_instance_by_id($cu_id);
                                 $cloud_user_group = new cloudusergroup();
                                 $cloud_user_group->get_instance_by_id($cloud_user->cg_id);
                                 //$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- we have found the users group $cloud_user_group->id", "", "", 0, 0, 0);
                                 // does it really belongs to the users group ?
                                 if ($private_resource->cg_id == $cloud_user_group->id) {
                                     // resource belongs to the users group, add appliance to list
                                     //$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- adding appliance $id   ", "", "", 0, 0, 0);
                                     $active_appliance_list[] .= $id;
                                     $active_appliance_resource_list[] .= $appliance->resources;
                                     //} else {
                                     //    $event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Appliance $id (resource $appliance->resources) is NOT in dedicated for the users group", "", "", 0, 0, 0);
                                 }
                                 //} else {
                                 //    $event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Appliance $id (resource $appliance->resources) is marked as hidden", "", "", 0, 0, 0);
                             }
                         }
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:kelubo,项目名称:OpenQRM,代码行数:101,代码来源:cloudvm.class.php

示例9: openqrm_cloud_monitor

function openqrm_cloud_monitor()
{
    global $event;
    global $APPLIANCE_INFO_TABLE;
    global $IMAGE_INFO_TABLE;
    global $CLOUD_IMAGE_TABLE;
    global $CLOUD_APPLIANCE_TABLE;
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $openqrm_server;
    global $BaseDir;
    global $RootDir;
    global $vm_create_timout;
    $vmware_mac_address_space = "00:50:56";
    $cloud_monitor_lock = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/web/action/cloud-conf/cloud-monitor.lock";
    $cloud_monitor_timeout = "600";
    $cloud_volume_clone_timeout = "4800";
    // lock to prevent running multiple times in parallel
    if (file_exists($cloud_monitor_lock)) {
        // check from when it is, if it is too old we remove it and start
        $cloud_monitor_lock_date = file_get_contents($cloud_monitor_lock);
        $now = $_SERVER['REQUEST_TIME'];
        if ($now - $cloud_monitor_lock_date > $cloud_monitor_timeout) {
            $event->log("cloud", $_SERVER['REQUEST_TIME'], 2, "monitor-hook", "Timeout for the cloud-monitor-lock reached, creating new lock", "", "", 0, 0, 0);
            $cloud_lock_fp = fopen($cloud_monitor_lock, 'w');
            fwrite($cloud_lock_fp, $now);
            fclose($cloud_lock_fp);
        } else {
            return 0;
        }
    } else {
        $now = $_SERVER['REQUEST_TIME'];
        $cloud_lock_fp = fopen($cloud_monitor_lock, 'w');
        fwrite($cloud_lock_fp, $now);
        fclose($cloud_lock_fp);
    }
    // prepare performance parameter
    $cloud_performance_config = new cloudconfig();
    $max_parallel_phase_one_actions = $cloud_performance_config->get_value(27);
    // 27 max-parallel-phase-one-actions
    $max_parallel_phase_two_actions = $cloud_performance_config->get_value(28);
    // 28 max-parallel-phase-two-actions
    $max_parallel_phase_three_actions = $cloud_performance_config->get_value(29);
    // 29 max-parallel-phase-three-actions
    $max_parallel_phase_four_actions = $cloud_performance_config->get_value(30);
    // 30 max-parallel-phase-four-actions
    $max_parallel_phase_five_actions = $cloud_performance_config->get_value(31);
    // 31 max-parallel-phase-five-actions
    $max_parallel_phase_six_actions = $cloud_performance_config->get_value(32);
    // 32 max-parallel-phase-six-actions
    $max_parallel_phase_seven_actions = $cloud_performance_config->get_value(33);
    // 33 max-parallel-phase-seven-actions
    $parallel_phase_one_actions = 0;
    $parallel_phase_two_actions = 0;
    $parallel_phase_three_actions = 0;
    $parallel_phase_four_actions = 0;
    $parallel_phase_five_actions = 0;
    $parallel_phase_six_actions = 0;
    $parallel_phase_seven_actions = 0;
    // appliance hostname
    $cloud_appliance_hostname_enabled = $cloud_performance_config->get_value(34);
    // 34 appliance-hostname
    // $event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "monitor-hook", "Cloud Phase I - Image actions, VM-removal", "", "", 0, 0, 0);
    // #################### clone-on-deploy image resize / remove ################################
    // here we check if we have any clone-on-deploy images to resize or to remove
    // get cloudimage ids
    $cil = new cloudimage();
    $cloud_image_list = $cil->get_all_ids();
    foreach ($cloud_image_list as $ci_list) {
        $phase_one_actions = 0;
        $ci_id = $ci_list['ci_id'];
        $ci = new cloudimage();
        $ci->get_instance_by_id($ci_id);
        $ci_state = $ci->state;
        $ci_image_id = $ci->image_id;
        $ci_appliance_id = $ci->appliance_id;
        $ci_resource_id = $ci->resource_id;
        $ci_cr_id = $ci->cr_id;
        $ci_resource = new resource();
        $ci_resource->get_instance_by_id($ci_resource_id);
        $ci_appliance = new appliance();
        $ci_appliance->get_instance_by_id($ci->appliance_id);
        // not the openQRM server resource, accept 0 only for private image remove
        if ($ci_cr_id != 0) {
            if ($ci_resource_id == 0) {
                continue;
            }
            // not when the cr is in starting phase
            $ci_request = new cloudrequest();
            $ci_request->get_instance_by_id($ci_cr_id);
            if ($ci_request->status == 8) {
                continue;
            }
        }
        // image still in use ?
        if ($ci_state == 1) {
            // its resource its active with the idle image ? sounds like pause
            if (!strcmp($ci_resource->state, "active") && $ci_resource->imageid == 1) {
                // ####################### remove auto createed vm #################
//.........这里部分代码省略.........
开发者ID:kelubo,项目名称:OpenQRM,代码行数:101,代码来源:openqrm-cloud-monitor-hook.php

示例10: image

 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;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:67,代码来源:image.install2.class.php

示例11: init

 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']));
     }
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:22,代码来源:nfs-storage.edit.class.php

示例12: edit

 function edit()
 {
     $resource_icon_default = "/img/resource.png";
     $storage_icon = "/plugins/kvm/img/plugin.png";
     //$state_icon = $this->openqrm->get('baseurl')."/img/".$this->resource->state.".png";
     if ($this->file->exists($this->openqrm->get('webdir') . $storage_icon)) {
         $resource_icon_default = $storage_icon;
     }
     $resource_icon_default = $this->openqrm->get('baseurl') . $resource_icon_default;
     // check if we have a plugin implementing the remote console
     $remote_console = false;
     $plugin = new plugin();
     $enabled_plugins = $plugin->enabled();
     foreach ($enabled_plugins as $index => $plugin_name) {
         //$plugin_remote_console_running = $this->openqrm->get('webdir')."/plugins/".$plugin_name."/.running";
         $plugin_remote_console_hook = $this->openqrm->get('webdir') . "/plugins/" . $plugin_name . "/openqrm-" . $plugin_name . "-remote-console-hook.php";
         if ($this->file->exists($plugin_remote_console_hook)) {
             require_once "{$plugin_remote_console_hook}";
             $link_function = str_replace("-", "_", "openqrm_" . "{$plugin_name}" . "_remote_console");
             if (function_exists($link_function)) {
                 $remote_functions[] = $link_function;
                 $remote_console = true;
             }
         }
     }
     // prepare list of all Host resource id for the migration select
     // we need a select with the ids/ips from all resources which
     // are used by appliances with kvm capabilities
     $kvm_hosts = array();
     $appliance_list = new appliance();
     $appliance_list_array = $appliance_list->get_list();
     foreach ($appliance_list_array as $index => $app) {
         $appliance_kvm_host_check = new appliance();
         $appliance_kvm_host_check->get_instance_by_id($app["value"]);
         // only active appliances
         if (!strcmp($appliance_kvm_host_check->state, "active") || $appliance_kvm_host_check->resources == 0) {
             $virtualization = new virtualization();
             $virtualization->get_instance_by_id($appliance_kvm_host_check->virtualization);
             if (!strcmp($virtualization->type, "kvm") && !strstr($virtualization->type, "kvm-vm")) {
                 $kvm_host_resource = new resource();
                 $kvm_host_resource->get_instance_by_id($appliance_kvm_host_check->resources);
                 // exclude source host
                 #if ($kvm_host_resource->id == $this->resource->id) {
                 #	continue;
                 #}
                 // only active appliances
                 if (!strcmp($kvm_host_resource->state, "active")) {
                     $migration_select_label = "Res. " . $kvm_host_resource->id . "/" . $kvm_host_resource->ip;
                     $kvm_hosts[] = array("value" => $kvm_host_resource->id, "label" => $migration_select_label);
                 }
             }
         }
     }
     $d['state'] = '<span class="pill ' . $this->resource->state . '">' . $this->resource->state . '</span>';
     $d['resource'] = $this->resource->id . ' / ' . $this->resource->ip;
     $d['name'] = $this->appliance->name;
     $d['id'] = $this->appliance->id;
     $a = $this->response->html->a();
     $a->label = $this->lang['action_add_local_vm'];
     $a->css = 'add';
     $a->handler = 'onclick="wait();"';
     $a->href = $this->response->get_url($this->actions_name, "add") . '&vmtype=kvm-vm-local';
     $d['add_local_vm'] = $a->get_string();
     $a = $this->response->html->a();
     $a->label = $this->lang['action_add_network_vm'];
     $a->css = 'add';
     $a->handler = 'onclick="wait();"';
     $a->href = $this->response->get_url($this->actions_name, "add") . '&vmtype=kvm-vm-net';
     $d['add_network_vm'] = $a->get_string();
     $body = array();
     $identifier_disabled = array();
     $file = $this->statfile;
     if ($this->file->exists($file)) {
         $lines = explode("\n", $this->file->get_contents($file));
         if (count($lines) >= 1) {
             $i = 0;
             foreach ($lines as $line) {
                 if ($line !== '') {
                     $line = explode('@', $line);
                     $state = $line[0];
                     $name = $line[1];
                     $mac = $line[2];
                     $resource = new resource();
                     $resource->get_instance_by_mac($mac);
                     if ($resource->vhostid != $this->resource->id) {
                         continue;
                     }
                     $res_virtualization = new virtualization();
                     $res_virtualization->get_instance_by_id($resource->vtype);
                     $update = '';
                     $a = $this->response->html->a();
                     $a->title = $this->lang['action_update'];
                     $a->label = $this->lang['action_update'];
                     $a->handler = 'onclick="wait();"';
                     $a->css = 'edit';
                     $a->href = $this->response->get_url($this->actions_name, "update") . '&vm=' . $name . '&vmtype=' . $res_virtualization->type;
                     $update_link = $a->get_string();
                     $clone = '';
                     $a = $this->response->html->a();
                     $a->title = $this->lang['action_clone'];
//.........这里部分代码省略.........
开发者ID:kelubo,项目名称:OpenQRM,代码行数:101,代码来源:kvm-vm.edit.class.php

示例13: init

 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';
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:20,代码来源:lvm-storage.volgroup.class.php

示例14: edit

 function edit()
 {
     $response = $this->get_response();
     $form = $response->form;
     $id = $this->response->html->request()->get('image_id');
     if ($id !== '') {
         // check password
         $pass = $form->get_request('image_password');
         if ($pass !== '' && $pass !== $form->get_request('image_password_2')) {
             $form->set_error('image_password_2', $this->lang['error_password']);
         }
         $image = new image();
         $image->get_instance_by_id($id);
         if (!$form->get_errors() && $this->response->submit()) {
             $image_password = $this->response->html->request()->get('image_password');
             $install_from_local = $this->response->html->request()->get('install_from_local');
             $transfer_to_local = $this->response->html->request()->get('transfer_to_local');
             $install_from_nfs = $this->response->html->request()->get('install_from_nfs');
             $transfer_to_nfs = $this->response->html->request()->get('transfer_to_nfs');
             $install_from_template = $this->response->html->request()->get('install_from_template');
             $image_comment = $this->response->html->request()->get('image_comment');
             $image_version = $this->response->html->request()->get('image_version');
             // update image
             $fields['image_comment'] = $image_comment;
             $fields['image_version'] = $image_version;
             $image->update($id, $fields);
             $image->get_instance_by_id($id);
             # set password if given
             if (strlen($image_password)) {
                 $image->set_root_password($id, $image_password);
             } else {
                 $CMD = "rm -f " . $this->openqrm->get('basedir') . "/web/action/image-auth/iauth." . $id . ".php";
                 exec($CMD);
             }
             // install-from-nfs
             if (strlen($install_from_nfs)) {
                 $install_from_nfs_image = new image();
                 $install_from_nfs_image->get_instance_by_id($install_from_nfs);
                 $install_from_nfs_storage = new storage();
                 $install_from_nfs_storage->get_instance_by_id($install_from_nfs_image->storageid);
                 $install_from_nfs_storage_resource = new resource();
                 $install_from_nfs_storage_resource->get_instance_by_id($install_from_nfs_storage->resource_id);
                 $install_from_nfs_storage_ip = $install_from_nfs_storage_resource->ip;
                 $install_from_nfs_storage_path = $install_from_nfs_image->rootdevice;
                 $install_from_nfs_path = $install_from_nfs_image->storageid . ":" . $install_from_nfs_storage_ip . ":" . $install_from_nfs_storage_path;
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_NFS", $install_from_nfs_path);
             } else {
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_NFS", "");
             }
             // transfer-to-nfs, we have to refresh the image object here
             $image->get_instance_by_id($id);
             if (strlen($transfer_to_nfs)) {
                 $transfer_to_nfs_image = new image();
                 $transfer_to_nfs_image->get_instance_by_id($transfer_to_nfs);
                 $transfer_to_nfs_storage = new storage();
                 $transfer_to_nfs_storage->get_instance_by_id($transfer_to_nfs_image->storageid);
                 $transfer_to_nfs_storage_resource = new resource();
                 $transfer_to_nfs_storage_resource->get_instance_by_id($transfer_to_nfs_storage->resource_id);
                 $transfer_to_nfs_storage_ip = $transfer_to_nfs_storage_resource->ip;
                 $transfer_to_nfs_storage_path = $transfer_to_nfs_image->rootdevice;
                 $transfer_to_nfs_path = $transfer_to_nfs_image->storageid . ":" . $transfer_to_nfs_storage_ip . ":" . $transfer_to_nfs_storage_path;
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_NFS", $transfer_to_nfs_path);
             } else {
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_NFS", "");
             }
             // install-from-local, we have to refresh the image object again
             $image->get_instance_by_id($id);
             if (strlen($install_from_local)) {
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_LOCAL", $install_from_local);
             } else {
                 $image->set_deployment_parameters("IMAGE_INSTALL_FROM_LOCAL", "");
             }
             // transfer-to-local, we have to refresh the image object again
             $image->get_instance_by_id($id);
             if (strlen($transfer_to_local)) {
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_LOCAL", $transfer_to_local);
             } else {
                 $image->set_deployment_parameters("IMAGE_TRANSFER_TO_LOCAL", "");
             }
             // reset deployment parameter INSTALL_CONFIG
             $image->set_deployment_parameters("INSTALL_CONFIG", "");
             if (strlen($install_from_template)) {
                 // redirect to install-from-template step1
                 $response->msg = 'install-from-template';
                 $response->install_from_template = $install_from_template;
             } else {
                 $response->msg = sprintf($this->lang['msg'], $image->name);
             }
             $response->image_id = $id;
         }
         $response->name = $image->name;
     } else {
         $response->msg = '';
     }
     return $response;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:96,代码来源:image.edit.class.php

示例15: storage_auth_deployment_stop

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;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:20,代码来源:openqrm-kvm-lvm-deployment-auth-hook.php


注:本文中的storage::get_instance_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。