Beispiel #1
0
 def get_server_temp(self, server_bay_no):
     """ This function will return the current server temperature present in OA """
     output = False
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show server Temp %s" % (server_bay_no))
         ha_library.closeConnection()
         delimiter = ' '
         SystemName = self.find_value_by_key(
             output, "Ambient Zone     (01-Inlet Ambient)", delimiter)
         temp_OA = SystemName.split()[2]
         if not temp_OA:
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (SystemName))
             raise ValueError
         else:
             output = temp_OA[:-1]
         return output
     except:
         raise Exception("Failed to get server temperature")
Beispiel #2
0
    def get_system_name(self):
        """
        Description:
        Returns the ILO host name if true else returns false
        Input:username,password and IP of an ILO

        """
        try:
            output = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "show /map1/enetport1")
            ha_library.closeConnection()
            SystemName = self.find_value_by_keyword(output, "SystemName")
            if not SystemName:
                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % (SystemName))
                raise ValueError
            else:
                output = SystemName
            return output
        except:
            raise Exception("Failed to get ILO Host Name")
Beispiel #3
0
    def get_serial_number(self):
        """
        Description:
        Returns the serial number of an ILO if true else returns false
        Input:username,password and IP of ILO

        """
        try:
            output = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "show /system1 number")
            ha_library.closeConnection()
            SerialNumber = self.find_value_by_keyword(output, "number")
            if not SerialNumber:
                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % (SerialNumber))
                raise ValueError
            else:
                output = SerialNumber.rstrip()
            return output
        except:
            raise Exception("Failed to get Server Serial Number")
Beispiel #4
0
    def get_server_adapter_information(self, server_bay_no, adapter_dict):
        """
            Description:This function will return the server adapter information to validate server hardware type page
            Params:server_bay_no--> The bay number of server
            Return:Returns the list with the adapter information
        """
        output = None
        try:
            output = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "show server info %s" % (server_bay_no))
            ha_library.closeConnection()
            output = output.split('\n')
            model = ""
            adapter_list = []
            for line in output:
                data_list = []
                data_dict = {
                    'location': '',
                    'model': '',
                    'devicetype': '',
                    'speed': '',
                    'ports': ''
                }
                try:
                    if ("FlexFabric" in line):
                        if not ("FlexFabric Embedded Ethernet" in line):
                            '''if("FLB Adapter 1" in line.split(':')[0]):
                                data_dict['location'] = "FlexibleLOM 1"
                                data_list.append("FlexibleLOM 1")'''
                            model = line.split(':')[1].strip(' ').strip('\r')
                            data_dict['model'] = model
                            model_info = adapter_dict[model]
                            arrinfo = model_info.split(',')
                            data_list.append(arrinfo[0])
                            data_list.append(model)
                            data_list.append(arrinfo[1])
                            data_list.append(arrinfo[2])
                            data_list.append(arrinfo[3])

                    if ("Mezzanine" in line):
                        if not ("This server does not contain any mezzanine cards"
                                in line):
                            data_dict['location'] = line.split(':')[0].strip(
                                ' ')
                            model = line.split(':')[1].strip(' ')
                            data_dict['model'] = model
                            model_info = adapter_dict[model]
                            arrinfo = model_info.split(',')
                            data_list.append(arrinfo[0])
                            data_list.append(model)
                            data_list.append(arrinfo[1])
                            data_list.append(arrinfo[2])
                            data_list.append(arrinfo[3])

                    if (data_list != []):
                        adapter_list.append(data_list)
                except Exception as e:
                    adapter_list.append(data_list)
                    logger._warn(
                        "Given adapter %s information is not updated in the resource file. Exception is %s"
                        % (model, e))
                    return (False, [])
            return (True, adapter_list)
        except Exception as e:
            logger._log_to_console_and_log_file(
                "Unable to read data from the server in bay %s of enclosure %s. Exception while processing information is %s"
                % (server_bay_no, self.hw_ip, e))
            return (False, [])
Beispiel #5
0
    def get_server_port_information(self, encname):
        """
            Description:This function will return the server adapter information to validate server hardware type page
            Params:server_bay_no--> The bay number of server
            Return:Returns the list with the adapter information
        """
        output2 = None
        try:
            output2 = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "show server info all")
            ha_library.closeConnection()
            output2 = output2.split('\n')
            ports_list = []
            WWWN_list = []
            for line in output2:
                if "LOM" in line and (not ("Name" in line)):
                    line_cont = ""
                    for word in line.strip(" ").strip("\r").strip("\t").split(
                            " "):
                        if word != "":
                            if word != "  ":
                                line_cont += word.strip(" ").strip("\r").strip(
                                    "\t") + "="
                    line_cont.strip('=')
                    WWWN_list = []
                    line_cont = line_cont.strip(" ").split("=")
                    if "FC" in line_cont[0]:
                        if (len(line_cont) < 6):
                            WWWN_list.append(
                                ("Flexible" + line_cont[2]).replace(
                                    "LOM", "LOM "))
                        elif (len(line_cont) > 6):
                            WWWN_list.append(
                                ("Flexible" + line_cont[4]).replace(
                                    "LOM", "LOM "))
                        else:
                            WWWN_list.append(
                                ("Flexible" + line_cont[3]).replace(
                                    "LOM", "LOM "))
                        WWWN_list.append("FC")
                    else:
                        if (len(line_cont) < 6):
                            WWWN_list.append(
                                ("Flexible" + line_cont[2]).replace(
                                    "LOM", "LOM "))
                        elif (len(line_cont) > 6):
                            WWWN_list.append(
                                ("Flexible" + line_cont[4]).replace(
                                    "LOM", "LOM "))
                        else:
                            WWWN_list.append(
                                ("Flexible" + line_cont[3]).replace(
                                    "LOM", "LOM "))
                        WWWN_list.append(line_cont[0])

                    if (len(line_cont) < 6):
                        WWWN_list.append(line_cont[3])
                    elif (len(line_cont) > 6):
                        WWWN_list.append(line_cont[5])
                    else:
                        WWWN_list.append(line_cont[4])
                    ports_list.append(WWWN_list)
                # adapter_list.append(data_list)
            return (True, ports_list)
        except Exception as e:
            logger._log_to_console_and_log_file(
                "Unable to read data from the server in bay %s of enclosure %s. Exception while processing information is %s"
                % (encname, self.hw_ip, e))
            return (False, [])