本文整理汇总了PHP中getAttrValues函数的典型用法代码示例。如果您正苦于以下问题:PHP getAttrValues函数的具体用法?PHP getAttrValues怎么用?PHP getAttrValues使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getAttrValues函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getExpirationsText
function getExpirationsText()
{
$row_format = "%3s|%-30s|%-15s|%-15s|%s\r\n";
$ret = '';
$breakdown = array();
$breakdown[21] = array(array('from' => -365, 'to' => 0, 'title' => 'has expired within last year'), array('from' => 0, 'to' => 30, 'title' => 'expires within 30 days'));
$breakdown[22] = $breakdown[21];
$breakdown[24] = $breakdown[21];
$attrmap = getAttrMap();
foreach ($breakdown as $attr_id => $sections) {
$ret .= $attrmap[$attr_id]['name'] . "\r\n";
$ret .= "===========================================\r\n";
foreach ($sections as $section) {
$count = 1;
$result = scanAttrRelativeDays($attr_id, $section['from'], $section['to']);
if (!count($result)) {
continue;
}
$ret .= $section['title'] . "\r\n";
$ret .= "-----------------------------------------------------------------------------------\r\n";
$ret .= sprintf($row_format, '#', 'Name', 'Asset Tag', 'OEM S/N 1', 'Date Warranty Expires');
$ret .= "-----------------------------------------------------------------------------------\r\n";
foreach ($result as $row) {
$object = spotEntity('object', $row['object_id']);
$attributes = getAttrValues($object['id']);
$ret .= sprintf($row_format, $count, $object['dname'], $object['asset_no'], array_key_exists(1, $attributes) ? $attributes[1]['a_value'] : '', datetimestrFromTimestamp($row['uint_value']));
$count++;
}
$ret .= "-----------------------------------------------------------------------------------\r\n";
}
$ret .= "\r\n";
}
return $ret;
}
示例2: requireMandatoryAttrGeneric
function requireMandatoryAttrGeneric($listsrc, $attr_id, $newval)
{
$object_id = getBypassValue();
$attrs = getAttrValues($object_id);
if (array_key_exists($attr_id, $attrs) && considerGivenConstraint(spotEntity('object', $object_id), $listsrc) && !mb_strlen($newval)) {
showError('Mandatory attribute "' . $attrs[$attr_id]['name'] . '" not set');
stopOpPropagation();
}
return '';
}
示例3: checkTypeAndAttribute
function checkTypeAndAttribute($object_id, $type_id, $attr_id, $values, $hit = 'std')
{
$object = spotEntity('object', $object_id);
if ($object['objtype_id'] != $type_id) {
return '';
}
foreach (getAttrValues($object_id) as $record) {
if ($record['id'] == $attr_id and in_array($record['key'], $values)) {
return $hit;
}
}
return '';
}
示例4: detectDeviceBreed
function detectDeviceBreed($object_id)
{
global $breed_by_swcode, $breed_by_hwcode, $breed_by_mgmtcode;
foreach (getAttrValues($object_id) as $record) {
if ($record['id'] == 4 and array_key_exists($record['key'], $breed_by_swcode)) {
return $breed_by_swcode[$record['key']];
} elseif ($record['id'] == 2 and array_key_exists($record['key'], $breed_by_hwcode)) {
return $breed_by_hwcode[$record['key']];
} elseif ($record['id'] == 30 and array_key_exists($record['key'], $breed_by_mgmtcode)) {
return $breed_by_mgmtcode[$record['key']];
}
}
return '';
}
示例5: getCellFilter
// UI handler: renderDepot()
case 'get_depot':
require_once 'inc/init.php';
$cellfilter = getCellFilter();
$objects = filterCellList(listCells('object'), $cellfilter['expression']);
// get details if requested
if (isset($_REQUEST['include_attrs'])) {
foreach ($objects as $object_id => $object) {
amplifyCell($object);
// return the attributes in an array keyed on 'name', unless otherwise requested
$key_attrs_on = 'name';
if (isset($_REQUEST['key_attrs_on'])) {
$key_attrs_on = $_REQUEST['key_attrs_on'];
}
$attrs = array();
foreach (getAttrValues($object_id) as $record) {
// check that the key exists for this record
if (!isset($record[$key_attrs_on])) {
throw new InvalidRequestArgException('key_attrs_on', $_REQUEST['key_attrs_on'], 'requested keying value not set for all attributes');
}
if (strlen($record['value'])) {
$attrs[$record[$key_attrs_on]] = $record;
}
}
$objects[$object_id] = $object;
$objects[$object_id]['attrs'] = $attrs;
}
}
sendAPIResponse($objects);
break;
// get all available object attributes
示例6: detectDeviceBreed
function detectDeviceBreed($object_id)
{
$breed_by_swcode = array(251 => 'ios12', 252 => 'ios12', 254 => 'ios12', 963 => 'nxos4', 964 => 'nxos4', 1365 => 'nxos4', 1410 => 'nxos4', 1411 => 'nxos4', 1643 => 'nxos4', 1352 => 'xos12', 1360 => 'vrp53', 1361 => 'vrp55', 1369 => 'vrp55', 1363 => 'fdry5', 1367 => 'jun10', 1597 => 'jun10', 1598 => 'jun10', 1599 => 'jun10', 1594 => 'ftos8', 1673 => 'air12', 1674 => 'air12', 1675 => 'eos4', 1759 => 'iosxr4', 1786 => 'ros11', 242 => 'linux', 243 => 'linux', 1331 => 'linux', 1332 => 'linux', 1333 => 'linux', 1334 => 'linux', 1395 => 'linux', 1396 => 'linux');
for ($i = 225; $i <= 235; $i++) {
$breed_by_swcode[$i] = 'linux';
}
for ($i = 418; $i <= 436; $i++) {
$breed_by_swcode[$i] = 'linux';
}
for ($i = 1417; $i <= 1422; $i++) {
$breed_by_swcode[$i] = 'linux';
}
$breed_by_hwcode = array();
for ($i = 589; $i <= 637; $i++) {
$breed_by_hwcode[$i] = 'dlink';
}
$breed_by_mgmtcode = array(1788 => 'ucs');
foreach (getAttrValues($object_id) as $record) {
if ($record['id'] == 4 and array_key_exists($record['key'], $breed_by_swcode)) {
return $breed_by_swcode[$record['key']];
} elseif ($record['id'] == 2 and array_key_exists($record['key'], $breed_by_hwcode)) {
return $breed_by_hwcode[$record['key']];
} elseif ($record['id'] == 30 and array_key_exists($record['key'], $breed_by_mgmtcode)) {
return $breed_by_mgmtcode[$record['key']];
}
}
return '';
}
示例7: renderVMReport
function renderVMReport()
{
$aResult = array();
$iTotal = 0;
$sFilter = '{$typeid_1504}';
# typeid_1504 = Virtual machines
foreach (scanRealmByText('object', $sFilter) as $Result) {
$aResult[$Result['id']] = array();
$aResult[$Result['id']]['sName'] = $Result['name'];
// Create active links in comment
$aResult[$Result['id']]['sComment'] = makeLinksInText($Result['comment']);
// Load additional attributes:
$attributes = getAttrValues($Result['id']);
$aResult[$Result['id']]['sContact'] = '';
if (isset($attributes['14']['a_value'])) {
$aResult[$Result['id']]['sContact'] = $attributes['14']['a_value'];
}
$aResult[$Result['id']]['OEMSN'] = '';
if (isset($attributes['1']['a_value'])) {
$aResult[$Result['id']]['OEMSN'] = $attributes['1']['a_value'];
}
$aResult[$Result['id']]['sOS'] = '';
if (isset($attributes['4']['a_value'])) {
$aResult[$Result['id']]['sOS'] = $attributes['4']['a_value'];
}
// IP Informations
$aResult[$Result['id']]['ipV4List'] = getObjectIPv4AllocationList($Result['id']);
$aResult[$Result['id']]['ipV6List'] = getObjectIPv6AllocationList($Result['id']);
// Port (MAC) Informations
$aResult[$Result['id']]['ports'] = getObjectPortsAndLinks($Result['id']);
// Container
$aResult[$Result['id']]['container'] = getObjectContainerList($Result['id']);
$iTotal++;
}
if (isset($_GET['csv'])) {
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename=export_' . date("Ymdhis") . '.csv');
header('Pragma: no-cache');
header('Expires: 0');
$outstream = fopen("php://output", "w");
$aCSVRow = array('Name', 'MAC', 'IP(s)', 'Comment', 'Contact', 'OS', 'Hypervisor');
fputcsv($outstream, $aCSVRow);
foreach ($aResult as $id => $aRow) {
$aCSVRow = array();
$aCSVRow[0] = $aRow['sName'];
$aCSVRow[1] = '';
foreach ($aRow['ports'] as $portNumber => $aPortDetails) {
if (trim($aPortDetails['l2address']) != '') {
$aCSVRow[1] .= $aPortDetails['l2address'] . ' ';
}
}
$aCSVRow[1] = trim($aCSVRow[1]);
$aCSVRow[2] = '';
foreach ($aRow['ipV4List'] as $key => $aDetails) {
if (function_exists('ip4_format')) {
$key = ip4_format($key);
}
if (trim($key) != '') {
$aCSVRow[2] .= $key . ' ';
}
}
foreach ($aRow['ipV6List'] as $key => $aDetails) {
if (function_exists('ip6_format')) {
$key = ip6_format($key);
}
if (trim($key) != '') {
$aCSVRow[2] .= $key . ' ';
}
}
$aCSVRow[2] = trim($aCSVRow[2]);
$aCSVRow[3] = str_replace('"', "'", $aRow['sComment']);
$aCSVRow[4] = $aRow['sContact'];
$aCSVRow[5] = $aRow['sOS'];
$aCSVRow[6] = '';
foreach ($aRow['container'] as $key => $aDetails) {
$aCSVRow[6] .= trim($aDetails['container_name']) . ' ';
}
$aCSVRow[6] = trim($aCSVRow[6]);
fputcsv($outstream, $aCSVRow);
}
fclose($outstream);
exit(0);
# Exit normally after send CSV to browser
}
// Load stylesheet and jquery scripts
addCSS('css/extensions/style.css');
addJS('js/extensions/jquery-latest.js');
addJS('js/extensions/jquery.tablesorter.js');
addJS('js/extensions/picnet.table.filter.min.js');
// Display the stat array
echo "<h2>Virtual machines report ({$iTotal})</h2><ul>";
echo '<a href="index.php?page=reports&tab=vm&csv">CSV Export</a>';
echo '<table id="reportTable" class="tablesorter">
<thead>
<tr>
<th>Name</th>
<th>MAC</th>
<th>IP(s)</th>
<th>Comment</th>
<th>Contact</th>
//.........这里部分代码省略.........
示例8: linkmgmt_renderObjectLinks
function linkmgmt_renderObjectLinks($object_id)
{
$object = spotEntity('object', $object_id);
$object['attr'] = getAttrValues($object_id);
/* get ports */
/* calls getObjectPortsAndLinks */
amplifyCell($object);
//$ports = getObjectPortsAndLinks($object_id);
$ports = $object['ports'];
/* reindex array so key starts at 0 */
$ports = array_values($ports);
/* URL param handling */
if (isset($_GET['allports'])) {
$allports = $_GET['allports'];
} else {
$allports = FALSE;
}
if (isset($_GET['allback'])) {
$allback = $_GET['allback'];
} else {
$allback = FALSE;
}
echo '<table><tr>';
if ($allports) {
echo '<td width=200><a href="' . makeHref(portlist::urlparams('allports', '0', '0')) . '">Hide Ports without link</a></td>';
} else {
echo '<td width=200><a href="' . makeHref(portlist::urlparams('allports', '1', '0')) . '">Show All Ports</a></td>';
}
echo '<td width=200><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'PortLinkDialog', 'linktype' => 'back', 'byname' => '1'))) . '","name","height=700,width=800,scrollbars=yes");><a>Link Object Ports by Name</a></span></td>';
if ($allback) {
echo '<td width=200><a href="' . makeHref(portlist::urlparams('allback', '0', '0')) . '">Collapse Backend Links on same Object</a></td>';
} else {
echo '<td width=200><a href="' . makeHref(portlist::urlparams('allback', '1', '0')) . '">Expand Backend Links on same Object</a></td>';
}
/* Graphviz map */
echo '<td width=100><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'map', 'usemap' => 1))) . '","name","height=800,width=800,scrollbars=yes");><a>Object Map</a></span></td>';
/* Help */
echo '<td width=200><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'Help'))) . '","name","height=400,width=500");><a>Help</a></span></td>';
if (isset($_REQUEST['hl_port_id'])) {
$hl_port_id = $_REQUEST['hl_port_id'];
} else {
$hl_port_id = NULL;
}
echo '</tr></table>';
echo '<br><br><table id=renderobjectlinks0>';
/* switch display order depending on backend links */
$first = portlist::hasbackend($object_id);
$rowcount = 0;
foreach ($ports as $key => $port) {
$plist = new portlist($port, $object_id, $allports, $allback);
//echo "<td><img src=\"index.php?module=redirect&page=object&tab=linkmgmt&op=map&object_id=$object_id&port_id=${port['id']}&allports=$allports\" ></td>";
if ($plist->printportlistrow($first, $hl_port_id, $rowcount % 2 ? portlist::ALTERNATE_ROW_BGCOLOR : "#ffffff")) {
$rowcount++;
}
}
echo "</table>";
}
示例9: renderEditLocationForm
function renderEditLocationForm($location_id)
{
global $pageno;
$location = spotEntity('location', $location_id);
amplifyCell($location);
startPortlet('Attributes');
printOpFormIntro('updateLocation');
echo '<table border=0 align=center>';
echo "<tr><td> </td><th class=tdright>Parent location:</th><td class=tdleft>";
$locations = array();
$locations[0] = '-- NOT SET --';
foreach (listCells('location') as $id => $locationInfo) {
$locations[$id] = $locationInfo['name'];
}
natcasesort($locations);
printSelect($locations, array('name' => 'parent_id'), $location['parent_id']);
echo "</td></tr>\n";
echo "<tr><td> </td><th class=tdright>Name (required):</th><td class=tdleft><input type=text name=name value='{$location['name']}'></td></tr>\n";
// optional attributes
$values = getAttrValues($location_id);
$num_attrs = count($values);
echo "<input type=hidden name=num_attrs value={$num_attrs}>\n";
$i = 0;
foreach ($values as $record) {
echo "<input type=hidden name={$i}_attr_id value={$record['id']}>";
echo '<tr><td>';
if (strlen($record['value'])) {
echo "<a href='" . makeHrefProcess(array('op' => 'clearSticker', 'location_id' => $location_id, 'attr_id' => $record['id'])) . "'>";
printImageHREF('clear', 'Clear value');
echo '</a>';
} else {
echo ' ';
}
echo '</td>';
echo "<th class=sticker>{$record['name']}:</th><td class=tdleft>";
switch ($record['type']) {
case 'uint':
case 'float':
case 'string':
echo "<input type=text name={$i}_value value='{$record['value']}'>";
break;
case 'dict':
$chapter = readChapter($record['chapter_id'], 'o');
$chapter[0] = '-- NOT SET --';
$chapter = cookOptgroups($chapter, 1562, $record['key']);
printNiftySelect($chapter, array('name' => "{$i}_value"), $record['key']);
break;
}
echo "</td></tr>\n";
$i++;
}
echo "<tr><td> </td><th class=tdright>Has problems:</th><td class=tdleft><input type=checkbox name=has_problems";
if ($location['has_problems'] == 'yes') {
echo ' checked';
}
echo "></td></tr>\n";
if (count($location['locations']) == 0 and count($location['rows']) == 0) {
echo "<tr><td> </td><th class=tdright>Actions:</th><td class=tdleft>";
echo "<a href='" . makeHrefProcess(array('op' => 'deleteLocation', 'location_id' => $location_id)) . "' onclick=\"javascript:return confirm('Are you sure you want to delete the location?')\">" . getImageHREF('destroy', 'Delete location') . "</a>";
echo " </td></tr>\n";
}
echo "<tr><td colspan=3><b>Comment:</b><br><textarea name=comment rows=10 cols=80>{$location['comment']}</textarea></td></tr>";
echo "<tr><td class=submit colspan=3>";
printImageHREF('SAVE', 'Save changes', TRUE);
echo "</td></tr>\n";
echo '</form></table><br>';
finishPortlet();
startPortlet('History');
renderObjectHistory($location_id);
finishPortlet();
}
示例10: renderPortletWattConsumption
function renderPortletWattConsumption($info)
{
$rackTotalWattage = 0;
$rackData = spotEntity('rack', $info['id']);
amplifyCell($rackData);
$objectChildren = getEntityRelatives('children', 'object', $objectData['id']);
foreach ($rackData['mountedObjects'] as $object) {
$objectData = spotEntity('object', $object);
amplifyCell($objectData);
foreach (getAttrValues($objectData['id']) as $record) {
if ($record['name'] == 'Wattage consumption') {
$rackTotalWattage += $record['value'];
}
}
}
startPortlet('Wattage Consumption');
echo "<table border=0 cellspacing=5 align='center'><tr>";
echo "<td>The total for attribute Wattage consuption is: <b>{$rackTotalWattage}</b></td>\n";
echo "</tr></table>\n";
finishPortlet();
}
示例11: snmpgeneric_opcreate
function snmpgeneric_opcreate()
{
$object_id = $_REQUEST['object_id'];
$attr = getAttrValues($object_id);
// sg_var_dump_html($_REQUEST);
// sg_var_dump_html($attr);
/* commitUpdateAttrValue ($object_id, $attr_id, $new_value); */
if (isset($_POST['updateattr'])) {
foreach ($_POST['updateattr'] as $attr_id => $value) {
// if(empty($attr[$attr_id]['value']))
if (!empty($value)) {
commitUpdateAttrValue($object_id, $attr_id, $value);
showSuccess("Attribute " . $attr[$attr_id]['name'] . " set to {$value}");
}
}
unset($attr_id);
unset($value);
}
/* updateattr */
/* create ports */
if (isset($_POST['portcreate'])) {
foreach ($_POST['portcreate'] as $if => $value) {
$ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
$ifPhysAddress = isset($_POST['ifPhysAddress'][$if]) ? trim($_POST['ifPhysAddress'][$if]) : '';
$ifAlias = isset($_POST['ifAlias'][$if]) ? trim($_POST['ifAlias'][$if]) : '';
$ifDescr = isset($_POST['ifDescr'][$if]) ? trim($_POST['ifDescr'][$if]) : '';
//$visible_label = (empty($ifAlias) ? '' : $ifAlias.'; ').$ifDescr;
$visible_label = $ifAlias;
if (empty($ifName)) {
showError('Port without ifName ' . $_POST['porttypeid'][$if] . ', ' . $visible_label . ', ' . $ifPhysAddress);
} else {
commitAddPort($object_id, $ifName, $_POST['porttypeid'][$if], $visible_label, $ifPhysAddress);
showSuccess('Port created ' . $ifName . ', ' . $_POST['porttypeid'][$if] . ', ' . $visible_label . ', ' . $ifPhysAddress);
}
}
unset($if);
unset($value);
}
/* portcreate */
/* net create */
if (isset($_POST['netcreate'])) {
foreach ($_POST['netcreate'] as $id => $addrtype) {
$range = $_POST['netprefix'][$id];
$name = $_POST['netname'][$id];
$is_reserved = isset($_POST['netreserve'][$id]);
if ($addrtype == 'ipv4' || $addrtype == 'ipv4z') {
createIPv4Prefix($range, $name, $is_reserved);
} else {
createIPv6Prefix($range, $name, $is_reserved);
}
showSuccess("{$range} {$name} created");
}
unset($id);
unset($addrtype);
}
/* netcreate */
/* allocate ipv6 adresses */
if (isset($_POST['ipv6addrcreate'])) {
foreach ($_POST['ipv6addrcreate'] as $ipaddr => $if) {
bindIPv6ToObject(ip6_parse($ipaddr), $object_id, $_POST['ifName'][$if], 1);
/* connected */
showSuccess("{$ipaddr} allocated");
}
unset($ipaddr);
unset($if);
}
/* allocate ip adresses */
if (isset($_POST['ipaddrcreate'])) {
foreach ($_POST['ipaddrcreate'] as $ipaddr => $if) {
bindIPToObject(ip_parse($ipaddr), $object_id, $_POST['ifName'][$if], 1);
/* connected */
showSuccess("{$ipaddr} allocated");
}
unset($ipaddr);
unset($if);
}
/* ipaddrecreate */
/* update label */
if (isset($_POST['updatelabel'])) {
foreach ($_POST['updatelabel'] as $if => $port_id) {
$ifAlias = isset($_POST['ifAlias'][$if]) ? trim($_POST['ifAlias'][$if]) : '';
sg_commitUpdatePortLabel($object_id, $port_id, $ifAlias);
$ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
showSuccess("label updated on {$ifName} to {$ifAlias}");
}
unset($if);
unset($port_id);
}
/* updatemac */
/* update mac addresses only */
if (isset($_POST['updatemac'])) {
foreach ($_POST['updatemac'] as $if => $port_id) {
$ifPhysAddress = isset($_POST['ifPhysAddress'][$if]) ? trim($_POST['ifPhysAddress'][$if]) : '';
sg_commitUpdatePortl2address($object_id, $port_id, $ifPhysAddress);
$ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
showSuccess("l2address updated on {$ifName} to {$ifPhysAddress}");
}
unset($if);
unset($port_id);
}
//.........这里部分代码省略.........
示例12: renderExpirations
function renderExpirations()
{
global $nextorder;
$breakdown = array();
$breakdown[21] = array(array('from' => -365, 'to' => 0, 'class' => 'has_problems_', 'title' => 'has expired within last year'), array('from' => 0, 'to' => 30, 'class' => 'row_', 'title' => 'expires within 30 days'), array('from' => 30, 'to' => 60, 'class' => 'row_', 'title' => 'expires within 60 days'), array('from' => 60, 'to' => 90, 'class' => 'row_', 'title' => 'expires within 90 days'));
$breakdown[22] = $breakdown[21];
$breakdown[24] = $breakdown[21];
$attrmap = getAttrMap();
foreach ($breakdown as $attr_id => $sections) {
startPortlet($attrmap[$attr_id]['name']);
foreach ($sections as $section) {
$count = 1;
$order = 'odd';
$result = scanAttrRelativeDays($attr_id, $section['from'], $section['to']);
echo '<table align=center width=60% border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
echo "<caption>{$section['title']}</caption>\n";
if (!count($result)) {
echo "<tr><td colspan=4>(none)</td></tr></table><br>\n";
continue;
}
echo '<tr valign=top><th align=center>Count</th><th align=center>Name</th>';
echo "<th align=center>Asset Tag</th><th align=center>OEM S/N 1</th><th align=center>Date Warranty <br> Expires</th></tr>\n";
foreach ($result as $row) {
$date_value = datetimestrFromTimestamp($row['uint_value']);
$object = spotEntity('object', $row['object_id']);
$attributes = getAttrValues($object['id']);
$oem_sn_1 = array_key_exists(1, $attributes) ? $attributes[1]['a_value'] : ' ';
echo '<tr class=' . $section['class'] . $order . ' valign=top>';
echo "<td>{$count}</td>";
echo '<td>' . mkA($object['dname'], 'object', $object['id']) . '</td>';
echo "<td>{$object['asset_no']}</td>";
echo "<td>{$oem_sn_1}</td>";
echo "<td>{$date_value}</td>";
echo "</tr>\n";
$order = $nextorder[$order];
$count++;
}
echo "</table><br>\n";
}
finishPortlet();
}
}
示例13: setSwitchVLANs
function setSwitchVLANs($object_id = 0, $setcmd)
{
global $remote_username;
$objectInfo = spotEntity('object', $object_id);
$endpoints = findAllEndpoints($object_id, $objectInfo['name']);
if (count($endpoints) == 0) {
throw new RTGatewayError('no management address set');
}
if (count($endpoints) > 1) {
throw new RTGatewayError('cannot pick management address');
}
$hwtype = $swtype = 'unknown';
foreach (getAttrValues($object_id) as $record) {
if ($record['name'] == 'SW type' && strlen($record['o_value'])) {
$swtype = strtr(execGMarker($record['o_value']), ' ', '+');
}
if ($record['name'] == 'HW type' && strlen($record['o_value'])) {
$hwtype = strtr(execGMarker($record['o_value']), ' ', '+');
}
}
$endpoint = str_replace(' ', '+', $endpoints[0]);
$data = queryGateway('switchvlans', array("connect {$endpoint} {$hwtype} {$swtype} {$remote_username}", $setcmd));
// Finally we can parse the response into message array.
foreach (explode(';', substr($data[1], strlen('OK!'))) as $text) {
$message = 'gw: ' . substr($text, 2);
if (strpos($text, 'I!') === 0) {
showSuccess($message);
} elseif (strpos($text, 'W!') === 0) {
showWarning($message);
} elseif (strpos($text, 'E!') === 0) {
showError($message);
} else {
// All improperly formatted messages must be treated as error conditions.
showError('unexpected line from gw: ' . $text);
}
}
}
示例14: doSNMPmining
function doSNMPmining($object_id, $snmpsetup)
{
$objectInfo = spotEntity('object', $object_id);
$objectInfo['attrs'] = getAttrValues($object_id);
$endpoints = findAllEndpoints($object_id, $objectInfo['name']);
if (count($endpoints) == 0) {
return showFuncMessage(__FUNCTION__, 'ERR1');
}
// endpoint not found
if (count($endpoints) > 1) {
return showFuncMessage(__FUNCTION__, 'ERR2');
}
// can't pick an address
switch ($objectInfo['objtype_id']) {
case 7:
case 8:
$device = new RTSNMPDevice($endpoints[0], $snmpsetup);
return doSwitchSNMPmining($objectInfo, $device);
case 2:
$device = new APCPowerSwitch($endpoints[0], $snmpsetup);
return doPDUSNMPmining($objectInfo, $device);
}
}
示例15: handleNetworkStickerClear
function handleNetworkStickerClear()
{
global $sic, $pageno;
assertUIntArg('attr_id');
if (permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $sic['attr_id'])))) {
commitUpdateAttrForNetwork(spotEntity($pageno === 'ipv4net' ? 'ipv4net' : 'ipv6net', getBypassValue()), $sic['attr_id']);
showSuccess("Attribute value cleared successfully");
} else {
$oldvalues = getAttrValues(getBypassValue());
showError('Permission denied, "' . $oldvalues[$sic['attr_id']]['name'] . '" left unchanged');
}
}