Пример #1
0
def export_cmd(jail):
    """Make a recursive snapshot of the jail and export to a file."""
    jails, paths = IOCList("uuid").list_datasets()
    _jail = {
        tag: uuid
        for (tag, uuid) in jails.items()
        if uuid.startswith(jail) or tag == jail
    }

    if len(_jail) == 1:
        tag, uuid = next(iter(_jail.items()))
        path = paths[tag]
    elif len(_jail) > 1:
        lgr.error("Multiple jails found for" " {}:".format(jail))
        for t, u in sorted(_jail.items()):
            lgr.error("  {} ({})".format(u, t))
        raise RuntimeError()
    else:
        lgr.critical("{} not found!".format(jail))
        exit(1)

    status, _ = IOCList().list_get_jid(uuid)
    if status:
        lgr.critical("{} ({}) is runnning, stop the jail before "
                     "exporting!".format(uuid, tag))
        exit(1)

    IOCImage(callback=callback).export_jail(uuid, tag, path)
Пример #2
0
    def _import(self, job, jail):
        """Imports jail from zip file"""
        from iocage.lib.ioc_image import IOCImage

        IOCImage().import_jail(jail)

        return True
Пример #3
0
    def export(self, job, jail):
        """Exports jail to zip file"""
        uuid, path, _ = self.check_jail_existence(jail)
        status, jid = IOCList.list_get_jid(uuid)
        started = False

        if status:
            self.stop(jail)
            started = True

        IOCImage().export_jail(uuid, path)

        if started:
            self.start(jail)

        return True
Пример #4
0
    def export(self, job, jail):
        """Exports jail to zip file"""
        from iocage.lib.ioc_image import IOCImage
        tag, uuid, path = self.check_jail_existence(jail)
        status, jid = IOCList.list_get_jid(uuid)
        started = False

        if status:
            self.stop(jail)
            started = True

        IOCImage().export_jail(uuid, tag, path)

        if started:
            self.start(jail)

        return True
Пример #5
0
    def _import(self, job, jail):
        """Imports jail from zip file"""

        IOCImage().import_jail(jail)

        return True
Пример #6
0
def import_cmd(jail):
    """Import from an iocage export."""
    IOCImage(callback=callback).import_jail(jail)