Merge "Add wait event for metadataagent sb_idl"
This commit is contained in:
commit
12eecf9679
@ -15,6 +15,7 @@
|
|||||||
import collections
|
import collections
|
||||||
import functools
|
import functools
|
||||||
import re
|
import re
|
||||||
|
import threading
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from neutron_lib import constants as n_const
|
from neutron_lib import constants as n_const
|
||||||
@ -202,6 +203,18 @@ class MetadataAgent(object):
|
|||||||
self._process_monitor = external_process.ProcessMonitor(
|
self._process_monitor = external_process.ProcessMonitor(
|
||||||
config=self.conf,
|
config=self.conf,
|
||||||
resource_type='metadata')
|
resource_type='metadata')
|
||||||
|
self._sb_idl = None
|
||||||
|
self._post_fork_event = threading.Event()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sb_idl(self):
|
||||||
|
if not self._sb_idl:
|
||||||
|
self._post_fork_event.wait()
|
||||||
|
return self._sb_idl
|
||||||
|
|
||||||
|
@sb_idl.setter
|
||||||
|
def sb_idl(self, val):
|
||||||
|
self._sb_idl = val
|
||||||
|
|
||||||
def _load_config(self):
|
def _load_config(self):
|
||||||
self.chassis = self._get_own_chassis_name()
|
self.chassis = self._get_own_chassis_name()
|
||||||
@ -245,6 +258,7 @@ class MetadataAgent(object):
|
|||||||
# Chassis table.
|
# Chassis table.
|
||||||
# Open the connection to OVN SB database.
|
# Open the connection to OVN SB database.
|
||||||
self.has_chassis_private = False
|
self.has_chassis_private = False
|
||||||
|
self._post_fork_event.clear()
|
||||||
try:
|
try:
|
||||||
self.sb_idl = ovsdb.MetadataAgentOvnSbIdl(
|
self.sb_idl = ovsdb.MetadataAgentOvnSbIdl(
|
||||||
chassis=self.chassis, tables=tables + ('Chassis_Private', ),
|
chassis=self.chassis, tables=tables + ('Chassis_Private', ),
|
||||||
@ -255,6 +269,9 @@ class MetadataAgent(object):
|
|||||||
chassis=self.chassis, tables=tables,
|
chassis=self.chassis, tables=tables,
|
||||||
events=events + (ChassisCreateEvent(self), )).start()
|
events=events + (ChassisCreateEvent(self), )).start()
|
||||||
|
|
||||||
|
# Now IDL connections can be safely used.
|
||||||
|
self._post_fork_event.set()
|
||||||
|
|
||||||
# Do the initial sync.
|
# Do the initial sync.
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user