Exemplo n.º 1
0
    def copy_files_to_image(self):
        # create image
        myfiles = []
        if "netboot/packages" in self.settings:
            if isinstance(self.settings['netboot/packages'], str):
                loopy = [self.settings["netboot/packages"]]
            else:
                loopy = self.settings["netboot/packages"]

        for x in loopy:
            if "netboot/packages/" + x + "/files" in self.settings:
                if isinstance(
                        type(self.settings['netboot/packages/' + x +
                                           '/files']), str):
                    myfiles.extend(self.settings["netboot/packages/" + x +
                                                 "/files"])
                else:
                    myfiles.append(self.settings["netboot/packages/" + x +
                                                 "/files"])

        if "netboot/extra_files" in self.settings:
            if isinstance(self.settings['netboot/extra_files'], list):
                myfiles.extend(self.settings["netboot/extra_files"])
            else:
                myfiles.append(self.settings["netboot/extra_files"])

        try:
            cmd([self.settings['controller_file'], 'image'] + myfiles,
                env=self.env)
        except CatalystError:
            self.unbind()
            raise CatalystError("netboot build aborting due to error.",
                                print_traceback=True)
Exemplo n.º 2
0
    def run(self):
        if "purgeonly" in self.settings["options"]:
            self.purge()
            return

        if "purge" in self.settings["options"]:
            self.purge()

        self.setup()
        print "Creating Portage tree snapshot "+self.settings["version_stamp"]+\
         " from "+self.settings["portdir"]+"..."

        mytmp = self.settings["tmp_path"]
        ensure_dirs(mytmp)

        cmd("rsync -a --delete --exclude /packages/ --exclude /distfiles/ " +
            "--exclude /local/ --exclude CVS/ --exclude .svn --filter=H_**/files/digest-* "
            + self.settings["portdir"] + "/ " + mytmp +
            "/%s/" % self.settings["repo_name"],
            "Snapshot failure",
            env=self.env)

        print "Compressing Portage snapshot tarball..."
        cmd("tar -I lbzip2 -cf " + self.settings["snapshot_path"] + " -C " +
            mytmp + " " + self.settings["repo_name"],
            "Snapshot creation failure",
            env=self.env)

        self.gen_contents_file(self.settings["snapshot_path"])
        self.gen_digest_file(self.settings["snapshot_path"])

        self.cleanup()
        print "snapshot: complete!"
Exemplo n.º 3
0
	def copy_files_to_image(self):
		# create image
		myfiles=[]
		if "netboot/packages" in self.settings:
			if isinstance(self.settings['netboot/packages'], str):
				loopy=[self.settings["netboot/packages"]]
			else:
				loopy=self.settings["netboot/packages"]

		for x in loopy:
			if "netboot/packages/"+x+"/files" in self.settings:
				if isinstance(type(self.settings['netboot/packages/'+x+'/files']), str):
					myfiles.extend(self.settings["netboot/packages/"+x+"/files"])
				else:
					myfiles.append(self.settings["netboot/packages/"+x+"/files"])

		if "netboot/extra_files" in self.settings:
			if isinstance(self.settings['netboot/extra_files'], list):
				myfiles.extend(self.settings["netboot/extra_files"])
			else:
				myfiles.append(self.settings["netboot/extra_files"])

		try:
			cmd([self.settings['controller_file'], 'image'] + myfiles,
				env=self.env)
		except CatalystError:
			self.unbind()
			raise CatalystError("netboot build aborting due to error.",
				print_traceback=True)
Exemplo n.º 4
0
    def copy_files_to_image(self):
        # create image
        myfiles = []
        if "netboot/packages" in self.settings:
            if type(self.settings["netboot/packages"]) == types.StringType:
                loopy = [self.settings["netboot/packages"]]
            else:
                loopy = self.settings["netboot/packages"]

        for x in loopy:
            if "netboot/packages/" + x + "/files" in self.settings:
                if type(self.settings["netboot/packages/" + x +
                                      "/files"]) == types.ListType:
                    myfiles.extend(self.settings["netboot/packages/" + x +
                                                 "/files"])
                else:
                    myfiles.append(self.settings["netboot/packages/" + x +
                                                 "/files"])

        if "netboot/extra_files" in self.settings:
            if type(self.settings["netboot/extra_files"]) == types.ListType:
                myfiles.extend(self.settings["netboot/extra_files"])
            else:
                myfiles.append(self.settings["netboot/extra_files"])

        try:
            cmd(self.settings["controller_file"]+\
             " image " + list_bashify(myfiles),env=self.env)
        except CatalystError:
            self.unbind()
            raise CatalystError("netboot build aborting due to error.",
                                print_traceback=True)
