本文整理汇总了PHP中image::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP image::remove方法的具体用法?PHP image::remove怎么用?PHP image::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: image
function image()
{
$response = '';
$errors = array();
$message = array();
$image_command = $this->response->html->request()->get('image_command');
if ($image_command !== '') {
switch ($image_command) {
case 'add':
$root_device = $this->response->html->request()->get('root_device');
if ($this->deployment->type == 'kvm-gluster-deployment') {
$image_name = $this->response->html->request()->get('image_name');
} else {
$image_name = basename($root_device);
}
// check if image name is not in use yet
$image = new image();
$image->get_instance_by_name($image_name);
if (strlen($image->id)) {
$errors[] = sprintf($this->lang['error_exists'], $image_name);
} else {
$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'] = $image_name;
$image_fields['image_type'] = $this->deployment->type;
$image_fields['image_rootfstype'] = 'local';
$image_fields['image_storageid'] = $this->storage->id;
$image_fields['image_comment'] = "Image Object for volume {$image_name}";
$image_fields['image_rootdevice'] = $root_device;
$image = new image();
$image->add($image_fields);
$message[] = sprintf($this->lang['msg_added_image'], $image_name);
}
break;
case 'remove':
$image_id = $this->response->html->request()->get('image_id');
// check if image is not in use any more before removing
$remove_error = 0;
$appliance = new appliance();
$appliance_id_list = $appliance->get_all_ids();
foreach ($appliance_id_list as $appliance_list) {
$appliance_id = $appliance_list['appliance_id'];
$app_image_remove_check = new appliance();
$app_image_remove_check->get_instance_by_id($appliance_id);
if ($app_image_remove_check->imageid == $image_id) {
$image_is_used_by_appliance .= $appliance_id . " ";
$remove_error = 1;
}
}
if ($remove_error == 1) {
$errors[] = sprintf($this->lang['error_image_still_in_use'], $image_id, $image_is_used_by_appliance);
} else {
$image_remove = new image();
$image_remove->remove($image_id);
$message[] = sprintf($this->lang['msg_removed_image'], $image_id);
}
break;
}
if (count($errors) === 0) {
$response = join('<br>', $message);
} else {
$msg = array_merge($errors, $message);
$response = join('<br>', $msg);
}
} else {
$response = '';
}
return $response;
}
示例2: stripslashes
$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);
break;
case 'remove':
$image = new image();
$image->remove($image_id);
break;
case 'remove_by_name':
$image = new image();
$image->remove_by_name($image_name);
break;
case 'add_deployment_type':
$deployment = new deployment();
$deployment_fields["deployment_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$deployment->add($deployment_fields);
break;
case 'remove_deployment_type':
$deployment = new deployment();
$deployment->remove_by_type($deployment_name);
break;
default:
示例3: openqrm_cloud_monitor
//.........这里部分代码省略.........
$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 #################
// check for auto-create vms, if yes remove the resource if it is virtual
$app_stop_autovm_remove_conf = new cloudconfig();
$app_stop_auto_remove_vms = $app_stop_autovm_remove_conf->get_value(7);
// 7 is auto_create_vms
if (!strcmp($app_stop_auto_remove_vms, "true")) {
// we only remove virtual machines
if ($ci_resource->vtype != 1) {
// check if we still wait for the image_authentication stop hook
unset($ci_image_authentication);
$ci_image_authentication = new image_authentication();
$ci_image_authentication->get_instance_by_image_id($ci_image_id);
if (strlen($ci_image_authentication->id)) {
// we still wait for the image_authentication hook to run
continue;
}
// cloudvm->remove .....
$event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "monitor-hook", "Auto-removing resource {$ci_resource_id}", "", "", 0, 0, 0);
$auto_cloudvm = new cloudvm();
$auto_cloudvm->remove($ci_resource_id, $ci_resource->vtype, $ci_appliance->name, $ci_resource->mac);
// update cloudimage with resource -1
$ar_ci_update = array('ci_resource_id' => "-1");
$ci->update($ci->id, $ar_ci_update);
$phase_one_actions = 1;
}
}
// ####################### end remove auto createed vm #############
}
// the image is still in use
continue;
}
// image not in use any more and resource active (idle) again ?
if ($ci_resource_id > 0) {
if (strcmp($ci_resource->state, "active")) {
// not yet active again
示例4: image
function image()
{
$response = '';
$errors = array();
$message = array();
$image_command = $this->response->html->request()->get('image_command');
if ($image_command !== '') {
switch ($image_command) {
case 'add':
$root_device = $this->response->html->request()->get('root_device');
$image_name = $this->response->html->request()->get('image_name');
// check if image name is not in use yet
$image = new image();
$image->get_instance_by_name($image_name);
if (strlen($image->id)) {
$errors[] = sprintf($this->lang['error_exists'], $image_name);
} else {
$image_rootfstype = '';
// 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 . '.lvm.' . $image_name . '.adapt';
$get_ident_command = $this->openqrm->get('basedir') . '/plugins/lvm-storage/bin/openqrm-lvm-storage adapt';
$get_ident_command .= ' -n ' . $image_name;
$get_ident_command .= ' -t ' . $this->deployment->type . ' -v ' . $this->volgroup;
$get_ident_command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
$get_ident_command .= ' --openqrm-ui-user ' . $this->user->name;
$get_ident_command .= ' --openqrm-cmd-mode background';
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();
}
$found = false;
if ($this->deployment->type == 'lvm-aoe-deployment') {
$name = $root_device;
$root_device = '';
$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) {
$root_device = $ident_line[1];
$image_rootfstype = 'ext3';
$found = true;
break;
}
}
}
}
} else {
if ($this->deployment->type == 'lvm-iscsi-deployment') {
$image_rootfstype = 'ext3';
$found = true;
} else {
if ($this->deployment->type == 'lvm-nfs-deployment') {
$image_rootfstype = 'nfs';
$found = true;
}
}
}
if ($found) {
$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'] = $image_name;
$image_fields['image_type'] = $this->deployment->type;
$image_fields['image_rootfstype'] = $image_rootfstype;
$image_fields['image_storageid'] = $this->storage->id;
$image_fields['image_comment'] = "Image Object for volume {$image_name}";
$image_fields['image_rootdevice'] = $root_device;
$image = new image();
$image->add($image_fields);
$message[] = sprintf($this->lang['msg_added_image'], $image_name);
} else {
$message[] = sprintf($this->lang['msg_add_failed'], $image_name);
}
}
break;
case 'remove':
$image_id = $this->response->html->request()->get('image_id');
// check if image is not in use any more before removing
$remove_error = 0;
$appliance = new appliance();
$appliance_id_list = $appliance->get_all_ids();
foreach ($appliance_id_list as $appliance_list) {
$appliance_id = $appliance_list['appliance_id'];
$app_image_remove_check = new appliance();
$app_image_remove_check->get_instance_by_id($appliance_id);
if ($app_image_remove_check->imageid == $image_id) {
$image_is_used_by_appliance .= $appliance_id . " ";
$remove_error = 1;
}
}
if ($remove_error == 1) {
//.........这里部分代码省略.........
示例5: add
function add()
{
$response = $this->get_response();
$form = $response->form;
if (!$form->get_errors() && $this->response->submit()) {
$config = $form->get_request('config');
$storage_id = $this->response->html->request()->get('storage_id');
$storage = new storage();
$resource = new resource();
$storage->get_instance_by_id($storage_id);
$resource->get_instance_by_id($storage->resource_id);
$file = $this->openqrm->get('basedir') . "/plugins/nfs-storage/web/storage/" . $resource->id . ".nfs.stat.manual";
$image = new image();
$error = '';
// get old data
$old = array();
if ($this->file->exists($file)) {
$old = $this->file->get_contents($file);
$old = str_replace("\r\n", "\n", $old);
$old = explode("\n", $old);
}
if (isset($config) && $config !== '') {
$new = str_replace("\r\n", "\n", $config);
$new = explode("\n", $new);
$new = array_unique($new);
// sync old and new values
foreach ($old as $v) {
if (!in_array($v, $new)) {
$name = substr($v, strrpos($v, '/') + 1);
if (isset($name) && $name !== '' && $name !== false) {
$current = $image->get_instance_by_name($name);
if (isset($current) && $current->name === $name) {
$image->remove($current->id);
}
}
} else {
if (in_array($v, $new)) {
unset($new[array_search($v, $new)]);
}
}
}
// add new values to images
foreach ($new as $v) {
$name = substr($v, strrpos($v, '/') + 1);
if (isset($name) && $name !== '' && $name !== false) {
$current = $image->get_instance_by_name($name);
if (isset($current) && $current->name === $name) {
$error[] = sprintf($this->lang['error_image_in_use'], $name, $v);
} else {
if ($v !== '') {
$tables = $this->openqrm->get('table');
$f['image_id'] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$f['image_name'] = $name;
$f['image_type'] = 'nfs-deployment';
$f['image_rootfstype'] = 'nfs';
$f['image_rootdevice'] = $v;
$f['image_storageid'] = $this->storage;
$f['image_comment'] = 'Manually added nfs export';
$image->add($f);
}
}
} else {
if ((!isset($name) || $name === '' || $name === false) && $v !== '') {
$error[] = $this->lang['error_name_empty'];
}
}
}
// handle config file
if ($error === '') {
if (!($handle = fopen($file, 'w+'))) {
$error = "Cannot open file ({$file})";
}
if (fwrite($handle, $config) === FALSE) {
$error = "Cannot write to file ({$file})";
}
if ($error !== '') {
$response->error = $error;
} else {
$response->msg = $this->lang['saved'];
}
} else {
if (is_array($error)) {
$response->error = implode('<br>', $error);
} else {
if (is_string($error)) {
$response->error = $error;
}
}
}
} else {
// remove old values from image table
foreach ($old as $v) {
if (!in_array($v, $new)) {
$name = substr($v, strrpos($v, '/') + 1);
if (isset($name) && $name !== '' && $name !== false) {
$current = $image->get_instance_by_name($name);
if (isset($current) && $current->name === $name) {
$image->remove($current->id);
}
}
//.........这里部分代码省略.........
示例6: remove
function remove()
{
$response = $this->get_response();
$remove_image_id = $this->response->html->request()->get($this->identifier_name);
$force_remove = $response->html->request()->get('force_remove');
$form = $response->form;
$image = new image();
if ($remove_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->get_instance_by_id($remove_image_id);
$d['param_f' . $remove_image_id]['label'] = $image->name;
$d['param_f' . $remove_image_id]['object']['type'] = 'htmlobject_input';
$d['param_f' . $remove_image_id]['object']['attrib']['type'] = 'checkbox';
$d['param_f' . $remove_image_id]['object']['attrib']['name'] = $this->identifier_name;
$d['param_f' . $remove_image_id]['object']['attrib']['value'] = $remove_image_id;
$d['param_f' . $remove_image_id]['object']['attrib']['checked'] = true;
$d['force_remove']['label'] = $this->lang['msg_force_remove'];
$d['force_remove']['object']['type'] = 'htmlobject_input';
$d['force_remove']['object']['attrib']['type'] = 'checkbox';
$d['force_remove']['object']['attrib']['name'] = 'force_remove';
$d['force_remove']['object']['attrib']['value'] = 1;
$d['force_remove']['object']['attrib']['checked'] = false;
$form->add($d);
if (!$form->get_errors() && $response->submit()) {
$errors = array();
$message = array();
if ($force_remove == 1) {
$image->get_instance_by_id($remove_image_id);
$image_is_used_by_appliance = "";
$remove_error = 0;
$appliance = new appliance();
$appliance_id_list = $appliance->get_all_ids();
foreach ($appliance_id_list as $appliance_list) {
$appliance_id = $appliance_list['appliance_id'];
$app_image_remove_check = new appliance();
$app_image_remove_check->get_instance_by_id($appliance_id);
if ($app_image_remove_check->imageid == $remove_image_id) {
$image_is_used_by_appliance .= $appliance_id . " ";
$remove_error = 1;
}
}
if ($remove_error == 1) {
$message[] = sprintf($this->lang['msg_not_removing_active'], $remove_image_id, $image_is_used_by_appliance);
} else {
$image_name = $image->name;
$image->remove($remove_image_id);
$form->remove($this->identifier_name . '[' . $remove_image_id . ']');
$message[] = sprintf($this->lang['msg'], $image_name);
}
} else {
$message[] = sprintf($this->lang['msg_not_removing'], $image->name);
}
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;
}
示例7: foreach
foreach ($list as $hc_id) {
$storage->get_instance_by_id($hc_id);
if ($storage->resource_id == 0) {
$found_hc = true;
$found_hc_id = $storage->id;
break;
}
}
}
if ($found_hc) {
// remove all AMI Images, then the storage
$image = new image();
$hc_image_list = $image->get_ids_by_storage($found_hc_id);
foreach ($hc_image_list as $list) {
foreach ($list as $hc_image_id) {
$image->remove($hc_image_id);
$event->log("init", $_SERVER['REQUEST_TIME'], 5, "hybrid-cloud-ation", "Removed AMI Image Object " . $hc_image_id . ".", "", "", 0, 0, 0);
}
}
$storage->remove($found_hc_id);
}
// remove cloud products
if (file_exists($cloud_usergroup_class)) {
require_once $cloud_usergroup_class;
$cloud_project = new cloudusergroup();
$cloud_project->get_instance_by_name('Admin');
if (file_exists($cloud_selector_class)) {
if (file_exists($cloud_product_hook)) {
$cloud_hook_config = array();
$cloud_hook_config['cloud_admin_procect'] = $cloud_project->id;
require_once $cloud_product_hook;
示例8: image
function __remove_cloud_image($image_id, $noop)
{
$error = '';
$image = new image();
$image->get_instance_by_id($image_id);
if (strlen($image->name)) {
$authblocker = new authblocker();
$authblocker->get_instance_by_image_id($image->id);
if ($authblocker->image_name == $image->name) {
if ($noop) {
$authblocker->remove($authblocker->id);
} else {
// error
$error = "removing authblocker: " . $authblocker->id . "<br>";
}
}
$this->cloudimage->get_instance_by_image_id($image_id);
if ($noop) {
$this->cloudstorage->remove($this->cloudimage->id, $this->timeout);
$image->remove($image->id);
}
}
return $error;
}