本文整理汇总了PHP中storage::add方法的典型用法代码示例。如果您正苦于以下问题:PHP storage::add方法的具体用法?PHP storage::add怎么用?PHP storage::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类storage
的用法示例。
在下文中一共展示了storage::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
function add()
{
$response = $this->get_response();
$form = $response->form;
if (!$form->get_errors() && $this->response->submit()) {
$name = $form->get_request('name');
$storage_type = $form->get_request('type');
$storge_capabilities = $form->get_request('capabilities');
$resource_id = $form->get_request('resource');
$comment = $form->get_request('comment');
// check if name already exists
// check that name is unique
$storage_name_check = new storage();
$storage_name_check->get_instance_by_name($name);
if ($storage_name_check->id > 0) {
$error = sprintf($this->lang['error_exists'], $name);
}
if (isset($error)) {
$response->error = $error;
} else {
$storage = new storage();
$storage_fields['storage_id'] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$storage_fields['storage_name'] = $name;
$storage_fields['storage_type'] = $storage_type;
$storage_fields['storage_comment'] = $comment;
$storage_fields['storage_resource_id'] = $resource_id;
// unqote capabilities
$storage_fields['storage_capabilities'] = stripslashes($storge_capabilities);
$storage->add($storage_fields);
$response->msg = sprintf($this->lang['msg'], $name);
}
}
return $response;
}
示例2: deployment
$OPENQRM_SERVER_IP_ADDRESS = $openqrm_server->get_ip_address();
global $OPENQRM_SERVER_IP_ADDRESS;
$event->log("{$local_server_command}", $_SERVER['REQUEST_TIME'], 5, "local-server-action", "Processing local-server command {$local_server_command}", "", "", 0, 0, 0);
switch ($local_server_command) {
case 'integrate':
// create storage server
$storage_fields["storage_name"] = "resource{$local_server_id}";
$storage_fields["storage_resource_id"] = "{$local_server_id}";
$deployment = new deployment();
$deployment->get_instance_by_type('local-server');
$storage_fields["storage_type"] = $deployment->id;
$storage_fields["storage_comment"] = "Local-server resource {$local_server_id}";
$storage_fields["storage_capabilities"] = 'TYPE=local-server';
$storage = new storage();
$storage_fields["storage_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$storage->add($storage_fields);
// create image
$image_fields["image_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$image_fields["image_name"] = "resource{$local_server_id}";
$image_fields["image_type"] = $deployment->type;
$image_fields["image_rootdevice"] = $local_server_root_device;
$image_fields["image_rootfstype"] = $local_server_root_device_type;
$image_fields["image_storageid"] = $storage_fields["storage_id"];
$image_fields["image_comment"] = "Local-server image resource {$local_server_id}";
$image_fields["image_capabilities"] = 'TYPE=local-server';
$image = new image();
$image->add($image_fields);
// create kernel
$kernel_fields["kernel_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$kernel_fields["kernel_name"] = "resource{$local_server_id}";
$kernel_fields["kernel_version"] = "{$local_server_kernel_version}";
示例3: openqrm_kvm_appliance
//.........这里部分代码省略.........
// $kvm_host_resource = new resource();
// $kvm_host_resource->get_instance_by_id($resource->vhostid);
// if ($resource->vtype != $virtualization->id) {
// $kvm_command="$OPENQRM_SERVER_BASE_DIR/openqrm/plugins/kvm/bin/openqrm-kvm reset_vlans_by_mac -b stop -m $resource->mac";
// $kvm_host_resource->send_command($kvm_host_resource->ip, $kvm_command);
// return;
// }
// check resource type -> kvm-vm-local
$virtualization = new virtualization();
$virtualization->get_instance_by_type("kvm-vm-local");
if ($resource->vtype != $virtualization->id) {
$event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "{$appliance_id} is not from type kvm-vm, skipping .. {$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id);
return;
}
// check image is on the same storage server
// get the kvm host resource
$kvm_host_resource = new resource();
$kvm_host_resource->get_instance_by_id($resource->vhostid);
// get the kvm resource
$image = new image();
$image->get_instance_by_id($appliance->imageid);
$storage = new storage();
$storage->get_instance_by_id($image->storageid);
$kvm_resource = new resource();
$kvm_resource->get_instance_by_id($storage->resource_id);
if ($kvm_host_resource->id != $kvm_resource->id) {
$event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "Appliance {$appliance_id} image is not available on this kvm host. Assuming SAN-Backend", "", "", 0, 0, $appliance_id);
}
$kvm_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm-vm restart_by_mac -m " . $resource->mac . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background";
$kvm_host_resource->send_command($kvm_host_resource->ip, $kvm_command);
break;
case "update":
// check if the appliance was set to a kvm Host, if yes, auto-create the storage objects
$virtualization = new virtualization();
$virtualization->get_instance_by_type("kvm");
if ($appliance->virtualization == $virtualization->id) {
// KVM LVM Storage
$deployment = new deployment();
$deployment->get_instance_by_name('kvm-lvm-deployment');
$storage = new storage();
$kvm_id_list = $storage->get_ids_by_storage_type($deployment->id);
$found_kvm = false;
$found_kvm_id = -1;
foreach ($kvm_id_list as $list) {
foreach ($list as $kvm_id) {
$storage->get_instance_by_id($kvm_id);
if ($storage->resource_id == $appliance->resources) {
$found_kvm = true;
$found_kvm_id = $storage->id;
break;
}
}
}
if (!$found_kvm) {
$found_kvm_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$storage_fields['storage_id'] = $found_kvm_id;
$storage_fields['storage_name'] = $appliance->name . "-lvm";
$storage_fields['storage_type'] = $deployment->id;
$storage_fields['storage_comment'] = 'KVM LVM Storage Object for Appliance ' . $appliance->name;
$storage_fields['storage_resource_id'] = $appliance->resources;
$storage_fields['storage_capabilities'] = '';
$storage->add($storage_fields);
$event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "Created KVM LVM Storage Object for Appliance " . $appliance_id . "!", "", "", 0, 0, $appliance_id);
} else {
$event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "KVM LVM Storage Object for Appliance " . $appliance_id . " already existing.", "", "", 0, 0, $appliance_id);
}
// KVM Blockfile Storage
$deployment = new deployment();
$deployment->get_instance_by_name('kvm-bf-deployment');
$storage = new storage();
$kvm_id_list = $storage->get_ids_by_storage_type($deployment->id);
$found_kvm = false;
$found_kvm_id = -1;
foreach ($kvm_id_list as $list) {
foreach ($list as $kvm_id) {
$storage->get_instance_by_id($kvm_id);
if ($storage->resource_id == $appliance->resources) {
$found_kvm = true;
$found_kvm_id = $storage->id;
break;
}
}
}
if (!$found_kvm) {
$found_kvm_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$storage_fields['storage_id'] = $found_kvm_id;
$storage_fields['storage_name'] = $appliance->name . "-bf";
$storage_fields['storage_type'] = $deployment->id;
$storage_fields['storage_comment'] = 'KVM Blockfile Storage Object for Appliance ' . $appliance->name;
$storage_fields['storage_resource_id'] = $appliance->resources;
$storage_fields['storage_capabilities'] = '';
$storage->add($storage_fields);
$event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "Created KVM Blockfile Storage Object for Appliance " . $appliance_id . "!", "", "", 0, 0, $appliance_id);
} else {
$event->log("openqrm_kvm_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-kvm-appliance-hook.php", "KVM Blockfile Storage Object for Appliance " . $appliance_id . " already existing.", "", "", 0, 0, $appliance_id);
}
}
break;
}
}