Exemplo n.º 5
0
def clear_dir(target,
              mode=0o755,
              chg_flags=False,
              remove=False,
              clear_nondir=True):
    '''Universal directory clearing function

	@target: string, path to be cleared or removed
	@mode: integer, desired mode to set the directory to
	@chg_flags: boolean used for FreeBSD hosts
	@remove: boolean, passed through to clear_dir()
	@return boolean
	'''
    log.debug('start: %s', target)
    if not target:
        log.debug('no target... returning')
        return False

    mystat = None
    if os.path.isdir(target) and not os.path.islink(target):
        log.notice('Emptying directory: %s', target)
        # stat the dir, delete the dir, recreate the dir and set
        # the proper perms and ownership
        try:
            log.debug('os.stat()')
            mystat = os.stat(target)
            # There's no easy way to change flags recursively in python
            if chg_flags and os.uname()[0] == "FreeBSD":
                cmd(['chflags', '-R', 'noschg', target])
            log.debug('shutil.rmtree()')
            shutil.rmtree(target)
        except Exception:
            log.error('clear_dir failed', exc_info=True)
            return False
    elif os.path.exists(target):
        if clear_nondir:
            log.debug("Clearing (unlinking) non-directory: %s", target)
            os.unlink(target)
        else:
            log.info('clear_dir failed: %s: is not a directory', target)
            return False
    else:
        log.debug("Condidtions not met to clear: %s", target)
        log.debug("                       isdir: %s", os.path.isdir(target))
        log.debug("                      islink: %s", os.path.islink(target))
        log.debug("                      exists: %s", os.path.exists(target))

    if not remove:
        log.debug('ensure_dirs()')
        ensure_dirs(target, mode=mode)
        if mystat:
            os.chown(target, mystat[ST_UID], mystat[ST_GID])
            os.chmod(target, mystat[ST_MODE])

    log.debug('DONE, returning True')
    return True
Exemplo n.º 6
0
	def create_netboot_files(self):
		# finish it all up
		try:
			cmd([self.settings['controller_file'], 'finish'], env=self.env)
		except CatalystError:
			self.unbind()
			raise CatalystError("netboot build aborting due to error.",
				print_traceback=True)
		# end
		log.notice('netboot: build finished !')
Exemplo n.º 7
0
 def create_netboot_files(self):
     # finish it all up
     try:
         cmd(self.settings["controller_file"] + " finish", env=self.env)
     except CatalystError:
         self.unbind()
         raise CatalystError("netboot build aborting due to error.",
                             print_traceback=True)
     # end
     print "netboot: build finished !"
Exemplo n.º 8
0
 def create_netboot_files(self):
     # finish it all up
     try:
         cmd([self.settings['controller_file'], 'finish'], env=self.env)
     except CatalystError:
         self.unbind()
         raise CatalystError("netboot build aborting due to error.",
                             print_traceback=True)
     # end
     log.notice('netboot: build finished !')
