Drop L from literal integer numbers for Python 3

On Python 3, 123L is a syntax error. Replace 123L with 123 to get code working
on Python 2 and Python 3.

This patch was generated by the following tool (revision 9f3076ad5e09) using
the "long" operation:
https://bitbucket.org/haypo/misc/src/tip/python/sixer.py

Manual change:

* In nova/tests/unit/objects/test_fields.py, we explicitly want to check that
  long integers are supported as well. Keep the test on long, but replace
  1L with long(1) to avoid the syntax error on Python 3.

Blueprint nova-python3
Change-Id: I6a1234673a82909780dc7a82d5998705342dbfc6
This commit is contained in:
Victor Stinner 2015-05-04 17:55:59 +02:00
parent 621c09595d
commit 9bc21deea7
11 changed files with 330 additions and 327 deletions

View File

@ -25,11 +25,11 @@ class ComputeDriverCPUMonitorTestCase(test.NoDBTestCase):
class FakeDriver(object):
def get_host_cpu_stats(self):
return {'kernel': 5664160000000L,
'idle': 1592705190000000L,
return {'kernel': 5664160000000,
'idle': 1592705190000000,
'frequency': 800,
'user': 26728850000000L,
'iowait': 6121490000000L}
'user': 26728850000000,
'iowait': 6121490000000}
class FakeComputeManager(object):
driver = FakeDriver()
@ -59,10 +59,10 @@ class ComputeDriverCPUMonitorTestCase(test.NoDBTestCase):
metrics[metric['name']] = metric['value']
self.assertEqual(metrics["cpu.frequency"], 800)
self.assertEqual(metrics["cpu.user.time"], 26728850000000L)
self.assertEqual(metrics["cpu.kernel.time"], 5664160000000L)
self.assertEqual(metrics["cpu.idle.time"], 1592705190000000L)
self.assertEqual(metrics["cpu.iowait.time"], 6121490000000L)
self.assertEqual(metrics["cpu.user.time"], 26728850000000)
self.assertEqual(metrics["cpu.kernel.time"], 5664160000000)
self.assertEqual(metrics["cpu.idle.time"], 1592705190000000)
self.assertEqual(metrics["cpu.iowait.time"], 6121490000000)
self.assertTrue(metrics["cpu.user.percent"] <= 1
and metrics["cpu.user.percent"] >= 0)
self.assertTrue(metrics["cpu.kernel.percent"] <= 1

View File

@ -765,7 +765,7 @@ class ComputeVolumeTestCase(BaseTestCase):
db.block_device_mapping_get_by_volume_id(self.context, 1, []).\
AndReturn(bdm)
self.compute.driver.block_stats(instance, 'vdb').\
AndReturn([1L, 30L, 1L, 20L, None])
AndReturn([1, 30, 1, 20, None])
self.compute._get_host_volume_bdms(self.context,
use_slave=True).AndReturn(
host_volume_bdms)

View File

@ -17,6 +17,7 @@ import datetime
import iso8601
import netaddr
from oslo_utils import timeutils
import six
from nova.network import model as network_model
from nova.objects import base as obj_base
@ -74,8 +75,9 @@ class TestString(TestField):
def setUp(self):
super(TestString, self).setUp()
self.field = fields.StringField()
self.coerce_good_values = [('foo', 'foo'), (1, '1'), (1L, '1'),
(True, 'True')]
self.coerce_good_values = [('foo', 'foo'), (1, '1'), (True, 'True')]
if six.PY2:
self.coerce_good_values.append((long(1), '1'))
self.coerce_bad_values = [None]
self.to_primitive_values = self.coerce_good_values[0:1]
self.from_primitive_values = self.coerce_good_values[0:1]
@ -88,9 +90,10 @@ class TestEnum(TestField):
def setUp(self):
super(TestEnum, self).setUp()
self.field = fields.EnumField(
valid_values=['foo', 'bar', 1, 1L, True])
self.coerce_good_values = [('foo', 'foo'), (1, '1'), (1L, '1'),
(True, 'True')]
valid_values=['foo', 'bar', 1, 1, True])
self.coerce_good_values = [('foo', 'foo'), (1, '1'), (True, 'True')]
if six.PY2:
self.coerce_good_values.append((long(1), '1'))
self.coerce_bad_values = ['boo', 2, False]
self.to_primitive_values = self.coerce_good_values[0:1]
self.from_primitive_values = self.coerce_good_values[0:1]

View File

