Merge "Fix field of LifecycleChangeNotificationsFilter"

changes/09/866109/8
Zuul 2 months ago committed by Gerrit Code Review
commit 46a3e3dcbe

@ -199,7 +199,7 @@ def get_lcmocc_subscs(context, lcmocc, inst):
lcmocc.operation, lcmocc.operationState)
def get_matched_subscs(context, inst, notif_type, op_type, op_status):
def get_matched_subscs(context, inst, notif_type, op_type, op_state):
subscs = []
for subsc in get_subsc_all(context):
# subsc: LccnSubscription
@ -209,11 +209,11 @@ def get_matched_subscs(context, inst, notif_type, op_type, op_status):
subscs.append(subsc)
continue
# subsc.fulter: LifecycleChangeNotificationsFilter
# subsc.filter: LifecycleChangeNotificationsFilter
# - vnfInstanceSubscriptionFilter 0..1
# - notificationTypes 0..N
# - operationTypes 0..N
# - operationStatus 0..N
# - operationStates 0..N
if subsc.filter.obj_attr_is_set('vnfInstanceSubscriptionFilter'):
inst_filter = subsc.filter.vnfInstanceSubscriptionFilter
if not match_inst_subsc_filter(inst_filter, inst):
@ -228,9 +228,9 @@ def get_matched_subscs(context, inst, notif_type, op_type, op_status):
if op_type not in subsc.filter.operationTypes:
continue
if (op_status is not None and
subsc.filter.obj_attr_is_set('operationStatus')):
if op_status not in subsc.filter.operationStatus:
if (op_state is not None and
subsc.filter.obj_attr_is_set('operationStates')):
if op_state not in subsc.filter.operationStates:
continue
# OK, matched

@ -40,6 +40,6 @@ class LifecycleChangeNotificationsFilterV2(base.TackerObject,
),
'operationTypes': fields.Field(fields.List(
v2fields.LcmOperationTypeField(), nullable=True)),
'operationStatus': fields.Field(fields.List(
'operationStates': fields.Field(fields.List(
v2fields.LcmOperationStateTypeField(), nullable=True)),
}

@ -313,9 +313,9 @@ class TestSubscriptionUtils(base.BaseTestCase):
inst = objects.VnfInstanceV2(id='test-instance', vnfProvider='company')
notif_type = 'VnfLcmOperationOccurrenceNotification'
op_type = 'INSTANTIATE'
op_status = 'COMPLETED'
op_state = 'COMPLETED'
subscs_no_fileter = objects.LccnSubscriptionV2(id='subsc-1')
subscs_no_filter = objects.LccnSubscriptionV2(id='subsc-1')
products_vnfproducts_no_exist = objects._VnfProductsFromProviders(
vnfProvider='company')
@ -349,21 +349,21 @@ class TestSubscriptionUtils(base.BaseTestCase):
id='subsc-7', filter=objects.LifecycleChangeNotificationsFilterV2(
operationTypes=['TERMINATE']))
subscs_op_status_match = objects.LccnSubscriptionV2(
subscs_op_state_match = objects.LccnSubscriptionV2(
id='subsc-8', filter=objects.LifecycleChangeNotificationsFilterV2(
operationStatus=['COMPLETED']))
subscs_op_status_mismatch = objects.LccnSubscriptionV2(
operationStates=['COMPLETED']))
subscs_op_state_mismatch = objects.LccnSubscriptionV2(
id='subsc-9', filter=objects.LifecycleChangeNotificationsFilterV2(
operationStatus=['FAILED_TEMP']))
operationStates=['FAILED_TEMP']))
mock_subscs.return_value = [
subscs_no_fileter, subscs_filter_match, subscs_filter_mismatch,
subscs_no_filter, subscs_filter_match, subscs_filter_mismatch,
subscs_noti_type_match, subscs_noti_type_mismatch,
subscs_op_type_match, subscs_op_type_mismatch,
subscs_op_status_match, subscs_op_status_mismatch]
subscs_op_state_match, subscs_op_state_mismatch]
result = subsc_utils.get_matched_subscs(
context, inst, notif_type, op_type, op_status)
context, inst, notif_type, op_type, op_state)
expected_ids = ['subsc-1', 'subsc-2', 'subsc-4', 'subsc-6', 'subsc-8']

Loading…
Cancel
Save