Esempio n. 1
0
 def set_ebipa_server_and_inter_gateway(self, gateway):
     """
         Description : This function sets EBIPA server and interconnect gateway ip address
         Params      :
                       gateway    --> gateway for OA
         Usage       : set_ebipa_ser_inter_gateway("172.24.110.2", "Admin", "Insight7", "172.24.110.1")
         Return      : return output if there is no exception else return false
     """
     try:
         output1 = False
         output2 = False
         output3 = False
         output4 = False
         output1 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set ebipa server gateway %s 1-16" % (gateway),
             "Successfully set the gateway")
         output2 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password, "SAVE EBIPA",
             "EBIPA configuration was saved.")
         output3 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set ebipa interconnect gateway %s 1-4" % (gateway),
             "Successfully set the gateway")
         output4 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password, "SAVE EBIPA",
             "EBIPA configuration was saved.")
         if output1 and output2 and output3 and output4:
             log._info("EBIPA interconnect and server gateway is set")
         else:
             log._error("EBIPA interconnect and server gateway is not set")
     except:
         raise Exception("Failed to set EBIPA Server Gateway")
Esempio n. 2
0
 def set_ebipa_servers(self, start_server_address, subnetmask):
     """
         Description : This function sets the IP address for all 16 bays
         Params      :
                         start_server_address --> starting Address of Bays
                         subnetmask -->  The subnet mask
         Usage       : set_ebipa_address("172.24.110.45", "255.255.255.0")
         Return      : return message if there is no exception else return false
     """
     try:
         output1 = False
         output2 = False
         output1 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set ebipa server %s %s 1-16" %
             (start_server_address, subnetmask),
             "Successfully set device (iLO) bay # 1 to IP address")
         output2 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password, "SAVE EBIPA",
             "EBIPA configuration was saved.")
         if output1 and output2:
             log._info("EBIPA Address set for all the bays")
         else:
             log._error("EBIPA Address not set for all the bays")
     except:
         raise Exception("Failed to set EBIPA Address")
    def record_ilo_firmware_details_and_return_bay_no(self, command):
        try:
            output = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.oa_ip, self.oa_username, self.oa_password, command)
            ot1 = output.split("Device Bay:")
            temp_ilo_version_gen8 = []
            temp_ilo_version_gen7 = []
            bay_no_gen8 = []
            bay_no_gen7 = []
            temp = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.oa_ip, self.oa_username, self.oa_password,
                "show server names")
            no_of_servers = int(temp.split(':')[1].split(' ')[1]) + 1

            for j in range(1, no_of_servers):
                ilo_type = ot1[j].split("Discovered:")[1].split('\n')[5].split(
                    ' ')[0].strip().split('O')[1]
                if ilo_type == '4':
                    temp_ilo_version_gen8.append(
                        ot1[j].split("Discovered:")[1].split('\n')[5].split(
                            '4')[1].strip().split(' ')[0])
                    bay_no_gen8.append(ot1[j].split("Discovered:")[0].strip())
                elif ilo_type == '3':
                    temp_ilo_version_gen7.append(
                        ot1[j].split("Discovered:")[1].split('\n')[5].split(
                            '3')[1].strip().split(' ')[0])
                    bay_no_gen7.append(ot1[j].split("Discovered:")[0].strip())
            self.dict_info_gen8 = dict(zip(bay_no_gen8, temp_ilo_version_gen8))
            self.dict_info_gen7 = dict(zip(bay_no_gen7, temp_ilo_version_gen7))
        except:
            log._error("Unable to get ILO firmware details")
Esempio n. 4
0
 def reset_ilo(self, ilo_bay_number, force="false"):
     """
         Description   :    This function will reset ilo present in a bay. It will reset based on the force parameter
         Params        :
                         ilo_bay_number--> Bay number of server which should be resetted
                         force    --> a boolean parameter based on which ilo will be reset. By default this parameter will be false.
         Return        :    Returns a message if command is executed else returns false
     """
     try:
         output1 = False
         output2 = False
         if force == "false":
             output1 = ha_library.runOAcommands(
                 self.oa_ip, self.oa_username, self.oa_password,
                 "reset iLO %s" % (ilo_bay_number),
                 "Successfully reset iLO through IPMI")
         else:
             output2 = ha_library.runOAcommands(
                 self.oa_ip, self.oa_username, self.oa_password,
                 "reset iLO %s force" % (ilo_bay_number),
                 "Successfully reset iLO through IPMI")
             log._debug(output2)
         if output1 or output2:
             log._info("ILO is successfully reset")
         else:
             log._error("ILO is not successfully reset")
     except:
         raise Exception("Failed to reset iLO")
