ovsdb-subordinate: Gate available state on presence of chassis_name

Change-Id: Id04d2c33fef71c345e1f591d9e5259a834262260
Closes-Bug: #1893446
This commit is contained in:
Frode Nordahl 2020-10-21 10:39:08 +02:00
parent 78d6c208b4
commit 93e40a6bd5
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
2 changed files with 10 additions and 1 deletions

View File

@ -129,7 +129,10 @@ class OVSDBSubordinateRequires(Endpoint):
@when('endpoint.{endpoint_name}.joined')
def joined(self):
reactive.set_flag(self.expand_name('{endpoint_name}.connected'))
reactive.set_flag(self.expand_name('{endpoint_name}.available'))
if self.chassis_name:
reactive.set_flag(self.expand_name('{endpoint_name}.available'))
else:
reactive.clear_flag(self.expand_name('{endpoint_name}.available'))
@when_not('endpoint.{endpoint_name}.joined')
def broken(self):

View File

@ -112,6 +112,12 @@ class TestOVSDBSubordinateRequires(test_utils.PatchHelper):
def test_joined(self):
self.patch_object(requires.reactive, 'set_flag')
self.target.joined()
self.set_flag.assert_called_once_with('some-relation.connected')
# available flag should be set when there is a value for chassis_name
self.patch_target('_all_joined_units')
self._all_joined_units.received.get.return_value = 'some.fqdn'
self.set_flag.reset_mock()
self.target.joined()
self.set_flag.assert_has_calls([
mock.call('some-relation.connected'),
mock.call('some-relation.available'),