本文整理汇总了PHP中storage类的典型用法代码示例。如果您正苦于以下问题:PHP storage类的具体用法?PHP storage怎么用?PHP storage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了storage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: install
public function install($db_type)
{
$f3 = \Base::instance();
$db_type = strtoupper($db_type);
if ($db = storage::instance()->get($db_type)) {
$f3->set('DB', $db);
} else {
$f3->error(256, 'no valid DB specified');
}
// setup the models
\Model\Post::setup();
\Model\Tag::setup();
\Model\Comment::setup();
\Model\User::setup();
// create demo admin user
$user = new \Model\User();
$user->load(array('username = ?', 'admin'));
if ($user->dry()) {
$user->username = 'admin';
$user->name = 'Administrator';
$user->password = 'fabulog';
$user->save();
\Flash::instance()->addMessage('Admin User created,' . ' username: admin, password: fabulog', 'success');
}
\Flash::instance()->addMessage('Setup complete', 'success');
}
开发者ID:xfra35,项目名称:fabulog,代码行数:26,代码来源:setup.php
示例3: __construct
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
示例4: __construct
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
示例5: checkOut
/**
* Checkout cart
*/
public function checkOut($drop)
{
if (!empty($this->storage->db)) {
$this->storage->lock($drop, $this);
} else {
$this->deleteAll();
}
}
开发者ID:dextercool,项目名称:yii2-cart,代码行数:11,代码来源:Cart.php
示例6: testClear
/**
* @covers ZfcUser\Authentication\Storage\Db::clear
*/
public function testClear()
{
$reflectionClass = new \ReflectionClass('ZfcUser\\Authentication\\Storage\\Db');
$reflectionProperty = $reflectionClass->getProperty('resolvedIdentity');
$reflectionProperty->setAccessible(true);
$this->storage->expects($this->once())->method('clear');
$this->db->setStorage($this->storage);
$this->db->clear();
$this->assertNull($reflectionProperty->getValue($this->db));
}
开发者ID:projectsmahendra,项目名称:blogger,代码行数:13,代码来源:DbTest.php
示例7: setAuthenticationCredentials
protected function setAuthenticationCredentials($identity = 'ZfcUser', $credential = 'ZfcUserPassword')
{
$this->storage->expects($this->at(0))->method('read')->will($this->returnValue(array('is_satisfied' => false)));
$post = $this->getMock('Zend\\Stdlib\\Parameters');
$post->expects($this->at(0))->method('get')->with('identity')->will($this->returnValue($identity));
$post->expects($this->at(1))->method('get')->with('credential')->will($this->returnValue($credential));
$request = $this->getMock('Zend\\Http\\Request');
$request->expects($this->exactly(2))->method('getPost')->will($this->returnValue($post));
$this->authEvent->expects($this->exactly(2))->method('getRequest')->will($this->returnValue($request));
}
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:10,代码来源:DbTest.php
示例8: setHeaders
/**
* Set the headers for the request
* @param array $options
* @return array $headers
*/
private function setHeaders(array $options)
{
$format = $options['format'];
$authToken = $this->storage->getTokenData();
$accessToken = $authToken['access_token'];
$tokenType = $authToken['token_type'];
$this->headers['Authorization'] = "{$tokenType} {$accessToken}";
$this->setRequestFormat($options['format']);
$this->setCompression($options);
}
开发者ID:jhoff,项目名称:forrest,代码行数:15,代码来源:Client.php
示例9: 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
示例10: 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
示例11: revokeToken
/**
* Revokes an authorization token. This both revokes the token by making a
* Google Accounts API request to revoke the token as well as deleting the
* token from the storage mechanism. If any errors occur, the authorization
* exception is caught and the message is stored in error.
*/
public function revokeToken()
{
$accessToken = $this->storage->get();
if ($accessToken) {
$tokenObj = json_decode($accessToken);
try {
$this->client->revokeToken($tokenObj->refresh_token);
$this->storage->delete();
} catch (Google_AuthException $e) {
$this->errorMsg = $e->getMessage();
}
}
// Keep things pretty. Removes the auth code from the URL.
header("Location: {$this->controllerUrl}");
}
开发者ID:ricain59,项目名称:fortaff,代码行数:21,代码来源:authHelper.php
示例12: savecoins
private static function savecoins($coins)
{
$old = storage::load();
if (!$old) {
$old = array();
}
foreach ($coins as $val => $ccs) {
foreach ($ccs as $id => $coin) {
$old[$val][$id] = $coin;
}
}
if (storage::save($old)) {
return true;
}
return false;
}
开发者ID:perfectcode1,项目名称:Gcoin,代码行数:16,代码来源:mine.php
示例13: setup
/**
* @param $contract
* @return array
* @throws \Exception
*/
public function setup($contract)
{
$this->logger->info('Download started...', ['file' => $contract->file]);
$pdfFile = '';
try {
$pdfFile = $this->storage->disk('s3')->get($contract->file);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['contract id' => $contract->id, 'file' => $contract->file]);
}
$this->storage->disk('local')->put($contract->file, $pdfFile);
$this->logger->info('Download completed...', ['file' => $pdfFile]);
if (!$this->fileSystem->isDirectory($this->getContractDirectory($contract->id))) {
$this->addDirectory($contract->id, $this->getWriteDirectory());
}
$writeFolderPath = $this->getContractDirectory($contract->id);
$readFilePath = sprintf('%s/app/%s', storage_path(), $contract->file);
return [$writeFolderPath, $readFilePath];
}
开发者ID:sadhakbj,项目名称:resourcecontracts.org,代码行数:23,代码来源:ProcessService.php
示例14: handle
/**
* 获取内容并输出
* 如果stroage里面不存在,则从URL里面获取
* */
private function handle($filename, $key, $delete = false, $direct = false)
{
$content = '';
if ($this->succeed) {
$storage = storage::gethandle();
if ($delete) {
if (!$storage->exists($key)) {
die(json_encode(array('purge' => $filename, 'key' => $key, 'success' => 'not exists')));
}
$return = $storage->delete($key);
die(json_encode(array('purge' => $filename, 'key' => $key, 'success' => $return)));
}
if ($storage->exists($key) && !$direct) {
if (!NO_LOCATE && ($url = $storage->url($key))) {
$this->locate($url);
}
$content = $storage->read($key);
$this->hit = $key;
if (empty($content)) {
$this->succeed = false;
$this->error_type = 'empty_conent';
}
} else {
//$content = @file_get_contents(BASE_URL.$filename);
$content = lib::fetch_url(BASE_URL . $filename);
if (!is_array($content) || count($content) < 2) {
$this->succeed = false;
$this->error_type = 'fetch_error';
} elseif ($content[0] == 200) {
//返回200,才写入
if (!$direct) {
$storage->write($key, $content[1]);
}
} else {
header('HTTP/1.1 ' . $content[0]);
}
$content = $content[1];
}
}
//显示内容
$this->render($content);
}
开发者ID:coffiner,项目名称:Layer,代码行数:46,代码来源:controller.php
示例15: duplicate
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;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:76,代码来源:nfs-storage.clone.class.php
示例16: 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
示例17: create
//.........这里部分代码省略.........
}
}
}
}
// did we found any active host ?
if (count($active_appliance_list) < 1) {
$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Warning ! There is no active virtualization host type {$vhost_type->name} available to bring up a new VM", "", "", 0, 0, 0);
$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Notice : Trying to find a Host which can start-from-off .....", "", "", 0, 0, 0);
// if this method finds a host it will block until the host is up + active
$cloud_host_start_from_off = new cloudhoststartfromoff();
$start_from_off_appliance_id = $cloud_host_start_from_off->find_host_to_start_from_off($vhost_type->id, $show_resource_pools, $cu_id, $host_start_from_off_timeout);
if ($start_from_off_appliance_id > 0) {
//$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "------- adding appliance $id ", "", "", 0, 0, 0);
$active_appliance_list[] .= $start_from_off_appliance_id;
// add to active resource list
$start_from_off_appliance = new appliance();
$start_from_off_appliance->get_instance_by_id($start_from_off_appliance_id);
$active_appliance_resource_list[] .= $start_from_off_appliance->resources;
} else {
// here we did not found any host to start-from-off
$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Warning ! Could not find any virtualization host type {$vhost_type->name} to start-from-off", "", "", 0, 0, 0);
$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Warning ! Giving up trying to start a new VM type {$vhost_type->name}", "", "", 0, 0, 0);
return false;
}
}
// ! for all virt-localboot VMs we need to make sure the VM is created on
// ! the same host as the image is located, for all others we try to lb
$less_load_resource_id = -1;
if (strstr($vtype->type, "-vm-local")) {
$origin_appliance = new appliance();
$origin_appliance->get_instance_by_name($name);
// if we have a cloudappliance already this create is coming from unpause
// The host to create the new VM on must be the image storage resource
$vstorage_cloud_app = new cloudappliance();
$vstorage_cloud_app->get_instance_by_appliance_id($origin_appliance->id);
if (strlen($vstorage_cloud_app->id)) {
$vstorage_image = new image();
$vstorage_image->get_instance_by_id($origin_appliance->imageid);
$vstorage = new storage();
$vstorage->get_instance_by_id($vstorage_image->storageid);
$vstorage_host_res_id = $vstorage->resource_id;
// check if the origin host is in the active appliances we have found
if (in_array($vstorage_host_res_id, $active_appliance_resource_list)) {
$event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Origin host {$vstorage_host_res_id} is active. Creating the new VM", "", "", 0, 0, 0);
$resource = new resource();
$resource->get_instance_by_id($vstorage_host_res_id);
$less_load_resource_id = $vstorage_host_res_id;
} else {
$event->log("create", $_SERVER['REQUEST_TIME'], 2, "cloudvm.class.php", "Origin host {$vstorage_host_res_id} is not active. Not creating the new VM", "", "", 0, 0, 0);
}
} else {
// if we do not have a cloudappliance yet we can (should) loadbalance the create VM request
$event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Using Loadbalancing Algorithm " . $vm_loadbalance_algorithm . " for creating the new VM", "", "", 0, 0, 0);
// the cloud-deployment hook of the virt-localboot VM will adapt the image storage id to the host id
switch ($vm_loadbalance_algorithm) {
case '0':
$less_load_resource_id = $this->vm_balance_load($active_appliance_list);
break;
case '1':
$less_load_resource_id = $this->vm_balance_memory($active_appliance_list, $memory);
break;
case '2':
$less_load_resource_id = $this->vm_balance_random($active_appliance_list);
break;
case '3':
$less_load_resource_id = $this->vm_balance_first_available($active_appliance_list);
开发者ID:kelubo,项目名称:OpenQRM,代码行数:67,代码来源:cloudvm.class.php
示例18: str_replace
require_once "{$plugin_start_appliance_hook}";
$appliance_function = "openqrm_" . "{$plugin_name}" . "_appliance";
$appliance_function = str_replace("-", "_", $appliance_function);
// stop
$appliance_function("stop", $appliance_fields);
// remove
$appliance_function("remove", $appliance_fields);
}
}
// remove appliance
$appliance->remove($appliance_id);
}
}
// remove kernel
$kernel = new kernel();
$kernel->remove_by_name("resource{$local_server_id}");
// remove image
$image = new image();
$image->remove_by_name("resource{$local_server_id}");
// remove storage serveer
$storage = new storage();
$storage->remove_by_name("resource{$local_server_id}");
break;
default:
$event->log("{$local_server_command}", $_SERVER['REQUEST_TIME'], 3, "local-server-action", "No such local-server command ({$local_server_command})", "", "", 0, 0, 0);
break;
}
?>
</body>
开发者ID:kelubo,项目名称:OpenQRM,代码行数:30,代码来源:local-server-action.php
示例19: 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;
// 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);
}
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:62,代码来源:openqrm-lvm-nfs-deployment-auth-hook.php
示例20: 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", "Cr
|
请发表评论