Antoni Segura Puimedon has uploaded a new change for review. Change subject: PEP8 completely fix caps and its tests. ......................................................................
PEP8 completely fix caps and its tests. This is not only nice but necessary because as of the previous commit, the build didn't work. Change-Id: I1108522ba9c4736a6a8a3f1ac828d3eb364206dd Signed-off-by: Antoni S. Puimedon <[email protected]> --- M tests/capsTests.py M vdsm/caps.py 2 files changed, 16 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/34/10034/1 diff --git a/tests/capsTests.py b/tests/capsTests.py index dec0ec7..f0d6b54 100644 --- a/tests/capsTests.py +++ b/tests/capsTests.py @@ -50,7 +50,7 @@ vpid""".split())) self.assertEqual(c.mhz(), '2533.402') self.assertEqual(c.model(), - 'Intel(R) Xeon(R) CPU E5649 @ 2.53GHz') + 'Intel(R) Xeon(R) CPU E5649 @ 2.53GHz') def testCpuTopology(self): testPath = os.path.realpath(__file__) @@ -67,14 +67,14 @@ path = os.path.join(dirName, "caps_libvirt.out") machines = caps._getEmulatedMachines(file(path).read()) expectedMachines = ['pc-1.2', 'none', 'pc', 'pc-1.1', 'pc-1.0', - 'pc-0.15', 'pc-0.14', 'pc-0.13', 'pc-0.12', 'pc-0.11', - 'pc-0.10', 'isapc'] + 'pc-0.15', 'pc-0.14', 'pc-0.13', 'pc-0.12', + 'pc-0.11', 'pc-0.10', 'isapc'] self.assertEqual(machines, expectedMachines) def test_parseKeyVal(self): lines = ["x=&2", "y& = 2", " z = 2 ", " s=3=&'5", " w=", "4&"] expectedRes = [{'x': '&2', 'y&': '2', 'z': '2', 's': "3=&'5", 'w': ''}, - {'x=': '2', 'y': '= 2', 's=3=': "'5", '4': ''}] + {'x=': '2', 'y': '= 2', 's=3=': "'5", '4': ''}] sign = ["=", "&"] for res, s in zip(expectedRes, sign): self.assertEqual(res, caps._parseKeyVal(lines, s)) diff --git a/vdsm/caps.py b/vdsm/caps.py index 0b16796..d1297c9 100644 --- a/vdsm/caps.py +++ b/vdsm/caps.py @@ -117,9 +117,9 @@ cells = host.getElementsByTagName('cells')[0] topology = {'cells': int(cells.getAttribute('num')), 'sockets': int(cpu.getElementsByTagName('topology')[0]. - getAttribute('sockets')), + getAttribute('sockets')), 'cores': int(cpu.getElementsByTagName('topology')[0]. - getAttribute('cores')), + getAttribute('cores')), 'threads': cells.getElementsByTagName('cpu').length} return topology @@ -134,6 +134,7 @@ return [m.firstChild.data for m in archTag.childNodes if m.nodeName == 'machine'] return [] + def _getAllCpuModels(): cpu_map = minidom.parseString( @@ -171,9 +172,8 @@ xml = '<cpu match="minimum"><model>%s</model>' \ '<vendor>%s</vendor></cpu>' % (model, vendor) try: - return c.compareCPU(xml, 0) in ( - libvirt.VIR_CPU_COMPARE_SUPERSET, - libvirt.VIR_CPU_COMPARE_IDENTICAL) + return c.compareCPU(xml, 0) in (libvirt.VIR_CPU_COMPARE_SUPERSET, + libvirt.VIR_CPU_COMPARE_IDENTICAL) except libvirt.libvirtError, e: # hack around libvirt BZ#795836 if e.get_error_code() == libvirt.VIR_ERR_OPERATION_INVALID: @@ -198,7 +198,7 @@ def _getIscsiIniName(): try: return _parseKeyVal( - file('/etc/iscsi/initiatorname.iscsi'))['InitiatorName'] + file('/etc/iscsi/initiatorname.iscsi'))['InitiatorName'] except: logging.error('reporting empty InitiatorName', exc_info=True) return '' @@ -248,8 +248,8 @@ caps = {} caps['kvmEnabled'] = \ - str(config.getboolean('vars', 'fake_kvm_support') or - os.path.exists('/dev/kvm')).lower() + str(config.getboolean('vars', 'fake_kvm_support') or + os.path.exists('/dev/kvm')).lower() cpuInfo = CpuInfo() cpuTopology = CpuTopology() @@ -289,9 +289,8 @@ caps['vmTypes'] = ['kvm'] caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024) - caps['reservedMem'] = str( - config.getint('vars', 'host_mem_reserve') + - config.getint('vars', 'extra_mem_reserve')) + caps['reservedMem'] = str(config.getint('vars', 'host_mem_reserve') + + config.getint('vars', 'extra_mem_reserve')) caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead') return caps @@ -301,7 +300,7 @@ remote = struct.unpack('I', socket.inet_aton(addr))[0] for line in itertools.islice(file(fileName), 1, None): iface, dest, gateway, flags, refcnt, use, metric, \ - mask, mtu, window, irtt = line.split() + mask, mtu, window, irtt = line.split() dest = int(dest, 16) mask = int(mask, 16) if remote & mask == dest & mask: @@ -313,7 +312,7 @@ def kernelDict(): try: ver, rel = file('/proc/sys/kernel/osrelease').read(). \ - strip().split('-', 1) + strip().split('-', 1) except: logging.error('kernel release not found', exc_info=True) ver, rel = '0', '0' -- To view, visit http://gerrit.ovirt.org/10034 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1108522ba9c4736a6a8a3f1ac828d3eb364206dd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Antoni Segura Puimedon <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
