Exemple #1
0
 def test_update_admin_status_to_locking(self):
     super().setUp()
     sub = create_subscription_data('sub')
     nf_list = create_multiple_network_function_data(['pnf_101', 'pnf_102'])
     db.session.add(sub)
     for nf in nf_list:
         nf_service.save_nf(nf)
         measurement_group_service. \
             apply_nf_status_to_measurement_group(nf.nf_name, sub.measurement_groups[0].
                                                  measurement_group_name,
                                                  MgNfState.CREATED.value)
     db.session.commit()
     measurement_group_service.update_admin_status(
         sub.measurement_groups[0], 'LOCKED')
     meas_grp = measurement_group_service.query_meas_group_by_name(
         'sub', 'MG1')
     self.assertEqual(meas_grp.subscription_name, 'sub')
     self.assertEqual(meas_grp.measurement_group_name, 'MG1')
     self.assertEqual(meas_grp.administrative_state, 'LOCKING')
     meas_group_nfs = db.session.query(NfMeasureGroupRelationalModel).filter(
         NfMeasureGroupRelationalModel.measurement_grp_name == meas_grp.measurement_group_name)\
         .all()
     for nf in meas_group_nfs:
         self.assertEqual(nf.nf_measure_grp_status,
                          MgNfState.PENDING_DELETE.value)
Exemple #2
0
def save_filtered_nfs(filtered_nfs):
    """
    Saves a network function

    Args:
        filtered_nfs (list[NetworkFunction]): list of filtered network functions to save.
    """
    pmsh_nf_names = list(nf.nf_name for nf in NetworkFunctionModel.query.all())
    for nf in filtered_nfs:
        if nf.nf_name not in pmsh_nf_names:
            nf_service.save_nf(nf)
Exemple #3
0
 def test_save_nf_new_nf(self, mock_filter_call, mock_model_aai, mock_aai):
     mock_aai.return_value = json.loads(self.aai_response_data)
     mock_model_aai.return_value = json.loads(self.good_model_info)
     subscription = json.loads(self.subscription_request)['subscription']
     mock_filter_call.return_value = NetworkFunctionFilter(
         **subscription["nfFilter"])
     nf = nf_service.capture_filtered_nfs(
         subscription["subscriptionName"])[0]
     nf.nf_name = 'newnf1'
     nf_service.save_nf(nf)
     network_function = NetworkFunctionModel.query.filter(
         NetworkFunctionModel.nf_name == nf.nf_name).one_or_none()
     self.assertIsNotNone(network_function)
Exemple #4
0
 def test_delete_nf_to_measurement_group_with_nf_delete(self):
     nf = NetworkFunction(nf_name='pnf_test2')
     nf_service.save_nf(nf)
     db.session.commit()
     measurement_group_service.apply_nf_status_to_measurement_group(
         "pnf_test2", "measure_grp_name2", MgNfState.PENDING_CREATE.value)
     measurement_group_service.delete_nf_to_measurement_group(
         "pnf_test2", "measure_grp_name2", MgNfState.DELETED.value)
     measurement_grp_rel = (NfMeasureGroupRelationalModel.query.filter(
         NfMeasureGroupRelationalModel.measurement_grp_name ==
         'measure_grp_name2', NfMeasureGroupRelationalModel.nf_name ==
         'pnf_test2').one_or_none())
     self.assertIsNone(measurement_grp_rel)
