/****************************************************************************** * Copyright 1991-2006 by ADIC, Inc. All rights reserved. * No part of this work may be reproduced or transmitted in any * form or by any means, electronic or mechanical, including * photocopying and recording, or by any information storage * or retrieval system, except as may be expressly permitted by * the 17 U.S.C. section 101, et. seq., or in writing by * ADIC, Inc. *******************************************************************************/ /*############################################################################## # NOTE: The XAJAX stuff MUST be before any Code. # You MUST use both the name and id in all form data to use it in xajax. # Groups of controls like raidoButtons need to all have the SAME name # but different IDs. ##############################################################################*/ require_once("xajax_core/xajax.inc.php"); $xajax = new xajax(); /*############################################################################ # Note: I found that the order these functionas are in matter when calling # them from the same javaScript function. I had enablePort second here and # even though I was calling it first in enablePort(). Because aJax is async # it was being called after xajax_getPortFailOver(). #############################################################################*/ $xajax->registerFunction("enablePort"); $xajax->registerFunction("getPortFailOver"); session_start(); $user = $_SESSION['user']; $in_xAjax = false; $xAjax_objResponse; include('common_admin_inc.htm'); include('IOB_inc.htm'); // The php function that is called from JavaScript tough xAjax when the user selects a Blade. function getPortFailOver($aBladeID) { global $in_xAjax; global $xAjax_objResponse; $user = $_SESSION['user']; $xAjax_objResponse = new xajaxResponse(); $in_xAjax = true; $IOB_state = array('Online', 'Offline' ); $IOB_failure = array('None', 'Link down', 'Link error'); $IOB_Intervention = array('Not required', 'Required' ); // First get the Channel Zonning Data. If any Channel Zoning has been done we disable the PortFailover page for this blade. $theData = get_blade_zoning($user, $aBladeID); error_log("theData = ". print_r($theData, true) ); // Load up the zones for the first target $hasZones = false; foreach( $theData as $zones ) { // Data returned is in a 0-5 array for($i = 2; $i<6; $i++) { //error_log("Channel ". ($i+1) ." = ".$zones[$i]); if( $zones[$i] == 0 ) { // Zoning has been done - lets get out of here. $hasZones = true; // $xAjax_objResponse->assign("theShadeBG", "style.visibility", 'visible' ); // $xAjax_objResponse->assign("theShade", "style.visibility", 'visible' ); $xAjax_objResponse->assign("hasZones", "value", 1 ); // return $xAjax_objResponse; // break; } } } // Now get the Failover data error_log("Calling get_host_port_failover($user, $aBladeID);"); $theData = get_host_port_failover($user, $aBladeID); error_log("theData = ". print_r($theData, true) ); // If the PortId is BLANK - force disabled if( $theData->port_id == '' ) { $theData->enabled = false; $thePort = 'n/a'; } else { $thePort = $theData->port_id[strlen($theData->port_id)-1]; error_log("* * * * thePort = ". $thePort); } // First load the original values so we know if there was a change. $xAjax_objResponse->assign("primPortIdOrig", "value", $theData->port_id ); $xAjax_objResponse->assign("ActivePortOrig", "value", $theData->activePort ); $xAjax_objResponse->assign("featureEnabledOrig", "value", $theData->enabled ); // $xAjax_objResponse->script('alert(xajax.$("primPortIdOrig").value);'); // $xAjax_objResponse->script('alert(xajax.$("featureEnabledOrig").value);'); // Now change the Current primary port on the page. $xAjax_objResponse->assign("primPortSpan", "innerHTML", $thePort ); // Next change the vales of the data on the page. // For now only Ports 1 and 2 can be confired has host ports. $xAjax_objResponse->assign("primPortId", "value", $theData->port_id ); $xAjax_objResponse->assign("CurActivePort", "innerHTML", " " . ($thePort==0?"None":$thePort) ); $xAjax_objResponse->assign("primPort", "value", $thePort ); if( $theData->enabled == 1 ) { error_log("SETTING featureEnabled to true"); $xAjax_objResponse->assign("featureEnabled", "checked", true ); $xAjax_objResponse->assign("primPort", "disabled", false ); // We are enabled - so load the Physical Port Data $xAjax_objResponse->assign("state1", "innerHTML", $IOB_state[$theData->Ports[0]->state]); $xAjax_objResponse->assign("fail1", "innerHTML", $IOB_failure[$theData->Ports[0]->failure]); $xAjax_objResponse->assign("intervention1", "innerHTML", $IOB_Intervention[$theData->Ports[0]->intervention]); $xAjax_objResponse->assign("enable1", "disabled", $theData->Ports[0]->intervention?false:true ); $xAjax_objResponse->assign("state2", "innerHTML", $IOB_state[$theData->Ports[1]->state]); $xAjax_objResponse->assign("fail2", "innerHTML", $IOB_failure[$theData->Ports[1]->failure]); $xAjax_objResponse->assign("intervention2", "innerHTML", $IOB_Intervention[$theData->Ports[1]->intervention]); $xAjax_objResponse->assign("enable2", "disabled", $theData->Ports[1]->intervention?false:true ); // Create the Active Port drop down According to the State of Ports 1 and 2. // If the Port is Offline it can NOT be set to active. $Sel1 = ""; $Sel2 = ""; if( $thePort == 1 ) $Sel1 = "selected"; else if( $thePort == 2 ) $Sel2 = "selected"; $theCode = " "; $xAjax_objResponse->assign("actPort", "innerHTML", $theCode); } else { error_log("SETTING featureEnabled to false"); $xAjax_objResponse->assign("featureEnabled", "checked", false ); $xAjax_objResponse->assign("primPort", "disabled", true ); // When enabling the feature ALWAY show both ports $theCode = " "; $xAjax_objResponse->assign("actPort", "innerHTML", $theCode); $xAjax_objResponse->assign("enable1", "disabled", true ); $xAjax_objResponse->assign("enable2", "disabled", true ); } // Some Debug examples //$xAjax_objResponse->script('alert(xajax.$("testlevel[1]").value);'); //$xAjax_objResponse->script('alert(xajax.viewSource());'); $in_xAjax = false; return $xAjax_objResponse; } // The php function that is called from JavaScript tough xAjax when the user selects a Blade. function enablePort($aBladeID, $aPortNum) { global $in_xAjax; global $xAjax_objResponse; $user = $_SESSION['user']; $xAjax_objResponse = new xajaxResponse(); $in_xAjax = true; error_log("Enabling port $aPortNum on blade $aBladeID"); $xAjax_objResponse->script("alert( Enabling port xajax.$(aPortNum));"); //$xAjax_objResponse->script('alert(xajax.$("testlevel[1]").value);'); enable_port($user, $aBladeID, (int)$aPortNum); $in_xAjax = false; return $xAjax_objResponse; } $xajax->processRequest(); /*******************************************************************************************/ // Handle the progress screen if opened and get the NEW data if ($_SERVER[REQUEST_METHOD] == "POST") { $operationInProgress = true; $status = new ReturnStatus(); error_log("_POST = ". print_r($_POST, true) ); $theBlade = $_POST['bladeId']; if(isset($_POST['featureEnabled'])) $theEnable = true; else $theEnable = false; $thePort = $_POST['primPort']; $thePortId = $_POST['primPortId']; error_log("Setting the Port failover with ". $theBlade .",". $thePortId .",". $theEnable?'true':'false' .".\n\n\n"); set_host_port_failover($user, $theBlade, $thePortId, $theEnable ); print $status->out(); return; } $isEnabled = true; $primary_port = 0; $active_port = "none"; $linkDelay = 3; $disabled = $isEnabled ? "Enabled" : "Disabled"; ?>
$xajax->printJavascript(); ?>