def _get_mts(self): """ Connect to IVM and get the machine type/model/serial based on adapter information. :returns mts: String in the form of type.model.serial """ if(not hasattr(self, 'powervm_mts') or len(self.powervm_mts.strip()) == 0): cmd = utils.get_all_sea_with_physloc_cmd() output = self._pvmops.run_vios_command(cmd) virt_eths = utils.parse_physloc_adapter_output(output) self.powervm_mts = utils.get_mts(virt_eths) return self.powervm_mts
def _populate_adapters_into_vios(self, vios, dom_factory=model.No_DB_DOM_Factory()): """ Overridden method from powervc_nova.virt.ibmpowervm.vif.topo.IBMPowerVMNetworkTopo This method returns all the adapters, both SEA and VEA, for the VIOS this IVM runs on. Each VEA will be attached to it's owning SEA, if it has one. :param vios: VioServer to fetch adapters from :param dom_factory: Factory used to create the DOM objects, optional. :returns boolean: True if at least one adapter was found, False otherwise. """ ras.function_tracepoint(LOG, __name__, ras.TRACE_DEBUG, "Enter") try: # If the VIOS RMC state is down, we can't use adapters on it. if vios.rmc_state.lower() != "active": ras.trace(LOG, __name__, ras.TRACE_INFO, _("RMC state is not active on VIOS lpar %s") % vios.lpar_name) return False # Find all of the adapters on the VIOS cmd = utils.get_all_sea_with_physloc_cmd() output = self._pvmops.run_vios_command(cmd) virt_eths = utils.parse_physloc_adapter_output(output) # Find all of the SEAs on this IVM seas_found = {} for vea in virt_eths: if virt_eths[vea][0].strip() != "Shared Ethernet Adapter": # this is not a SEA device. continue seas_found[vea] = virt_eths[vea] # Go through the SEAs and get their current configuration from IVM veas_attached_to_seas = [] for sea_devname in seas_found: # Connect to the IVM endpoint and collect the SEA info sea_dev = self._get_sea_from_ivm(vios, sea_devname, virt_eths, dom_factory) # Keep track of which VEAs are owned by an SEA so we can later # detect orphan VEAs veas_attached_to_seas.append(sea_dev.primary_vea.name) for vea in sea_dev.additional_veas: veas_attached_to_seas.append(vea.name) # Any VEA not on an SEA is considered an orphan self._find_orphaned_veas(vios, virt_eths, veas_attached_to_seas, dom_factory) # Return True if adapters were found if len(seas_found.values()) > 0: ras.trace(LOG, __name__, ras.TRACE_DEBUG, "SEA discover finished successfully.") return True ras.trace(LOG, __name__, ras.TRACE_ERROR, ras.vif_get_msg("error", "VIOS_NOSEA")) raise excp.IBMPowerVMValidSEANotFound() except pvmexcp.IBMPowerVMCommandFailed: ras.trace(LOG, __name__, ras.TRACE_EXCEPTION, ras.vif_get_msg("error", "VIOS_CMDFAIL") % {"cmd": cmd}) return False except Exception as e: ras.trace( LOG, __name__, ras.TRACE_EXCEPTION, ras.vif_get_msg("error", "VIOS_UNKNOWN") + " (" + _("%s") % e + ")" ) return False