def test_group_reuse(): """We can re-use a group.""" grp = Group([ Docker('py35', image='python:3.5'), Docker('py36', image='python:3.6') ]) with grp: grp.call(time.time) grp.call(time.time)
"""Exercise the chopsticks parallel API.""" from __future__ import print_function from chopsticks.tunnel import Local, Docker from chopsticks.group import Group import chopsticks.facts import time group = Group([ Local('worker-1'), 'byzantium', 'office', Docker('docker-1') ]) for host, t in group.call(time.time).successful(): print('Time on %s:' % host, t) print() for host, addr in group.call(chopsticks.facts.ip).successful(): print('%s ip:' % host, addr) print() for host, ver in group.call(chopsticks.facts.python_version).successful(): print('%s Python version:' % host, tuple(ver))
"""Exercise the chopsticks Docker connectivity.""" import sys from chopsticks.facts import python_version if __name__ == '__main__': from chopsticks.tunnel import Docker from chopsticks.group import Group group = Group([ Docker('worker-1', image='python:3.4'), Docker('worker-2', image='python:3.5'), Docker('worker-3', image='python:3.6'), ]) for host, python_version in group.call(python_version).items(): print('%s Python version:' % host, python_version)
"""Exercise the chopsticks Docker connectivity.""" import sys from chopsticks.facts import python_version from funcs import print_is_function def hello(): print >> sys.stderr, "hello" return "hello chopsticks" if __name__ == '__main__': from chopsticks.tunnel import Docker from chopsticks.group import Group group = Group([ Docker('worker-1'), # Docker('worker-1', image='python:3.4'), # Docker('worker-2', image='python:3.5'), # Docker('worker-3', image='python:3.6'), ]) for host, result in group.call(print_is_function).items(): print(host, result) # for host, python_version in group.call(python_version).items(): # print('%s Python version:' % host, python_version)
"""Exercise the chopsticks parallel API.""" from __future__ import print_function from chopsticks.tunnel import Local, Docker from chopsticks.group import Group import chopsticks.facts import time group = Group([Local('worker-1'), 'byzantium', 'office', Docker('docker-1')]) for host, t in group.call(time.time).successful(): print('Time on %s:' % host, t) print() for host, addr in group.call(chopsticks.facts.ip).successful(): print('%s ip:' % host, addr) print() for host, ver in group.call(chopsticks.facts.python_version).successful(): print('%s Python version:' % host, tuple(ver))
from __future__ import print_function from chopsticks.tunnel import Tunnel, Docker, Local from chopsticks.group import Group from chopsticks.helpers import check_output from chopsticks.facts import python_version t = Docker('test-1') res = t.put('/usr/share/common-licenses/GPL', 'blah', mode=0o755) print(res) print(t.call(python_version)) print(t.call(check_output, ['ls', '-l', res['remote_path']])) g = Group([t, Docker('test-2')]) for host, res in g.put('/usr/share/common-licenses/GPL').iteritems(): print(host, res) for host, res in g.call(check_output, ['ls', '-l', '/tmp']).iteritems(): print(host) print(res)
from __future__ import print_function from chopsticks.tunnel import Tunnel, Docker, Local from chopsticks.group import Group from chopsticks.helpers import check_output from chopsticks.facts import python_version t = Docker('test-1') res = t.put('/usr/share/common-licenses/GPL', 'blah', mode=0o755) print(res) print(t.call(python_version)) print(t.call(check_output, ['ls', '-l', res['remote_path']])) g = Group([t, Docker('test-2')]) for host, res in g.put('/usr/share/common-licenses/GPL').successful(): print(host, res) for host, res in g.call(check_output, ['ls', '-l', '/tmp']).successful(): print(host) print(res)