Esempio n. 5
0
 def set_ebipa_for_interconnect(self, start_server_address, subnetmask):
     """
         Description : This function sets an IP address for the four interconnect bays
         Params      :
                         start_server_address --> starting address of interconnect bays
                         subnetmask   --> subnet mask
         Usage       : set_ebipa_interconnect()
         Return      : return a message if there is no excpetion else return false
     """
     try:
         output1 = False
         output2 = False
         output1 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set ebipa interconnect %s %s 1-4" %
             (start_server_address, subnetmask),
             "Successfully set interconnect bay # 1 to IP address")
         output2 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password, "SAVE EBIPA",
             "EBIPA configuration was saved.")
         if output1 and output2:
             log._info(
                 "EBIPA Interconnect Address set for all the interconnects")
         else:
             log._error(
                 "EBIPA Interconnect Address not set for all the interconnects"
             )
     except:
         raise Exception("Failed to set EBIPA Interconnect Address")
Esempio n. 6
0
 def add_user(self, username, password, nickname=None, group=None):
     """
         Description: This function adds a user to the specified iLO console
         Params:
               username     -->  username of new user to add
               password     -->  password of new uer
               nickname     -->  nickname of new user
               group        -->  group of new user (see XML environment file)
         Usage       : addUser(username, password, group)
         Return      : return output from ssh interaction
     """
     if nickname and group:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.mgt_ip, self.mgt_username, self.mgt_pw,
             "create /map1/accounts1 username=%s password=%s name=%s group=%s"
             % (username, password, nickname, group))
     elif nickname and not group:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.mgt_ip, self.mgt_username, self.mgt_pw,
             "create /map1/accounts1 username=%s password=%s name=%s" %
             (username, password, nickname))
     elif group and not nickname:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.mgt_ip, self.mgt_username, self.mgt_pw,
             "create /map1/accounts1 username=%s password=%s group=%s" %
             (username, password, group))
     elif not group and not nickname:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.mgt_ip, self.mgt_username, self.mgt_pw,
             "create /map1/accounts1 username=%s password=%s" %
             (username, password))
     else:
         log._error("iLO.py internal error in logic!!")
     clean_msg = _get_command_status(output)
     return output  # clean_msg
 def check_if_any_gen8_needs_firmware_update_and_return_bay_no(self):
     try:
         bay_needing_firmware_update_gen8 = []
         for bay_gen8 in self.dict_info_gen8.iterkeys():
             if self.dict_info_gen8[bay_gen8] < '1.30':
                 bay_needing_firmware_update_gen8.append(bay_gen8)
             else:
                 pass
         return bay_needing_firmware_update_gen8
     except:
         log._error("Unable to check Gen8 blades for firmware upgrade")
 def check_if_any_gen7_needs_firmware_update_and_return_bay_no(self):
     try:
         bay_needing_firmware_update_gen7 = []
         for bay_gen7 in self.dict_info_gen7.iterkeys():
             if self.dict_info_gen7[bay_gen7] < '1.61':
                 bay_needing_firmware_update_gen7.append(bay_gen7)
             else:
                 pass
         return bay_needing_firmware_update_gen7
     except:
         log._error("Unable to check G7 blades for firmware upgrade")
 def update_oa_firmware(self):
     """
         Description : This function is to initiate OA firmware update
         Usage       : update_oa_firmware()
         Return      : output message from console interaction
     """
     try:
         ha_library.execute_Remote_commands_iLO_and_return_output(
             self.oa_ip, self.oa_username, self.oa_password,
             "Update Image force FW_ISO")
     except:
         log._error("Unable to run OA firmware update")
