diff --git a/src/ovsdb_subordinate/requires.py b/src/ovsdb_subordinate/requires.py index ba30ebd..4245e02 100644 --- a/src/ovsdb_subordinate/requires.py +++ b/src/ovsdb_subordinate/requires.py @@ -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): diff --git a/unit_tests/test_ovsdb_subordinate_requires.py b/unit_tests/test_ovsdb_subordinate_requires.py index a2cccab..169b48a 100644 --- a/unit_tests/test_ovsdb_subordinate_requires.py +++ b/unit_tests/test_ovsdb_subordinate_requires.py @@ -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'),