Commit 08a77949 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Interdomain component:

- Added setting to (de)activate the topology abstractor module.
parent b9a00b18
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -11,3 +11,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from common.Settings import get_setting

SETTING_NAME_TOPOLOGY_ABSTRACTOR = 'TOPOLOGY_ABSTRACTOR'
TRUE_VALUES = {'Y', 'YES', 'TRUE', 'T', 'E', 'ENABLE', 'ENABLED'}

def is_topology_abstractor_enabled() -> bool:
    is_enabled = get_setting(SETTING_NAME_TOPOLOGY_ABSTRACTOR, default=None)
    if is_enabled is None: return False
    str_is_enabled = str(is_enabled).upper()
    return str_is_enabled in TRUE_VALUES
+7 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ from common.Constants import ServiceNameEnum
from common.Settings import (
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port,
    wait_for_environment_variables)
from interdomain.Config import is_topology_abstractor_enabled
from .topology_abstractor.TopologyAbstractor import TopologyAbstractor
from .InterdomainService import InterdomainService
from .RemoteDomainClients import RemoteDomainClients
@@ -63,6 +64,8 @@ def main():
    grpc_service.start()

    # Subscribe to Context Events
    topology_abstractor_enabled = is_topology_abstractor_enabled()
    if topology_abstractor_enabled:
        topology_abstractor = TopologyAbstractor()
        topology_abstractor.start()

@@ -70,6 +73,7 @@ def main():
    while not terminate.wait(timeout=1.0): pass

    LOGGER.info('Terminating...')
    if topology_abstractor_enabled:
        topology_abstractor.stop()
    grpc_service.stop()
    remote_domain_clients.stop()