def test_clean():
    # Unless we change directory (not sure why) this will crash pytest.
    os.chdir("/")

    IOCClean().clean_jails()
    IOCClean().clean_all()

    assert True == True
Exemple #2
0
    def clean(self, ds_type):
        """Cleans all iocage datasets of ds_type"""

        if ds_type == "JAIL":
            IOCClean().clean_jails()
        elif ds_type == "ALL":
            IOCClean().clean_all()
        elif ds_type == "TEMPLATE":
            IOCClean().clean_templates()

        return True
Exemple #3
0
    def clean(self, ds_type):
        """Cleans all iocage datasets of ds_type"""
        from iocage.lib.ioc_clean import IOCClean

        if ds_type == "JAIL":
            IOCClean().clean_jails()
        elif ds_type == "ALL":
            IOCClean().clean_all()
        elif ds_type == "RELEASE":
            pass
        elif ds_type == "TEMPLATE":
            IOCClean().clean_templates()

        return True
Exemple #4
0
def clean_cmd(force, dataset_type):
    """Calls the correct destroy function."""
    lgr = ioc_logger.Logger('ioc_cli_clean').getLogger()

    if dataset_type == "jails":
        if not force:
            lgr.warning("\nThis will destroy ALL jails"
                        " and any snapshots on a RELEASE, including "
                        "templates!")
            if not click.confirm("\nAre you sure?"):
                exit()

        IOCClean().clean_jails()
        lgr.info("All iocage jail datasets have been destroyed.")
    elif dataset_type == "all":
        if not force:
            lgr.warning("\nThis will destroy ALL iocage data!")
            if not click.confirm("\nAre you sure?"):
                exit()

        IOCClean().clean_all()
        lgr.info("All iocage datasets have been destroyed.")
    elif dataset_type == "release":
        pass
    elif dataset_type == "template":
        if not force:
            lgr.warning("This will destroy ALL templates"
                        " and jails created from them!")
            if not click.confirm("\nAre you sure?"):
                exit()

        IOCClean().clean_templates()
        lgr.info("All iocage template datasets have been destroyed.")
    else:
        lgr.critical("Please specify a dataset type to clean!")
        exit(1)