本文整理汇总了PHP中storage::get_list方法的典型用法代码示例。如果您正苦于以下问题:PHP storage::get_list方法的具体用法?PHP storage::get_list怎么用?PHP storage::get_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类storage
的用法示例。
在下文中一共展示了storage::get_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: statistics
function statistics()
{
$resources_all = 0;
$resources_active = 0;
$resources_available = 0;
$dc_load_overall = 0;
$appliance_load_overall = 0;
$appliance_active = 0;
$storage_load_overall = 0;
$storage_active = 0;
$cpu_total = 0;
$mem_used = 0;
$mem_total = 0;
// run only each minute
$db = openqrm_get_db_connection();
$rs = $db->Execute("select MAX(datacenter_id) from {$this->_db_table}");
foreach ($rs as $index => $dc) {
if (isset($dc['MAX(datacenter_id)'])) {
$this->last_statistics = $dc['MAX(datacenter_id)'];
} else {
if (isset($dc['max'])) {
$this->last_statistics = $dc['max'];
}
}
}
// get an array of resources which are assigned to an appliance
$appliance_resources_array = array();
$appliance = new appliance();
$appliance_list = $appliance->get_all_ids();
foreach ($appliance_list as $app) {
$app_id = $app['appliance_id'];
$g_appliance = new appliance();
$g_appliance->get_instance_by_id($app_id);
$g_appliance_resource = $g_appliance->resources;
if (!strcmp($g_appliance->state, "active") || $g_appliance_resource == 0) {
if ($g_appliance_resource != "-1") {
$appliance_resources_array[] .= $g_appliance_resource;
}
}
}
// get an array of resources which are a storage server
$storage_resources_array = array();
$storage = new storage();
$storage_list = $storage->get_list();
foreach ($storage_list as $store) {
$storage_id = $store['value'];
$g_storage = new storage();
$g_storage->get_instance_by_id($storage_id);
$g_storage_resource = $g_storage->resource_id;
$storage_resources_array[] .= $g_storage_resource;
}
$resource = new resource();
$resource_list = $resource->get_list();
foreach ($resource_list as $res) {
$res_id = $res['resource_id'];
//echo "!! res_id $res_id <br>";
$g_resource = new resource();
$g_resource->get_instance_by_id($res_id);
// start gathering
$resources_all++;
$cpu_total = $cpu_total + $g_resource->cpunumber;
$mem_used = $mem_used + $g_resource->memused;
$mem_total = $mem_total + $g_resource->memtotal;
// resource load
if ("{$g_resource->imageid}" == "1" && "{$g_resource->state}" == "active") {
// idle
$resources_available++;
} else {
if ("{$g_resource->state}" == "active") {
// active
$resources_active++;
$dc_load_overall = $dc_load_overall + $g_resource->load;
// is storage ?
if (in_array($g_resource->id, $storage_resources_array)) {
$storage_active++;
$storage_load_overall = $storage_load_overall + $g_resource->load;
}
// is appliance ?
if (in_array($g_resource->id, $appliance_resources_array)) {
$appliance_active++;
$appliance_load_overall = $appliance_load_overall + $g_resource->load;
}
}
}
}
if ($resources_active != 0) {
$dc_load_overall = $dc_load_overall / $resources_active;
$dc_load_overall = number_format($dc_load_overall, 2, '.', '');
}
if ($appliance_active != 0) {
$appliance_load_overall = $appliance_load_overall / $appliance_active;
$appliance_load_overall = number_format($appliance_load_overall, 2, '.', '');
}
if ($storage_active != 0) {
$storage_load_overall = $storage_load_overall / $storage_active;
$storage_load_overall = number_format($storage_load_overall, 2, '.', '');
}
$datacenter_fields = array();
$datacenter_fields['datacenter_load_overall'] = $dc_load_overall;
$datacenter_fields['datacenter_load_server'] = $appliance_load_overall;
//.........这里部分代码省略.........
示例2: array
$arHead['storage_icon'] = array();
$arHead['storage_icon']['title'] = '';
$arHead['storage_id'] = array();
$arHead['storage_id']['title'] = 'ID';
$arHead['storage_name'] = array();
$arHead['storage_name']['title'] = 'Name';
$arHead['storage_resource'] = array();
$arHead['storage_resource']['title'] = 'Res.';
$arHead['storage_type'] = array();
$arHead['storage_type']['title'] = 'Type';
$arHead['storage_load'] = array();
$arHead['storage_load']['title'] = 'Load';
$arBody = array();
$store_load_array = array();
$storage = new storage();
$storage_list = $storage->get_list();
foreach ($storage_list as $st) {
$store_all++;
$storage_id = $st['value'];
$g_storage = new storage();
$g_storage->get_instance_by_id($storage_id);
// check resource state
$st_resource = new resource();
$st_resource->get_instance_by_id($g_storage->resource_id);
if ("{$st_resource->state}" == "active") {
$store_load = $st_resource->load;
$store_load_array[$g_storage->id] = $st_resource->load;
} else {
if ("{$st_resource->state}" == "error") {
$store_error++;
}
示例3: array
function dc_status()
{
// number of idle systems
$resources_all = 0;
// active deployed resources
$resources_active = 0;
// resources in error state
$resources_error = 0;
// physical resources
$resources_physical = 0;
// virtual resources
$resources_virtual = 0;
// number of idle systems
$resources_available = 0;
// physical resource available
$resources_available_physical = 0;
// virtal resource available
$resources_available_virtual = 0;
// overall load
$dc_load_overall = 0;
// active appliance load
$appliance_load_overall = 0;
// peak in appliance load
$appliance_load_peak = 0;
// active appliances
$appliance_active = 0;
// active appliance with resource in error state
$appliance_error = 0;
// storage load
$storage_load_overall = 0;
// storage peak
$storage_load_peak = 0;
// active storages
$storage_active = 0;
// storage with resource in error state
$storage_error = 0;
// get an array of resources which are assigned to an appliance
$appliance_resources_array = array();
$appliance = new appliance();
$appliance_list = $appliance->get_all_ids();
foreach ($appliance_list as $app) {
$app_id = $app['appliance_id'];
$g_appliance = new appliance();
$g_appliance->get_instance_by_id($app_id);
$g_appliance_resource = $g_appliance->resources;
if (!strcmp($g_appliance->state, "active") || $g_appliance_resource == 0) {
if ($g_appliance_resource != "-1") {
$appliance_resources_array[] .= $g_appliance_resource;
}
}
}
// get an array of resources which are a storage server
$storage_resources_array = array();
$storage = new storage();
$storage_list = $storage->get_list();
foreach ($storage_list as $store) {
$storage_id = $store['value'];
$g_storage = new storage();
$g_storage->get_instance_by_id($storage_id);
$g_storage_resource = $g_storage->resource_id;
$storage_resources_array[] .= $g_storage_resource;
}
$restype = 0;
$resource = new resource();
$resource_list = $resource->get_list();
foreach ($resource_list as $res) {
$res_id = $res['resource_id'];
//echo "!! res_id $res_id <br>";
$g_resource = new resource();
$g_resource->get_instance_by_id($res_id);
// start gathering
$resources_all++;
// physical or virtual ?
if (strlen($g_resource->vtype) && $g_resource->vtype != "NULL") {
$virtualization = new virtualization();
$virtualization->get_instance_by_id($g_resource->vtype);
if (strstr($virtualization->type, "-vm")) {
// virtual
$resources_virtual++;
$restype = 1;
} else {
// physical
$resources_physical++;
$restype = 0;
}
} else {
// we treat unknown system types as physical
$resources_physical++;
$restype = 0;
}
// resource load
// is idle or active ?
if ("{$g_resource->imageid}" == "1" && "{$g_resource->state}" == "active") {
// idle
$resources_available++;
// virtual or physical ?
if ($restype == 0) {
$resources_available_physical++;
} else {
$resources_available_virtual++;
//.........这里部分代码省略.........