本文整理汇总了PHP中image::get_instance_by_name方法的典型用法代码示例。如果您正苦于以下问题:PHP image::get_instance_by_name方法的具体用法?PHP image::get_instance_by_name怎么用?PHP image::get_instance_by_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::get_instance_by_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: add
function add()
{
$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'], $this->max));
}
if (!$form->get_errors()) {
$name = $form->get_request('name');
$command = $this->openqrm->get('basedir') . '/plugins/kvm/bin/openqrm-kvm add';
$command .= ' -n ' . $name . ' -m ' . $form->get_request('size');
$command .= ' -o ' . $form->get_request('type');
$command .= ' -t ' . $this->deployment->type . ' -v ' . $this->volgroup;
$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/kvm/web/storage/' . $this->resource->id . '.' . $this->volgroup . '.lv.stat';
if ($this->file->exists($statfile)) {
$lines = explode("\n", $this->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);
}
}
}
}
}
// check for image name
$image = new image();
$image->get_instance_by_name($name);
if (isset($image->id) && $image->id > 1) {
$error = sprintf($this->lang['error_exists'], $name);
}
if (isset($error)) {
$response->error = $error;
} else {
if ($this->file->exists($statfile)) {
$this->file->remove($statfile);
}
$this->resource->send_command($this->resource->ip, $command);
while (!$this->file->exists($statfile)) {
usleep(10000);
// sleep 10ms to unload the CPU
clearstatcache();
}
// add check that volume $name is now in the statfile
$created = false;
$bf_volume_path = "";
$lines = explode("\n", $this->file->get_contents($statfile));
if (count($lines) >= 1) {
foreach ($lines as $line) {
if ($line !== '') {
$line = explode('@', $line);
$check = $line[1];
if ($name === $check) {
$created = true;
$bf_volume_path = $line[2];
break;
}
}
}
}
if ($created) {
$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'] = $this->deployment->type;
$image_fields['image_rootfstype'] = 'local';
$image_fields['image_storageid'] = $this->storage->id;
$image_fields['image_comment'] = "Image Object for volume {$name}";
switch ($this->deployment->type) {
case 'kvm-lvm-deployment':
$image_fields['image_rootdevice'] = '/dev/' . $this->volgroup . '/' . $name;
break;
case 'kvm-bf-deployment':
$image_fields['image_rootdevice'] = $bf_volume_path;
break;
case 'kvm-gluster-deployment':
$image_fields['image_rootdevice'] = "gluster://" . $this->resource->ip . "/" . $this->volgroup . "/" . $name;
break;
}
$image = new image();
$image->add($image_fields);
$response->msg = sprintf($this->lang['msg_added'], $name);
// save image id in response for the wizard
$response->image_id = $image_fields["image_id"];
} else {
$response->msg = sprintf($this->lang['msg_add_failed'], $name);
}
}
}
}
return $response;
}
示例3: remove
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;
}
示例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: openqrm_cloud_monitor
//.........这里部分代码省略.........
$tmp_cloud_app = new cloudappliance();
$tmp_cloud_app_id = $capp['ca_id'];
$tmp_cloud_app->get_instance_by_id($tmp_cloud_app_id);
// active ?
if ($tmp_cloud_app->state == 0) {
continue;
}
// check if the cr is ours
$rc_tmp_cr = new cloudrequest();
$rc_tmp_cr->get_instance_by_id($tmp_cloud_app->cr_id);
if ($rc_tmp_cr->cu_id != $cr_cu_id) {
continue;
}
$users_appliance_count++;
}
// $event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "cloud-monitor", "User $cr_cu_id has already $users_appliance_count appliance(s) running.", "", "", 0, 0, 0);
$cc_max_app = new cloudconfig();
$max_apps_per_user = $cc_max_app->get_value(13);
// 13 is max_apps_per_user
if ($users_appliance_count + $resource_quantity > $max_apps_per_user) {
$event->log("cloud", $_SERVER['REQUEST_TIME'], 2, "cloud-monitor", "Not provisining CR {$cr_id} from user {$cr_cu_id} who has already {$users_appliance_count} appliance(s) running.", "", "", 0, 0, 0);
$cr->setstatus($cr_id, 'deny');
continue;
}
$cr_resource_number = 1;
// ################################## create appliance ###############################
// set hostname
$appliance_name = "cloud-" . $cr_id . "-" . $cr_resource_number . "-x";
if (!strcmp($cloud_appliance_hostname_enabled, "true")) {
if (strlen($cr->appliance_hostname)) {
$appliance_requested_hostname = $cr->appliance_hostname;
// check if the hostname is free, if not return to regular naming convention
$appliance_chk_hostname = new appliance();
$appliance_chk_hostname->get_instance_by_name($appliance_requested_hostname);
if ($appliance_chk_hostname->id > 0) {
$event->log("cloud", $_SERVER['REQUEST_TIME'], 2, "cloud-monitor", "Requested hostname " . $appliance_requested_hostname . " already in use. Reverting to " . $appliance_name . " (CR ID " . $cr_id . ").", "", "", 0, 0, 0);
} else {
// set requested hostname
$appliance_name = $appliance_requested_hostname;
}
}
}
// update cr with new hostname
$cr_update_hostname_fields = array();
$cr_update_hostname_fields["cr_appliance_hostname"] = $appliance_name;
$cr->update($cr->id, $cr_update_hostname_fields);
$cr->get_instance_by_id($cr->id);
// get new appliance id
$appliance_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
// we
$user_network_cards = $cr->network_req + 1;
// prepare array to add appliance
$ar_request = array('appliance_id' => $appliance_id, 'appliance_resources' => "-1", 'appliance_name' => $appliance_name, 'appliance_kernelid' => $cr->kernel_id, 'appliance_imageid' => $cr->image_id, 'appliance_virtualization' => $cr->resource_type_req, 'appliance_cpunumber' => $cr->cpu_req, 'appliance_memtotal' => $cr->ram_req, 'appliance_nics' => $user_network_cards, 'appliance_comment' => "Requested by user {$cu_name}", 'appliance_ssi' => $cr->shared_req, 'appliance_highavailable' => $cr->ha_req, 'appliance_capabilities' => $cr->appliance_capabilities);
// create + start the appliance :)
$appliance = new appliance();
$appliance->add($ar_request);
// first get admin email
$cc_acr_conf = new cloudconfig();
$cc_acr_admin_email = $cc_acr_conf->get_value(1);
// 1 is admin_email
// and the user details
$cu_name = $cu->name;
$cu_forename = $cu->forename;
$cu_lastname = $cu->lastname;
$cu_email = $cu->email;
// now lets find a resource for this new appliance
示例6: edit
//.........这里部分代码省略.........
$hc_authentication .= ' -p ' . $this->hc->password;
$hc_authentication .= ' -q ' . $this->hc->host;
$hc_authentication .= ' -x ' . $this->hc->port;
$hc_authentication .= ' -g ' . $this->hc->tenant;
$hc_authentication .= ' -e ' . $this->hc->endpoint;
$hc_authentication .= ' -f ' . $this->filter;
#$d['ami_type_switch'] = '';
}
$command = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/bin/openqrm-hybrid-cloud-ami describe_images';
$command .= ' -i ' . $this->hc->id;
$command .= ' -t ' . $this->hc->account_type;
$command .= ' -n ' . $this->hc->account_name;
$command .= $hc_authentication;
$command .= ' --openqrm-ui-user ' . $this->user->name;
$command .= ' --openqrm-cmd-mode background';
$server = new openqrm_server();
$server->send_command($command, NULL, true);
while (!$this->file->exists($file)) {
usleep(10000);
// sleep 10ms to unload the CPU
clearstatcache();
}
$content = $this->file->get_contents($file);
$content = explode("\n", $content);
$b = array();
foreach ($content as $k => $v) {
if ($v !== '') {
// e.g. IMAGE@ami-25f9c051@021471307000/ami_hapx_ubuntu_10_04@021471307000@available@public@@i386@machine@aki-4deec439@@@ebs@paravirtual@xen
$tmp = explode('@', $v);
$ami = $tmp[1];
$path = $tmp[2];
if ($this->hc->account_type == 'aws' || $this->hc->account_type == 'euca') {
$state = $tmp[4];
$perm = $tmp[5];
$arch = $tmp[7];
$type = $tmp[13];
$virt = $tmp[14];
}
if ($this->hc->account_type == 'lc-openstack') {
$state = '';
$perm = '';
$arch = '';
$type = '';
$virt = '';
}
if ($arch != "i386" && $arch != "x86_64") {
$arch = '';
}
$image_add_remove = '';
$deployment_type = '';
$image = new image();
$image->get_instance_by_name($ami);
if (strlen($image->id)) {
if ($image->type != $this->deployment->type) {
$deployment_type = $image->type;
$disabled[] = $ami;
} else {
$i = $this->response->html->a();
$i->title = $this->lang['action_remove_image'];
$i->label = $this->lang['action_remove_image'];
$i->handler = 'onclick="wait();"';
$i->css = 'edit';
$i->href = $this->response->get_url($this->actions_name, "image") . '&image_id=' . $image->id . '&image_command=remove';
$image_add_remove = $i;
}
} else {
$i = $this->response->html->a();
$i->title = $this->lang['action_add_image'];
$i->label = $this->lang['action_add_image'];
$i->handler = 'onclick="wait();"';
$i->css = 'edit';
$i->href = $this->response->get_url($this->actions_name, "image") . '&image_name=' . $ami . '&image_rootdevice=' . $ami . '&image_comment=' . basename($path) . '&image_command=add';
$disabled[] = $ami;
$image_add_remove = $i;
}
$b[] = array('ami' => $ami, 'path' => basename($path), 'perm' => $perm, 'arch' => $arch, 'type' => $type, 'virt' => $virt, 'state' => $arch, 'image' => $image_add_remove);
}
}
$params = $this->response->get_array($this->actions_name, 'edit');
$table = $this->response->html->tablebuilder('hybridcloud_ami_edit', $params);
$table->offset = 0;
$table->sort = 'ami';
$table->limit = 200;
$table->order = 'ASC';
$table->id = 'Tabelle';
$table->css = 'htmlobject_table';
$table->border = 1;
$table->cellspacing = 0;
$table->cellpadding = 3;
$table->autosort = true;
$table->sort_link = false;
$table->max = count($b);
$table->head = $h;
$table->body = $b;
$table->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), array("value" => 200, "text" => 200));
$d['name'] = $this->hc->account_name;
$d['form'] = $this->response->get_form($this->actions_name, 'edit', false)->get_elements();
$d['table'] = $table;
return $d;
}
示例7: 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);
}
}
//.........这里部分代码省略.........
示例8: edit
function edit()
{
if (strpos($this->deployment->type, 'lvm') !== false) {
$resource_icon_default = "/img/resource.png";
$storage_icon = "/plugins/lvm-storage/img/plugin.png";
$state_icon = '<span class="pill">' . $this->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;
// Storage info
$d['state'] = $state_icon;
// $d['icon'] = "<img width=24 height=24 src=$resource_icon_default>";
$d['resource'] = $this->resource->id . ' / ' . $this->resource->ip;
$d['name'] = $this->storage->name;
$d['deployment'] = $this->deployment->type;
$d['id'] = $this->storage->id;
// Volgroup info
$lines = explode("\n", file_get_contents($this->openqrm->get('basedir') . '/plugins/lvm-storage/web/storage/' . $this->resource->id . '.vg.stat'));
foreach ($lines as $line) {
$line = explode("@", $line);
if (isset($line[0]) && $line[0] === $this->volgroup) {
$vsize = number_format(substr($line[5], 0, strpos($line[5], '.')), 0, '', '') . ' MB';
$vfree = str_replace('m', '', $line[6]);
if ($vfree !== '0') {
$vfree = substr($line[6], 0, strpos($line[6], '.'));
}
$d['volgroup_name'] = $line[0];
$d['volgroup_pv'] = $line[1];
$d['volgroup_lv'] = $line[2];
$d['volgroup_sn'] = $line[3];
$d['volgroup_attr'] = $line[4];
$d['volgroup_vsize'] = $vsize;
$d['volgroup_vfree'] = number_format($vfree, 0, '', '') . ' MB';
}
}
$a = ' ';
if ($d['volgroup_vfree'] !== '0 MB') {
$a = $this->response->html->a();
$a->label = $this->lang['action_add'];
$a->css = 'add';
$a->href = $this->response->get_url($this->actions_name, "add");
}
$d['add'] = $a;
$body = array();
$file = $this->statfile;
if (file_exists($file)) {
$lines = explode("\n", file_get_contents($file));
if (count($lines) >= 1) {
$disabled = array();
$t = $this->response->html->template($this->openqrm->get('webdir') . '/js/openqrm-progressbar.js');
foreach ($lines as $line) {
if ($line !== '') {
$s = ' ';
$c = ' ';
$r = ' ';
$src = ' ';
$line = explode('@', $line);
$name = $line[1];
$mode = substr($line[3], 0, 1);
if ($line[4] == "clone_in_progress") {
// add to disabled identifier
$disabled[] = $name;
// progressbar
$t->add(uniqid('b'), 'id');
$t->add($this->openqrm->get('baseurl') . '/api.php?action=plugin&plugin=lvm-storage&lvm_storage_action=progress&name=' . $this->resource->id . '.lvm.' . $name . '.sync_progress', 'url');
$t->add($this->lang['action_clone_in_progress'], 'lang_in_progress');
$t->add($this->lang['action_clone_finished'], 'lang_finished');
$volume_size = $t->get_string();
} else {
if ($line[4] == "sync_in_progress") {
$volume_size = $this->lang['action_sync_in_progress'];
$disabled[] = $name;
} else {
$volume_size = number_format(substr($line[4], 0, strpos($line[4], '.')), 0, '', '') . ' MB';
$image_add_remove = '';
$deployment_type = '';
$image = new image();
$image->get_instance_by_name($name);
if (strlen($image->id)) {
if ($image->type == $this->deployment->type) {
if ($line[0] === $this->deployment->type) {
if ($d['volgroup_vfree'] !== '0 MB') {
if ($mode !== 's') {
$s = $this->response->html->a();
$s->title = $this->lang['action_snap'];
$s->label = $this->lang['action_snap'];
$s->handler = 'onclick="wait();"';
$s->css = 'snap';
$s->href = $this->response->get_url($this->actions_name, "snap") . '&lvol=' . $line[1];
} else {
$disabled[] = $line[5];
$src = $line[5];
}
if ($vfree >= (int) substr($line[4], 0, strpos($line[4], '.'))) {
$c = $this->response->html->a();
$c->title = $this->lang['action_clone'];
$c->label = $this->lang['action_clone'];
$c->handler = 'onclick="wait();"';
$c->css = 'clone';
//.........这里部分代码省略.........
示例9: CloudProvision
function CloudProvision($method_parameters)
{
global $CLOUD_REQUEST_TABLE;
global $event;
$parameter_array = explode(',', $method_parameters);
$mode = $parameter_array[0];
$username = $parameter_array[1];
$password = $parameter_array[2];
$cloud_username = $parameter_array[3];
$start = $parameter_array[4];
$stop = $parameter_array[5];
$kernel_id = $parameter_array[6];
$image_name = $parameter_array[7];
$ram_req = $parameter_array[8];
$cpu_req = $parameter_array[9];
$disk_req = $parameter_array[10];
$network_req = $parameter_array[11];
$resource_quantity = $parameter_array[12];
$virtualization_id = $parameter_array[13];
$ha_req = $parameter_array[14];
$application_groups = $parameter_array[15];
$ip_mgmt = $parameter_array[16];
$app_hostname = $parameter_array[17];
$app_hostname = preg_replace('/\\s\\s+/', ' ', trim($app_hostname));
// check all user input
for ($i = 0; $i <= 17; $i++) {
if (!$this->check_param($parameter_array[$i])) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Not allowing user-intput with special-characters : {$parameter_array[$i]}", "", "", 0, 0, 0);
return -1;
}
}
// check parameter count
$parameter_count = count($parameter_array);
if ($parameter_count != 18) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Wrong parameter count {$parameter_count} ! Exiting.", "", "", 0, 0, 0);
return -2;
}
// check authentication
if (!$this->check_user($mode, $username, $password)) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "User authentication failed (mode {$mode})", "", "", 0, 0, 0);
return -3;
}
$cc_conf = new cloudconfig();
$cl_user = new clouduser();
// check that the user exists in the Cloud
if ($cl_user->is_name_free($cloud_username)) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User name {$cloud_username} does not exists in the Cloud. Not adding the request !", "", "", 0, 0, 0);
return -4;
}
// check that in user mode the username is the same as the cloud_username
switch ($mode) {
case 'user':
if (strcmp($username, $cloud_username)) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User {$username} is trying to submit a Provsion request as Cloud User {$cloud_username} !", "", "", 0, 0, 0);
return -5;
}
break;
}
// check if billing is enabled
$cl_user->get_instance_by_name($cloud_username);
$cloud_billing_enabled = $cc_conf->get_value(16);
// 16 is cloud_billing_enabled
if ($cloud_billing_enabled == 'true') {
if ($cl_user->ccunits < 1) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud for user {$cloud_username} does not have any CCUs! Not adding the request.", "", "", 0, 0, 0);
return -6;
}
}
// check valid hostname
if (!$this->check_hostname($app_hostname)) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Not allowing user hostname intput with special-characters : " . $app_hostname, "", "", 0, 0, 0);
return -1;
}
// check global limits
// max disk size
$max_disk_size = $cc_conf->get_value(8);
// 8 is max_disk_size config
if ($disk_req > $max_disk_size) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User {$cloud_username} Disk must be <= {$max_disk_size}.", "", "", 0, 0, 0);
return -7;
}
// max network interfaces
$max_network_infterfaces = $cc_conf->get_value(9);
// 9 is max_network_interfaces
if ($network_req > $max_network_infterfaces) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User {$cloud_username} Network must be <= {$max_network_infterfaces}.", "", "", 0, 0, 0);
return -8;
}
// max resource per cr
$max_res_per_cr = $cc_conf->get_value(6);
// 6 is max_resources_per_cr
if ($resource_quantity > $max_res_per_cr) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User {$cloud_username} Resource quantity must be <= {$max_res_per_cr}.", "", "", 0, 0, 0);
return -9;
}
// check user limits
$cloud_user_limit = new clouduserlimits();
$cloud_user_limit->get_instance_by_cu_id($cl_user->id);
if (!$cloud_user_limit->check_limits($resource_quantity, $ram_req, $disk_req, $cpu_req, $network_req)) {
$event->log("cloudsoap->CloudProvision", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User {$cloud_username} exceeds its Cloud-Limits ! Not adding the request.", "", "", 0, 0, 0);
//.........这里部分代码省略.........
示例10: 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');
// 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;
}
示例11: edit
function edit()
{
if ($this->deployment->type === 'iscsi-deployment') {
$resource_icon_default = "/img/resource.png";
$storage_icon = "/plugins/iscsi-storage/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;
$d['state'] = "<img width=24 height=24 src={$state_icon}>";
$d['icon'] = "<img width=24 height=24 src={$resource_icon_default}>";
$d['resource'] = $this->resource->id . ' / ' . $this->resource->ip;
$d['name'] = $this->storage->name;
$d['id'] = $this->storage->id;
$a = $this->response->html->a();
$a->label = $this->lang['action_add'];
$a->css = 'add';
$a->handler = 'onclick="wait();"';
$a->href = $this->response->get_url($this->actions_name, "add");
$d['add'] = $a->get_string();
$body = array();
$identifier_disabled = array();
$file = $this->statfile;
if (file_exists($file)) {
$lines = explode("\n", file_get_contents($file));
if (count($lines) >= 1) {
$i = 0;
$t = $this->response->html->template($this->openqrm->get('webdir') . '/js/openqrm-progressbar.js');
foreach ($lines as $line) {
if ($line !== '') {
$line = explode('@', $line);
if ($i === 0) {
$d['vsize'] = number_format($line[0], 0, '', '') . ' MB';
$d['vfree'] = number_format($line[1], 0, '', '') . ' MB';
} else {
$name = $line[2];
$volume_size = $line[5];
$auth_link = ' ';
$clone_link = ' ';
// create/remove image object, check if image exists
$image_add_remove = '';
$deployment_type = '';
$image = new image();
$image->get_instance_by_name($name);
if (strlen($image->id)) {
if ($image->type == $this->deployment->type) {
if ($line[0] === $this->deployment->type) {
if ($d['vfree'] !== '0 MB') {
$a = $this->response->html->a();
$a->title = $this->lang['action_clone'];
$a->label = $this->lang['action_clone'];
$a->handler = 'onclick="wait();"';
$a->css = 'clone';
$a->href = $this->response->get_url($this->actions_name, "clone") . '&volume=' . $name;
$clone_link = $a->get_string();
}
$a = $this->response->html->a();
$a->title = $this->lang['action_auth'];
$a->label = $this->lang['action_auth'];
$a->handler = 'onclick="wait();"';
$a->css = 'edit';
$a->href = $this->response->get_url($this->actions_name, "auth") . '&volume=' . $name;
$auth_link = $a->get_string();
} else {
$identifier_disabled[] = $name;
}
}
}
// create/remove image object, check if image exists
$deployment_type = $this->deployment->type;
if (strlen($image->id)) {
if ($image->type != $this->deployment->type) {
$deployment_type = $image->type;
$identifier_disabled[] = $name;
} else {
$i = $this->response->html->a();
$i->title = $this->lang['action_remove_image'];
$i->label = $this->lang['action_remove_image'];
$i->handler = 'onclick="wait();"';
$i->css = 'edit';
$i->href = $this->response->get_url($this->actions_name, "image") . '&image_id=' . $image->id . '&image_command=remove';
$image_add_remove = $i;
}
} else {
$i = $this->response->html->a();
$i->title = $this->lang['action_add_image'];
$i->label = $this->lang['action_add_image'];
$i->handler = 'onclick="wait();"';
$i->css = 'edit';
if ($this->deployment->type === 'iscsi-deployment') {
$image_root_device = '/dev/' . $name . '/1';
$i->href = $this->response->get_url($this->actions_name, "image") . '&root_device=' . $image_root_device . '&image_name=' . $name . '&image_command=add';
}
$identifier_disabled[] = $name;
$image_add_remove = $i;
}
if ($volume_size == "clone_in_progress") {
// add to disabled identifier
$identifier_disabled[] = $name;
//.........这里部分代码省略.........
示例12: remove
function remove()
{
$response = $this->get_response();
$volume_names = $response->html->request()->get($this->identifier_name);
$form = $response->form;
if ($volume_names !== '') {
$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 ($volume_names 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()) {
$storage_id = $this->response->html->request()->get('storage_id');
$storage = new storage();
$resource = new resource();
$errors = array();
$message = array();
foreach ($volume_names as $key => $volume_name) {
// check if an appliance is still using the volume as an image
$image = new image();
$image->get_instance_by_name($volume_name);
// 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_image_still_in_use'], $volume_name, $image->id, $appliances_using_resource_str);
} else {
// remove volume
$linuxcoe_volume = new linuxcoe_volume();
$linuxcoe_volume->remove_by_name($volume_name);
// remove the image of the volume
$image->remove_by_name($volume_name);
$form->remove($this->identifier_name . '[' . $key . ']');
$message[] = sprintf($this->lang['msg_removed'], $volume_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;
}
示例13: image
function remove_by_name($image_name)
{
// do not remove the idle + openqrm image
if ($image_name == "openqrm" || $image_name == "idle") {
return;
}
// remove auth file
$rem_image = new image();
$rem_image->get_instance_by_name($image_name);
$rem_image_id = $rem_image->id;
$CMD = "rm -f {$this->_base_dir}/openqrm/web/action/image-auth/iauth.{$rem_image_id}";
exec($CMD);
// remove from db
$db = openqrm_get_db_connection();
$rs = $db->Execute("delete from {$this->_db_table} where image_name='{$image_name}'");
}
示例14: import
function import()
{
$response = '';
$errors = array();
$message = array();
$event = new event();
$instance_command = $this->response->html->request()->get('instance_command');
if ($instance_command !== '') {
switch ($instance_command) {
case 'add':
// instance_command=add
// &instance_name='.$name.'
// &instance_mac='.$mac.'
// &instance_public_ip='.$public_ip.'
// &instance_type='.$type.'
// &instance_keypair='.$keypair.'
// &instance_region='.$region.'
// &instance_ami='.$ami;
$now = $_SERVER['REQUEST_TIME'];
$openqrm = new openqrm_server();
$instance_name = $this->response->html->request()->get('instance_name');
$instance_mac = $this->response->html->request()->get('instance_mac');
$instance_public_ip = $this->response->html->request()->get('instance_public_ip');
$instance_type = $this->response->html->request()->get('instance_type');
$instance_keypair = $this->response->html->request()->get('instance_keypair');
$instance_region = $this->response->html->request()->get('instance_region');
$instance_ami = $this->response->html->request()->get('instance_ami');
// create resource, image and appliance
$event->log("import", $_SERVER['REQUEST_TIME'], 5, "hybrid-cloud-vm-import", "Importing " . $instance_name . " - " . $instance_mac . " - " . $instance_public_ip . " - " . $instance_type . " - " . $instance_keypair . " - " . $instance_region . " - " . $instance_ami . ".", "", "", 0, 0, 0);
$import_resource = new resource();
$deployment = new deployment();
$deployment->get_instance_by_name('ami-deployment');
$virtualization = new virtualization();
$virtualization->get_instance_by_type("hybrid-cloud-vm-local");
// create resource
$resid = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
// send command to the openQRM-server
$openqrm->send_command('openqrm_server_add_resource ' . $resid . ' ' . $instance_mac . ' ' . $instance_public_ip);
// add to openQRM database
$resource_fields["resource_id"] = $resid;
$resource_fields["resource_ip"] = $instance_public_ip;
$resource_fields["resource_mac"] = $instance_mac;
$resource_fields["resource_kernel"] = 'local';
$resource_fields["resource_kernelid"] = 0;
$resource_fields["resource_localboot"] = 0;
$resource_fields["resource_hostname"] = $this->hc->account_type . $resid;
$resource_fields["resource_vtype"] = $virtualization->id;
$resource_fields["resource_vhostid"] = 0;
$import_resource->add($resource_fields);
$import_resource->get_instance_by_mac($instance_mac);
// update stats
#if ($state == 'running') {
$rfields["resource_state"] = 'idle';
#$rfields["resource_lastgood"]=$now;
#} else {
# $rfields["resource_state"]='off';
#}
#$import_resource->update_info($import_resource->id, $rfields);
// set account id in resource capabilities
$import_resource->set_resource_capabilities("HCACL", $this->id);
// auto create image object
$storage = new storage();
$storage->get_instance_by_name('ami-image-storage');
$image = new image();
$image->get_instance_by_name($instance_ami);
if (isset($image->id) && $image->id > 0) {
$image_exists = true;
} else {
$image_fields = array();
$vm_image_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$image_fields["image_id"] = $vm_image_id;
$image_fields['image_name'] = $instance_ami;
$image_fields['image_type'] = 'ami-deployment';
$image_fields['image_rootfstype'] = 'local';
$image_fields['image_isactive'] = 0;
$image_fields['image_storageid'] = $storage->id;
$image_fields['image_comment'] = "Image Object for AMI {$instance_ami}";
$image_fields['image_rootdevice'] = $instance_ami;
$image->add($image_fields);
# update image object
$image->get_instance_by_id($vm_image_id);
// update resource with image infos
$rfields["resource_id"] = $resid;
$rfields["resource_image"] = $image->name;
$rfields["resource_imageid"] = $image->id;
$import_resource->update_info($import_resource->id, $rfields);
$import_resource->get_instance_by_mac($instance_mac);
}
// create the appliance
$appliance = new appliance();
$appliance->get_instance_by_name($instance_name);
if (isset($appliance->id) && $appliance->id > 0) {
$appliance_exists = true;
} else {
$new_appliance_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$afields['appliance_id'] = $new_appliance_id;
$afields['appliance_name'] = $this->hc->account_type . $resid;
$afields['appliance_resources'] = $resid;
$afields['appliance_kernelid'] = '1';
$afields['appliance_imageid'] = $image->id;
//.........这里部分代码省略.........
示例15: duplicate
function duplicate()
{
$response = $this->get_response();
$form = $response->form;
if (!$form->get_errors() && $this->response->submit()) {
$name = $form->get_request('name');
$command = $this->openqrm->get('basedir') . '/plugins/kvm/bin/openqrm-kvm clone';
$command .= ' -t ' . $this->deployment->type;
$command .= ' -v ' . $this->volgroup;
$command .= ' -n ' . $this->lvol;
$command .= ' -s ' . $name;
$command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
$command .= ' --caching false';
$command .= ' --openqrm-ui-user ' . $this->user->name;
$command .= ' --openqrm-cmd-mode background';
$statfile = $this->openqrm->get('basedir') . '/plugins/kvm/web/storage/' . $this->resource->id . '.' . $this->volgroup . '.lv.stat';
if ($this->file->exists($statfile)) {
$lines = explode("\n", $this->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);
}
}
}
}
}
// check for image name
$image = new image();
$image->get_instance_by_name($name);
if (isset($image->id) && $image->id > 1) {
$error = sprintf($this->lang['error_exists'], $name);
}
if (isset($error)) {
$response->error = $error;
} else {
$file = $this->openqrm->get('basedir') . '/plugins/kvm/web/storage/' . $this->resource->id . '.lvm.' . $name . '.sync_progress';
if ($this->file->exists($file)) {
$this->file->remove($file);
}
$root_device_ident = $this->openqrm->get('basedir') . '/plugins/kvm/web/storage/' . $this->resource->id . '.' . $name . '.root_device';
if ($this->file->exists($root_device_ident)) {
$this->file->remove($root_device_ident);
}
$this->resource->send_command($this->resource->ip, $command);
while (!$this->file->exists($file)) {
usleep(10000);
clearstatcache();
}
// wait for the root-device identifier
while (!$this->file->exists($root_device_ident)) {
usleep(10000);
clearstatcache();
}
$root_device = trim($this->file->get_contents($root_device_ident));
$this->file->remove($root_device_ident);
$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'] = $this->deployment->type;
$image_fields['image_rootfstype'] = 'local';
$image_fields['image_storageid'] = $this->storage->id;
$image_fields['image_comment'] = "Image Object for volume {$name}";
$image_fields['image_rootdevice'] = $root_device;
$image = new image();
$image->add($image_fields);
$response->image_id = $image_fields["image_id"];
$response->msg = sprintf($this->lang['msg_cloned'], $this->lvol, $name);
}
}
return $response;
}