Esempio n. 10
0
 def __init__(self, config_xml):
     """
     config_xml should be full path to XML'
     """
     # state = MyWorkflow()  #google Pylint False Positive E1101
     self.xml = config_xml
     try:
         self.my_parser = config_parser.ConfigParser(self.xml)
     except:
         log._error(
             "Unable to use given path to input XML, please check the path for errors"
         )
         exit(0)
 def update_server_firmware(self, bay_no):
     """
         Description : This function is to initiate firmware update on individual servers
         params      : bay_no --> server bay number.
         Usage       : update_server_firmware('2')
         Return      : output message from console interaction
     """
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.oa_ip, self.oa_username, self.oa_password,
             "update firmware server %s" % bay_no)
         return output
     except:
         log._error("Unable to apply Server power policy")
 def disable_firmware_management(self):
     """
         Description : This function enables/disbale firmware management on OA based on "state" parameter
         Params      : state --> word enable/disable
         Usage       : enable_disable_firmware_management("enable/disable")
         Return      : output message from console interaction
     """
     try:
         output = ha_library.execute_Remote_commands_iLO_and_return_output(
             self.oa_ip, self.oa_username, self.oa_password,
             "disable firmware management")
         return output
     except:
         log._error("Unable to enable firmware management for enclosure")
 def enable_force_downgrade(self):
     """
         Description : This function is to enable force downgrade the firmware to lower versions on devices within the enclosure
         Usage       : enable_force_downgrade()
         Return      : output message from console interaction
     """
     try:
         output = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set firmware management force downgrade enable",
             "Operation was successful.")
         if output:
             log._info("Force downgrade is enabled")
         else:
             log._warn("Failed to enable force downgrade")
     except:
         log._error("Unable to enable force downgrade")
 def select_bays_for_firmware_deployment(self):
     """
         Description : This function is to select the device for firmware upgrade
         Usage       : select_bays_for_firmware_deployment()
         Return      : output message from console interaction
     """
     try:
         output = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set firmware management BAYS_TO_INCLUDE Server 1-16",
             "Enclosure Firmware Management settings applied successfully.")
         if output:
             log._info("Server bay selection done")
         else:
             log._warn("server bay not selected")
     except:
         log._error("Unable to select Server Bay")
 def set_power_policy(self):
     """
         Description : This function is to set power policy while firmware update initiated
         Usage       : set_power_policy()
         Return      : output message from console interaction
     """
     try:
         output = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "SET FIRMWARE MANAGEMENT POWER force",
             "Power policy successfully changed to FORCE.")
         if output:
             log._info("Server power policy applied successfully")
         else:
             log._warn("Server power policy not applied")
     except:
         log._error("Unable to apply Server power policy")
Esempio n. 16
0
 def restart_interconnect(self):
     """
         Description : This function restarts interconnects e.i., VC module
         Params      : none
         Usage       : restart_interconnect()
         Return      : return output if there is no exception else return false
     """
     try:
         output = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "restart interconnect 1", "Resetting Interconnect tray in bay")
         if output:
             log._info("VC module has been restarted successfully")
         else:
             log._error("Failed to restart VC module")
     except:
         raise Exception("Failed to clear VC mode")
 def set_spp_url_for_firmware_management(self, url):
     """
         Description : This function sets SPP url to OA
         Params      : url --> http url where SPP iso is been served
         Usage       : set_spp_url_for_firmware_management("http://172.24.36.85/SPP2013020.2013_0204.107.iso")
         Return      : output message from console interaction
     """
     try:
         output = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set firmware management url " + url,
             "Enclosure Firmware Management URL set to")
         if output:
             log._info("Successfully set the SPP ISO URL")
         else:
             log._warn("Error setting SPP ISO URL")
     except:
         log._error("Unable to set Firmware management URL")
 def set_firmware_management_policy(self):
     """
         Description : This function is to set firmware update policy when a blade is insrted into enclosure
         Usage       : set_firmware_management_policy()
         Return      : output message from console interaction
     """
     try:
         output = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "set firmware  management policy manual",
             "Enclosure Firmware Management policy set to manual update and discovery."
         )
         if output:
             log._info("Firmware management policy set to manual")
         else:
             log._warn("Firmware management policy falied")
     except:
         log._error("Unable to set firmware deployment policy")
