diff --git a/nova/api/openstack/compute/simple_tenant_usage.py b/nova/api/openstack/compute/simple_tenant_usage.py index 09dd3735d9..c0b3512c1d 100644 --- a/nova/api/openstack/compute/simple_tenant_usage.py +++ b/nova/api/openstack/compute/simple_tenant_usage.py @@ -242,7 +242,7 @@ class SimpleTenantUsageController(wsgi.Controller): # instance object fields and still maintain backwards compatibility # in the API. if value.utcoffset() is None: - value = value.replace(tzinfo=iso8601.iso8601.Utc()) + value = value.replace(tzinfo=iso8601.UTC) return value def _get_datetime_range(self, req): diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index cfb0264a3c..bfe4cc98ab 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -94,7 +94,7 @@ def set_update_time_on_success(function): else: now = timeutils.utcnow() # NOTE(sbauza): Objects are UTC tz-aware by default - self.updated = now.replace(tzinfo=iso8601.iso8601.Utc()) + self.updated = now.replace(tzinfo=iso8601.UTC) return return_value return decorated_function diff --git a/nova/servicegroup/drivers/mc.py b/nova/servicegroup/drivers/mc.py index d5d3d0832a..11d11f6f98 100644 --- a/nova/servicegroup/drivers/mc.py +++ b/nova/servicegroup/drivers/mc.py @@ -77,7 +77,7 @@ class MemcachedDriver(base.Driver): if updated_time_in_mc: # Change mc time to offset-aware time updated_time_in_mc = \ - updated_time_in_mc.replace(tzinfo=iso8601.iso8601.Utc()) + updated_time_in_mc.replace(tzinfo=iso8601.UTC) if updated_time_in_db <= updated_time_in_mc: return updated_time_in_mc diff --git a/nova/tests/unit/api/openstack/compute/test_networks.py b/nova/tests/unit/api/openstack/compute/test_networks.py index 9ece15c8ad..c641542302 100644 --- a/nova/tests/unit/api/openstack/compute/test_networks.py +++ b/nova/tests/unit/api/openstack/compute/test_networks.py @@ -40,7 +40,7 @@ import nova.utils CONF = cfg.CONF FAKE_NETWORK_PROJECT_ID = '6133f8b603924f45bc0c9e21f6df12fa' -UTC = iso8601.iso8601.Utc() +UTC = iso8601.UTC FAKE_NETWORKS = [ { 'bridge': 'br100', 'vpn_public_port': 1000, diff --git a/nova/tests/unit/api/openstack/compute/test_services.py b/nova/tests/unit/api/openstack/compute/test_services.py index 297178d305..d539f5a8ac 100644 --- a/nova/tests/unit/api/openstack/compute/test_services.py +++ b/nova/tests/unit/api/openstack/compute/test_services.py @@ -1180,7 +1180,7 @@ class ServicesCellsTestV21(test.TestCase): def test_services_detail(self): req = FakeRequest() res_dict = self.controller.index(req) - utc = iso8601.iso8601.Utc() + utc = iso8601.UTC response = {'services': [ {'id': 'cell1@1', 'binary': 'nova-scheduler', diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index def1315bf7..78419f3343 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -891,7 +891,7 @@ class _ComputeAPIUnitTestMixIn(object): 'cores': -inst.flavor.vcpus, 'ram': -inst.flavor.memory_mb} delete_time = datetime.datetime(1955, 11, 5, 9, 30, - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) self.useFixture(utils_fixture.TimeFixture(delete_time)) task_state = (delete_type == 'soft_delete' and task_states.SOFT_DELETING or task_states.DELETING) @@ -1096,7 +1096,7 @@ class _ComputeAPIUnitTestMixIn(object): inst, 'delete.start') db.constraint(host=mox.IgnoreArg()).AndReturn('constraint') delete_time = datetime.datetime(1955, 11, 5, 9, 30, - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) updates['deleted_at'] = delete_time updates['deleted'] = True fake_inst = fake_instance.fake_db_instance(**updates) diff --git a/nova/tests/unit/db/test_db_api.py b/nova/tests/unit/db/test_db_api.py index 8c3109f9a1..b7a9d8e3b9 100644 --- a/nova/tests/unit/db/test_db_api.py +++ b/nova/tests/unit/db/test_db_api.py @@ -1051,8 +1051,8 @@ class SqlAlchemyDbApiNoDbTestCase(test.NoDBTestCase): t2 = t1 + datetime.timedelta(seconds=10) t3 = t2 + datetime.timedelta(hours=1) - t2_utc = t2.replace(tzinfo=iso8601.iso8601.Utc()) - t3_utc = t3.replace(tzinfo=iso8601.iso8601.Utc()) + t2_utc = t2.replace(tzinfo=iso8601.UTC) + t3_utc = t3.replace(tzinfo=iso8601.UTC) datetime_keys = ('created_at', 'deleted_at') @@ -2373,7 +2373,7 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin): dt_keys = ('created_at', 'deleted_at', 'updated_at', 'launched_at', 'terminated_at') dt = timeutils.utcnow() - dt_utc = dt.replace(tzinfo=iso8601.iso8601.Utc()) + dt_utc = dt.replace(tzinfo=iso8601.UTC) for key in dt_keys: values[key] = dt_utc inst = db.instance_create(self.ctxt, values) @@ -2390,7 +2390,7 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin): dt_keys = ('created_at', 'deleted_at', 'updated_at', 'launched_at', 'terminated_at') dt = timeutils.utcnow() - dt_utc = dt.replace(tzinfo=iso8601.iso8601.Utc()) + dt_utc = dt.replace(tzinfo=iso8601.UTC) for key in dt_keys: values[key] = dt_utc inst = db.instance_create(self.ctxt, {}) diff --git a/nova/tests/unit/objects/test_bandwidth_usage.py b/nova/tests/unit/objects/test_bandwidth_usage.py index 648a8315ac..44030d42bf 100644 --- a/nova/tests/unit/objects/test_bandwidth_usage.py +++ b/nova/tests/unit/objects/test_bandwidth_usage.py @@ -69,7 +69,7 @@ class _TestBandwidthUsage(test.TestCase): @staticmethod def _time_now_and_start_period(): - now = timeutils.utcnow().replace(tzinfo=iso8601.iso8601.Utc(), + now = timeutils.utcnow().replace(tzinfo=iso8601.UTC, microsecond=0) start_period = now - datetime.timedelta(seconds=10) return now, start_period diff --git a/nova/tests/unit/objects/test_fields.py b/nova/tests/unit/objects/test_fields.py index d220da32f8..3d0d786fa1 100644 --- a/nova/tests/unit/objects/test_fields.py +++ b/nova/tests/unit/objects/test_fields.py @@ -400,7 +400,7 @@ class TestBoolean(TestField): class TestDateTime(TestField): def setUp(self): super(TestDateTime, self).setUp() - self.dt = datetime.datetime(1955, 11, 5, tzinfo=iso8601.iso8601.Utc()) + self.dt = datetime.datetime(1955, 11, 5, tzinfo=iso8601.UTC) self.field = fields.DateTimeField() self.coerce_good_values = [(self.dt, self.dt), (utils.isotime(self.dt), self.dt)] @@ -413,7 +413,7 @@ class TestDateTime(TestField): '1955-11-05T18:00:00Z', self.field.stringify( datetime.datetime(1955, 11, 5, 18, 0, 0, - tzinfo=iso8601.iso8601.Utc()))) + tzinfo=iso8601.UTC))) class TestDict(TestField): diff --git a/nova/tests/unit/objects/test_fixed_ip.py b/nova/tests/unit/objects/test_fixed_ip.py index 459f985863..922550a8f1 100644 --- a/nova/tests/unit/objects/test_fixed_ip.py +++ b/nova/tests/unit/objects/test_fixed_ip.py @@ -213,7 +213,7 @@ class _TestFixedIPObject(object): now = timeutils.utcnow() now_tz = timeutils.parse_isotime( utils.isotime(now)).replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) disassociate.return_value = 123 result = fixed_ip.FixedIP.disassociate_all_by_timeout(self.context, 'host', now) diff --git a/nova/tests/unit/objects/test_task_log.py b/nova/tests/unit/objects/test_task_log.py index 8cff42b5ea..1773f50bec 100644 --- a/nova/tests/unit/objects/test_task_log.py +++ b/nova/tests/unit/objects/test_task_log.py @@ -71,9 +71,9 @@ class _TestTaskLog(object): self.context, fake_task_log['task_name'], fake_task_log['period_beginning'].replace( - tzinfo=iso8601.iso8601.Utc()), + tzinfo=iso8601.UTC), fake_task_log['period_ending'].replace( - tzinfo=iso8601.iso8601.Utc()), + tzinfo=iso8601.UTC), fake_task_log['host'], task_items=fake_task_log['task_items'], message=fake_task_log['message']) @@ -92,9 +92,9 @@ class _TestTaskLog(object): self.context, fake_task_log['task_name'], fake_task_log['period_beginning'].replace( - tzinfo=iso8601.iso8601.Utc()), + tzinfo=iso8601.UTC), fake_task_log['period_ending'].replace( - tzinfo=iso8601.iso8601.Utc()), + tzinfo=iso8601.UTC), fake_task_log['host'], errors=fake_task_log['errors'], message=fake_task_log['message']) diff --git a/nova/tests/unit/servicegroup/test_mc_servicegroup.py b/nova/tests/unit/servicegroup/test_mc_servicegroup.py index 6d432db49a..552d6a37bd 100644 --- a/nova/tests/unit/servicegroup/test_mc_servicegroup.py +++ b/nova/tests/unit/servicegroup/test_mc_servicegroup.py @@ -71,7 +71,7 @@ class MemcachedServiceGroupTestCase(test.NoDBTestCase): service_ref = { 'host': 'fake-host', 'topic': 'compute', - 'updated_at': updated_at_time.replace(tzinfo=iso8601.iso8601.Utc()) + 'updated_at': updated_at_time.replace(tzinfo=iso8601.UTC) } self.mc_client.get.return_value = None @@ -81,12 +81,12 @@ class MemcachedServiceGroupTestCase(test.NoDBTestCase): self.mc_client.reset_mock() retval = timeutils.utcnow() self.mc_client.get.return_value = retval - self.assertEqual(retval.replace(tzinfo=iso8601.iso8601.Utc()), + self.assertEqual(retval.replace(tzinfo=iso8601.UTC), self.servicegroup_api.get_updated_time(service_ref)) self.mc_client.get.assert_called_once_with('compute:fake-host') self.mc_client.reset_mock() service_ref['updated_at'] = \ - retval.replace(tzinfo=iso8601.iso8601.Utc()) + retval.replace(tzinfo=iso8601.UTC) self.mc_client.get.return_value = updated_at_time self.assertEqual(service_ref['updated_at'], self.servicegroup_api.get_updated_time(service_ref))