Merge "Replace deprecated datetime.utcnow()"

This commit is contained in:
Zuul 2024-10-15 15:49:04 +00:00 committed by Gerrit Code Review
commit 5d4a790478
13 changed files with 139 additions and 143 deletions

View File

@ -34,7 +34,7 @@ oslo.rootwrap>=5.8.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.service>=2.5.0 # Apache-2.0
oslo.upgradecheck>=1.3.0 # Apache-2.0
oslo.utils>=4.8.0 # Apache-2.0
oslo.utils>=7.0.0 # Apache-2.0
oslo.versionedobjects>=1.33.3 # Apache-2.0
openstacksdk>=0.44.0 # Apache-2.0
python-barbicanclient>=4.5.2 # Apache-2.0

View File

@ -1402,7 +1402,7 @@ class VnfLcmController(wsgi.Controller):
if vnf_info['before_error_point'] == fields.ErrorPoint.INITIAL:
vnf_lcm_op_occs_id = uuidutils.generate_uuid()
timestamp = datetime.datetime.utcnow()
timestamp = timeutils.utcnow()
operation_params = {
'type': scale_vnf_request.type,
'aspect_id': scale_vnf_request.aspect_id,
@ -1760,7 +1760,7 @@ class VnfLcmController(wsgi.Controller):
vnf_lcm_op_occs.operation_state = "FAILED"
vnf_lcm_op_occs.state_entered_time = \
datetime.datetime.utcnow().isoformat()
timeutils.utcnow().isoformat()
vnf_lcm_op_occs.updated_at = vnf_lcm_op_occs.state_entered_time
error_details = objects.ProblemDetails(

View File

@ -267,7 +267,7 @@ def grant_error_common(function):
try:
vnf_lcm_op_occs = objects.VnfLcmOpOcc.get_by_id(
context, vnf_lcm_op_occ_id)
timestamp = datetime.datetime.utcnow()
timestamp = timeutils.utcnow()
vnf_lcm_op_occs.operation_state = 'ROLLED_BACK'
vnf_lcm_op_occs.state_entered_time = timestamp
vnf_lcm_op_occs.save()
@ -927,7 +927,7 @@ class Conductor(manager.Manager, v2_hook.ConductorV2Hook):
csar zip files and vnf packages files from the extracted path.
"""
time_duration = datetime.datetime.utcnow() - datetime.timedelta(
time_duration = timeutils.utcnow() - datetime.timedelta(
seconds=CONF.vnf_package_delete_interval)
filters = {'field': 'deleted_at', 'model': 'VnfPackage',
'value': time_duration,
@ -1893,8 +1893,7 @@ class Conductor(manager.Manager, v2_hook.ConductorV2Hook):
notification['links']['subscription']['href'] = \
CONF.vnf_lcm.endpoint_url + \
"/vnflcm/v1/subscriptions/" + line.id
notification['timeStamp'] = datetime.datetime.utcnow(
).isoformat()
notification['timeStamp'] = timeutils.utcnow().isoformat()
try:
self.__set_auth_subscription(line)

View File

@ -16,12 +16,12 @@
"""Context: context for security/db session."""
import copy
import datetime
from castellan.common.credentials import keystone_password
from oslo_config import cfg
from oslo_context import context as oslo_context
from oslo_db.sqlalchemy import enginefacade
from oslo_utils import timeutils
from tacker.common import exceptions
from tacker.common.ext_oauth2_auth import ExtOAuth2Auth
@ -53,7 +53,7 @@ class ContextBase(oslo_context.RequestContext):
self.user_name = user_name
if not timestamp:
timestamp = datetime.datetime.utcnow()
timestamp = timeutils.utcnow()
self.timestamp = timestamp
# self.is_advsvc = is_advsvc
# if self.is_advsvc is None:

View File

@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from datetime import datetime
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import timeutils
@ -67,7 +65,7 @@ def _vnf_lcm_op_occ_update(context, values):
update = {'operation_state': values.operation_state,
'state_entered_time': values.state_entered_time,
'error_point': values.error_point,
'updated_at': datetime.utcnow()}
'updated_at': timeutils.utcnow()}
LOG.debug('values %s', values)
if 'resource_changes' in values:
if values.resource_changes:

View File

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from datetime import datetime
from oslo_log import log as logging
from oslo_utils import timeutils
from oslo_utils import uuidutils
from tacker.sol_refactored.common import exceptions as sol_ex
@ -61,7 +60,7 @@ def make_alarm_notif_data(subsc, alarm, endpoint):
id=uuidutils.generate_uuid(),
notificationType="AlarmClearedNotification",
subscriptionId=subsc.id,
timeStamp=datetime.utcnow(),
timeStamp=timeutils.utcnow(),
alarmId=alarm.id,
alarmClearedTime=alarm.alarmClearedTime,
_links=objects.AlarmClearedNotificationV1_Links(
@ -76,7 +75,7 @@ def make_alarm_notif_data(subsc, alarm, endpoint):
id=uuidutils.generate_uuid(),
notificationType="AlarmNotification",
subscriptionId=subsc.id,
timeStamp=datetime.utcnow(),
timeStamp=timeutils.utcnow(),
alarm=alarm,
_links=objects.AlarmNotificationV1_Links(
subscription=objects.NotificationLink(

View File

@ -14,9 +14,8 @@
# under the License.
from datetime import datetime
from oslo_log import log as logging
from oslo_utils import timeutils
from oslo_utils import uuidutils
from tacker.sol_refactored.common import exceptions as sol_ex
@ -71,7 +70,7 @@ def make_lcmocc_notif_data(subsc, lcmocc, endpoint):
id=uuidutils.generate_uuid(),
notificationType="VnfLcmOperationOccurrenceNotification",
subscriptionId=subsc.id,
timeStamp=datetime.utcnow(),
timeStamp=timeutils.utcnow(),
operationState=lcmocc.operationState,
vnfInstanceId=lcmocc.vnfInstanceId,
operation=lcmocc.operation,
@ -609,13 +608,13 @@ def check_lcmocc_in_progress(context, inst_id):
def update_lcmocc_status(lcmocc, op_state):
lcmocc.operationState = op_state
lcmocc.stateEnteredTime = datetime.utcnow()
lcmocc.stateEnteredTime = timeutils.utcnow()
def new_lcmocc(inst_id, operation, req_body,
op_state=fields.LcmOperationStateType.STARTING,
auto_invocation=False):
now = datetime.utcnow()
now = timeutils.utcnow()
lcmocc = objects.VnfLcmOpOccV2(
id=uuidutils.generate_uuid(),
operationState=op_state,

View File

@ -18,7 +18,9 @@ import datetime
import iso8601
import sys
from oslo_utils import timeutils
from oslo_utils import uuidutils
from tacker.common import exceptions
from tacker import context
from tacker.db.db_sqlalchemy import api
@ -893,8 +895,8 @@ class TestDbMigrationToV2(SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=op_state,
stateEnteredTime=datetime.datetime.utcnow(),
startTime=datetime.datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields_v2.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -906,8 +908,8 @@ class TestDbMigrationToV2(SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=op_state,
stateEnteredTime=datetime.datetime.utcnow(),
startTime=datetime.datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields_v2.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,

View File

@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from datetime import datetime
from unittest import mock
import ddt
from kubernetes import client
from oslo_log import log as logging
from oslo_utils import timeutils
from oslo_utils import uuidutils
from tooz.drivers import file
@ -66,8 +66,8 @@ class TestConductorV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=op_state,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -99,8 +99,8 @@ class TestConductorV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=op_state,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_VNFPKG,
isAutomaticInvocation=False,
@ -555,8 +555,8 @@ class TestConductorV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=op_state,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,

View File

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
from datetime import datetime
import os
import pickle
import subprocess
from unittest import mock
from kubernetes import client
from oslo_utils import timeutils
from oslo_utils import uuidutils
from tacker import context
@ -851,8 +851,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -943,8 +943,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -1038,8 +1038,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,
@ -1328,8 +1328,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.PROCESSING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
operation=fields.LcmOperationType.MODIFY_INFO,
isAutomaticInvocation=False,
isCancelPending=False,
@ -1458,8 +1458,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.PROCESSING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
operation=fields.LcmOperationType.MODIFY_INFO,
isAutomaticInvocation=False,
isCancelPending=False,
@ -1534,8 +1534,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_EXT_CONN,
isAutomaticInvocation=False,
@ -1634,8 +1634,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.HEAL,
isAutomaticInvocation=False,
@ -1939,8 +1939,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.PROCESSING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_VNFPKG,
isAutomaticInvocation=False,
@ -2024,8 +2024,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2089,8 +2089,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -2170,8 +2170,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_VNFPKG,
isAutomaticInvocation=False,
@ -2201,8 +2201,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_VNFPKG,
isAutomaticInvocation=False,
@ -2234,8 +2234,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2274,8 +2274,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2302,8 +2302,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -2328,8 +2328,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.MODIFY_INFO,
isAutomaticInvocation=False,
@ -2364,8 +2364,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2379,8 +2379,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -2398,8 +2398,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,
@ -2532,8 +2532,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2572,8 +2572,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2610,8 +2610,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2646,8 +2646,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2675,8 +2675,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2703,8 +2703,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2738,8 +2738,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2766,8 +2766,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -2805,8 +2805,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -2838,8 +2838,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -2867,8 +2867,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -2937,8 +2937,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,
@ -2964,8 +2964,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,
@ -3004,8 +3004,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,
@ -3021,8 +3021,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,
@ -3051,8 +3051,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.SCALE,
isAutomaticInvocation=False,
@ -3090,8 +3090,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.HEAL,
isAutomaticInvocation=False,
@ -3117,8 +3117,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.HEAL,
isAutomaticInvocation=False,
@ -3157,8 +3157,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_EXT_CONN,
isAutomaticInvocation=False,
@ -3187,8 +3187,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_EXT_CONN,
isAutomaticInvocation=False,
@ -3271,8 +3271,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_VNFPKG,
isAutomaticInvocation=False,
@ -3368,8 +3368,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_EXT_CONN,
isAutomaticInvocation=False,
@ -3426,8 +3426,8 @@ class TestVnfLcmDriverV2(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.STARTING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_VNFPKG,
isAutomaticInvocation=False,

View File

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
from datetime import datetime
import ddt
from http import client as http_client
import requests
from unittest import mock
from oslo_policy import policy as oslo_policy
from oslo_utils import timeutils
from oslo_utils import uuidutils
from tacker.common.exceptions import PolicyNotAuthorized
@ -830,8 +830,8 @@ class TestVnflcmV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=op_state,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -1447,8 +1447,8 @@ class TestVnflcmV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.FAILED_TEMP,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId='inst-1',
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -1471,8 +1471,8 @@ class TestVnflcmV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.FAILED_TEMP,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId='inst-1',
operation=fields.LcmOperationType.HEAL,
isAutomaticInvocation=False,
@ -1512,8 +1512,8 @@ class TestVnflcmV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.FAILED_TEMP,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId='inst-1',
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,
@ -1536,8 +1536,8 @@ class TestVnflcmV2(db_base.SqlTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.FAILED_TEMP,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId='inst-1',
operation=fields.LcmOperationType.HEAL,
isAutomaticInvocation=False,
@ -2064,8 +2064,8 @@ class TestVnflcmV2EnhancedPolicy(TestVnflcmV2):
# required fields
id=uuidutils.generate_uuid(),
operationState=op_state,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,

View File

@ -12,10 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from datetime import datetime
import os
from unittest import mock
from oslo_utils import timeutils
from oslo_utils import uuidutils
from tacker import context
@ -696,8 +696,8 @@ class TestLocalNfvo(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.PROCESSING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.TERMINATE,
isAutomaticInvocation=False,
@ -724,8 +724,8 @@ class TestLocalNfvo(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.PROCESSING,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.CHANGE_VNFPKG,
isAutomaticInvocation=False,
@ -759,8 +759,8 @@ class TestLocalNfvo(base.BaseTestCase):
# required fields
id=uuidutils.generate_uuid(),
operationState=fields.LcmOperationStateType.ROLLED_BACK,
stateEnteredTime=datetime.utcnow(),
startTime=datetime.utcnow(),
stateEnteredTime=timeutils.utcnow(),
startTime=timeutils.utcnow(),
vnfInstanceId=inst.id,
operation=fields.LcmOperationType.INSTANTIATE,
isAutomaticInvocation=False,

View File

@ -15,7 +15,6 @@
import ast
import copy
from datetime import datetime
import functools
import hashlib
import inspect
@ -106,7 +105,7 @@ def revert_to_error_scale(function):
detail=str(ex))
try:
timestamp = datetime.utcnow()
timestamp = timeutils.utcnow()
vnf_lcm_op_occ = vnf_info['vnf_lcm_op_occ']
vnf_lcm_op_occ.operation_state = 'FAILED_TEMP'
vnf_lcm_op_occ.state_entered_time = timestamp
@ -241,7 +240,7 @@ def revert_to_error_rollback(function):
detail=str(ex))
try:
timestamp = datetime.utcnow()
timestamp = timeutils.utcnow()
vnf_lcm_op_occ = vnf_info['vnf_lcm_op_occ']
vnf_lcm_op_occ.operation_state = 'FAILED_TEMP'
vnf_lcm_op_occ.state_entered_time = timestamp
@ -1342,7 +1341,7 @@ class VnfLcmDriver(abstract_driver.VnfInstanceAbstractDriver):
def scale_vnf(self, context, vnf_info, vnf_instance, scale_vnf_request):
LOG.info("Request received for scale vnf '%s'", vnf_instance.id)
timestamp = datetime.utcnow()
timestamp = timeutils.utcnow()
vnf_lcm_op_occ = vnf_info['vnf_lcm_op_occ']
vnf_lcm_op_occ.operation_state = 'PROCESSING'
@ -1810,7 +1809,7 @@ class VnfLcmDriver(abstract_driver.VnfInstanceAbstractDriver):
vnf_lcm_op_occs.error_point = EP.VNF_CONFIG_START
timestamp = datetime.utcnow()
timestamp = timeutils.utcnow()
vnf_lcm_op_occs.operation_state = 'ROLLED_BACK'
vnf_lcm_op_occs.state_entered_time = timestamp
vnf_lcm_op_occs.resource_changes = resource_changes
@ -1844,7 +1843,7 @@ class VnfLcmDriver(abstract_driver.VnfInstanceAbstractDriver):
vnf_info['after_scale_level'] = scale.scale_level
break
timestamp = datetime.utcnow()
timestamp = timeutils.utcnow()
vnf_lcm_op_occs.operation_state = 'ROLLING_BACK'
vnf_lcm_op_occs.state_entered_time = timestamp