Esempio n. 19
0
    def set_port_fillword(self, port_number, fillword):
        """
        Configures the fill word for a single 8G FC port.

        fillword can be:
               0 | -idle-idle
                    Sets  IDLE  mode in the Link Init and IDLE as
                    the fill word (default).

               1 | -arbff-arbff
                    Sets ARB(ff) in the Link Init and ARB(ff)  as
                    the fill word.

               2 | -idlef-arbff
                    Sets  IDLE  mode in the Link Init and ARB(ff)
                    as the fill word.

               3 | -aa-then-ia
                    Attempts hardware arbff-arbff (mode 1) first.
                    If the attempt fails to go into active state,
                    this command executes software idle-arb (mode
                    2). Mode 3 is the preferable to modes 1 and 2
                    as it captures more cases.
        """
        acceptable_fillwords = [
            '0', '1', '2', '3', '-idle-idle', '-arbff-arbff', '-idlef-arbff',
            '-aa-then-ia'
        ]
        if fillword not in acceptable_fillwords:
            log._warn(
                "Invalid fillwords sent to san_hpsn600.<SwitchSN6000 object>.set_port_fillword()"
            )
            return False
        else:
            output = run('portcfgfillword %s, %s' % (port_number, fillword))
            if 'Invalid input' in output:
                log._error(
                    "Shouldn't have landed here, the SAN switch detected invalid input when running set_port_fillword()"
                )
                return False
            else:
                return True
Esempio n. 20
0
    def change_oa_ip_address(self, chngoa_ip, subnetmask, gateway):
        """
            Description : This function changes the OA IP Address
            Params      :
                            chngoa_ip   -->  The New IP Address of OA
                            subnetmask -->  The subnet mask
                            gateway  -->the gateway IP
            Usage       : change_oa_ip("172.24.111.2", "255.255.255.0", "172.24.111.1")
            Return      : output message from console interaction
        """
        try:
            output = ha_library.execute_Remote_commands_iLO_and_return_output(
                self.oa_ip, self.oa_username, self.oa_password,
                "set ipconfig static 1 %s %s %s" %
                (chngoa_ip, subnetmask, gateway))
            if output:
                log._info("OA IP is changed successfully")
            else:
                log._error("OA IP is not changed")

        except:
            raise Exception("Failed to change ip address")
Esempio n. 21
0
 def enable_ebipa_for_server(self):
     """
         Description : This function enables EBIPA checkbox in OA
         Params      :
         Usage       : enable_ebipa_for_server()
         Return      : return message if there is no exception else return false
     """
     try:
         output1 = False
         output2 = False
         output1 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password,
             "enable ebipa server 1-16",
             "EBIPA is enabled for device (iLO) bay #")
         output2 = ha_library.runOAcommands(
             self.oa_ip, self.oa_username, self.oa_password, "SAVE EBIPA",
             "EBIPA configuration was saved.")
         if output1 and output2:
             log._info("EBIPA is set")
         else:
             log._error("EBIPA is not set")
     except:
         raise Exception("Failed to set EBIPA Address")
Esempio n. 22
0
    def ping_vc_ip(self, vc_ip):
        """
            Description : This function checks if VC module is reachable when it is assigned with new IP
            Params      : vc_ip       -->  VC IP

            Usage       : ping_vc_ip()
            Return      : return output if there is no exception else return false
        """
        time.sleep(180)
        try:
            response = 1
            while response == 1:
                response = os.system("ping -n 1 " + vc_ip)
                time.sleep(10)
            log._info("VC module is back online with new IP %s " % vc_ip)

            if response == 0:
                log._info("VC is online")
            else:
                log._error("VC is not online")

        except:
            raise Exception("Unable to ping")
