github.com/ahjdzx/deis@v1.1.1/controller/scheduler/mock.py (about) 1 2 import json 3 from cStringIO import StringIO 4 5 6 class MockSchedulerClient(object): 7 8 def __init__(self, target, auth, options, pkey): 9 self.target = target 10 self.auth = auth 11 self.options = options 12 self.pkey = pkey 13 14 # container api 15 16 def create(self, name, image, command, **kwargs): 17 """ 18 Create a new container 19 """ 20 return 21 22 def start(self, name): 23 """ 24 Start a container 25 """ 26 return 27 28 def stop(self, name): 29 """ 30 Stop a container 31 """ 32 return 33 34 def destroy(self, name): 35 """ 36 Destroy a container 37 """ 38 return 39 40 def run(self, name, image, entrypoint, command): 41 """ 42 Run a one-off command 43 """ 44 # dump input into a json object for testing purposes 45 return 0, json.dumps({'name': name, 46 'image': image, 47 'entrypoint': entrypoint, 48 'command': command}) 49 50 def attach(self, name): 51 """ 52 Attach to a job's stdin, stdout and stderr 53 """ 54 return StringIO(), StringIO(), StringIO() 55 56 SchedulerClient = MockSchedulerClient