internal static void Initialize() { // For each blade for (int i = 0; i < ConfigLoaded.Population; i++) { // Initialize lock object for performing atomic blade power operations locker[i] = new object(); // Initialize Hard Power On/Off Switches (Blade Enable) BladePower[i] = new BladePowerSwitch(Convert.ToByte(i + 1)); // Get Actual Power State BladePower[i].GetBladePowerState(); // Create Blade Serial Console Metadata objects and initialize token, timestamp and associated member objects using class constructor BladeSerialMetadata.Add(i + 1, new BladeSerialSessionMetadata(i + 1)); } // For each PSU for (int i = 0; i < ConfigLoaded.NumPsus; i++) { psuLock[i] = new object(); } PsuInitialize(); // For each serial port // Create Serial Console Port Metadata objects and initialize the sessiontoken and timestamp using the class constructor SerialConsolePortsMetadata = new SerialConsoleMetadata[(uint)ConfigLoaded.MaxSerialConsolePorts]; for (int numPorts = 0; numPorts < (int)ConfigLoaded.MaxSerialConsolePorts; numPorts++) { SerialConsolePortsMetadata[numPorts] = new SerialConsoleMetadata(ChassisManagerUtil.GetSerialConsolePortIdFromIndex(numPorts), DateTime.Now); } // Create AC Power Socket objects AcPowerSockets = new AcSocket[(uint)ConfigLoaded.NumPowerSwitches]; for (int numSockets = 0; numSockets < (int)ConfigLoaded.NumPowerSwitches; numSockets++) { AcPowerSockets[numSockets] = new AcSocket((byte)(numSockets + 1)); } WatchDogTimerInitialize(); // Create fan objects for (int fanId = 0; fanId < (int)ConfigLoaded.NumFans; fanId++) { Fans[fanId] = new Fan((byte)(fanId + 1)); } }
/// <summary> /// Find group with given name, if not exists create /// </summary> /// <param name="role">Group name</param> /// <returns>Group DirectorEntry</returns> internal static DirectoryEntry FindGroupIfNotExistsCreate(WCSSecurityRole role) { try { DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"); DirectoryEntry grp = AD.Children.Find(role.ToString(), "group"); if (grp == null) { ChassisManagerUtil.CreateNewGroup(role); } return(grp); } catch (System.Runtime.InteropServices.COMException) { Tracer.WriteInfo(" Group: {0} not found , creating new", role.ToString()); return(ChassisManagerUtil.CreateNewGroup(role)); } }
internal static void Initialize() { for (int i = 0; i < ConfigLoaded.Population; i++) { _lock[i] = new object(); } // Create Serial Console Port Metadata objects and initialize the sessiontoken and timestamp using the class constructor SerialConsolePortsMetadata = new SerialConsoleMetadata[(uint)ConfigLoaded.MaxSerialConsolePorts]; for (int numPorts = 0; numPorts < (int)ConfigLoaded.MaxSerialConsolePorts; numPorts++) { SerialConsolePortsMetadata[numPorts] = new SerialConsoleMetadata(ChassisManagerUtil.GetSerialConsolePortIdFromIndex(numPorts), ConfigLoaded.InactiveSerialPortSessionToken, DateTime.Now); } // Create AC Power Socket objects AcPowerSockets = new AcSocket[(uint)ConfigLoaded.NumPowerSwitches]; for (int numSockets = 0; numSockets < (int)ConfigLoaded.NumPowerSwitches; numSockets++) { AcPowerSockets[numSockets] = new AcSocket((byte)(numSockets + 1)); } // Create PSU objects for (int psuIndex = 0; psuIndex < (int)ConfigLoaded.NumPsus; psuIndex++) { // Initially create instance of the base class // Later.. based on the psu model number, we create the appropriate psu class object Psu[psuIndex] = new PsuBase((byte)(psuIndex + 1)); } // Create fan objects for (int fanId = 0; fanId < (int)ConfigLoaded.NumPsus; fanId++) { Fans[fanId] = new Fan((byte)(fanId + 1)); } // Initialize Hard Power On/Off Switches (Blade Enable) for (int bladeId = 0; bladeId < BladePower.Length; bladeId++) { BladePower[bladeId] = new BladePowerSwitch(Convert.ToByte(bladeId + 1)); } }
public override bool CheckAccess(OperationContext operationContext, ref Message message) { // Open the request message using an xml reader XmlReader xr = OperationContext.Current.IncomingMessageHeaders.GetReaderAtHeader(0); // Split the URL at the API name--Parameters junction indicated by the '?' character - taking the first string will ignore all parameters string[] urlSplit = xr.ReadElementContentAsString().Split('/'); // Extract just the API name and rest of the URL, which will be the last item in the split using '/' string[] apiSplit = urlSplit[3].Split('?'); // Logging the username and API name Tracer.WriteUserLog(apiSplit[0] + " request from user: "******"Client IP address : " + ip); } // If the most-privileged-role that this user belongs has access to this api, then allow access, otherwise deny access // Returning true will allow the user to execute the actual API function; Returning false will deny access to the user // TODO: May be we should send back a HTTP error code; will include this after shivi checks in her code if (ChassisManagerSecurity.GetCurrentUserMostPrivilegedRole() <= ChassisManagerSecurity.GetCurrentApiLeastPrivilegedRole(apiSplit[0])) { Tracer.WriteUserLog("CheckAccess: Authorized"); return(true); } else { Tracer.WriteUserLog("CheckAccess: NOT Authorized"); return(false); } }
internal static Contracts.ChassisResponse StopBladeSerialSession(int bladeId, string sessionToken, bool forceKill = false) { Contracts.ChassisResponse response = new Contracts.ChassisResponse(); response.completionCode = Contracts.CompletionCode.Failure; Tracer.WriteInfo("BladeSerialSessionMetadata.Received Stopbladeserialsession({0})", bladeId); // If there is NOT an already existing Blade serial session (indicated by a invalid bladeId and a invalid sessionToken), return failure with appropriate completion code if (CompareAndSwapMetadata(ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken, ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken) == CompletionCode.Success) { Tracer.WriteError("StopBladeSerialSession({0}): Stop failed because of no active session.", bladeId); response.completionCode = Contracts.CompletionCode.NoActiveSerialSession; return(response); } // Normal scenario when forcekill option is not true.. check for bladeid correctness and if it currently holds the serial session if (!forceKill) { if (ChassisManagerUtil.CheckBladeId((byte)bladeId) != (byte)CompletionCode.Success) { response.completionCode = Contracts.CompletionCode.ParameterOutOfRange; return(response); } // If this bladeid do not currently hold the serial session, return failure if (CompareAndSwapMetadata(bladeId, sessionToken, bladeId, sessionToken) != CompletionCode.Success) { response.completionCode = Contracts.CompletionCode.SerialSessionActive; return(response); } } // Communication device has to come out of safe mode - should allow IPMI commands to go to the BMC if (!CommunicationDevice.DisableSafeMode()) { Tracer.WriteError( "BladeSerialSessionMetadata.StopBladeSerialSession({0}): CommunicationDevice.DisableSafeMode Failed", bladeId); } Ipmi.SerialMuxSwitch rms; // If forcekill parameter is false, then use the bladeid that is passed by the user if (!forceKill) { rms = WcsBladeFacade.ResetSerialMux((byte)bladeId); } // If forcekill parameter is true, then use the bladeid that currently holds the serial session else { rms = WcsBladeFacade.ResetSerialMux((byte)BladeSerialSessionMetadata.bladeId); } if (rms.CompletionCode != (byte)CompletionCode.Success) { Tracer.WriteError("BladeSerialSessionMetadata.StopBladeSerialSession({0}): Ipmi ReSetSerialMuxSwitch Failed", bladeId); } if (!BladeSerialSessionMetadata.ResetMetadata()) { Tracer.WriteError("BladeSerialSessionMetadata.StopBladeSerialSession: Unable to reset metadata"); } response.completionCode = Contracts.CompletionCode.Success; // Resetting TimeoutBladeSerialSessionInSecs to 0 to account for default or user provided session timeout value ConfigLoaded.TimeoutBladeSerialSessionInSecs = 0; return(response); }
/// <summary> /// Checks Blade Serial Sessions and Serial Port Console Sessions for inactivity. /// Closes inactive sessions to prevent conditions where users cannot open new sessions /// due to old sessions being abandoned. /// Receive and transmit commands are considered to be activity and will keep the session alive. /// </summary> private static void CheckBladeConsoleInactivity() { foreach (KeyValuePair <int, BladeSerialSessionMetadata> bladeSerialObject in ChassisState.BladeSerialMetadata) { bladeSerialObject.Value.BladeSerialSessionInactivityCheck(); } for (int numPorts = 0; numPorts < ConfigLoaded.MaxSerialConsolePorts; numPorts++) { ChassisState.SerialConsolePortsMetadata[numPorts].SerialPortConsoleInactivityCheck(ChassisManagerUtil.GetSerialConsolePortIdFromIndex(numPorts)); } }
/// <summary> /// Performs Blade Serial Console Inativity check /// </summary> private void CheckBladeConsoleInactivity() { BladeSerialSessionMetadata.BladeSerialSessionInactivityCheck(); for (int numPorts = 0; numPorts < ConfigLoaded.MaxSerialConsolePorts; numPorts++) { ChassisState.SerialConsolePortsMetadata[numPorts].SerialPortConsoleInactivityCheck(ChassisManagerUtil.GetSerialConsolePortIdFromIndex(numPorts)); } }