def pushIt(lab, docker_dir, registry, base_registry, logger): ''' Set the label and tags on any newly built image and push it to the given registry. ''' df_list = [f for f in os.listdir(docker_dir) if os.path.isfile(os.path.join(docker_dir, f))] did_one = False for df in df_list: if df.endswith('.swp'): continue logger.debug('tag and push %s' % df) try: parts = df.split('.') image = '%s.%s.student' % (parts[1], parts[2]) except: logger.error('could not get image from %s' % df); continue image_exists, dumb, dumb1 = labutils.ImageExists(image, None) if image_exists: dfile_path = os.path.join(docker_dir,df) image_base = VersionInfo.getFrom(dfile_path, base_registry) base_id = VersionInfo.getImageId(image_base, True) framework_version = labutils.framework_version relabel(image, framework_version, image_base, base_id, registry, logger) logger.debug('Did relabel of %s using base_id %s' % (image, base_id)) did_one = True else: logger.debug('Have not built %s, nothing to push' % image) ''' Delete the lab images. Two reasons: 1) ensure we run registry or dockerHub copy, 2) don't push on a rebuild if not rebuilt. ''' if did_one: removelab.removeLab(lab)
def pushIt(lab, docker_dir, registry, logger): ''' Set the label and tags on any newly built image and push it to the given registry. ''' df_list = [ f for f in os.listdir(docker_dir) if os.path.isfile(os.path.join(docker_dir, f)) ] for df in df_list: if df.endswith('.swp'): continue logger.DEBUG('tag and push %s' % df) try: parts = df.split('.') image = '%s.%s.student' % (parts[1], parts[2]) except: logger.ERROR('could not get image from %s' % df) continue image_exists, dumb, dumb1 = labutils.ImageExists(image, None) if image_exists: dfile_path = os.path.join(docker_dir, df) image_base = VersionInfo.getFrom(dfile_path, registry) base_id = VersionInfo.getImageId(image_base, True) framework_version = labutils.framework_version relabel(image, framework_version, image_base, base_id, registry) else: logger.DEBUG('Have not built %s, nothing to push' % image) ''' Delete the lab images. Two reasons: 1) ensure we run authoritative copy, which is from the dockerhub. 2) don't push on a rebuild if not rebuilt. ''' removelab.removeLab(lab)
def pushIt(lab, docker_dir, role, registry, logger): #print('would push to %s' % registry) df_list = [f for f in os.listdir(docker_dir) if os.path.isfile(os.path.join(docker_dir, f))] for df in df_list: logger.DEBUG('tag and push %s' % df) try: parts = df.split('.') image = '%s.%s.%s' % (parts[1], parts[2], role) except: logger.ERROR('could not get image from %s' % df); continue image_exists, dumb, dumb1 = labutils.ImageExists(image, None) if image_exists: cmd = 'docker tag %s %s/%s' % (image, registry, image) os.system(cmd) cmd = 'docker push %s/%s' % (registry, image) os.system(cmd) ''' Delete the image. Two reasons: 1) ensure we run authoritative copy, which is from the dockerhub. 2) don't push on a rebuild if not rebuilt. ''' cmd = './remove-container.sh %s' % (image) os.system(cmd) else: logger.DEBUG('Have not built %s, nothing to push' % image)