Beispiel #1
0
 def get_slot(self, pci_addr):
     '''
     Returns the slot number with pci_address
     '''
     if self.power_vm:
         devspec = genio.read_file("/sys/bus/pci/devices/%s/devspec" %
                                   pci_addr)
         slot = genio.read_file("/proc/device-tree/%s/ibm,loc-code" %
                                devspec)
         slot = re.match(r'((\w+)[\.])+(\w+)-P(\d+)-C(\d+)|Slot(\d+)',
                         slot).group()
     else:
         slot = pci.get_pci_prop(pci_addr, "PhySlot")
     if not os.path.isdir('/sys/bus/pci/slots/%s' % slot):
         self.log.info("%s Slot not available" % slot)
         return ""
     if not os.path.exists('/sys/bus/pci/slots/%s/power' % slot):
         self.log.info("%s Slot does not support hotplug" % slot)
         return ""
     return slot
Beispiel #2
0
 def setUp(self):
     """
     Setup the device.
     """
     if 'ppc' not in platform.processor():
         self.cancel("Processor is not ppc64")
     if os.path.exists('/proc/device-tree/bmc'):
         self.cancel("Test Unsupported! on this platform")
     cmd = "cat /proc/cpuinfo"
     if cpu._list_matches(open('/proc/cpuinfo').readlines(),
                          'platform\t: pSeries\n'):
         PowerVM = True
         for mdl in ['rpaphp', 'rpadlpar_io']:
             if not linux_modules.module_is_loaded(mdl):
                 linux_modules.load_module(mdl)
     elif cpu._list_matches(open('/proc/cpuinfo').readlines(),
                            'platform\t: PowerNV\n'):
         PowerVM = False
         if not linux_modules.module_is_loaded("pnv_php"):
             linux_modules.load_module("pnv_php")
     self.return_code = 0
     self.device = self.params.get('pci_device', default=' ')
     self.num_of_hotplug = int(self.params.get('num_of_hotplug', default='1'))
     if not os.path.isdir('/sys/bus/pci/devices/%s' % self.device):
         self.cancel("PCI device given does not exist")
     if PowerVM:
         devspec = genio.read_file("/sys/bus/pci/devices/%s/devspec"
                                   % self.device)
         self.slot = genio.read_file("/proc/device-tree/%s/ibm,loc-code"
                                     % devspec)
         self.slot = re.match(r'((\w+)[\.])+(\w+)-P(\d+)-C(\d+)|Slot(\d+)',
                              self.slot).group()
     else:
         self.slot = pci.get_pci_prop(self.device, "PhySlot")
     if not os.path.isdir('/sys/bus/pci/slots/%s' % self.slot):
         self.cancel("%s Slot not available" % self.slot)
     if not os.path.exists('/sys/bus/pci/slots/%s/power' % self.slot):
         self.cancel("%s Slot does not support hotplug" % self.slot)
 def setUp(self):
     """
     Setup the device.
     """
     cmd = "uname -p"
     if 'ppc' not in process.system_output(cmd, ignore_status=True):
         self.cancel("Processor is not ppc64")
     cmd = "cat /proc/cpuinfo"
     if cpu._list_matches(open('/proc/cpuinfo').readlines(),
                          'platform\t: pSeries\n'):
         PowerVM = True
         for mdl in ['rpaphp', 'rpadlpar_io']:
             if not linux_modules.module_is_loaded(mdl):
                 linux_modules.load_module(mdl)
     elif cpu._list_matches(open('/proc/cpuinfo').readlines(),
                            'platform\t: PowerNV\n'):
         PowerVM = False
         if not linux_modules.module_is_loaded("pnv_php"):
             linux_modules.load_module("pnv_php")
     self.return_code = 0
     self.device = self.params.get('pci_device', default=' ')
     self.num_of_hotplug = int(self.params.get('num_of_hotplug',
                               default='1'))
     if not os.path.isdir('/sys/bus/pci/devices/%s' % self.device):
         self.cancel("PCI device given does not exist")
     if PowerVM:
         devspec = genio.read_file("/sys/bus/pci/devices/%s/devspec"
                                   % self.device)
         self.slot = genio.read_file("/proc/device-tree/%s/ibm,loc-code"
                                     % devspec)
         self.slot = re.match(r'((\w+)[\.])+(\w+)-P(\d+)-C(\d+)|Slot(\d+)',
                              self.slot).group()
     else:
         self.slot = pci.get_pci_prop(self.device, "PhySlot")
     if not os.path.isdir('/sys/bus/pci/slots/%s' % self.slot):
         self.cancel("%s Slot not available" % self.slot)
     if not os.path.exists('/sys/bus/pci/slots/%s/power' % self.slot):
         self.cancel("%s Slot does not support hotplug" % self.slot)