Exemplo n.º 9
0
	def run(self):
		if "purgeonly" in self.settings["options"]:
			self.purge()
			return True

		if "purge" in self.settings["options"]:
			self.purge()

		success = True
		self.setup()
		log.notice('Creating %s tree snapshot %s from %s ...',
			self.settings["repo_name"], self.settings['version_stamp'],
			self.settings['portdir'])

		mytmp=self.settings["tmp_path"]
		ensure_dirs(mytmp)

		cmd(['rsync', '-a', '--no-o', '--no-g', '--delete',
			'--exclude=/packages/',
			'--exclude=/distfiles/',
			'--exclude=/local/',
			'--exclude=CVS/',
			'--exclude=.svn',
			'--exclude=.git/',
			'--filter=H_**/files/digest-*',
			self.settings['portdir'] + '/',
			mytmp + '/' + self.settings['repo_name'] + '/'],
			env=self.env)

		log.notice('Compressing %s snapshot tarball ...', self.settings["repo_name"])
		compressor = CompressMap(self.settings["compress_definitions"],
			env=self.env, default_mode=self.settings['compression_mode'],
			comp_prog=self.settings["comp_prog"])
		infodict = compressor.create_infodict(
			source=self.settings["repo_name"],
			destination=self.settings["snapshot_path"],
			basedir=mytmp,
			filename=self.settings["snapshot_path"],
			mode=self.settings["compression_mode"],
			auto_extension=True
			)
		if not compressor.compress(infodict):
			success = False
			log.error('Snapshot compression failure')
		else:
			filename = '.'.join([self.settings["snapshot_path"],
				compressor.extension(self.settings["compression_mode"])])
			log.notice('Snapshot successfully written to %s', filename)
			self.gen_contents_file(filename)
			self.gen_digest_file(filename)
		if "keepwork" not in self.settings["options"]:
			self.cleanup()
		if success:
			log.info('snapshot: complete!')
		return success
Exemplo n.º 10
0
	def setup_overlay(self):
		if "autoresume" in self.settings["options"] \
		and self.resume.is_enabled("setup_overlay"):
			log.notice('Resume point detected, skipping setup_overlay operation...')
		else:
			if "netboot2/overlay" in self.settings:
				for x in self.settings["netboot2/overlay"]:
					if os.path.exists(x):
						cmd("rsync -a "+x+"/ "+\
							self.settings["chroot_path"] + self.settings["merge_path"], "netboot2/overlay: "+x+" copy failed.",env=self.env)
				self.resume.enable("setup_overlay")
Exemplo n.º 11
0
	def move_kernels(self):
		# we're done, move the kernels to builds/*
		# no auto resume here as we always want the
		# freshest images moved
		try:
			cmd([self.settings['controller_file'], 'final'], env=self.env)
			log.notice('Netboot Build Finished!')
		except CatalystError:
			self.unbind()
			raise CatalystError("Failed to move kernel images!",
				print_traceback=True)
Exemplo n.º 12
0
	def run(self):
		if "purgeonly" in self.settings["options"]:
			self.purge()
			return True

		if "purge" in self.settings["options"]:
			self.purge()

		success = True
		self.setup()
		log.notice('Creating %s tree snapshot %s from %s ...',
			self.settings["repo_name"], self.settings['version_stamp'],
			self.settings['portdir'])

		mytmp=self.settings["tmp_path"]
		ensure_dirs(mytmp)

		cmd(['rsync', '-a', '--no-o', '--no-g', '--delete',
			'--exclude=/packages/',
			'--exclude=/distfiles/',
			'--exclude=/local/',
			'--exclude=CVS/',
			'--exclude=.svn',
			'--filter=H_**/files/digest-*',
			self.settings['portdir'] + '/',
			mytmp + '/' + self.settings['repo_name'] + '/'],
			env=self.env)

		log.notice('Compressing %s snapshot tarball ...', self.settings["repo_name"])
		compressor = CompressMap(self.settings["compress_definitions"],
			env=self.env, default_mode=self.settings['compression_mode'],
			comp_prog=self.settings["comp_prog"])
		infodict = compressor.create_infodict(
			source=self.settings["repo_name"],
			destination=self.settings["snapshot_path"],
			basedir=mytmp,
			filename=self.settings["snapshot_path"],
			mode=self.settings["compression_mode"],
			auto_extension=True
			)
		if not compressor.compress(infodict):
			success = False
			log.error('Snapshot compression failure')
		else:
			filename = '.'.join([self.settings["snapshot_path"],
				compressor.extension(self.settings["compression_mode"])])
			log.notice('Snapshot successfully written to %s', filename)
			self.gen_contents_file(filename)
			self.gen_digest_file(filename)
		if "keepwork" not in self.settings["options"]:
			self.cleanup()
		if success:
			log.info('snapshot: complete!')
		return success
