Exemplo n.º 1
0
 def get_server_present_power_consumption(self):
     """
     Description:
     Returns the Maximum power utilization of a server at that time if true else returns false
     Input:username,password and IP of an ILO
     """
     output = False
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show /system1/oemhp_power1")
         ha_library.closeConnection()
         delimiter = '='
         presentPower = self.find_value_by_key(output, "oemhp_PresentPower",
                                               delimiter)
         if not presentPower:
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (presentPower))
             raise ValueError
         else:
             output = presentPower
         return output
     except:
         raise Exception("Failed to get present Power Info")
Exemplo n.º 2
0
 def get_enclr_power_cap(self):
     """
     Description:
     Returns the enclosure power cap status.
     if power cap is already set this function returns power_cap value else Disabled
     """
     output = False
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show enclosure power_cap")
         ha_library.closeConnection()
         delimiter = ' '
         power_cap_status = self.find_value_by_key(
             output, "Enclosure Dynamic Power Cap:", delimiter)
         if not power_cap_status:
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (power_cap_status))
             raise ValueError
         else:
             output = power_cap_status.strip()
         return output
     except:
         raise Exception("Failed to get present Power Info")
Exemplo n.º 3
0
 def get_firmware_version_for_vc(self, interconnect_bay_number):
     """
         Description:This function will return the Firmware version of VC.It doesn't handle input "ALL" for interconnect_bay_number
         Params:interconnect_bay_number--> The bay number of interconnect
         Return: Returns the Firmware version if command is executed else Error will be shown
     """
     FirmVer = None
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show interconnect info %s" % (interconnect_bay_number))
         ha_library.closeConnection()
         FirmVer = self.find_value_by_oa_keyword(output, "Firmware Version")
         if not FirmVer:
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (FirmVer))
             return (False, '')
         else:
             return (True, FirmVer)
     except:
         logger._log_to_console_and_log_file(
             "Failed to get Firmware Version")
         return (False, '')
Exemplo n.º 4
0
    def get_server_model(self):
        """
        Description:
        Returns the Model name of the server 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 name")
            ha_library.closeConnection()
            ModelName = self.find_value_by_keyword(output, "name")
            if not ModelName:
                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % ModelName)
                raise ValueError
            else:
                output = ModelName
            return output
        except:
            raise Exception("Failed to get Server Model Number")
Exemplo n.º 5
0
    def get_port_nic_address(self):
        """
        Description:
        Function to retrieve the MAC address of NIC ports
        Returns the address separated by comma else false

        """
        try:
            output = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "show /system1/network1/Integrated_NICs")
            ha_library.closeConnection()
            Port1MACAddress = self.find_value_by_keyword(
                output, "Port1NIC_MACAddress")
            Port2MACAddress = self.find_value_by_keyword(
                output, "Port2NIC_MACAddress")
            if not Port1MACAddress and Port1MACAddress:
                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % (Port1MACAddress))
                logger._debug("result = %s" % (Port2MACAddress))
                raise ValueError
            else:
                output = Port1MACAddress + "," + Port2MACAddress
            return output
        except:
            raise Exception("Unable to get pORT NIC MAC Address")
Exemplo n.º 6
0
 def get_vc_status(self, interconnect_bay_number):
     """
         Description: This function will return the status of interconnect whether it is on or off.It doesn't handle input "ALL" for interconnect_bay_number
         Params:interconnect_bay_number--> The bay number of interconnect
         Return: Returns the status of interconnect if command is executed else false
     """
     status = None
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show interconnect status %s" % (interconnect_bay_number))
         ha_library.closeConnection()
         status = self.find_value_by_oa_keyword(output, "Powered")
         if not status:
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (status))
             return (False, '')
         else:
             output = status.lower()
             return (True, output)
     except:
         logger._log_to_console_and_log_file(
             "Failed to get Interconnect status")
         return (False, '')
Exemplo n.º 7
0
    def get_ilo_version_date(self):
        """
        Description:
        Returns the ILO firmware version and date 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 /map1/firmware1")
            ha_library.closeConnection()
            ILOVersion = self.find_value_by_keyword(output, "version")
            index = ILOVersion.rfind('p')
            if not index == -1:
                version = ILOVersion[0:index - 1]
                version.rstrip()
            else:
                version = ILOVersion
            ILODateFir = self.find_value_by_keyword(output, "date")
            if not ILOVersion and ILODateFir:
                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % (version))
                logger._debug("result = %s" % (ILODateFir))
                raise ValueError
            else:
                output = version + " " + ILODateFir
            return output
        except:
            raise Exception("Failed to get ILO Version Date")
