The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [1.0.3]
+### Fixed
+* Fixed bug where PMSH pushes subscription to xnf regardless of it's orchestration status (DCAEGEN2-2173)
+
## [1.0.2]
### Changed
* Moved subscription processing from main into its own subscription_handler module
for nf in nf_data['results']:
name_identifier = 'pnf-name' if nf['node-type'] == 'pnf' else 'vnf-name'
orchestration_status = nf['properties'].get('orchestration-status')
- if nf_filter.is_nf_in_filter(nf['properties'].get(name_identifier)) \
- and orchestration_status == 'Active':
+ if nf_filter.is_nf_in_filter(nf['properties'].get(name_identifier),
+ orchestration_status):
nf_set.add(NetworkFunction(
nf_name=nf['properties'].get(name_identifier),
orchestration_status=orchestration_status))
UPDATE = 'UPDATE'
-class OrchestrationStatus(Enum):
- ACTIVE = 'Active'
- INVENTORIED = 'Inventoried'
-
-
def process_aai_events(mr_sub, subscription, mr_pub, app, app_conf):
"""
Processes AAI UPDATE events for each filtered xNFs where orchestration status is set to Active.
'vnf-name']
new_status = aai_xnf['orchestration-status']
- if NetworkFunctionFilter(**subscription.nfFilter).is_nf_in_filter(xnf_name):
+ if NetworkFunctionFilter(**subscription.nfFilter).is_nf_in_filter(xnf_name, new_status):
_process_event(action, new_status, xnf_name, subscription, mr_pub, app_conf)
# ============LICENSE_END=====================================================
import re
+from enum import Enum
+
from mod import pmsh_logging as logger, db
from mod.db_models import NetworkFunctionModel
self.nf_names = kwargs.get('nfNames')
self.regex_matcher = re.compile('|'.join(raw_regex for raw_regex in self.nf_names))
- def is_nf_in_filter(self, nf_name):
+ def is_nf_in_filter(self, nf_name, orchestration_status):
"""Match the nf name against regex values in Subscription.nfFilter.nfNames
Args:
nf_name: the AAI nf name.
+ orchestration_status: orchestration status of the nf
Returns:
bool: True if matched, else False.
"""
- return self.regex_matcher.search(nf_name)
+ return self.regex_matcher.search(nf_name) and \
+ orchestration_status == OrchestrationStatus.ACTIVE.value
+
+
+class OrchestrationStatus(Enum):
+ ACTIVE = 'Active'
+ INVENTORIED = 'Inventoried'
from unittest import TestCase
from unittest.mock import patch, Mock
-from mod.aai_event_handler import OrchestrationStatus, process_aai_events
-from mod.network_function import NetworkFunction
+from mod.aai_event_handler import process_aai_events
+from mod.network_function import NetworkFunction, OrchestrationStatus
class AAIEventHandlerTest(TestCase):
import mod.aai_client as aai_client
from mod import db, create_app
-from mod.network_function import NetworkFunction, NetworkFunctionFilter
+from mod.network_function import NetworkFunction, NetworkFunctionFilter, OrchestrationStatus
from mod.pmsh_utils import AppConfig
from mod.subscription import Subscription
self.app_context.pop()
def test_xnf_filter_true(self):
- self.assertTrue(self.xnf_filter.is_nf_in_filter('pnf1'))
+ self.assertTrue(self.xnf_filter.is_nf_in_filter('pnf1', OrchestrationStatus.ACTIVE.value))
def test_xnf_filter_false(self):
- self.assertFalse(self.xnf_filter.is_nf_in_filter('PNF-33'))
+ self.assertFalse(self.xnf_filter.is_nf_in_filter('PNF-33',
+ OrchestrationStatus.ACTIVE.value))
def test_sub_measurement_group(self):
self.assertEqual(len(self.sub_1.measurementGroups), 2)