@ -32,10 +32,10 @@ class FakeCPUSpec(object):
class HostUtilsTestCase(test.NoDBTestCase):
"""Unit tests for the Hyper-V hostutils class."""
_FAKE_MEMORY_TOTAL = 1024L
_FAKE_MEMORY_FREE = 512L
_FAKE_DISK_SIZE = 1024L
_FAKE_DISK_FREE = 512L
_FAKE_MEMORY_TOTAL = 1024
_FAKE_MEMORY_FREE = 512
_FAKE_DISK_SIZE = 1024
_FAKE_DISK_FREE = 512
_FAKE_VERSION_GOOD = '6.2.0'
_FAKE_VERSION_BAD = '6.1.9'

View File

@ -29,7 +29,7 @@ class VHDUtilsBaseTestCase(test.NoDBTestCase):
_FAKE_FORMAT = 3
_FAKE_TYPE = 3
_FAKE_MAX_INTERNAL_SIZE = units.Gi
_FAKE_DYNAMIC_BLK_SIZE = 2097152L
_FAKE_DYNAMIC_BLK_SIZE = 2097152
_FAKE_BAD_TYPE = 5
_FAKE_JOB_PATH = 'fake_job_path'

View File

@ -23,11 +23,11 @@ from nova.virt.hyperv import vmutils
class VHDUtilsV2TestCase(test_vhdutils.VHDUtilsBaseTestCase):
"""Unit tests for the Hyper-V VHDUtilsV2 class."""
_FAKE_BLOCK_SIZE = 33554432L
_FAKE_BLOCK_SIZE = 33554432
_FAKE_LOG_SIZE = 1048576
_FAKE_LOGICAL_SECTOR_SIZE = 4096
_FAKE_METADATA_SIZE = 1048576
_FAKE_PHYSICAL_SECTOR_SIZE = 4096L
_FAKE_PHYSICAL_SECTOR_SIZE = 4096
def setUp(self):
super(VHDUtilsV2TestCase, self).setUp()

View File

