def deletesnapshot(dClusterId, tag=None): images = docker.images() for image in images: if image.repository.startswith(dClusterId) and tag is None: cmdutil.execute(["docker", "rmi", image.repository + ":" + image.tag]) elif image.repository.startswith(dClusterId + "/") and tag == image.tag: cmdutil.execute(["docker", "rmi", image.repository + ":" + image.tag])
def submit_data(self): str_command = '' for key in self.submit: if isinstance(self.submit[key], dict) == False: data = self.submit[key].get() if data != '': if key == 'image': continue else: str_command = str_command + " " + key + " " + self.submit[ key].get() else: temp = '' for key_1 in self.submit[key]: data = self.submit[key][key_1].get() if data == "": temp = '' elif key_1.find('source_') != -1: temp = " " + key + ' ' + data else: temp = temp + ':' + data if temp != '': str_command = str_command + " " + temp obj_docker = docker.images() obj_docker.docker_run(str_command, self.submit['image'].get()) self.destroy()
def check_image_name(docker, iname): print 'check_image_name,', if iname in ' '.join([z for z in [y.encode('utf-8').split(':')[0] for x in docker.images() for y in x['RepoTags']] if '<none>' not in z]): print '"%s" image exist' % iname return True else: print '"%s" image not exist' % iname return False
def del_image(self): is_del = tkinter.messagebox.askokcancel('敏感警告','你将删除镜像,是否执行') if is_del == False: return False iamges = docker.images() CheckbuttonValue = self.tableVies.get_check() for key in CheckbuttonValue: if CheckbuttonValue[key].get()=="1": iamges.del_image(key) self.resert_images()
def remove_dangling(docker): try: dangling_images_ids = \ [id['Id'].encode('utf-8') for id in docker.images(filters={'dangling': True})] for id in dangling_images_ids: docker.remove_image(image=id, force=True, noprune=False) print '%s image removed' % id except Exception,e: print 'type: %s' % type(e) print 'args: %s' % e.args print str(e)
def remove_dangling(docker): try: dangling_images_ids = \ [id['Id'].encode('utf-8') for id in docker.images(filters={'dangling': True})] for id in dangling_images_ids: docker.remove_image(image=id, force=True, noprune=False) print '%s image removed' % id except Exception, e: print 'type: %s' % type(e) print 'args: %s' % e.args print str(e)
def check_image_name(docker, iname): print 'check_image_name,', if iname in ' '.join([ z for z in [ y.encode('utf-8').split(':')[0] for x in docker.images() for y in x['RepoTags'] ] if '<none>' not in z ]): print '"%s" image exist' % iname return True else: print '"%s" image not exist' % iname return False
def ensure_docker_image(self, docker, image_name): images = docker.images() for image in images: if image['RepoTags'][0] == image_name: return logging.info("Image '%s' not found on '%s'. Building.", image_name, docker.base_url) result = docker.pull(image_name, stream=True) for line in result: logging.info(line)
def check_image_name(docker, service): print "check_image_name,", # pwd = os.path.dirname(os.path.realpath(__file__)).split('/')[-1] # folder = pwd cwd = os.getcwd().split("/")[-1] folder = cwd iname = "%s_%s" % (folder, service) if iname in [ z for z in [y.encode("utf-8").split(":")[0] for x in docker.images() for y in x["RepoTags"]] if "<none>" not in z ]: print '"%s" image exist' % iname return (True, iname) else: print '"%s" image not exist' % iname return (False, None)
def check_image_name(docker, service): print 'check_image_name,', #pwd = os.path.dirname(os.path.realpath(__file__)).split('/')[-1] #folder = pwd cwd = os.getcwd().split('/')[-1] folder = cwd iname = "%s_%s" % (folder, service) if iname in [ z for z in [ y.encode('utf-8').split(':')[0] for x in docker.images() for y in x['RepoTags'] ] if '<none>' not in z ]: print '"%s" image exist' % iname return (True, iname) else: print '"%s" image not exist' % iname return (False, None)
def remove_images(docker, composefile_name, dangling=False): try: if dangling: dangling_images_ids = [id["Id"].encode("utf-8") for id in docker.images(filters={"dangling": True})] for id in dangling_images_ids: docker.remove_image(image=id, force=True, noprune=False) print "%s image removed" % id with open(composefile_name, "r") as ymlfile: cfg = yaml.load(ymlfile) for service in cfg: exist, iname = check_image_name(docker, service) if exist: docker.remove_image(image=iname, force=True, noprune=False) print "%s image removed" % iname except Exception, e: print "type: %s" % type(e) print "args: %s" % e.args print str(e)
def remove_images(docker, composefile_name, dangling=False): try: if dangling: dangling_images_ids = \ [id['Id'].encode('utf-8') for id in docker.images(filters={'dangling': True})] for id in dangling_images_ids: docker.remove_image(image=id, force=True, noprune=False) print '%s image removed' % id with open(composefile_name, 'r') as ymlfile: cfg = yaml.load(ymlfile) for service in cfg: exist, iname = check_image_name(docker, service) if exist: docker.remove_image(image=iname, force=True, noprune=False) print '%s image removed' % iname except Exception, e: print 'type: %s' % type(e) print 'args: %s' % e.args print str(e)
def get_tag(self, image): data = docker.images().image_info(image) return data['RepoTags'][0]
def admin_home(): images = sorted(docker.images(), key=lambda i: i['repository']) processes = sorted(docker.ps(), key=lambda p: p['image']) return render_template('admin.html', images=images, processes=processes, current_tab='admin')