ovs: Support remove external_ids settings
For ovs-db external_ids, nmstate will not merge with current unless user never defined external_ids in desire state. To remove all external_ids, user could: ```yml interfaces: - name: br0 ovs-db: external_ids: {} ``` Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
parent
be8af1658c
commit
57e2547572
@ -236,6 +236,7 @@ class BaseIface:
|
||||
self._info[Interface.STATE] = InterfaceState.DOWN
|
||||
|
||||
def merge(self, other):
|
||||
self._ovsdb_pre_merge_clean_up(other)
|
||||
merge_dict(self._info, other._info)
|
||||
# If down state is not from orignal state, set it as UP.
|
||||
if (
|
||||
@ -244,6 +245,31 @@ class BaseIface:
|
||||
):
|
||||
self._info[Interface.STATE] = InterfaceState.UP
|
||||
|
||||
def _ovsdb_pre_merge_clean_up(self, other):
|
||||
"""
|
||||
* When user not define ovsdb external_ids, we copy from other.
|
||||
* When user define ovsdb external_ids, we don't merget from other and
|
||||
expecting user to provider full picture.
|
||||
"""
|
||||
desired_external_ids = self._info.get(OvsDB.OVS_DB_SUBTREE, {}).get(
|
||||
OvsDB.EXTERNAL_IDS
|
||||
)
|
||||
current_external_ids = other._info.get(OvsDB.OVS_DB_SUBTREE, {}).get(
|
||||
OvsDB.EXTERNAL_IDS
|
||||
)
|
||||
if desired_external_ids is None:
|
||||
if current_external_ids:
|
||||
self._info.update(
|
||||
{
|
||||
OvsDB.OVS_DB_SUBTREE: {
|
||||
OvsDB.EXTERNAL_IDS: current_external_ids
|
||||
}
|
||||
}
|
||||
)
|
||||
else:
|
||||
if current_external_ids:
|
||||
other._info[OvsDB.OVS_DB_SUBTREE].pop(OvsDB.EXTERNAL_IDS)
|
||||
|
||||
def _validate_port_ip(self):
|
||||
for family in (Interface.IPV4, Interface.IPV6):
|
||||
ip_state = IPState(family, self._origin_info.get(family, {}))
|
||||
|
Loading…
x
Reference in New Issue
Block a user