'Delete any previously built pxelinux.cfg tree and virt tree info and then create
directories.
Note: for SELinux reasons, some information goes in /tftpboot, some in
/var/www/cobbler and some must be duplicated in both.  This is because
PXE needs tftp, and automatic installation and Virt operations need http.
Only the kernel and initrd images are duplicated, which is unfortunate,
though SELinux won\'t let me give them two contexts, so symlinks are not
a solution.  *Otherwise* duplication is minimal.'

def clean_trees(self):

    for x in os.listdir(self.settings.webdir):
        path = os.path.join(self.settings.webdir, x)
        if os.path.isfile(path):
            if (not x.endswith('.py')):
                utils.rmfile(path, logger=self.logger)
        if os.path.isdir(path):
            if (x not in self.settings.webdir_whitelist):
                utils.rmtree(path, logger=self.logger)
            if (x in ['autoinstall_templates', 'autoinstall_templates_sys', 'images', 'systems', 'distros', 'profiles', 'repo_profile', 'repo_system', 'rendered']):
                utils.rmtree_contents(path, logger=self.logger)
    self.make_tftpboot()
    utils.rmtree_contents(self.pxelinux_dir, logger=self.logger)
    utils.rmtree_contents(self.grub_dir, logger=self.logger)
    utils.rmtree_contents(self.grub2_dir, logger=self.logger)
    utils.rmtree_contents(self.images_dir, logger=self.logger)
    utils.rmtree_contents(self.yaboot_bin_dir, logger=self.logger)
    utils.rmtree_contents(self.yaboot_cfg_dir, logger=self.logger)
    utils.rmtree_contents(self.rendered_dir, logger=self.logger)
