diff options
author | Yaron Yogev <yaronyogev@gmail.com> | 2017-08-28 07:06:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-08-28 07:06:52 +0000 |
commit | 834c0f5899a7823ce77453aae4add76245b794c6 (patch) | |
tree | 993acfaa6f2010e74ea6a3f73495714e1c8b917f /app/discover | |
parent | 23f0c36a014295988d5fcbf9f0bda0ae2cb54057 (diff) | |
parent | 2f9d5cf583b4b5dd635f386cb9ac07435bd44cc8 (diff) |
Merge "Heavily refactored all event based scans"
Diffstat (limited to 'app/discover')
-rw-r--r-- | app/discover/events/event_interface_add.py | 10 | ||||
-rw-r--r-- | app/discover/events/event_subnet_add.py | 1 | ||||
-rw-r--r-- | app/discover/events/event_subnet_update.py | 6 |
3 files changed, 12 insertions, 5 deletions
diff --git a/app/discover/events/event_interface_add.py b/app/discover/events/event_interface_add.py index a06ad14..2c7af13 100644 --- a/app/discover/events/event_interface_add.py +++ b/app/discover/events/event_interface_add.py @@ -37,7 +37,9 @@ class EventInterfaceAdd(EventBase): router_doc['gw_port_id'] = router['gw_port_id'] # add gateway port documents. - port_doc = EventSubnetAdd().add_port_document(env, router_doc['gw_port_id'], project_name=project) + port_doc = EventSubnetAdd().add_port_document(env, + router_doc['gw_port_id'], + project_name=project) mac_address = port_doc['mac_address'] if port_doc else None @@ -87,7 +89,8 @@ class EventInterfaceAdd(EventBase): subnet_id = interface['subnet_id'] router_id = encode_router_id(host_id, interface['id']) - network_document = self.inv.get_by_field(env, "network", "subnet_ids", subnet_id, get_single=True) + network_document = self.inv.get_by_field(env, "network", "subnet_ids", + subnet_id, get_single=True) if not network_document: self.log.info("network document not found, aborting interface adding") return EventResult(result=False, retry=True) @@ -99,7 +102,8 @@ class EventInterfaceAdd(EventBase): fetcher = ApiFetchRegions() fetcher.set_env(env) fetcher.get(None) - port_doc = EventSubnetAdd().add_port_document(env, port_id, network_name=network_name) + port_doc = EventSubnetAdd().add_port_document(env, port_id, + network_name=network_name) mac_address = port_doc['mac_address'] if port_doc else None diff --git a/app/discover/events/event_subnet_add.py b/app/discover/events/event_subnet_add.py index b519b1c..a33f7cf 100644 --- a/app/discover/events/event_subnet_add.py +++ b/app/discover/events/event_subnet_add.py @@ -130,7 +130,6 @@ class EventSubnetAdd(EventBase): # Check DHCP enable, if true, scan network. if subnet['enable_dhcp'] is True: # update network - # TODO: #AskCheng - why is this necessary? if len(ApiAccess.regions) == 0: fetcher = ApiFetchRegions() fetcher.set_env(env) diff --git a/app/discover/events/event_subnet_update.py b/app/discover/events/event_subnet_update.py index 9d3c48b..26d1984 100644 --- a/app/discover/events/event_subnet_update.py +++ b/app/discover/events/event_subnet_update.py @@ -93,10 +93,14 @@ class EventSubnetUpdate(EventBase): if subnet['name'] == subnets[key]['name']: subnets[key] = subnet else: - # TODO: #AskCheng shouldn't we remove the old one? + del subnets[key] subnets[subnet['name']] = subnet self.inv.set(network_document) return EventResult(result=True, related_object=subnet['id'], display_context=network_id) + else: + self.log.info( + 'subnet not in network, aborting subnet update') + return EventResult(result=False, retry=False)
\ No newline at end of file |