Esempio n. 1
0
    def interogate_lpar(self, lpar_id):
        """
        Will perform validation of the LPAR to determine whether or not it
        can be imported.

        :param lpar_id: The LPAR ID
        :returns: A list of reasons why the LPAR may not be imported.
        """
        # Store for all the warnings
        warnings_list = []

        # List all the adapters
        adapters = self.list_ports(lpar_id)

        # For each adapter, do interrogation.
        for adapter in adapters:
            # Validate it IS a Virtual Ethernet Adapter.
            if not self._is_veth_adapter(adapter):
                msg = ras.msg('info', 'IMPORT_NON_VIRTUAL_PORT')
                warnings_list.append(msg)
                continue

            # Validate that it is not a Qbg adapter
            if self._is_qbg_veth(adapter):
                msg = ras.msg('info', 'IMPORT_QBG_PORT')
                warnings_list.append(msg)
                continue

            # Validate that it has only a single VLAN (no addl_vlans)
            if not self._has_only_pvid(adapter):
                msg = ras.msg('info', 'IMPORT_ADDL_VLANS')
                warnings_list.append(msg)
                continue

            # Validate the adapter is not on an orphaned VLAN
            if self._is_orphan_vlan(adapter):
                msg = ras.msg('info', 'IMPORT_ORPHAN_VLANS')
                warnings_list.append(msg)
                continue

        return warnings_list
Esempio n. 2
0
    def _delete_vea_on_vios(self, vios, vea_dev, sea_dev, virt_adpts_list):
        """
        This method will remove the given VEA from the given SEA on the
        system and delete it.

        :param vios: VioServer DOM object representing VIOS this is being
                     removed from.
        :param vea_dev: VirtualEthernetAdapter DOM object
        :param sea_dev: SharedEthernetAdapter DOM object
        :param virt_adpts_list: List of VEA devnames that should remain on the
                                SEA
        """
        # Run the first two commands in a loop in case the rmdev fails.
        # Running the first command repeatedly isn't a problem because
        # it's setting the SEA to what we want, and that doesn't change.
        # If this fails, it'll be on the rmdev.
        for x in range(RMDEV_ATTEMPTS):
            try:
                cmds = \
                    (utils.change_sea_virt_adapters_cmd(seaname=sea_dev.name,
                                                        pveaname=sea_dev.
                                                        get_primary_vea().name,
                                                        virt_list=
                                                        virt_adpts_list)
                        + ' && ' +
                        utils.remove_virtual_device(vea_dev.name)
                        + ' && ' +
                        utils.remove_virtual_slot_cmd(lpar_id=vea_dev.
                                                      vio_server.lpar_id,
                                                      slot_num=vea_dev.slot))
                self._pvmops.run_vios_command(cmds)

                # If we got here, all is well
                break
            except Exception as e:
                ras.trace(LOG, __name__, ras.TRACE_ERROR,
                          ras.msg('error', 'VETH_FAILTOREMOVE') %
                          {'slotnum': vea_dev.slot} + '(' + _('%s') % e + ')')

                # Sleep before we try again
                if x < (RMDEV_ATTEMPTS - 1):
                    time.sleep(1)
                else:
                    # This was our last attempt.  Re-raise the exception.
                    raise
Esempio n. 3
0
    def _create_vea_on_vios(self, vios, sea, slotnum, port_vlan_id,
                            addl_vlan_ids):
        """
        This method will create the 802.1Q VirtualEthernetAdapter on the
        VIOS and return the device name of the newly created adapter.  A
        IBMPowerVMFailToAddDataVlan should be raised if unable to create the
        new VEA.

        :param vios: VioServer DOM object representing VIOS this is being
                     created on.
        :param sea: SEA that owns the VEA.  Not needed on IVM as the VEA is
                    attached to the SEA in a separate step.
        :param slotnum: Virtual slot number to create the new VEA in.
        :param port_vlan_id: pvid to set on the new VEA
        :param addl_vlan_ids: Additional vlan ids to set on the new VEA
        :returns vea_devname: Device name of the newly created VEA
        :returns slot_number: Always returns None
        """
        ras.function_tracepoint(LOG, __name__, ras.TRACE_DEBUG, "Enter")

        try:
            cmd = utils.create_8021Q_vea_cmd(lpar_id=vios.lpar_id,
                                             slotnum=slotnum,
                                             port_vlan_id=port_vlan_id,
                                             addl_vlan_ids=addl_vlan_ids)
            self._pvmops.run_vios_command(cmd)

            # find out the new slot's devname. Even though DR slot add
            # operation will call cfgmgr on the VIOS, just invoke cfgdev
            # again on vio0 to make sure the device is discovered by VIOS.
            cmd = utils.get_newly_added_slot_name_cmd(lpar_id=vios.lpar_id,
                                                      mts=self._get_mts(),
                                                      slotnum=slotnum)

            vea_devname = self._pvmops.run_vios_command(cmd)[0]
            msg = (ras.vif_get_msg('info', 'VEA_DEV_NAME') %
                   {'vea_dev': vea_devname, 'cmd': cmd})
        except Exception as e:  # catch the hmc/vios command exception
            ras.trace(LOG, __name__, ras.TRACE_EXCEPTION,
                      ras.msg('error', 'VETH_NOTCFG') % {'slotnum': slotnum} +
                      "(" + (_('%s') % e) + ")")
            raise

        if not vea_devname:
            # failed to find the newly created veth slot on VIOS. clean it up.
            ras.trace(LOG, __name__, ras.TRACE_ERROR,
                      ras.msg('error', 'VETH_NOTCFG') % {'slotnum': slotnum})
            try:
                cmds = utils.remove_virtual_slot_cmd(lpar_id=vios.lpar_id,
                                                     slot_num=slotnum)
                self._pvmops.run_vios_command(cmds)

                ras.trace(LOG, __name__, ras.TRACE_DEBUG,
                          'Clean up: slot %(slotnum)d has been removed' %
                          {'slotnum': slotnum})

            except Exception:
                ras.trace(LOG, __name__, ras.TRACE_EXCEPTION,
                          ras.msg('error', 'VETH_FAILTOREMOVE') %
                          {'slotnum': slotnum} + "(" + _('%s') % e + ")")

            raise excp.IBMPowerVMFailToAddDataVlan(data_vlan_id=addl_vlan_ids)

        # If we got here, we succeeded!
        return vea_devname, None