本文整理汇总了PHP中Cabinet::ListCabinetsByDC方法的典型用法代码示例。如果您正苦于以下问题:PHP Cabinet::ListCabinetsByDC方法的具体用法?PHP Cabinet::ListCabinetsByDC怎么用?PHP Cabinet::ListCabinetsByDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cabinet
的用法示例。
在下文中一共展示了Cabinet::ListCabinetsByDC方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: echoResponse
$tmp['DataCenterName'] = $dc->Name;
array_push($response['cabinet'], $tmp);
echoResponse(200, $response);
}
});
//
// URL: /api/v1/cabinet/bydc/:datacenterid
// Method: GET
// Params: datacenterid (passed in URL)
// Returns: All cabinet information within the given data center, if any
//
$app->get('/cabinet/bydc/:datacenterid', function ($datacenterid) {
$cab = new Cabinet();
$dc = new DataCenter();
$cab->DataCenterID = intval($datacenterid);
$cList = $cab->ListCabinetsByDC();
$response['error'] = false;
$response['errorcode'] = 200;
$response['cabinet'] = array();
foreach ($cList as $c) {
$tmp = array();
foreach ($c as $prop => $value) {
$tmp[$prop] = $value;
}
if ($dc->DataCenterID != $c->DataCenterID) {
$dc->DataCenterID = $c->DataCenterID;
$dc->GetDataCenter();
}
$tmp['DataCenterName'] = $dc->Name;
array_push($response['cabinet'], $tmp);
}
示例2: displayjson
$dcpicklist .= "<option value={$d->DataCenterID}>{$d->Name}</option>";
}
$dcpicklist .= '</select>';
return $dcpicklist;
}
// AJAX - Start
function displayjson($array)
{
header('Content-Type: application/json');
echo json_encode($array);
exit;
}
if (isset($_POST['dc'])) {
$cab = new Cabinet();
$cab->DataCenterID = $_POST['dc'];
displayjson($cab->ListCabinetsByDC());
}
if (isset($_POST['cab'])) {
$dev = new Device();
$dev->Cabinet = $_POST['cab'];
// Filter devices by rights
$devs = array();
foreach ($dev->ViewDevicesByCabinet(true) as $d) {
if ($d->Rights == "Write") {
$devs[] = $d;
}
}
displayjson($devs);
}
if (isset($_POST['dev'])) {
$dp = new DevicePorts();
示例3: array
}
} else {
//update cabinet
$cab->FrontEdge = $_POST["airflow"];
$cab->UpdateCabinet();
}
}
exit;
}
if (isset($_POST['dc']) && (isset($_POST['getobjects']) || isset($_POST['getoverview']))) {
$payload = array();
if (isset($_POST['getobjects'])) {
$cab->DataCenterID = $_POST['dc'];
$zone = new Zone();
$zone->DataCenterID = $cab->DataCenterID;
$payload = array('cab' => $cab->ListCabinetsByDC(true), 'zone' => $zone->GetZonesByDC(true));
} else {
$dc->DataCenterID = $_POST['dc'];
$dc->GetDataCenterByID();
$payload = $dc->GetOverview();
}
header('Content-Type: application/json');
echo json_encode($payload);
exit;
}
if (!isset($_GET["dc"])) {
// No soup for you.
header('Location: ' . redirect());
exit;
}
$dc->DataCenterID = $_GET["dc"];
示例4: array
$devList[$dev->DeviceType][$dev->DeviceID] = array();
}
}
} elseif (isset($_REQUEST['zoneid'])) {
$zoneid = isset($_POST['zoneid']) ? $_POST['zoneid'] : $_GET['zoneid'];
$zone = new Zone();
$zone->ZoneID = $zoneid;
$zone->GetZone();
$datacenter = new DataCenter();
$datacenter->DataCenterID = $zone->DataCenterID;
$datacenter->GetDataCenter();
$graphname .= "Zone " . $zone->Description . " in Data Center " . $datacenter->Name;
$cabinet = new Cabinet();
$cabinet->DataCenterID = $zone->DataCenterID;
$cabinet->ZoneID = $zone->ZoneID;
foreach ($cabinet->ListCabinetsByDC(true, true) as $cab) {
$device = new Device();
$device->Cabinet = $cab->CabinetID;
foreach ($device->ViewDevicesByCabinet(true) as $dev) {
if (!isset($devList[$dev->DeviceType])) {
$devList[$dev->DeviceType] = array();
}
$devList[$dev->DeviceType][$dev->DeviceID] = array();
}
}
} elseif (isset($_REQUEST['cabrowid'])) {
$cabrowid = isset($_POST['cabrowid']) ? $_POST['cabrowid'] : $_GET['cabrowid'];
$cabrow = new CabRow();
$cabrow->CabRowID = $cabrowid;
$cabrow->GetCabRow();
$cabinet = new Cabinet();
示例5: computeSheetBodyDCInventory
/**
* Compute the full inventory on devices in the data centers and return the data
* center summary statistics
*
* @param PHPExcel_Worksheet $worksheet
* @param array $DProps properties defined for the Excel document
* @return (array|array|array|boolean)[]
* statistics array, device inventory, cabinet inventory
*/
function computeSheetBodyDCInventory($DProps)
{
global $person;
global $sessID;
$dc = new DataCenter();
$cab = new Cabinet();
$device = new Device();
$invData = array();
$invCab = array();
$sheetColumns = $DProps['DC Inventory']['Columns'];
$cabinetColumns = $DProps['Rack Inventory']['Columns'];
$devTemplates = DeviceTemplate::getTemplateListIndexedbyID();
$deptList = Department::GetDepartmentListIndexedbyID();
$contactList = $person->GetUserList('indexed');
$limitedUser = false;
$dcList = $dc->GetDCList();
$Stats = array();
// A little code to update the counter
$percentDone = 0;
$sectionMaxPercent = 40;
$incrementalPercent = 1 / sizeof($dcList) * $sectionMaxPercent;
foreach ($dcList as $dc) {
$dcContainerList = $dc->getContainerList();
$dcStats = array();
$cab->DataCenterID = $dc->DataCenterID;
$dcStats['Fl_Spc'] = $dc->SquareFootage;
$dcStats['DesignPower'] = $dc->MaxkW;
$dcStats['Watts'] = 0;
$dcStats['Rk_Num'] = 0;
$dcStats['Rk_UtT'] = 0;
$dcStats['Rk_UtU'] = 0;
$dcStats['Rk_UtE'] = 0;
$dcStats['Rk_Res'] = 0;
$cabList = $cab->ListCabinetsByDC();
if (count($cabList) == 0) {
// empty data center room
$devSpec = makeEmptySpec($sheetColumns, $dcContainerList);
$devSpec['DC Name'] = $dc->Name;
$invData[] = $devSpec;
} else {
foreach ($cabList as $cab) {
if (!$person->ReadAccess and $cab->AssignedTo == 0 or $cab->AssignedTo > 0 and !$person->canRead($cab->AssignedTo)) {
// User is not allowed to see anything in here
$limitedUser = true;
continue;
}
$zoneName = getZoneName($cab);
$rowName = getRowName($cab);
addRackStat($invCab, $cab, $cabinetColumns, $dc, $dcContainerList);
$cab_height = $cab->CabinetHeight;
if (mb_strtoupper($cab->Model) == 'RESERVED') {
$dcStats['Rk_Res']++;
} else {
$dcStats['Rk_Num']++;
}
$dcStats['Rk_UtT'] += $cab_height;
$device->Cabinet = $cab->CabinetID;
$device_list = $device->ViewDevicesByCabinet();
// empty cabinet
if (count($device_list) == 0 && $cab->CabinetHeight > 0) {
$dcStats['Rk_UtE'] += $cab_height;
$devSpec = makeEmptySpec($sheetColumns, $dcContainerList);
$devSpec['Zone'] = $zoneName;
$devSpec['Row'] = $rowName;
$devSpec['DC Name'] = $dc->Name;
$devSpec['Cabinet'] = $cab->Location;
$devSpec['Position'] = 1;
$devSpec['Height'] = $cab->CabinetHeight;
$devSpec['Device'] = '__EMPTY';
$invData[] = $devSpec;
} else {
usort($device_list, 'cmpDevPos');
$low_idx = 1;
foreach ($device_list as $dev) {
if ($low_idx < $dev->Position) {
// range of empty slots
if ($dev->Position <= $cab_height) {
$height = $dev->Position - $low_idx;
} else {
$height = $cab_height - $low_idx + 1;
}
if ($height > 0) {
$dcStats['Rk_UtE'] += $height;
$devSpec = makeEmptySpec($sheetColumns, $dcContainerList);
${$devSpec}['Zone'] = $zoneName;
$devSpec['Row'] = $rowName;
$devSpec['DC Name'] = $dc->Name;
$devSpec['Cabinet'] = $cab->Location;
$devSpec['Position'] = $low_idx;
$devSpec['Height'] = $height;
$devSpec['Device'] = '__EMPTY';
//.........这里部分代码省略.........
示例6: GetOverview
function GetOverview()
{
$this->MakeSafe();
$statusarray = array();
// check to see if map was set
if (strlen($this->DrawingFileName)) {
$mapfile = "drawings" . DIRECTORY_SEPARATOR . $this->DrawingFileName;
$overview = array();
$space = array();
$weight = array();
$power = array();
$temperature = array();
$humidity = array();
$realpower = array();
$colors = array();
// map was set in config check to ensure a file exists before we attempt to use it
if (file_exists($mapfile)) {
$this->dcconfig = new Config();
$dev = new Device();
$templ = new DeviceTemplate();
$cab = new Cabinet();
// get all color codes and limits for use with loop below
$CriticalColor = html2rgb($this->dcconfig->ParameterArray["CriticalColor"]);
$CautionColor = html2rgb($this->dcconfig->ParameterArray["CautionColor"]);
$GoodColor = html2rgb($this->dcconfig->ParameterArray["GoodColor"]);
$SpaceRed = intval($this->dcconfig->ParameterArray["SpaceRed"]);
$SpaceYellow = intval($this->dcconfig->ParameterArray["SpaceYellow"]);
$WeightRed = intval($this->dcconfig->ParameterArray["WeightRed"]);
$WeightYellow = intval($this->dcconfig->ParameterArray["WeightYellow"]);
$PowerRed = intval($this->dcconfig->ParameterArray["PowerRed"]);
$PowerYellow = intval($this->dcconfig->ParameterArray["PowerYellow"]);
$unknown = html2rgb('FFFFFF');
// Copy all colors into an array to export
$color['unk'] = array('r' => $unknown[0], 'g' => $unknown[1], 'b' => $unknown[2]);
$color['bad'] = array('r' => $CriticalColor[0], 'g' => $CriticalColor[1], 'b' => $CriticalColor[2]);
$color['med'] = array('r' => $CautionColor[0], 'g' => $CautionColor[1], 'b' => $CautionColor[2]);
$color['low'] = array('r' => $GoodColor[0], 'g' => $GoodColor[1], 'b' => $GoodColor[2]);
$colors = $color;
// Assign color variables
$CriticalColor = 'bad';
$CautionColor = 'med';
$GoodColor = 'low';
$unknownColor = 'unk';
// Temperature
$TemperatureYellow = intval($this->dcconfig->ParameterArray["TemperatureYellow"]);
$TemperatureRed = intval($this->dcconfig->ParameterArray["TemperatureRed"]);
// Humidity
$HumidityMin = intval($this->dcconfig->ParameterArray["HumidityRedLow"]);
$HumidityMedMin = intval($this->dcconfig->ParameterArray["HumidityYellowLow"]);
$HumidityMedMax = intval($this->dcconfig->ParameterArray["HumidityYellowHigh"]);
$HumidityMax = intval($this->dcconfig->ParameterArray["HumidityRedHigh"]);
//Real Power
$RealPowerRed = intval($this->dcconfig->ParameterArray["PowerRed"]);
$RealPowerYellow = intval($this->dcconfig->ParameterArray["PowerYellow"]);
// get image file attributes and type
list($width, $height, $type, $attr) = getimagesize($mapfile);
$cdus = array();
$sql = "select c.CabinetID, P.RealPower, P.BreakerSize, P.InputAmperage*PP.PanelVoltage as VoltAmp from \n\t\t\t\t\t(fac_Cabinet c left join (select CabinetID, Wattage as RealPower, BreakerSize, InputAmperage, PanelID from fac_PowerDistribution PD \n\t\t\t\t\tleft join fac_PDUStats PS on PD.PDUID=PS.PDUID) P on c.CabinetID=P.CabinetID) \n\t\t\t\t\tleft join (select PanelVoltage, PanelID from fac_PowerPanel) PP on PP.PanelID=P.PanelID \n\t\t\t\t\twhere PanelVoltage is not null and RealPower is not null and c.DataCenterID=" . intval($this->DataCenterID);
$rpvalues = $this->query($sql);
foreach ($rpvalues as $cduRow) {
$cabid = $cduRow['CabinetID'];
$voltamp = $cduRow['VoltAmp'];
$rp = $cduRow['RealPower'];
$bs = $cduRow['BreakerSize'];
if ($bs == 1) {
$maxDraw = $voltamp / 1.732;
} elseif ($bs == 2) {
$maxDraw = $voltamp;
} else {
$maxDraw = $voltamp * 1.732;
}
// De-rate all breakers to 80% sustained load
$maxDraw *= 0.8;
// Only keep the highest percentage of any single CDU in a cabinet
if ($rp > 0) {
$pp = intval($rp / $maxDraw * 100);
} else {
$pp = 0;
}
$cdus[$cabid] = isset($cdus[$cabid]) && $cdus[$cabid] > $pp ? $cdus[$cabid] : $pp;
}
$cab->DataCenterID = $this->DataCenterID;
$cabList = $cab->ListCabinetsByDC();
$titletemp = 0;
$titlerp = 0;
// read all cabinets and calculate the color to display on the cabinet
foreach ($cabList as $cabRow) {
if ($cabRow->MapX1 == $cabRow->MapX2 || $cabRow->MapY1 == $cabRow->MapY2) {
continue;
}
$currentHeight = $cabRow->CabinetHeight;
$metrics = CabinetMetrics::getMetrics($cabRow->CabinetID);
$currentTemperature = $metrics->IntakeTemperature;
$currentHumidity = $metrics->IntakeHumidity;
$currentRealPower = $metrics->MeasuredPower;
$used = $metrics->SpaceUsed;
// check to make sure the cabinet height is set to keep errors out of the logs
if (!isset($cabRow->CabinetHeight) || $cabRow->CabinetHeight == 0) {
$SpacePercent = 100;
} else {
//.........这里部分代码省略.........