def validate_object_attributes(object):
    """
    Checks if the passed object has certain parameters defined, else it is
    ignored and the Parser will not store it in its list

    Returns True if object attributes are valid, else False.

    """
    # first check to see if ip address is valid for listed objects using check_ipv4
    # and check_ipv6 [currently not implemented]
    if any([
            isinstance(object, hw_objects.SanSwitchObject),
            isinstance(object, hw_objects.NetworkSwitchObject),
            isinstance(object, hw_objects.StorageObject),
            isinstance(object, hw_objects.HydrogenObject),
            isinstance(object, hw_objects.AltairObject),
            isinstance(object, hw_objects.OaObject),
            isinstance(object, hw_objects.VcObject),
            isinstance(object, hw_objects.VSphereObject),
            isinstance(object, hw_objects.VSphereObject),
    ]):
        if not check_ipv4(object.ip_address):
            # POSSIBLY USE IPV6 [NOT IMPLEMENTED]
            # if any([isinstance(object, hw_objects.SanSwitchObject),
            # isinstance(object, hw_objects.NetworkSwitchObject),
            # isinstance(object, hw_objects.StorageObject)]):
            # log._debug("%s ipv4 invalid, attempting to use ipv6..."%object)
            # if not check_ipv6(object.attrib['IPv6Address']:
            # return False
            # else:
            log._warn("Invalid ipv4 address for %s: %s" %
                      (object.tag, object.ip_address))
            return False
        else:  # if IP is valid, check if pingable
            if not device_discovery.ping_ip(object.ip_address):
                log._warn("IP not reachable in %s" % object.tag)
                return False
        if isinstance(object, hw_objects.VSphereObject):
            if not all([object.password, object.username]):
                log._warn("Username or password not defined for %s" %
                          object.tag)
                return False
        if any([
                isinstance(object, hw_objects.SanSwitchObject),
                isinstance(object, hw_objects.NetworkSwitchObject),
                isinstance(object, hw_objects.StorageObject),
        ]):
            # check to see if name, username exist for storage, switch
            if not all([object.name, object.username, object.model]):
                log._warn("Name, username, or model not defined for %s" %
                          object.tag)
                return False
        # elif isinstance(object, hw_objects.HydrogenObject):
        # if not all([object.xmgr, object.hc_dict, object.h3c_switch]):
        # log._warn("Incomplete Hydrogen details, check XML")
        # elif isinstance(object, hw_objects.AltairObject):
        # if not all([object.virtualhost_dict, object.mediaserver_dict]):
        # log._warn("Incomplete Altair details, check XML")
        return True

    # ________________SPECIAL CASES_____________________
    # rack objects
    elif isinstance(object, hw_objects.RackObject):
        if not all([object.name, object.servers]):
            log._warn("Incomplete Rack definition: missing name or servers")
            return False
        else:
            return True

    # server objects
    elif isinstance(object, hw_objects.ServerObject):
        if not all([object.ilo_ip, object.ilo_un]):
            log._warn("Incomplete iLO definition: missing IP or username")
            return False
        else:
            return True

    # Firmware objects
    elif isinstance(object, hw_objects.FirmwareObject):
        if not all([
                object.oa_ip, object.oa_user, object.vc_user,
                object.vc_firmware_location
        ]):
            log._warn(
                "Incomplete Firmware definition: missing required parameters")
            return False
        if not check_ipv4(object.oa_ip):
            log._warn(
                "Invalid IP, please check XML for Firmware details for correctness"
            )
            return False
        if not device_discovery.ping_ip(object.oa_ip):
            log._warn("IP not reachable in %s" % object.tag)
            return False
        else:
            return True

    # elif isinstance(object, hw_objects.NetworkSwitchObject):
    # if not check_ipv4(object.ip_address):
    # POSSIBLY USE IPV6 [NOT IMPLEMENTED]
    # if any([isinstance(object, hw_objects.SanSwitchObject),
    # isinstance(object, hw_objects.NetworkSwitchObject),
    # isinstance(object, hw_objects.StorageObject)]):
    # log._debug("%s ipv4 invalid, attempting to use ipv6..."%object)
    # if not check_ipv6(object.attrib['IPv6Address']:
    # return False
    # else:
    # log._warn("Invalid ipv4 address for %s: %s" % (object.tag, object.ip_address))
    # return False

    # else: #if IP is valid, check if pingable
    # if not device_discovery.ping_ip(object.ip_address):
    # log._warn("IP not reachable in %s" % object.tag)
    # return False
    else:
        log._error(
            "FATAL INTERNAL ERROR: OBJECT NOT RECOGNIZED, PLEASE REPORT")
        log._debug("Unrecognized object: %s" % object)
        return False