From dc2c79bac46ef3e9832f752d0ba467df634cbc88 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Tue, 29 Sep 2015 00:49:26 +0200 Subject: [PATCH] Fixed problem with transports connected to another transports - When transports_id value is False no magic mappings - Added is_own to location_id, when set to False location_id is not mapped --- resources/transport_solard/meta.yaml | 4 ++++ resources/transport_ssh/meta.yaml | 4 ++++ solar/solar/core/actions.py | 8 ++++---- solar/solar/core/signals.py | 17 +++++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/resources/transport_solard/meta.yaml b/resources/transport_solard/meta.yaml index 27279735..ac8b7aab 100644 --- a/resources/transport_solard/meta.yaml +++ b/resources/transport_solard/meta.yaml @@ -20,3 +20,7 @@ input: schema: str! value: reverse: True + is_own: False + transports_id: + schema: str! + value: False diff --git a/resources/transport_ssh/meta.yaml b/resources/transport_ssh/meta.yaml index 4a614ffa..97d27fbd 100644 --- a/resources/transport_ssh/meta.yaml +++ b/resources/transport_ssh/meta.yaml @@ -16,3 +16,7 @@ input: schema: str! value: reverse: True + is_own: False + transports_id: + schema: str! + value: False diff --git a/solar/solar/core/actions.py b/solar/solar/core/actions.py index deff8f69..4b54dbe8 100644 --- a/solar/solar/core/actions.py +++ b/solar/solar/core/actions.py @@ -20,11 +20,11 @@ from solar.core.transports.ssh import SSHSyncTransport, SSHRunTransport from solar.core.transports.solard_transport import SolardRunTransport, SolardSyncTransport _default_transports = { - # 'sync': SSHSyncTransport, # 'sync': RsyncSyncTransport, - # 'run': SSHRunTransport - 'run': SolardRunTransport, - 'sync': SolardSyncTransport + 'sync': SSHSyncTransport, + 'run': SSHRunTransport +# 'run': SolardRunTransport, +# 'sync': SolardSyncTransport } def resource_action(resource, action): diff --git a/solar/solar/core/signals.py b/solar/solar/core/signals.py index 6413e0d4..d741a82e 100644 --- a/solar/solar/core/signals.py +++ b/solar/solar/core/signals.py @@ -58,12 +58,21 @@ def location_and_transports(emitter, receiver, orig_mapping): elif isinstance(orig_mapping, set): orig_mapping.remove(single) - def _single(single, inps_emitter, inps_receiver): + def _single(single, emitter, receiver, inps_emitter, inps_receiver): if inps_emitter and inps_receiver: - log.debug("location and transports different, skipping") - return + if not inps_emitter == inps_receiver: + log.warning("Different %r defined %r => %r", single, emitter.name, receiver.name) + return + else: + log.debug("The same %r defined for %r => %r, skipping", single, emitter.name, receiver.name) + return emitter_single = emitter.db_obj.meta_inputs[single] receiver_single = receiver.db_obj.meta_inputs[single] + if emitter_single.get('value') is False: + log.debug("Disabled %r mapping for %r", single, emitter.name) + return + if receiver_single.get('is_own') is False: + log.debug("Not is_own %r for %r ", single, emitter.name) emitter_single_reverse = emitter_single.get('reverse') receiver_single_reverse = receiver_single.get('reverse') # connect in other direction @@ -86,7 +95,7 @@ def location_and_transports(emitter, receiver, orig_mapping): # XXX: should be somehow parametrized (input attribute?) for single in ('transports_id', 'location_id'): if single in inps_emitter and inps_receiver: - _single(single, inps_emitter[single], inps_receiver[single]) + _single(single, emitter, receiver, inps_emitter[single], inps_receiver[single]) else: log.warning('Unable to create connection for %s with' ' emitter %s, receiver %s',