Exemplo n.º 13
0
	def build_busybox(self):
		# build busybox
		if "netboot/busybox_config" in self.settings:
			mycmd = [self.settings['netboot/busybox_config']]
		else:
			mycmd = []
		try:
			cmd([self.settings['controller_file'], 'busybox'] + mycmd, env=self.env)
		except CatalystError:
			self.unbind()
			raise CatalystError("netboot build aborting due to error.",
				print_traceback=True)
Exemplo n.º 14
0
	def run_local(self):
		# tinderbox
		# example call: "grp.sh run xmms vim sys-apps/gleep"
		try:
			if os.path.exists(self.settings["controller_file"]):
				cmd(self.settings["controller_file"]+" run "+\
				list_bashify(self.settings["tinderbox/packages"]),"run script failed.",env=self.env)

		except CatalystError:
			self.unbind()
			raise CatalystError("Tinderbox aborting due to error.",
				print_traceback=True)
Exemplo n.º 15
0
def clear_dir(target, mode=0o755, chg_flags=False, remove=False,
		clear_nondir=True):
	'''Universal directory clearing function

	@target: string, path to be cleared or removed
	@mode: integer, desired mode to set the directory to
	@chg_flags: boolean used for FreeBSD hosts
	@remove: boolean, passed through to clear_dir()
	@return boolean
	'''
	log.debug('start: %s', target)
	if not target:
		log.debug('no target... returning')
		return False

	mystat = None
	if os.path.isdir(target) and not os.path.islink(target):
		log.notice('Emptying directory: %s', target)
		# stat the dir, delete the dir, recreate the dir and set
		# the proper perms and ownership
		try:
			log.debug('os.stat()')
			mystat = os.stat(target)
			# There's no easy way to change flags recursively in python
			if chg_flags and os.uname()[0] == "FreeBSD":
				cmd(['chflags', '-R', 'noschg', target])
			log.debug('shutil.rmtree()')
			shutil.rmtree(target)
		except Exception:
			log.error('clear_dir failed', exc_info=True)
			return False
	elif os.path.exists(target):
		if clear_nondir:
			log.debug("Clearing (unlinking) non-directory: %s", target)
			os.unlink(target)
		else:
			log.info('clear_dir failed: %s: is not a directory', target)
			return False
	else:
		log.debug("Condidtions not met to clear: %s", target)
		log.debug("                       isdir: %s", os.path.isdir(target))
		log.debug("                      islink: %s", os.path.islink(target))
		log.debug("                      exists: %s", os.path.exists(target))

	if not remove:
		log.debug('ensure_dirs()')
		ensure_dirs(target, mode=mode)
		if mystat:
			os.chown(target, mystat[ST_UID], mystat[ST_GID])
			os.chmod(target, mystat[ST_MODE])

	log.debug('DONE, returning True')
	return True
Exemplo n.º 16
0
 def setup_overlay(self):
     if "autoresume" in self.settings["options"] \
     and self.resume.is_enabled("setup_overlay"):
         log.notice(
             'Resume point detected, skipping setup_overlay operation...')
     else:
         if "netboot2/overlay" in self.settings:
             for x in self.settings["netboot2/overlay"]:
                 if os.path.exists(x):
                     cmd("rsync -a "+x+"/ "+\
                      self.settings["chroot_path"] + self.settings["merge_path"], "netboot2/overlay: "+x+" copy failed.",env=self.env)
             self.resume.enable("setup_overlay")
Exemplo n.º 17
0
	def build_busybox(self):
		# build busybox
		if "netboot/busybox_config" in self.settings:
			mycmd = self.settings["netboot/busybox_config"]
		else:
			mycmd = ""
		try:
			cmd(self.settings["controller_file"]+" busybox "+ mycmd,env=self.env)
		except CatalystError:
			self.unbind()
			raise CatalystError("netboot build aborting due to error.",
				print_traceback=True)
