本文整理汇总了PHP中image::set_deployment_parameters方法的典型用法代码示例。如果您正苦于以下问题:PHP image::set_deployment_parameters方法的具体用法?PHP image::set_deployment_parameters怎么用?PHP image::set_deployment_parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::set_deployment_parameters方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_clone_lvm_iscsi_deployment
function create_clone_lvm_iscsi_deployment($cloud_image_id, $image_clone_name, $disk_size)
{
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
global $RESOURCE_INFO_TABLE;
global $event;
$event->log("create_clone", $_SERVER['REQUEST_TIME'], 5, "lvm-iscsi-deployment-cloud-hook", "Creating clone of image on storage", "", "", 0, 0, 0);
// we got the cloudimage id here, get the image out of it
$cloudimage = new cloudimage();
$cloudimage->get_instance_by_id($cloud_image_id);
// get image, this is already the new logical clone
// we just need to physical snapshot it and update the rootdevice
$image = new image();
$image->get_instance_by_id($cloudimage->image_id);
$image_id = $image->id;
$image_name = $image->name;
$image_type = $image->type;
$image_version = $image->version;
$image_rootdevice = $image->rootdevice;
$image_rootfstype = $image->rootfstype;
$image_storageid = $image->storageid;
$image_isshared = $image->isshared;
$image_comment = $image->comment;
$image_capabilities = $image->capabilities;
$image_deployment_parameter = $image->deployment_parameter;
// get image storage
$storage = new storage();
$storage->get_instance_by_id($image_storageid);
$storage_resource_id = $storage->resource_id;
// get storage resource
$resource = new resource();
$resource->get_instance_by_id($storage_resource_id);
$resource_id = $resource->id;
$resource_ip = $resource->ip;
// generate a new image password for the clone
$image_password = $image->generatePassword(12);
$image->set_deployment_parameters("IMAGE_ISCSI_AUTH", $image_password);
// parse the volume group info in the identifier
$ident_separate = strpos($image_rootdevice, ":");
$volume_group = substr($image_rootdevice, 0, $ident_separate);
$root_device = substr($image_rootdevice, $ident_separate);
$image_location = dirname($root_device);
$image_location_name = basename($image_location);
// set default snapshot size
if (!strlen($disk_size)) {
$disk_size = 5000;
}
// update the image rootdevice parameter
$ar_image_update = array('image_rootdevice' => "{$volume_group}:/dev/{$image_clone_name}/1");
$event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "lvm-iscsi-deployment-cloud-hook", "Updating rootdevice of image {$image_id} / {$image_name} with {$volume_group}:/dev/{$image_clone_name}/1", "", "", 0, 0, 0);
$image->update($image_id, $ar_image_update);
// send command
$image_clone_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/lvm-storage/bin/openqrm-lvm-storage snap -n " . $image_location_name . " -v " . $volume_group . " -t lvm-iscsi-deployment -s " . $image_clone_name . " -m " . $disk_size . " -i " . $image_password . " --openqrm-cmd-mode background";
$event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "lvm-iscsi-deployment-cloud-hook", "Running : {$image_clone_cmd}", "", "", 0, 0, 0);
$resource->send_command($resource_ip, $image_clone_cmd);
}
示例2: edit
function edit()
{
$response = $this->get_response();
$form = $response->form;
$id = $this->response->html->request()->get('image_id');
if ($id !== '') {
// check password
$pass = $form->get_request('image_password');
if ($pass !== '' && $pass !== $form->get_request('image_password_2')) {
$form->set_error('image_password_2', $this->lang['error_password']);
}
$image = new image();
$image->get_instance_by_id($id);
if (!$form->get_errors() && $this->response->submit()) {
$image_password = $this->response->html->request()->get('image_password');
$install_from_local = $this->response->html->request()->get('install_from_local');
$transfer_to_local = $this->response->html->request()->get('transfer_to_local');
$install_from_nfs = $this->response->html->request()->get('install_from_nfs');
$transfer_to_nfs = $this->response->html->request()->get('transfer_to_nfs');
$install_from_template = $this->response->html->request()->get('install_from_template');
$image_comment = $this->response->html->request()->get('image_comment');
$image_version = $this->response->html->request()->get('image_version');
// update image
$fields['image_comment'] = $image_comment;
$fields['image_version'] = $image_version;
$image->update($id, $fields);
$image->get_instance_by_id($id);
# set password if given
if (strlen($image_password)) {
$image->set_root_password($id, $image_password);
} else {
$CMD = "rm -f " . $this->openqrm->get('basedir') . "/web/action/image-auth/iauth." . $id . ".php";
exec($CMD);
}
// install-from-nfs
if (strlen($install_from_nfs)) {
$install_from_nfs_image = new image();
$install_from_nfs_image->get_instance_by_id($install_from_nfs);
$install_from_nfs_storage = new storage();
$install_from_nfs_storage->get_instance_by_id($install_from_nfs_image->storageid);
$install_from_nfs_storage_resource = new resource();
$install_from_nfs_storage_resource->get_instance_by_id($install_from_nfs_storage->resource_id);
$install_from_nfs_storage_ip = $install_from_nfs_storage_resource->ip;
$install_from_nfs_storage_path = $install_from_nfs_image->rootdevice;
$install_from_nfs_path = $install_from_nfs_image->storageid . ":" . $install_from_nfs_storage_ip . ":" . $install_from_nfs_storage_path;
$image->set_deployment_parameters("IMAGE_INSTALL_FROM_NFS", $install_from_nfs_path);
} else {
$image->set_deployment_parameters("IMAGE_INSTALL_FROM_NFS", "");
}
// transfer-to-nfs, we have to refresh the image object here
$image->get_instance_by_id($id);
if (strlen($transfer_to_nfs)) {
$transfer_to_nfs_image = new image();
$transfer_to_nfs_image->get_instance_by_id($transfer_to_nfs);
$transfer_to_nfs_storage = new storage();
$transfer_to_nfs_storage->get_instance_by_id($transfer_to_nfs_image->storageid);
$transfer_to_nfs_storage_resource = new resource();
$transfer_to_nfs_storage_resource->get_instance_by_id($transfer_to_nfs_storage->resource_id);
$transfer_to_nfs_storage_ip = $transfer_to_nfs_storage_resource->ip;
$transfer_to_nfs_storage_path = $transfer_to_nfs_image->rootdevice;
$transfer_to_nfs_path = $transfer_to_nfs_image->storageid . ":" . $transfer_to_nfs_storage_ip . ":" . $transfer_to_nfs_storage_path;
$image->set_deployment_parameters("IMAGE_TRANSFER_TO_NFS", $transfer_to_nfs_path);
} else {
$image->set_deployment_parameters("IMAGE_TRANSFER_TO_NFS", "");
}
// install-from-local, we have to refresh the image object again
$image->get_instance_by_id($id);
if (strlen($install_from_local)) {
$image->set_deployment_parameters("IMAGE_INSTALL_FROM_LOCAL", $install_from_local);
} else {
$image->set_deployment_parameters("IMAGE_INSTALL_FROM_LOCAL", "");
}
// transfer-to-local, we have to refresh the image object again
$image->get_instance_by_id($id);
if (strlen($transfer_to_local)) {
$image->set_deployment_parameters("IMAGE_TRANSFER_TO_LOCAL", $transfer_to_local);
} else {
$image->set_deployment_parameters("IMAGE_TRANSFER_TO_LOCAL", "");
}
// reset deployment parameter INSTALL_CONFIG
$image->set_deployment_parameters("INSTALL_CONFIG", "");
if (strlen($install_from_template)) {
// redirect to install-from-template step1
$response->msg = 'install-from-template';
$response->install_from_template = $install_from_template;
} else {
$response->msg = sprintf($this->lang['msg'], $image->name);
}
$response->image_id = $id;
}
$response->name = $image->name;
} else {
$response->msg = '';
}
return $response;
}
示例3: openqrm_linuxcoe_appliance
function openqrm_linuxcoe_appliance($cmd, $appliance_fields)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$openqrm_server = new openqrm_server();
$appliance_id = $appliance_fields["appliance_id"];
$appliance_name = $appliance_fields["appliance_name"];
$resource = new resource();
$resource->get_instance_by_id($appliance_fields["appliance_resources"]);
$resource_mac = $resource->mac;
$resource_ip = $resource->ip;
$appliance = new appliance();
$appliance->get_instance_by_id($appliance_id);
$linuxcoe_install_timeout = 240;
// check appliance values, maybe we are in update and they are incomplete
if ($appliance->imageid == 1) {
return;
}
if ($resource->id == "-1" || $resource->id == "") {
return;
}
// check if image is type linuxcoe-deployment
$image = new image();
$image->get_instance_by_id($appliance->imageid);
// linuxcoe configured in image deployment parameters ?
$linuxcoe_auto_install_enabled = false;
$linuxcoe_deployment_parameters = trim($image->get_deployment_parameter("INSTALL_CONFIG"));
if (strlen($linuxcoe_deployment_parameters)) {
$linuxcoe_deployment_parameter_arr = explode(":", $linuxcoe_deployment_parameters);
$local_deployment_persistent = $linuxcoe_deployment_parameter_arr[0];
$local_deployment_type = $linuxcoe_deployment_parameter_arr[1];
if (strcmp($local_deployment_type, "linuxcoe-deployment")) {
$event->log("openqrm_linuxcoe_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "Appliance " . $appliance_id . "/" . $appliance_name . " image is not from type linuxcoe-deployment", "", "", 0, 0, $resource->id);
return;
}
$linuxcoe_server_storage_id = $linuxcoe_deployment_parameter_arr[2];
$linuxcoe_install_profile = $linuxcoe_deployment_parameter_arr[3];
$linuxcoe_auto_install_enabled = true;
}
$event->log("openqrm_linuxcoe_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$resource_ip}/{$resource_mac}", "", "", 0, 0, $resource->id);
switch ($cmd) {
case "start":
$event->log("openqrm_linuxcoe_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "START event {$appliance_id}/{$appliance_name}/{$resource_ip}/{$resource_mac}", "", "", 0, 0, $resource->id);
if ($linuxcoe_auto_install_enabled) {
// prepare automatic-installation / transfer client to linuxcoe server
$linuxcoe_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/linuxcoe/bin/openqrm-linuxcoe-manager transfer_to_linuxcoe -x " . $resource->id . " -i " . $resource_ip . " -m " . $resource_mac . " -n " . $linuxcoe_install_profile . " --openqrm-cmd-mode background";
$event->log("openqrm_linuxcoe_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "transfer_to_linuxcoe {$resource_ip} / {$linuxcoe_install_profile}", "", "", 0, 0, $resource->id);
$openqrm_server->send_command($linuxcoe_command, NULL, true);
// Remove image-deployment paramters, if auto-install is a single-shot actions
if (!strcmp($local_deployment_persistent, "0")) {
$image->set_deployment_parameters("INSTALL_CONFIG", "");
}
// create linuxcoestate-state object to allow to run a late setboot to local command on the vm host
$linuxcoe_state = new linuxcoestate();
$linuxcoe_state->remove_by_resource_id($resource->id);
$linuxcoe_state_fields = array();
$linuxcoe_state_fields["linuxcoe_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$linuxcoe_state_fields["linuxcoe_resource_id"] = $resource->id;
$linuxcoe_state_fields["linuxcoe_install_start"] = $_SERVER['REQUEST_TIME'];
$linuxcoe_state_fields["linuxcoe_timeout"] = $linuxcoe_install_timeout;
$linuxcoe_state->add($linuxcoe_state_fields);
} else {
if (strcmp($image->type, "linuxcoe-deployment")) {
$event->log("openqrm_linuxcoe_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "Appliance {$appliance_id}/{$appliance_name} image is not from type linuxcoe-deployment", "", "", 0, 0, $resource->id);
} else {
// we have auto-installed already, if it is VM the linuxcoeresource object will care to set the boot-sequence on the VM Host to local boot
$linuxcoeresource = new linuxcoeresource();
$linuxcoeresource->set_boot($resource->id, 1);
// set pxe config to local-boot
$event->log("openqrm_linuxcoe_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "Setting resource {$resource_ip} to local-boot", "", "", 0, 0, $resource->id);
$linuxcoe_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/linuxcoe/bin/openqrm-linuxcoe-manager set_linuxcoe_client_to_local_boot -m " . $resource_mac . " --openqrm-cmd-mode background";
$openqrm_server->send_command($linuxcoe_command, NULL, true);
}
}
break;
case "stop":
if (strcmp($image->type, "linuxcoe-deployment")) {
$event->log("stop", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "Appliance {$appliance_id}/{$appliance_name} image is not from type linuxcoe-deployment", "", "", 0, 0, $resource->id);
} else {
$event->log("stop", $_SERVER['REQUEST_TIME'], 5, "openqrm-linuxcoe-appliance-hook.php", "Stop event for appliance " . $appliance_id . "/" . $appliance->name . ".", "", "", 0, 0, $resource->id);
// remove linuxcoestate-state object if existing
$local_storage_state = new linuxcoestate();
$local_storage_state->remove_by_resource_id($resource->id);
// if it is VM the linuxcoeresource object will care to set the boot-sequence on the VM Host to network boot
$linuxcoeresource = new linuxcoeresource();
$linuxcoeresource->set_boot($resource->id, 0);
}
break;
}
}
示例4: storage_auth_stop
function storage_auth_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;
// generate a password for the image
$image_password = $image->generatePassword(12);
$image_deployment_parameter = $image->deployment_parameter;
$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;
$event->log("storage_auth_stop_in_background", $_SERVER['REQUEST_TIME'], 5, "openqrm-iscsi-deployment-auth-hook.php", "Authenticating {$image_name} / {$image_rootdevice} with password {$image_password}", "", "", 0, 0, $appliance_id);
$auth_stop_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $deployment_plugin_name . "/bin/openqrm-" . $deployment_plugin_name . " auth -r " . $image_rootdevice . " -i " . $image_password . " --openqrm-cmd-mode background";
$resource = new resource();
$resource->send_command($storage_ip, $auth_stop_cmd);
// and update the image params
$image->set_deployment_parameters("IMAGE_ISCSI_AUTH", $image_password);
}
示例5: storage_auth_stop
function storage_auth_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;
// generate a password for the image
$image_password = $image->generatePassword(12);
$image_deployment_parameter = $image->deployment_parameter;
// parse the volume group info in the identifier
$ident_separate = strpos($image_rootdevice, ":");
$volume_group = substr($image_rootdevice, 0, $ident_separate);
$root_device = substr($image_rootdevice, $ident_separate);
$image_location = dirname($root_device);
$image_location_name = basename($image_location);
$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;
$auth_stop_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/" . $deployment_plugin_name . "/bin/openqrm-" . $deployment_plugin_name . " auth -r /dev/" . $volume_group . "/" . $image_location_name . " -i " . $image_password . " -t lvm-iscsi-deployment --openqrm-cmd-mode background";
$resource = new resource();
$resource->send_command($storage_ip, $auth_stop_cmd);
// and update the image params
$image->set_deployment_parameters("IMAGE_ISCSI_AUTH", $image_password);
}
示例6: foreach
function check_all_image_authentication()
{
global $IMAGE_AUTHENTICATION_TABLE;
global $event;
global $RootDir;
// $event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Checking all image_authentications", "", "", 0, 0, 0);
$ia_id_ar = $this->get_all_ids();
foreach ($ia_id_ar as $ia_list) {
$ia_auth_id = $ia_list['ia_id'];
$ia_auth = new image_authentication();
$ia_auth->get_instance_by_id($ia_auth_id);
$event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Checking image_authentication {$ia_auth_id}", "", "", 0, 0, 0);
// get data
$image = new image();
$image->get_instance_by_id($ia_auth->image_id);
$image_name = $image->name;
$image_id = $image->id;
$deployment = new deployment();
$deployment->get_instance_by_type($image->type);
$deployment_type = $deployment->type;
$deployment_plugin_name = $deployment->storagetype;
$storage_auth_hook = "{$RootDir}/plugins/{$deployment_plugin_name}/openqrm-{$deployment_type}-auth-hook.php";
$resource_id = $ia_auth->resource_id;
$resource = new resource();
$resource->get_instance_by_id($resource_id);
// check for root or deployment auth
switch ($ia_auth->auth_type) {
case 0:
// run storage_auth_stop (rootfs)
if (!strcmp($resource->state, "active") && $resource->imageid == 1) {
$event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Resource {$resource_id} idle again, stop-auth {$image_name} ({$image_id})", "", "", 0, 0, $resource_id);
// include storage-plugin auth-hook
if (file_exists($storage_auth_hook)) {
$event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Deployment type {$deployment_type} handling stop-auth hook {$image_id}.", "", "", 0, 0, $resource_id);
require_once "{$storage_auth_hook}";
storage_auth_stop($image->id);
// remove image_authentication
$ia_auth->remove($ia_auth_id);
}
} else {
// resource is still on rebooting
$event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Resource {$resource_id} still rebooting, waiting for stop-auth {$image_name}", "", "", 0, 0, $resource_id);
}
break;
case 1:
// run storage_auth_stop (deployment export)
// we stop the deployment hook when the resource is active or active/idle
// -> in both states it for sure does not need the deployment mount any more
if (!strcmp($resource->state, "active")) {
$event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Resource {$resource_id} active, stop-deployment auth {$image_name}", "", "", 0, 0, $resource_id);
// include storage-plugin auth-hook
if (file_exists($storage_auth_hook)) {
$event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Deployment type {$deployment_type} handling stop-deployment auth hook {$image_id}.", "", "", 0, 0, $resource_id);
require_once "{$storage_auth_hook}";
storage_auth_deployment_stop($image->id);
$image->get_instance_by_id($ia_auth->image_id);
$image_name = $image->name;
$image_id = $image->id;
// remove all install from or transfer to deployment parameters
$image->set_deployment_parameters("IMAGE_INSTALL_FROM_NFS", "");
$image->set_deployment_parameters("IMAGE_TRANSFER_TO_NFS", "");
$image->set_deployment_parameters("IMAGE_INSTALL_FROM_LOCAL", "");
$image->set_deployment_parameters("IMAGE_TRANSFER_TO_LOCAL", "");
// remove image_authentication
$ia_auth->remove($ia_auth_id);
}
} else {
// resource is still on rebooting
$event->log("check_all_image_authentication", $_SERVER['REQUEST_TIME'], 5, "image_authentication.class.php", "Resource {$resource_id} is still rebooting, waiting for stop-deployment auth {$image_name}", "", "", 0, 0, $resource_id);
}
break;
}
}
}