本文整理汇总了PHP中image::get_ids_by_type方法的典型用法代码示例。如果您正苦于以下问题:PHP image::get_ids_by_type方法的具体用法?PHP image::get_ids_by_type怎么用?PHP image::get_ids_by_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::get_ids_by_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openqrm_hybrid_cloud_cloud_product
function openqrm_hybrid_cloud_cloud_product($cmd, $cloud_hook_config)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
global $RootDir;
$openqrm_server = new openqrm_server();
$event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Handling " . $cmd . " event", "", "", 0, 0, 0);
switch ($cmd) {
case "add":
$event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Handling cloud-product " . $cmd . " event", "", "", 0, 0, 0);
// create resource products
$db = openqrm_get_db_connection();
$image = new image();
$checked_virtualization_plugins = array();
$virtualization = new virtualization();
$virtualization_id_ar = $virtualization->get_list();
unset($virtualization_id_ar[0]);
foreach ($virtualization_id_ar as $key => $value) {
$next_sort_id = 0;
$id = $value['value'];
$virtualization->get_instance_by_id($id);
$pos = strpos($virtualization->type, 'hybrid-cloud-vm-');
if ($pos !== false) {
$event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Adding " . $virtualization->type . " as cloud-product", "", "", 0, 0, 0);
$cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_resource_cloudselector_config = "insert into cloud_selector (id, type, sort_id, quantity, price, name, description, state) VALUES (" . $cloud_product_id . ", 'resource', " . $next_sort_id . ", '" . $virtualization->id . "', 1, '" . $virtualization->type . "', '" . $virtualization->name . "', 1);";
$recordSet = $db->Execute($create_resource_cloudselector_config);
$next_sort_id++;
// add all existing images for this virtualization type to private images
$virtualization_plugin_name = $virtualization->get_plugin_name();
if (!in_array($virtualization_plugin_name, $checked_virtualization_plugins)) {
$checked_virtualization_plugins[] = $virtualization_plugin_name;
$deployment = new deployment();
$deployment_id_ar = $deployment->get_id_by_storagetype($virtualization_plugin_name);
foreach ($deployment_id_ar as $key => $value) {
$did = $value['value'];
$deployment->get_instance_by_id($did);
$image_id_deployment_ar = $image->get_ids_by_type($deployment->type);
foreach ($image_id_deployment_ar as $iid_ar) {
// add to private images
$image_id = $iid_ar['image_id'];
$event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Adding Image " . $image_id . " as private image", "", "", 0, 0, 0);
$cloud_pr_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_private_image_config = "insert into cloud_private_image (co_id, co_image_id, co_cu_id, co_clone_on_deploy, co_state) VALUES (" . $cloud_pr_id . ", " . $image_id . ", 0, 1, 1);";
$recordSet = $db->Execute($create_private_image_config);
}
}
}
}
}
// add host to admin resource pool
$admin_project_id = $cloud_hook_config['cloud_admin_procect'];
$virtualization->get_instance_by_type('hybrid-cloud');
$appliance = new appliance();
$appliance_id_ar = $appliance->get_ids_per_virtualization($virtualization->id);
foreach ($appliance_id_ar as $key => $value) {
$appliance_id = $value['appliance_id'];
$appliance->get_instance_by_id($appliance_id);
$cloud_respool_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_default_resource_pool_config = "insert into cloud_respool(rp_id, rp_resource_id, rp_cg_id) values (" . $cloud_respool_id . ", " . $appliance->resources . ", " . $admin_project_id . ");";
$recordSet = $db->Execute($create_default_resource_pool_config);
}
break;
case "remove":
$cloud_product_class = $RootDir . "/plugins/cloud/class/cloudselector.class.php";
if (file_exists($cloud_product_class)) {
require_once $cloud_product_class;
$cloud_selector = new cloudselector();
$virtualization = new virtualization();
$virtualization->get_instance_by_type('hybrid-cloud-vm-local');
$event->log("openqrm_hybrid_cloud_cloud_product", $_SERVER['REQUEST_TIME'], 5, "openqrm-hybrid-cloud-cloud-product-hook.php", "Removing resource type " . $virtualization->type . " from cloud-products", "", "", 0, 0, 0);
$cloud_selector->remove_by_quantity($virtualization->id);
}
break;
}
}
示例2: array
function get_response()
{
$OPENQRM_SERVER_BASE_DIR = $this->openqrm->get('basedir');
$response = $this->response;
$form = $response->get_form($this->actions_name, 'add');
$cpus[] = array("1", "1 CPU");
$cpus[] = array("2", "2 CPUs");
$cpus[] = array("4", "4 CPUs");
$cpus[] = array("8", "8 CPUs");
$cpus[] = array("16", "16 CPUs");
$ram[] = array("256", "256 MB");
$ram[] = array("512", "512 MB");
$ram[] = array("1024", "1 GB");
$ram[] = array("2048", "2 GB");
$ram[] = array("4096", "4 GB");
$ram[] = array("8192", "8 GB");
$ram[] = array("16384", "16 GB");
$ram[] = array("32768", "32 GB");
$ram[] = array("65536", "64 GB");
$nics[] = array("virtio", $this->lang['form_net_virtio']);
$nics[] = array("e1000", $this->lang['form_net_e1000']);
$nics[] = array("rtl8139", $this->lang['form_net_rtl8139']);
$keymaps[] = array("de", "de");
$keymaps[] = array("en-us", "en-us");
$keymaps[] = array("es", "es");
$keymaps[] = array("fr", "fr");
$keymaps[] = array("it", "it");
$keymaps[] = array("ja", "ja");
$keymaps[] = array("nl", "nl");
$keymaps[] = array("ru", "ru");
$keymaps[] = array("none", "none");
$disk_interfaces[] = array("virtio", "Virtio");
$disk_interfaces[] = array("ide", "IDE");
$swap_select_arr[] = array('1024', '1 GB');
$swap_select_arr[] = array('2048', '2 GB');
$swap_select_arr[] = array('4096', '4 GB');
// if we come from the wizard suggest the server name
$vm_name_suggestion = '';
if (isset($this->user->wizard_name) && $this->user->wizard_name === 'appliance' && $this->user->wizard_step == 2) {
$appliance = new appliance();
$appliance->get_instance_by_id($this->user->wizard_id);
$vm_name_suggestion = $appliance->name;
}
// get a list of existing kvm localboot images to select
$existing_image_arr = array();
$image = new image();
$image_image_id_ar = $image->get_ids_by_type('kvm-lvm-deployment');
foreach ($image_image_id_ar as $iid_ar) {
$image_id = $iid_ar['image_id'];
$image->get_instance_by_id($image_id);
$existing_image_arr[] = array($image->id, $image->name);
}
$image_image_id_ar = $image->get_ids_by_type('kvm-bf-deployment');
foreach ($image_image_id_ar as $iid_ar) {
$image_id = $iid_ar['image_id'];
$image->get_instance_by_id($image_id);
$existing_image_arr[] = array($image->id, $image->name);
}
$image_image_id_ar = $image->get_ids_by_type('kvm-gluster-deployment');
foreach ($image_image_id_ar as $iid_ar) {
$image_id = $iid_ar['image_id'];
$image->get_instance_by_id($image_id);
$existing_image_arr[] = array($image->id, $image->name);
}
$existing_image_arr[] = array('', '');
// get a list of network-deployment images for netboot vms
$existing_netboot_image_arr = array();
$existing_netboot_image_id_ar = $image->get_ids();
foreach ($existing_netboot_image_id_ar as $iid_ar) {
$image_id = $iid_ar['image_id'];
$image->get_instance_by_id($image_id);
if ($image->is_network_deployment()) {
$existing_netboot_image_arr[] = array($image->id, $image->name);
}
}
$existing_netboot_image_arr[] = array('', '');
$file = $OPENQRM_SERVER_BASE_DIR . '/plugins/kvm/web/kvm-stat/' . $this->resource->id . '.bridge_config';
$data = openqrm_parse_conf($file);
$bridges = array();
$bridge_list = $data['OPENQRM_KVM_BRIDGES'];
$bridge_list = rtrim($bridge_list, ":");
$bridge_array = explode(':', $bridge_list);
// handle no bridge error
if (isset($bridge_array[0]) && $bridge_array[0] !== '') {
foreach ($bridge_array as $b) {
$bridges[] = array($b, $b);
}
$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');
$d['name']['label'] = $this->lang['form_name'];
$d['name']['required'] = true;
$d['name']['validate']['regex'] = '/^[a-z0-9._]+$/i';
$d['name']['validate']['errormsg'] = sprintf($this->lang['error_name'], 'a-z0-9._');
$d['name']['object']['type'] = 'htmlobject_input';
$d['name']['object']['attrib']['name'] = 'name';
$d['name']['object']['attrib']['id'] = 'name';
//.........这里部分代码省略.........