Exemplo n.º 18
0
    def run_local(self):
        # tinderbox
        # example call: "grp.sh run xmms vim sys-apps/gleep"
        try:
            if os.path.exists(self.settings["controller_file"]):
                cmd(self.settings["controller_file"]+" run "+\
                list_bashify(self.settings["tinderbox/packages"]),"run script failed.",env=self.env)

        except CatalystError:
            self.unbind()
            raise CatalystError("Tinderbox aborting due to error.",
                                print_traceback=True)
Exemplo n.º 19
0
	def run_local(self):
		# tinderbox
		# example call: "grp.sh run xmms vim sys-apps/gleep"
		try:
			if os.path.exists(self.settings["controller_file"]):
				cmd([self.settings['controller_file'], 'run'] +
					self.settings['tinderbox/packages'], env=self.env)

		except CatalystError:
			self.unbind()
			raise CatalystError("Tinderbox aborting due to error.",
				print_traceback=True)
Exemplo n.º 20
0
	def run_local(self):
		for pkgset in self.settings["grp"]:
			# example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
			mypackages=list_bashify(self.settings["grp/"+pkgset+"/packages"])
			try:
				cmd(self.settings["controller_file"]+" run "+self.settings["grp/"+pkgset+"/type"]\
					+" "+pkgset+" "+mypackages,env=self.env)

			except CatalystError:
				self.unbind()
				raise CatalystError("GRP build aborting due to error.",
					print_traceback=True)
Exemplo n.º 21
0
	def setup_overlay(self):
		if "autoresume" in self.settings["options"] \
		and self.resume.is_enabled("setup_overlay"):
			log.notice('Resume point detected, skipping setup_overlay operation...')
		else:
			if "netboot2/overlay" in self.settings:
				for x in self.settings["netboot2/overlay"]:
					if os.path.exists(x):
						cmd(['rsync', '-a', x + '/',
							self.settings['chroot_path'] + self.settings['merge_path']],
							env=self.env)
				self.resume.enable("setup_overlay")
Exemplo n.º 22
0
    def unpack(self):
        _unpack = True
        display_msg = None

        clst_unpack_hash = self.resume.get("unpack")

        if os.path.isdir(self.settings["source_path"]):
            unpack_cmd = "rsync -a --delete " + self.settings[
                "source_path"] + " " + self.settings["chroot_path"]
            display_msg="\nStarting rsync from "+self.settings["source_path"]+"\nto "+\
             self.settings["chroot_path"]+" (This may take some time) ...\n"
            error_msg = "Rsync of " + self.settings[
                "source_path"] + " to " + self.settings[
                    "chroot_path"] + " failed."
            invalid_snapshot = False

        if "autoresume" in self.settings["options"]:
            if os.path.isdir(self.settings["source_path"]) and \
             self.resume.is_enabled("unpack"):
                print "Resume point detected, skipping unpack operation..."
                _unpack = False
            elif "source_path_hash" in self.settings:
                if self.settings["source_path_hash"] != clst_unpack_hash:
                    invalid_snapshot = True

        if _unpack:
            self.mount_safety_check()
            if invalid_snapshot:
                print "No Valid Resume point detected, cleaning up  ..."
                self.clear_autoresume()
                self.clear_chroot()

            ensure_dirs(self.settings["chroot_path"] + "/tmp", mode=1777)

            if "pkgcache" in self.settings["options"]:
                ensure_dirs(self.settings["pkgcache_path"], mode=0755)

            if not display_msg:
                raise CatalystError(
                    "Could not find appropriate source.\n"
                    "Please check the 'source_subpath' "
                    "setting in the spec file.",
                    print_traceback=True)

            print display_msg
            cmd(unpack_cmd, error_msg, env=self.env)

            if "source_path_hash" in self.settings:
                self.resume.enable("unpack",
                                   data=self.settings["source_path_hash"])
            else:
                self.resume.enable("unpack")
Exemplo n.º 23
0
	def set_target_path(self):
		self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+\
			self.settings["target_subpath"])
		if "autoresume" in self.settings["options"] \
			and self.resume.is_enabled("setup_target_path"):
			log.notice('Resume point detected, skipping target path setup operation...')
		else:
			# first clean up any existing target stuff
			if os.path.isfile(self.settings["target_path"]):
				cmd("rm -f "+self.settings["target_path"], \
					"Could not remove existing file: "+self.settings["target_path"],env=self.env)
				self.resume.enable("setup_target_path")
		ensure_dirs(self.settings["storedir"]+"/builds/")