@ -567,7 +567,7 @@ class Domain(object):
long(self._def['memory']),
long(self._def['memory']),
self._def['vcpu'],
123456789L]
123456789]
def migrateToURI(self, desturi, flags, dname, bandwidth):
raise make_libvirtError(
@ -713,7 +713,7 @@ class Domain(object):
def vcpus(self):
vcpus = ([], [])
for i in range(0, self._def['vcpu']):
vcpus[0].append((i, 1, 120405L, i))
vcpus[0].append((i, 1, 120405, i))
vcpus[1].append((True, True, True, True))
return vcpus
@ -1171,10 +1171,10 @@ class Connection(object):
def getCPUStats(self, cpuNum, flag):
if cpuNum < 2:
return {'kernel': 5664160000000L,
'idle': 1592705190000000L,
'user': 26728850000000L,
'iowait': 6121490000000L}
return {'kernel': 5664160000000,
'idle': 1592705190000000,
'user': 26728850000000,
'iowait': 6121490000000}
else:
raise make_libvirtError(
libvirtError,

View File

@ -9051,16 +9051,16 @@ class LibvirtConnTestCase(test.NoDBTestCase):
raise fakelibvirt.libvirtError('vcpus missing')
def blockStats(self, path):
return (169L, 688640L, 0L, 0L, -1L)
return (169, 688640, 0, 0, -1)
def interfaceStats(self, path):
return (4408L, 82L, 0L, 0L, 0L, 0L, 0L, 0L)
return (4408, 82, 0, 0, 0, 0, 0, 0)
def memoryStats(self):
return {'actual': 220160L, 'rss': 200164L}
return {'actual': 220160, 'rss': 200164}
def maxMemory(self):
return 280160L
return 280160
def fake_get_domain(self, instance):
return DiagFakeDomain()
@ -9070,27 +9070,27 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = objects.Instance(**self.test_instance)
actual = drvr.get_diagnostics(instance)
expect = {'vda_read': 688640L,
'vda_read_req': 169L,
'vda_write': 0L,
'vda_write_req': 0L,
'vda_errors': -1L,
'vdb_read': 688640L,
'vdb_read_req': 169L,
'vdb_write': 0L,
'vdb_write_req': 0L,
'vdb_errors': -1L,
'memory': 280160L,
'memory-actual': 220160L,
'memory-rss': 200164L,
'vnet0_rx': 4408L,
'vnet0_rx_drop': 0L,
'vnet0_rx_errors': 0L,
'vnet0_rx_packets': 82L,
'vnet0_tx': 0L,
'vnet0_tx_drop': 0L,
'vnet0_tx_errors': 0L,
'vnet0_tx_packets': 0L,
expect = {'vda_read': 688640,
'vda_read_req': 169,
'vda_write': 0,
'vda_write_req': 0,
'vda_errors': -1,
'vdb_read': 688640,
'vdb_read_req': 169,
'vdb_write': 0,
'vdb_write_req': 0,
'vdb_errors': -1,
'memory': 280160,
'memory-actual': 220160,
'memory-rss': 200164,
'vnet0_rx': 4408,
'vnet0_rx_drop': 0,
'vnet0_rx_errors': 0,
'vnet0_rx_packets': 82,
'vnet0_tx': 0,
'vnet0_tx_drop': 0,
'vnet0_tx_errors': 0,
'vnet0_tx_packets': 0,
}
self.assertEqual(actual, expect)
@ -9104,28 +9104,28 @@ class LibvirtConnTestCase(test.NoDBTestCase):
'cpu_details': [],
'disk_details': [{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L},
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0},
{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L}],
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0}],
'driver': 'libvirt',
'hypervisor_os': 'linux',
'memory_details': {'maximum': 2048, 'used': 1234},
'nic_details': [{'mac_address': '52:54:00:a4:38:38',
'rx_drop': 0L,
'rx_errors': 0L,
'rx_octets': 4408L,
'rx_packets': 82L,
'tx_drop': 0L,
'tx_errors': 0L,
'tx_octets': 0L,
'tx_packets': 0L}],
'rx_drop': 0,
'rx_errors': 0,
'rx_octets': 4408,
'rx_packets': 82,
'tx_drop': 0,
'tx_errors': 0,
'tx_octets': 0,
'tx_packets': 0}],
'state': 'running',
'uptime': 10,
'version': '1.0'}
@ -9158,10 +9158,10 @@ class LibvirtConnTestCase(test.NoDBTestCase):
super(DiagFakeDomain, self).__init__(fake_xml=xml)
def vcpus(self):
return ([(0, 1, 15340000000L, 0),
(1, 1, 1640000000L, 0),
(2, 1, 3040000000L, 0),
(3, 1, 1420000000L, 0)],
return ([(0, 1, 15340000000, 0),
(1, 1, 1640000000, 0),
(2, 1, 3040000000, 0),
(3, 1, 1420000000, 0)],
[(True, False),
(True, False),
(True, False),
@ -9171,13 +9171,13 @@ class LibvirtConnTestCase(test.NoDBTestCase):
raise fakelibvirt.libvirtError('blockStats missing')
def interfaceStats(self, path):
return (4408L, 82L, 0L, 0L, 0L, 0L, 0L, 0L)
return (4408, 82, 0, 0, 0, 0, 0, 0)
def memoryStats(self):
return {'actual': 220160L, 'rss': 200164L}
return {'actual': 220160, 'rss': 200164}
def maxMemory(self):
return 280160L
return 280160
def fake_get_domain(self, instance):
return DiagFakeDomain()
@ -9187,21 +9187,21 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = objects.Instance(**self.test_instance)
actual = drvr.get_diagnostics(instance)
expect = {'cpu0_time': 15340000000L,
'cpu1_time': 1640000000L,
'cpu2_time': 3040000000L,
'cpu3_time': 1420000000L,
'memory': 280160L,
'memory-actual': 220160L,
'memory-rss': 200164L,
'vnet0_rx': 4408L,
'vnet0_rx_drop': 0L,
'vnet0_rx_errors': 0L,
'vnet0_rx_packets': 82L,
'vnet0_tx': 0L,
'vnet0_tx_drop': 0L,
'vnet0_tx_errors': 0L,
'vnet0_tx_packets': 0L,
expect = {'cpu0_time': 15340000000,
'cpu1_time': 1640000000,
'cpu2_time': 3040000000,
'cpu3_time': 1420000000,
'memory': 280160,
'memory-actual': 220160,
'memory-rss': 200164,
'vnet0_rx': 4408,
'vnet0_rx_drop': 0,
'vnet0_rx_errors': 0,
'vnet0_rx_packets': 82,
'vnet0_tx': 0,
'vnet0_tx_drop': 0,
'vnet0_tx_errors': 0,
'vnet0_tx_packets': 0,
}
self.assertEqual(actual, expect)
@ -9212,23 +9212,23 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance.launched_at = lt
actual = drvr.get_instance_diagnostics(instance)
expected = {'config_drive': False,
'cpu_details': [{'time': 15340000000L},
{'time': 1640000000L},
{'time': 3040000000L},
{'time': 1420000000L}],
'cpu_details': [{'time': 15340000000},
{'time': 1640000000},
{'time': 3040000000},
{'time': 1420000000}],
'disk_details': [],
'driver': 'libvirt',
'hypervisor_os': 'linux',
'memory_details': {'maximum': 2048, 'used': 1234},
'nic_details': [{'mac_address': '52:54:00:a4:38:38',
'rx_drop': 0L,
'rx_errors': 0L,
'rx_octets': 4408L,
'rx_packets': 82L,
'tx_drop': 0L,
'tx_errors': 0L,
'tx_octets': 0L,
'tx_packets': 0L}],
'rx_drop': 0,
'rx_errors': 0,
'rx_octets': 4408,
'rx_packets': 82,
'tx_drop': 0,
'tx_errors': 0,
'tx_octets': 0,
'tx_packets': 0}],
'state': 'running',
'uptime': 10,
'version': '1.0'}
@ -9261,26 +9261,26 @@ class LibvirtConnTestCase(test.NoDBTestCase):
super(DiagFakeDomain, self).__init__(fake_xml=xml)
def vcpus(self):
return ([(0, 1, 15340000000L, 0),
(1, 1, 1640000000L, 0),
(2, 1, 3040000000L, 0),
(3, 1, 1420000000L, 0)],
return ([(0, 1, 15340000000, 0),
(1, 1, 1640000000, 0),
(2, 1, 3040000000, 0),
(3, 1, 1420000000, 0)],
[(True, False),
(True, False),
(True, False),
(True, False)])
def blockStats(self, path):
return (169L, 688640L, 0L, 0L, -1L)
return (169, 688640, 0, 0, -1)
def interfaceStats(self, path):
raise fakelibvirt.libvirtError('interfaceStat missing')
def memoryStats(self):
return {'actual': 220160L, 'rss': 200164L}
return {'actual': 220160, 'rss': 200164}
def maxMemory(self):
return 280160L
return 280160
def fake_get_domain(self, instance):
return DiagFakeDomain()
@ -9290,23 +9290,23 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = objects.Instance(**self.test_instance)
actual = drvr.get_diagnostics(instance)
expect = {'cpu0_time': 15340000000L,
'cpu1_time': 1640000000L,
'cpu2_time': 3040000000L,
'cpu3_time': 1420000000L,
'vda_read': 688640L,
'vda_read_req': 169L,
'vda_write': 0L,
'vda_write_req': 0L,
'vda_errors': -1L,
'vdb_read': 688640L,
'vdb_read_req': 169L,
'vdb_write': 0L,
'vdb_write_req': 0L,
'vdb_errors': -1L,
'memory': 280160L,
'memory-actual': 220160L,
'memory-rss': 200164L,
expect = {'cpu0_time': 15340000000,
'cpu1_time': 1640000000,
'cpu2_time': 3040000000,
'cpu3_time': 1420000000,
'vda_read': 688640,
'vda_read_req': 169,
'vda_write': 0,
'vda_write_req': 0,
'vda_errors': -1,
'vdb_read': 688640,
'vdb_read_req': 169,
'vdb_write': 0,
'vdb_write_req': 0,
'vdb_errors': -1,
'memory': 280160,
'memory-actual': 220160,
'memory-rss': 200164,
}
self.assertEqual(actual, expect)
@ -9317,22 +9317,22 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance.launched_at = lt
actual = drvr.get_instance_diagnostics(instance)
expected = {'config_drive': False,
'cpu_details': [{'time': 15340000000L},
{'time': 1640000000L},
{'time': 3040000000L},
{'time': 1420000000L}],
'cpu_details': [{'time': 15340000000},
{'time': 1640000000},
{'time': 3040000000},
{'time': 1420000000}],
'disk_details': [{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L},
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0},
{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L}],
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0}],
'driver': 'libvirt',
'hypervisor_os': 'linux',
'memory_details': {'maximum': 2048, 'used': 1234},
@ -9369,26 +9369,26 @@ class LibvirtConnTestCase(test.NoDBTestCase):
super(DiagFakeDomain, self).__init__(fake_xml=xml)
def vcpus(self):
return ([(0, 1, 15340000000L, 0),
(1, 1, 1640000000L, 0),
(2, 1, 3040000000L, 0),
(3, 1, 1420000000L, 0)],
return ([(0, 1, 15340000000, 0),
(1, 1, 1640000000, 0),
(2, 1, 3040000000, 0),
(3, 1, 1420000000, 0)],
[(True, False),
(True, False),
(True, False),
(True, False)])
def blockStats(self, path):
return (169L, 688640L, 0L, 0L, -1L)
return (169, 688640, 0, 0, -1)
def interfaceStats(self, path):
return (4408L, 82L, 0L, 0L, 0L, 0L, 0L, 0L)
return (4408, 82, 0, 0, 0, 0, 0, 0)
def memoryStats(self):
raise fakelibvirt.libvirtError('memoryStats missing')
def maxMemory(self):
return 280160L
return 280160
def fake_get_domain(self, instance):
return DiagFakeDomain()
@ -9398,29 +9398,29 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = objects.Instance(**self.test_instance)
actual = drvr.get_diagnostics(instance)
expect = {'cpu0_time': 15340000000L,
'cpu1_time': 1640000000L,
'cpu2_time': 3040000000L,
'cpu3_time': 1420000000L,
'vda_read': 688640L,
'vda_read_req': 169L,
'vda_write': 0L,
'vda_write_req': 0L,
'vda_errors': -1L,
'vdb_read': 688640L,
'vdb_read_req': 169L,
'vdb_write': 0L,
'vdb_write_req': 0L,
'vdb_errors': -1L,
'memory': 280160L,
'vnet0_rx': 4408L,
'vnet0_rx_drop': 0L,
'vnet0_rx_errors': 0L,
'vnet0_rx_packets': 82L,
'vnet0_tx': 0L,
'vnet0_tx_drop': 0L,
'vnet0_tx_errors': 0L,
'vnet0_tx_packets': 0L,
expect = {'cpu0_time': 15340000000,
'cpu1_time': 1640000000,
'cpu2_time': 3040000000,
'cpu3_time': 1420000000,
'vda_read': 688640,
'vda_read_req': 169,
'vda_write': 0,
'vda_write_req': 0,
'vda_errors': -1,
'vdb_read': 688640,
'vdb_read_req': 169,
'vdb_write': 0,
'vdb_write_req': 0,
'vdb_errors': -1,
'memory': 280160,
'vnet0_rx': 4408,
'vnet0_rx_drop': 0,
'vnet0_rx_errors': 0,
'vnet0_rx_packets': 82,
'vnet0_tx': 0,
'vnet0_tx_drop': 0,
'vnet0_tx_errors': 0,
'vnet0_tx_packets': 0,
}
self.assertEqual(actual, expect)
@ -9431,34 +9431,34 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance.launched_at = lt
actual = drvr.get_instance_diagnostics(instance)
expected = {'config_drive': False,
'cpu_details': [{'time': 15340000000L},
{'time': 1640000000L},
{'time': 3040000000L},
{'time': 1420000000L}],
'cpu_details': [{'time': 15340000000},
{'time': 1640000000},
{'time': 3040000000},
{'time': 1420000000}],
'disk_details': [{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L},
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0},
{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L}],
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0}],
'driver': 'libvirt',
'hypervisor_os': 'linux',
'memory_details': {'maximum': 2048, 'used': 1234},
'nic_details': [{'mac_address': '52:54:00:a4:38:38',
'rx_drop': 0L,
'rx_errors': 0L,
'rx_octets': 4408L,
'rx_packets': 82L,
'tx_drop': 0L,
'tx_errors': 0L,
'tx_octets': 0L,
'tx_packets': 0L}],
'rx_drop': 0,
'rx_errors': 0,
'rx_octets': 4408,
'rx_packets': 82,
'tx_drop': 0,
'tx_errors': 0,
'tx_octets': 0,
'tx_packets': 0}],
'state': 'running',
'uptime': 10,
'version': '1.0'}
@ -9491,26 +9491,26 @@ class LibvirtConnTestCase(test.NoDBTestCase):
super(DiagFakeDomain, self).__init__(fake_xml=xml)
def vcpus(self):
return ([(0, 1, 15340000000L, 0),
(1, 1, 1640000000L, 0),
(2, 1, 3040000000L, 0),
(3, 1, 1420000000L, 0)],
return ([(0, 1, 15340000000, 0),
(1, 1, 1640000000, 0),
(2, 1, 3040000000, 0),
(3, 1, 1420000000, 0)],
[(True, False),
(True, False),
(True, False),
(True, False)])
def blockStats(self, path):
return (169L, 688640L, 0L, 0L, -1L)
return (169, 688640, 0, 0, -1)
def interfaceStats(self, path):
return (4408L, 82L, 0L, 0L, 0L, 0L, 0L, 0L)
return (4408, 82, 0, 0, 0, 0, 0, 0)
def memoryStats(self):
return {'actual': 220160L, 'rss': 200164L}
return {'actual': 220160, 'rss': 200164}
def maxMemory(self):
return 280160L
return 280160
def fake_get_domain(self, instance):
return DiagFakeDomain()
@ -9520,31 +9520,31 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = objects.Instance(**self.test_instance)
actual = drvr.get_diagnostics(instance)
expect = {'cpu0_time': 15340000000L,
'cpu1_time': 1640000000L,
'cpu2_time': 3040000000L,
'cpu3_time': 1420000000L,
'vda_read': 688640L,
'vda_read_req': 169L,
'vda_write': 0L,
'vda_write_req': 0L,
'vda_errors': -1L,
'vdb_read': 688640L,
'vdb_read_req': 169L,
'vdb_write': 0L,
'vdb_write_req': 0L,
'vdb_errors': -1L,
'memory': 280160L,
'memory-actual': 220160L,
'memory-rss': 200164L,
'vnet0_rx': 4408L,
'vnet0_rx_drop': 0L,
'vnet0_rx_errors': 0L,
'vnet0_rx_packets': 82L,
'vnet0_tx': 0L,
'vnet0_tx_drop': 0L,
'vnet0_tx_errors': 0L,
'vnet0_tx_packets': 0L,
expect = {'cpu0_time': 15340000000,
'cpu1_time': 1640000000,
'cpu2_time': 3040000000,
'cpu3_time': 1420000000,
'vda_read': 688640,
'vda_read_req': 169,
'vda_write': 0,
'vda_write_req': 0,
'vda_errors': -1,
'vdb_read': 688640,
'vdb_read_req': 169,
'vdb_write': 0,
'vdb_write_req': 0,
'vdb_errors': -1,
'memory': 280160,
'memory-actual': 220160,
'memory-rss': 200164,
'vnet0_rx': 4408,
'vnet0_rx_drop': 0,
'vnet0_rx_errors': 0,
'vnet0_rx_packets': 82,
'vnet0_tx': 0,
'vnet0_tx_drop': 0,
'vnet0_tx_errors': 0,
'vnet0_tx_packets': 0,
}
self.assertEqual(actual, expect)
@ -9555,34 +9555,34 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance.launched_at = lt
actual = drvr.get_instance_diagnostics(instance)
expected = {'config_drive': False,
'cpu_details': [{'time': 15340000000L},
{'time': 1640000000L},
{'time': 3040000000L},
{'time': 1420000000L}],
'cpu_details': [{'time': 15340000000},
{'time': 1640000000},
{'time': 3040000000},
{'time': 1420000000}],
'disk_details': [{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L},
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0},
{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L}],
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0}],
'driver': 'libvirt',
'hypervisor_os': 'linux',
'memory_details': {'maximum': 2048, 'used': 1234},
'nic_details': [{'mac_address': '52:54:00:a4:38:38',
'rx_drop': 0L,
'rx_errors': 0L,
'rx_octets': 4408L,
'rx_packets': 82L,
'tx_drop': 0L,
'tx_errors': 0L,
'tx_octets': 0L,
'tx_packets': 0L}],
'rx_drop': 0,
'rx_errors': 0,
'rx_octets': 4408,
'rx_packets': 82,
'tx_drop': 0,
'tx_errors': 0,
'tx_octets': 0,
'tx_packets': 0}],
'state': 'running',
'uptime': 10,
'version': '1.0'}
@ -9623,26 +9623,26 @@ class LibvirtConnTestCase(test.NoDBTestCase):
super(DiagFakeDomain, self).__init__(fake_xml=xml)
def vcpus(self):
return ([(0, 1, 15340000000L, 0),
(1, 1, 1640000000L, 0),
(2, 1, 3040000000L, 0),
(3, 1, 1420000000L, 0)],
return ([(0, 1, 15340000000, 0),
(1, 1, 1640000000, 0),
(2, 1, 3040000000, 0),
(3, 1, 1420000000, 0)],
[(True, False),
(True, False),
(True, False),
(True, False)])
def blockStats(self, path):
return (169L, 688640L, 0L, 0L, -1L)
return (169, 688640, 0, 0, -1)
def interfaceStats(self, path):
return (4408L, 82L, 0L, 0L, 0L, 0L, 0L, 0L)
return (4408, 82, 0, 0, 0, 0, 0, 0)
def memoryStats(self):
return {'actual': 220160L, 'rss': 200164L}
return {'actual': 220160, 'rss': 200164}
def maxMemory(self):
return 280160L
return 280160
def fake_get_domain(self):
return DiagFakeDomain()
@ -9652,39 +9652,39 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = objects.Instance(**self.test_instance)
actual = drvr.get_diagnostics(instance)
expect = {'cpu0_time': 15340000000L,
'cpu1_time': 1640000000L,
'cpu2_time': 3040000000L,
'cpu3_time': 1420000000L,
'vda_read': 688640L,
'vda_read_req': 169L,
'vda_write': 0L,
'vda_write_req': 0L,
'vda_errors': -1L,
'vdb_read': 688640L,
'vdb_read_req': 169L,
'vdb_write': 0L,
'vdb_write_req': 0L,
'vdb_errors': -1L,
'memory': 280160L,
'memory-actual': 220160L,
'memory-rss': 200164L,
'vnet0_rx': 4408L,
'vnet0_rx_drop': 0L,
'vnet0_rx_errors': 0L,
'vnet0_rx_packets': 82L,
'vnet0_tx': 0L,
'vnet0_tx_drop': 0L,
'vnet0_tx_errors': 0L,
'vnet0_tx_packets': 0L,
'br0_rx': 4408L,
'br0_rx_drop': 0L,
'br0_rx_errors': 0L,
'br0_rx_packets': 82L,
'br0_tx': 0L,
'br0_tx_drop': 0L,
'br0_tx_errors': 0L,
'br0_tx_packets': 0L,
expect = {'cpu0_time': 15340000000,
'cpu1_time': 1640000000,
'cpu2_time': 3040000000,
'cpu3_time': 1420000000,
'vda_read': 688640,
'vda_read_req': 169,
'vda_write': 0,
'vda_write_req': 0,
'vda_errors': -1,
'vdb_read': 688640,
'vdb_read_req': 169,
'vdb_write': 0,
'vdb_write_req': 0,
'vdb_errors': -1,
'memory': 280160,
'memory-actual': 220160,
'memory-rss': 200164,
'vnet0_rx': 4408,
'vnet0_rx_drop': 0,
'vnet0_rx_errors': 0,
'vnet0_rx_packets': 82,
'vnet0_tx': 0,
'vnet0_tx_drop': 0,
'vnet0_tx_errors': 0,
'vnet0_tx_packets': 0,
'br0_rx': 4408,
'br0_rx_drop': 0,
'br0_rx_errors': 0,
'br0_rx_packets': 82,
'br0_tx': 0,
'br0_tx_drop': 0,
'br0_tx_errors': 0,
'br0_tx_packets': 0,
}
self.assertEqual(actual, expect)
@ -9695,43 +9695,43 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance.launched_at = lt
actual = drvr.get_instance_diagnostics(instance)
expected = {'config_drive': False,
'cpu_details': [{'time': 15340000000L},
{'time': 1640000000L},
{'time': 3040000000L},
{'time': 1420000000L}],
'cpu_details': [{'time': 15340000000},
{'time': 1640000000},
{'time': 3040000000},
{'time': 1420000000}],
'disk_details': [{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L},
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0},
{'errors_count': 0,
'id': '',
'read_bytes': 688640L,
'read_requests': 169L,
'write_bytes': 0L,
'write_requests': 0L}],
'read_bytes': 688640,
'read_requests': 169,
'write_bytes': 0,
'write_requests': 0}],
'driver': 'libvirt',
'hypervisor_os': 'linux',
'memory_details': {'maximum': 2048, 'used': 1234},
'nic_details': [{'mac_address': '52:54:00:a4:38:38',
'rx_drop': 0L,
'rx_errors': 0L,
'rx_octets': 4408L,
'rx_packets': 82L,
'tx_drop': 0L,
'tx_errors': 0L,
'tx_octets': 0L,
'tx_packets': 0L},
'rx_drop': 0,
'rx_errors': 0,
'rx_octets': 4408,
'rx_packets': 82,
'tx_drop': 0,
'tx_errors': 0,
'tx_octets': 0,
'tx_packets': 0},
{'mac_address': '53:55:00:a5:39:39',
'rx_drop': 0L,
'rx_errors': 0L,
'rx_octets': 4408L,
'rx_packets': 82L,
'tx_drop': 0L,
'tx_errors': 0L,
'tx_octets': 0L,
'tx_packets': 0L}],
'rx_drop': 0,
'rx_errors': 0,
'rx_octets': 4408,
'rx_packets': 82,
'tx_drop': 0,
'tx_errors': 0,
'tx_octets': 0,
'tx_packets': 0}],
'state': 'running',
'uptime': 10.,
'version': '1.0'}
@ -12814,7 +12814,7 @@ class LibvirtVolumeUsageTestCase(test.NoDBTestCase):
def test_get_all_volume_usage(self):
def fake_block_stats(instance_name, disk):
return (169L, 688640L, 0L, 0L, -1L)
return (169, 688640, 0, 0, -1)
self.stubs.Set(self.drvr, 'block_stats', fake_block_stats)
vol_usage = self.drvr.get_all_volume_usage(self.c,
@ -12822,12 +12822,12 @@ class LibvirtVolumeUsageTestCase(test.NoDBTestCase):
expected_usage = [{'volume': 1,
'instance': self.ins_ref,
'rd_bytes': 688640L, 'wr_req': 0L,
'rd_req': 169L, 'wr_bytes': 0L},
'rd_bytes': 688640, 'wr_req': 0,
'rd_req': 169, 'wr_bytes': 0},
{'volume': 2,
'instance': self.ins_ref,
'rd_bytes': 688640L, 'wr_req': 0L,
'rd_req': 169L, 'wr_bytes': 0L}]
'rd_bytes': 688640, 'wr_req': 0,
'rd_req': 169, 'wr_bytes': 0}]
self.assertEqual(vol_usage, expected_usage)
def test_get_all_volume_usage_device_not_found(self):

