Raise sync error in Executor
This commit is contained in:
parent
8ad488a866
commit
a73746a621
@ -39,8 +39,7 @@ class AnsibleTemplate(TempFileHandler):
|
||||
self._copy_templates_and_scripts(resource, action_name)
|
||||
self.transport_sync.copy(resource, self.dst, '/tmp')
|
||||
self.transport_sync.copy(resource, '/vagrant/library', '/tmp')
|
||||
sync_results = self.transport_sync.sync_all()
|
||||
self.verify_sync_results(sync_results)
|
||||
self.transport_sync.sync_all()
|
||||
|
||||
# remote paths are not nested inside solar_local
|
||||
remote_playbook_file = playbook_file.replace(
|
||||
|
@ -43,15 +43,6 @@ class BaseHandler(object):
|
||||
self.transport_sync.bind_with(self.transport_run)
|
||||
self.transport_run.bind_with(self.transport_sync)
|
||||
|
||||
def verify_sync_results(self, results):
|
||||
for result in results:
|
||||
if isinstance(result, tuple) and len(result) == 3:
|
||||
# TODO Include file information in result
|
||||
rc, out, err = result
|
||||
log.debug('RC %s OUT %s ERR %s', rc, out, err)
|
||||
if rc:
|
||||
raise errors.SolarError(err)
|
||||
|
||||
def verify_run_result(self, cmd, result):
|
||||
rc, out, err = result
|
||||
log.debug('CMD %r RC %s OUT %s ERR %s', cmd, rc, out, err)
|
||||
|
@ -27,5 +27,4 @@ class NaiveSync(BaseHandler):
|
||||
# to understand where src comes from
|
||||
for item in args['sources']:
|
||||
self.transport_sync.copy(resource, item['src'], item['dst'])
|
||||
results = self.transport_sync.sync_all()
|
||||
self.verify_sync_results(results)
|
||||
self.transport_sync.sync_all()
|
||||
|
@ -37,8 +37,7 @@ class Puppet(TempFileHandler):
|
||||
|
||||
self.prepare_templates_and_scripts(resource, action_file, '')
|
||||
self.transport_sync.copy(resource, action_file, action_file_name)
|
||||
sync_results = self.transport_sync.sync_all()
|
||||
self.verify_sync_results(sync_results)
|
||||
self.transport_sync.sync_all()
|
||||
|
||||
cmd_args = ['puppet', 'apply', '-vd',
|
||||
action_file_name,
|
||||
|
@ -33,9 +33,7 @@ class Shell(TempFileHandler):
|
||||
self._copy_templates_and_scripts(resource, action_name)
|
||||
|
||||
self.transport_sync.copy(resource, self.dst, '/tmp')
|
||||
sync_results = self.transport_sync.sync_all()
|
||||
# TODO Include file information in result
|
||||
self.verify_sync_results(sync_results)
|
||||
self.transport_sync.sync_all()
|
||||
|
||||
rst = self.transport_run.run(
|
||||
resource,
|
||||
|
@ -12,6 +12,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from solar.core.log import log
|
||||
from solar import errors
|
||||
|
||||
|
||||
class Executor(object):
|
||||
|
||||
@ -38,7 +41,13 @@ class Executor(object):
|
||||
|
||||
def run(self, transport):
|
||||
if self.valid:
|
||||
return self._executor(transport)
|
||||
result = self._executor(transport)
|
||||
if isinstance(result, tuple) and len(result) == 3:
|
||||
# TODO Include file information in result
|
||||
rc, out, err = result
|
||||
log.debug('RC %s OUT %s ERR %s', rc, out, err)
|
||||
if rc:
|
||||
raise errors.SolarError(err)
|
||||
|
||||
|
||||
class SolarRunResultWrp(object):
|
||||
@ -131,10 +140,8 @@ class SyncTransport(SolarTransport):
|
||||
self.preprocess(executor)
|
||||
|
||||
def run_all(self):
|
||||
rst = []
|
||||
for executor in self.executors:
|
||||
rst.append(executor.run(self))
|
||||
return rst
|
||||
executor.run(self)
|
||||
|
||||
def sync_all(self):
|
||||
"""Syncs all
|
||||
@ -144,9 +151,8 @@ class SyncTransport(SolarTransport):
|
||||
Could be someday changed to parallel thing.
|
||||
"""
|
||||
self.preprocess_all()
|
||||
rst = self.run_all()
|
||||
self.run_all()
|
||||
self.executors = [] # clear after all
|
||||
return rst
|
||||
|
||||
|
||||
class RunTransport(SolarTransport):
|
||||
|
@ -60,12 +60,8 @@ class OnAll(object):
|
||||
|
||||
def __get__(self, obj, objtype):
|
||||
def _inner(*args, **kwargs):
|
||||
results = []
|
||||
for transport in obj._used_transports:
|
||||
rst = getattr(transport, self._target)(*args, **kwargs)
|
||||
if rst:
|
||||
results.extend(rst)
|
||||
return results
|
||||
getattr(transport, self._target)(*args, **kwargs)
|
||||
return _inner
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user