Exemplo n.º 24
0
    def run_local(self):
        for pkgset in self.settings["grp"]:
            # example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
            mypackages = list_bashify(self.settings["grp/" + pkgset +
                                                    "/packages"])
            try:
                cmd(self.settings["controller_file"]+" run "+self.settings["grp/"+pkgset+"/type"]\
                 +" "+pkgset+" "+mypackages,env=self.env)

            except CatalystError:
                self.unbind()
                raise CatalystError("GRP build aborting due to error.",
                                    print_traceback=True)
Exemplo n.º 25
0
	def run_local(self):
		for pkgset in self.settings["grp"]:
			# example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
			try:
				cmd([self.settings['controller_file'], 'run',
					self.settings['grp/' + pkgset + '/type'],
					pkgset] + self.settings['grp/' + pkgset + '/packages'],
					env=self.env)

			except CatalystError:
				self.unbind()
				raise CatalystError("GRP build aborting due to error.",
					print_traceback=True)
Exemplo n.º 26
0
    def run_local(self):
        # tinderbox
        # example call: "grp.sh run xmms vim sys-apps/gleep"
        try:
            if os.path.exists(self.settings["controller_file"]):
                cmd([self.settings['controller_file'], 'run'] +
                    self.settings['tinderbox/packages'],
                    env=self.env)

        except CatalystError:
            self.unbind()
            raise CatalystError("Tinderbox aborting due to error.",
                                print_traceback=True)
Exemplo n.º 27
0
 def build_busybox(self):
     # build busybox
     if "netboot/busybox_config" in self.settings:
         mycmd = [self.settings['netboot/busybox_config']]
     else:
         mycmd = []
     try:
         cmd([self.settings['controller_file'], 'busybox'] + mycmd,
             env=self.env)
     except CatalystError:
         self.unbind()
         raise CatalystError("netboot build aborting due to error.",
                             print_traceback=True)
Exemplo n.º 28
0
    def run_local(self):
        for pkgset in self.settings["grp"]:
            # example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
            try:
                cmd([
                    self.settings['controller_file'], 'run',
                    self.settings['grp/' + pkgset + '/type'], pkgset
                ] + self.settings['grp/' + pkgset + '/packages'],
                    env=self.env)

            except CatalystError:
                self.unbind()
                raise CatalystError("GRP build aborting due to error.",
                                    print_traceback=True)
Exemplo n.º 29
0
 def set_target_path(self):
     self.settings["target_path"] = normpath(
         self.settings["storedir"] + "/builds/" +
         self.settings["target_subpath"] + '/')
     if "autoresume" in self.settings["options"] \
      and self.resume.is_enabled("setup_target_path"):
         print "Resume point detected, skipping target path setup operation..."
     else:
         # first clean up any existing target stuff
         if os.path.exists(self.settings["target_path"]):
             cmd("rm -rf "+self.settings["target_path"],\
              "Could not remove existing directory: "+self.settings["target_path"],env=self.env)
             self.resume.enable("setup_target_path")
         ensure_dirs(self.settings["target_path"])