View File

@ -763,7 +763,7 @@ Active: 8381604 kB
mock.patch('sys.platform', 'linux2'),
) as (mock_file, mock_conn, mock_platform):
mock_conn().getInfo.return_value = [
arch.X86_64, 15814L, 8, 1208, 1, 1, 4, 2]
arch.X86_64, 15814, 8, 1208, 1, 1, 4, 2]
self.assertEqual(6866, self.host.get_memory_mb_used())
@ -810,7 +810,7 @@ Active: 8381604 kB
DiagFakeDomain(1, 750),
DiagFakeDomain(2, 1042)]
mock_conn.getInfo.return_value = [
arch.X86_64, 15814L, 8, 1208, 1, 1, 4, 2]
arch.X86_64, 15814, 8, 1208, 1, 1, 4, 2]
self.assertEqual(8657, self.host.get_memory_mb_used())
mock_list.assert_called_with(only_guests=False)
@ -818,11 +818,11 @@ Active: 8381604 kB
def test_get_cpu_stats(self):
stats = self.host.get_cpu_stats()
self.assertEqual(
{'kernel': 5664160000000L,
'idle': 1592705190000000L,
{'kernel': 5664160000000,
'idle': 1592705190000000,
'frequency': 800,
'user': 26728850000000L,
'iowait': 6121490000000L},
'user': 26728850000000,
'iowait': 6121490000000},
stats)
@mock.patch.object(fakelibvirt.virConnect, "defineXML")

View File

@ -2452,6 +2452,6 @@ class VMInfoTests(VMUtilsTestBase):
info = vm_utils.compile_info(self.session, "dummy")
self.assertEqual(hardware.InstanceInfo(state=power_state.RUNNING,
max_mem_kb=10L, mem_kb=9L,
max_mem_kb=10, mem_kb=9,
num_cpu='5', cpu_time_ns=0),
info)

View File

@ -377,15 +377,15 @@ class FakeDriver(driver.ComputeDriver):
return volusage
def get_host_cpu_stats(self):
stats = {'kernel': 5664160000000L,
'idle': 1592705190000000L,
'user': 26728850000000L,
'iowait': 6121490000000L}
stats = {'kernel': 5664160000000,
'idle': 1592705190000000,
'user': 26728850000000,
'iowait': 6121490000000}
stats['frequency'] = 800
return stats
def block_stats(self, instance, disk_id):
return [0L, 0L, 0L, 0L, None]
return [0, 0, 0, 0, None]
def get_console_output(self, context, instance):
return 'FAKE CONSOLE OUTPUT\nANOTHER\nLAST LINE'