Ejemplo n.º 1
0
    def _find_orphaned_veas(self, vios, virt_eths, veas_attached_to_seas, dom_factory=model.No_DB_DOM_Factory()):
        """
        Connect to the IVM endpoint and find any VEAs that are not associated
        with an SEA, and thus are "orphans."

        Results are not returned from this method, but are set into this
        objects member attributes.

        :param vios: The VioServer DOM object that represents this IVM
        :param virt_eths: Dictionary of physical adapter info from IVM
        :param veas_attached_to_seas: List of device names of VEAs that are
                                      attached to SEAs, and thus are not
                                      orphans
        :param dom_factory: Factory used to create the DOM objects, optional.
        :returns List: A list of VirtualEthernetAdapter DOM objects
        """
        # Loop back through the list of virtual devices.  We need to find
        # the VEAs that are not attached to any SEA.  They may have VLANs
        # attached to them that we do not wish to override
        orphan_veas = []
        for vea in virt_eths:
            if not (virt_eths[vea][0].strip().startswith("Virtual I/O Ethernet Adapter")):
                # this is not a VEA device.
                continue

            # Check to see if this VEA is part of the existing SEA list
            if vea in veas_attached_to_seas:
                continue

            # Get the slot number for this adapter
            vea_slot_num = utils.parse_slot_num(virt_eths, vea)

            # As an 'orphan' VEA (one not backed by a SEA), we need to get
            # the VLANs off of it and add it to a list of elements we do
            # not provision

            vea_dev = self._get_vea_for_slot(vios, vea, vea_slot_num, None, dom_factory)  # No SEA to check
            # The VEA in vea_slot_num may have been unavailable (ie, "Defined"
            # status), which returns None.  Don't include those.
            if vea_dev:
                orphan_veas.append(vea_dev)

        return orphan_veas
Ejemplo n.º 2
0
    def _get_sea_from_ivm(self, vios, sea_devname, virt_eths, dom_factory=model.No_DB_DOM_Factory()):
        """
        Connect to an IVM endpoint and retrieve all of the configuration for a
        SEA and the VEAs associated with it.

        :param vios: The VioServer DOM object that represents this IVM
        :param sea_devname: The device name for the SEA to query
        :param virt_eths: Dictionary of physical adapter info from IVM
        :param dom_factory: Factory used to create the DOM objects, optional.
        :returns SharedEthernetAdapter: An SEA DOM object
        """
        # Got the SEA logical device name on VIOS.
        # Need to find out its pvid_adapter and virt_adapters and pvid
        cmd = utils.get_sea_attribute_cmd(sea_devname)

        output = self._pvmops.run_vios_command(cmd)

        # Output example:
        # ['value', '', '100', 'ent4', 'ent4,ent13,ent14',
        #  'ent24            Available     Shared Ethernet Adapter']
        if len(output) == 0 or output[0] != "value":
            ras.trace(LOG, __name__, ras.TRACE_ERROR, ras.vif_get_msg("error", "VIOS_CMDFAIL") % {"cmd": cmd})
            return None

        # Get rid of 'value','' from the list
        output[0:2] = []

        # Find out pvid adapter and all the virt_adapters for
        # the give SEA and create SeaDevices object based
        # on the information retrieved from HMC/IVM.
        sea_pvid = int(output[0].strip())

        sea_pvid_adpt = output[1].strip()
        sea_virt_adpts = output[2].strip().split(",")
        sea_state = output[3].split()[1]

        # virt_adpts has at least pvid_adpt
        if sea_pvid_adpt not in sea_virt_adpts:
            msg = ras.vif_get_msg("error", "SEA_INVALIDSTATE")
            ras.function_tracepoint(LOG, __name__, ras.TRACE_ERROR, msg)
            return None

        # Get the full virt_adapters list without the pvid_adapter
        sea_virt_adpts.remove(sea_pvid_adpt)

        # Get the slot number for this adapter
        vea_slot_num = utils.parse_slot_num(virt_eths, sea_pvid_adpt)

        # Create the VEA and SEA dom objects
        vea_dev = self._get_vea_for_slot(vios, sea_pvid_adpt, vea_slot_num, sea_pvid, dom_factory)
        sea_dev = dom_factory.create_sea(
            name=sea_devname,
            vio_server=vios,
            slot=vea_slot_num,
            state=sea_state,
            primary_vea=vea_dev,
            control_channel=None,
            additional_veas=None,
        )

        ras.trace(LOG, __name__, ras.TRACE_DEBUG, ("SEA %(devname)s is discovered" % {"devname": sea_devname}))

        # Find all the virt_adapters if there are any in sea_virt_adpts
        # list
        for devname in sea_virt_adpts:

            # Get the slot number for this adapter
            vea_slot_num = utils.parse_slot_num(virt_eths, devname)

            vea_dev = self._get_vea_for_slot(vios, devname, vea_slot_num, sea_pvid, dom_factory)

            try:
                sea_dev.add_vea_to_sea(vea_dev)
            except excp.IBMPowerVMInvalidSEAConfig:
                msg = ras.vif_get_msg("error", "SEA_FAILTOADDVEA") % {"veaname": vea_dev.name, "seaname": sea_dev.name}
                ras.trace(LOG, __name__, ras.TRACE_EXCEPTION, msg)
                return None
        # End of for loop to discovery all the virtual adapters
        # for the SEA. It is the end of the inner for loop
        return sea_dev