Exemplo n.º 8
0
    def get_rom_version_date(self):
        """
        Description:
        Returns the ROM Version and date 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 /system1/firmware1")
            ha_library.closeConnection()
            ROMVersion = self.find_value_by_keyword(output, "version")
            ROMDateFir = self.find_value_by_keyword(output, "date")
            if not ROMVersion and ROMDateFir:

                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % (ROMVersion))
                logger._debug("result = %s" % (ROMDateFir))
                raise ValueError
            else:
                output = ROMVersion + " " + ROMDateFir
            return output
        except:
            raise Exception("Failed to get ROM Version date")
Exemplo n.º 9
0
    def set_enclr_power_cap(self, power_cap):
        """
        Description:
        sets dynamic power cap to enclosures Returns the enclosures power cap
        """

        output = False
        try:
            output = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "set enclosure power_cap %s" % (power_cap))
            ha_library.closeConnection()
            delimiter = ' '
            power_cap_status = self.find_value_by_key(
                output, "Enclosure Dynamic Power Cap:", delimiter)
            if not power_cap_status:
                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % (power_cap))
                raise ValueError
            else:
                output = power_cap_status.split()[0]
            return output
        except:
            raise Exception("Failed to get present Power Info")
Exemplo n.º 10
0
 def disable_enclr_power_cap(self):
     """
     Description:
     This function will remove the enclosure power cap and returns the power cap status.
     """
     output = False
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "set enclosure power_cap off")
         ha_library.closeConnection()
         delimiter = ' '
         power_cap_status = self.find_value_by_key(
             output, "Enclosure Dynamic Power Cap:", delimiter)
         if power_cap_status.strip() != "Disabled":
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (power_cap_status))
             raise ValueError
         else:
             output = True
         return output
     except:
         raise Exception("Failed to get present Power Info")
Exemplo n.º 11
0
 def get_allowable_enclr_power_cap(self):
     """
     Description:
     Returns the Allowable Enclosure Dynamic Power Cap.
     """
     output = False
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show enclosure power_cap")
         ha_library.closeConnection()
         delimiter = ' '
         power_cap = self.find_value_by_key(
             output, "Allowable Enclosure Dynamic Power Cap:", delimiter)
         if not power_cap:
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (power_cap))
             raise ValueError
         else:
             output = power_cap.split('-')[0]
         return output.strip()
     except:
         raise Exception("Failed to get present Power Info")
Exemplo n.º 12
0
 def get_vc_part_number(self, interconnect_bay_number):
     """
         Description:This function will return the Part number of VC.It doesn't handle input "ALL" for interconnect_bay_number
         Params:interconnect_bay_number--> The bay number of interconnect
         Return:Returns the part number of VC if command is executed else Error will be shown
     """
     PartNumber = None
     output = None
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show interconnect info %s" % (interconnect_bay_number))
         pos = output.find("Part Number")
         if pos == -1:
             return False
         start = pos + len("Part Number:") + 1
         end = output.find("\n", start)
         PartNumber = output[start:end - 1]
         PartNumber.rstrip()
         ha_library.closeConnection()
         #             PartNumber = self.find_value_by_oa_keyword(output, "Part Number:")
         if not PartNumber:
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (PartNumber))
             return (False, '')
         else:
             return (True, PartNumber)
     except:
         logger._log_to_console_and_log_file("Failed to get Part NUmber")
         return (False, '')
Exemplo n.º 13
0
 def get_server_license(self):
     """ This function will return the server license captured from OA """
     output = False
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show /map1 license")
         ha_library.closeConnection()
         delimiter = '='
         server_license = self.find_value_by_key(output, "license",
                                                 delimiter)
         if not server_license:
             output = False
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (server_license))
             raise ValueError
         else:
             output = server_license
         return output
     except:
         raise Exception("Failed to get ILO License")
Exemplo n.º 14
0
    def get_cpu_proc_number_name(self):
        """
        Description:
        Returns the number of processors a server has and its name else false
        Input:Username,password and IP of ILO"

        """
        try:
            FullProcNumberAndName = None
            output1 = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "show /system1 processor_number")
            ha_library.closeConnection()
            output2 = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.hw_ip, self.hw_username, self.hw_password,
                "show /system1/cpu1")
            ha_library.closeConnection()
            ProcNumber = self.find_value_by_keyword(output1,
                                                    "processor_number")
            CPUName = self.find_value_by_keyword(output2, "name")
            CPUForName = CPUName.replace("@", "(").rstrip()
            CoreNumber = self.find_value_by_keyword(output2, "number_cores")
            if not ProcNumber and CPUName and CoreNumber:
                output = False
                logger._warn("Failed to send the command")
                logger._debug("output = %s" % (output))
                logger._debug("result = %s" % (ProcNumber))
                logger._debug("result = %s" % (CoreNumber))
                raise ValueError
            else:
                if (ProcNumber > "1"):
                    FullProcNumberAndName = ProcNumber + " " + "processors," + \
                        "" + CPUForName + "/ " + CoreNumber + "-core)"
                else:
                    FullProcNumberAndName = ProcNumber + " " + "processor," + \
                        "" + CPUForName + "/ " + CoreNumber + "-core)"
            return FullProcNumberAndName
        except:
            raise Exception("Failed to get CPU Processor Number and Name")
Exemplo n.º 15
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")
Exemplo n.º 16
0
 def get_vc_product_name(self, interconnect_bay_number):
     """
         Description:This function will return the Product name of VC.It doesn't handle input "ALL" for interconnect_bay_number
         Params:interconnect_bay_number--> The bay number of interconnect
         Return: Returns the product name of VC if command is executed else Error will be shown
     """
     ProdName = None
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.hw_ip, self.hw_username, self.hw_password,
             "show interconnect info %s" % (interconnect_bay_number))
         ha_library.closeConnection()
         ProdName = self.find_value_by_oa_keyword(output, "Product Name")
         if not ProdName:
             logger._warn("Failed to send the command")
             logger._debug("output = %s" % (output))
             logger._debug("result = %s" % (ProdName))
             return (False, '')
         else:
             return (True, ProdName)
     except:
         logger._log_to_console_and_log_file("Failed to get VC Name")
         return (False, '')
Exemplo n.º 17
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")
Exemplo n.º 18
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")
Exemplo n.º 19
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, [])