Merge "[OVN] Introduce the new OVN Neutron Agent"

This commit is contained in:
Zuul 2023-01-24 02:16:49 +00:00 committed by Gerrit Code Review
commit 21927e7907
2 changed files with 39 additions and 0 deletions

View File

@ -74,9 +74,13 @@ OVN_AGENT_DESC_KEY = 'neutron:description'
OVN_AGENT_METADATA_SB_CFG_KEY = 'neutron:ovn-metadata-sb-cfg'
OVN_AGENT_METADATA_DESC_KEY = 'neutron:description-metadata'
OVN_AGENT_METADATA_ID_KEY = 'neutron:ovn-metadata-id'
OVN_AGENT_NEUTRON_SB_CFG_KEY = 'neutron:ovn-neutron-agent-sb-cfg'
OVN_AGENT_NEUTRON_DESC_KEY = 'neutron:description-neutron-agent'
OVN_AGENT_NEUTRON_ID_KEY = 'neutron:ovn-neutron-agent-id'
OVN_CONTROLLER_AGENT = 'OVN Controller agent'
OVN_CONTROLLER_GW_AGENT = 'OVN Controller Gateway agent'
OVN_METADATA_AGENT = 'OVN Metadata agent'
OVN_NEUTRON_AGENT = 'OVN Neutron agent'
OVN_CONTROLLER_TYPES = (OVN_CONTROLLER_AGENT,
OVN_CONTROLLER_GW_AGENT,
)

View File

@ -220,6 +220,41 @@ class MetadataAgent(NeutronAgent):
ovn_const.OVN_AGENT_METADATA_DESC_KEY, '')
class OVNNeutronAgent(NeutronAgent):
agent_type = ovn_const.OVN_NEUTRON_AGENT
binary = 'neutron-ovn-agent'
@property
def alive(self):
# If ovn-controller is down, then OVN Neutron Agent is down even
# if the neutron-ovn-agent binary is updating external_ids.
try:
if not AgentCache()[self.chassis_private.name].alive:
return False
except KeyError:
return False
return super().alive
@property
def nb_cfg(self):
return int(self.chassis_private.external_ids.get(
ovn_const.OVN_AGENT_NEUTRON_SB_CFG_KEY, 0))
@staticmethod
def id_from_chassis_private(chassis_private):
return chassis_private.external_ids.get(
ovn_const.OVN_AGENT_NEUTRON_ID_KEY)
@property
def agent_id(self):
return self.id_from_chassis_private(self.chassis_private)
@property
def description(self):
return self.chassis_private.external_ids.get(
ovn_const.OVN_AGENT_NEUTRON_DESC_KEY, '')
@utils.SingletonDecorator
class AgentCache:
def __init__(self, driver=None):