Exemplo n.º 30
0
	def run(self):
		if "purgeonly" in self.settings["options"]:
			self.purge()
			return True

		if "purge" in self.settings["options"]:
			self.purge()

		success = True
		self.setup()
		log.notice('Creating Portage tree snapshot %s from %s ...',
			self.settings['version_stamp'], self.settings['portdir'])

		mytmp=self.settings["tmp_path"]
		ensure_dirs(mytmp)

		target_snapshot = self.settings["portdir"] + "/ " + mytmp + "/%s/" % self.settings["repo_name"]
		cmd("rsync -a --no-o --no-g --delete --exclude /packages/ --exclude /distfiles/ " +
			"--exclude /local/ --exclude CVS/ --exclude .svn --filter=H_**/files/digest-* " +
			target_snapshot,
			"Snapshot failure", env=self.env)

		log.notice('Compressing Portage snapshot tarball ...')
		compressor = CompressMap(self.settings["compress_definitions"],
			env=self.env, default_mode=self.settings['compression_mode'])
		infodict = compressor.create_infodict(
			source=self.settings["repo_name"],
			destination=self.settings["snapshot_path"],
			basedir=mytmp,
			filename=self.settings["snapshot_path"],
			mode=self.settings["compression_mode"],
			auto_extension=True
			)
		if not compressor.compress(infodict):
			success = False
			log.error('Snapshot compression failure')
		else:
			filename = '.'.join([self.settings["snapshot_path"],
				compressor.extension(self.settings["compression_mode"])])
			log.notice('Snapshot successfully written to %s', filename)
			self.gen_contents_file(filename)
			self.gen_digest_file(filename)

		self.cleanup()
		if success:
			log.info('snapshot: complete!')
		return success
Exemplo n.º 31
0
    def copy_files_to_image(self):
        # copies specific files from the buildroot to merge_path
        myfiles = []

        # check for autoresume point
        if "autoresume" in self.settings["options"] \
                and self.resume.is_enabled("copy_files_to_image"):
            log.notice(
                'Resume point detected, skipping target path setup operation...'
            )
        else:
            if "netboot/packages" in self.settings:
                if isinstance(self.settings['netboot/packages'], str):
                    loopy = [self.settings["netboot/packages"]]
                else:
                    loopy = self.settings["netboot/packages"]

            for x in loopy:
                if "netboot/packages/" + x + "/files" in self.settings:
                    if isinstance(
                            self.settings['netboot/packages/' + x + '/files'],
                            list):
                        myfiles.extend(self.settings["netboot/packages/" + x +
                                                     "/files"])
                    else:
                        myfiles.append(self.settings["netboot/packages/" + x +
                                                     "/files"])

            if "netboot/extra_files" in self.settings:
                if isinstance(self.settings['netboot/extra_files'], list):
                    myfiles.extend(self.settings["netboot/extra_files"])
                else:
                    myfiles.append(self.settings["netboot/extra_files"])

            try:
                cmd([self.settings['controller_file'], 'image'] + myfiles,
                    env=self.env)
            except CatalystError:
                self.unbind()
                raise CatalystError("Failed to copy files to image!",
                                    print_traceback=True)

            self.resume.enable("copy_files_to_image")
Exemplo n.º 32
0
	def copy_files_to_image(self):
		# copies specific files from the buildroot to merge_path
		myfiles=[]

		# check for autoresume point
		if "autoresume" in self.settings["options"] \
			and self.resume.is_enabled("copy_files_to_image"):
			log.notice('Resume point detected, skipping target path setup operation...')
		else:
			if "netboot2/packages" in self.settings:
				if isinstance(self.settings['netboot2/packages'], str):
					loopy=[self.settings["netboot2/packages"]]
				else:
					loopy=self.settings["netboot2/packages"]

			for x in loopy:
				if "netboot2/packages/"+x+"/files" in self.settings:
					if isinstance(self.settings['netboot2/packages/'+x+'/files'], list):
						myfiles.extend(self.settings["netboot2/packages/"+x+"/files"])
					else:
						myfiles.append(self.settings["netboot2/packages/"+x+"/files"])

			if "netboot2/extra_files" in self.settings:
				if isinstance(self.settings['netboot2/extra_files'], list):
					myfiles.extend(self.settings["netboot2/extra_files"])
				else:
					myfiles.append(self.settings["netboot2/extra_files"])

			try:
				cmd([self.settings['controller_file'], 'image'] +
					myfiles, env=self.env)
			except CatalystError:
				self.unbind()
				raise CatalystError("Failed to copy files to image!",
					print_traceback=True)

			self.resume.enable("copy_files_to_image")
Exemplo n.º 33
0
 def move_kernels(self):
     # we're done, move the kernels to builds/*
     # no auto resume here as we always want the
     # freshest images moved
     cmd([self.settings['controller_file'], 'final'], env=self.env)
     log.notice('Netboot Build Finished!')