예제 #1
0
 def run(self, *args, **kwargs):
     build = kwargs.pop('build', None)
     image = kwargs.get('image', None)
     if build:
         L.info("Building image %s on node %s"%(image, self.name))
         self.call_docker("build %s"%build)
     if image:
         tagged = ':' in image and image or '%s:latest'%image
         if not tagged in self.local_images():
             L.info("Can't find image %s, attempting to pull..."%image)
             self.call_docker("pull %s"%image)
         elif ':' in image and image.endswith('latest'):
             L.info("Image %s tagged 'latest', updating..."%image)
             try: self.call_docker("pull %s"%image)
             except: pass
         kwargs['image'] = image
     command_line = 'docker %s run %s %s'%(self.node_connect_str,
         image, kwargs.get('command','') or '')
     L.v("Using docker-py API to create container, you can run this --")
     L.v(command_line)
     dns = kwargs.pop('dns', None)
     dns_search = kwargs.pop('dns_search', None)
     privileged = kwargs.pop('privileged', '') == 'ceph' and 'ceph/' in image
     container = self.client.create_container(*args, **kwargs)
     return self.client.start(container, dns=dns, privileged=privileged), container
예제 #2
0
파일: pipe.py 프로젝트: nickatnight/srvrdj
def call(command):
    L.v("$ %s"%command)
    return subprocess.check_output(command, shell=True).strip()