Exemple #5
0
 def test_lock_nf_to_meas_grp_with_no_LOCKED_update(self):
     sub = create_subscription_data('sub')
     sub.measurement_groups[1].administrative_state = 'LOCKING'
     nf_list = create_multiple_network_function_data(['pnf_101', 'pnf_102'])
     db.session.add(sub)
     for nf in nf_list:
         nf_service.save_nf(nf)
         measurement_group_service. \
             apply_nf_status_to_measurement_group(nf.nf_name, sub.measurement_groups[1].
                                                  measurement_group_name,
                                                  MgNfState.PENDING_DELETE.value)
     db.session.commit()
     measurement_group_service.lock_nf_to_meas_grp("pnf_101", "MG2",
                                                   MgNfState.DELETED.value)
     measurement_grp_rel = (NfMeasureGroupRelationalModel.query.filter(
         NfMeasureGroupRelationalModel.measurement_grp_name == 'MG2',
         NfMeasureGroupRelationalModel.nf_name == 'pnf_101').one_or_none())
     self.assertIsNone(measurement_grp_rel)
 def test_get_meas_group_with_nfs_api(self):
     sub = create_subscription_data('sub1')
     nf_list = create_multiple_network_function_data(['pnf101', 'pnf102'])
     measurement_group_service.save_measurement_group(
         sub.measurement_groups[0].serialize()['measurementGroup'],
         sub.subscription_name)
     for nf in nf_list:
         nf_service.save_nf(nf)
         measurement_group_service. \
             apply_nf_status_to_measurement_group(nf.nf_name, sub.measurement_groups[0].
                                                  measurement_group_name,
                                                  MgNfState.PENDING_CREATE.value)
     db.session.commit()
     mg_with_nfs, status_code = get_meas_group_with_nfs('sub1', 'MG1')
     self.assertEqual(status_code, HTTPStatus.OK.value)
     self.assertEqual(mg_with_nfs['subscriptionName'], 'sub1')
     self.assertEqual(mg_with_nfs['measurementGroupName'], 'MG1')
     self.assertEqual(mg_with_nfs['administrativeState'], 'UNLOCKED')
     self.assertEqual(len(mg_with_nfs['networkFunctions']), 2)
 def test_update_admin_state_api_for_locked_update(self):
     sub = create_subscription_data('sub1')
     nf_list = create_multiple_network_function_data(['pnf_101', 'pnf_102'])
     db.session.add(sub)
     for nf in nf_list:
         nf_service.save_nf(nf)
         measurement_group_service. \
             apply_nf_status_to_measurement_group(nf.nf_name, sub.measurement_groups[0].
                                                  measurement_group_name,
                                                  MgNfState.CREATED.value)
     db.session.commit()
     response = update_admin_state('sub1', 'MG1',
                                   {'administrativeState': 'LOCKED'})
     self.assertEqual(response[1], HTTPStatus.OK.value)
     self.assertEqual(response[0], 'Successfully updated admin state')
     mg_with_nfs, status_code = get_meas_group_with_nfs('sub1', 'MG1')
     self.assertEqual(mg_with_nfs['subscriptionName'], 'sub1')
     self.assertEqual(mg_with_nfs['measurementGroupName'], 'MG1')
     self.assertEqual(mg_with_nfs['administrativeState'], 'LOCKING')
     for nf in mg_with_nfs['networkFunctions']:
         self.assertEqual(nf['nfMgStatus'], MgNfState.PENDING_DELETE.value)
Exemple #8
0
 def test_filter_nf_to_meas_grp_for_delete(self):
     sub = create_subscription_data('sub')
     db.session.add(sub)
     nf = NetworkFunction(nf_name='pnf_test2')
     nf_service.save_nf(nf)
     measurement_group_service.apply_nf_status_to_measurement_group(
         "pnf_test2", "MG2", MgNfState.PENDING_DELETE.value)
     db.session.commit()
     measurement_group_service.filter_nf_to_meas_grp(
         "pnf_test2", "MG2", MgNfState.DELETED.value)
     measurement_group_service.filter_nf_to_meas_grp(
         "pnf_test2", "MG2", MgNfState.DELETED.value)
     measurement_grp_rel = (NfMeasureGroupRelationalModel.query.filter(
         NfMeasureGroupRelationalModel.measurement_grp_name == 'MG2',
         NfMeasureGroupRelationalModel.nf_name ==
         'pnf_test2').one_or_none())
     self.assertIsNone(measurement_grp_rel)
     meas_grp = measurement_group_service.query_meas_group_by_name(
         'sub', 'MG2')
     self.assertEqual(meas_grp.subscription_name, 'sub')
     self.assertEqual(meas_grp.measurement_group_name, 'MG2')
     self.assertEqual(meas_grp.administrative_state, 'UNLOCKED')