def list_sites(self, directory, site=''): """ List site into sites-available or site-enabled directory. directory is required and must be set in conf.d/*/services.conf. In this case, * must be your env. site could be empty or glob characters. """ config = {} # Filesystem operations callback (fsh) is required. if not hasattr(self, 'fsh'): self.load_callbacks('fsh') config = __config.get_config('services.conf', [self.systemtype]).get_section('nginx')[1] valid_directory = ['available', 'enabled'] if directory not in valid_directory: __LOG.log_die("%s: not a valid path." % (directory)) config_path_site = config["path_sites_%s" % (directory)] site_exist = self.fsh.file_exists("%s" % (config_path_site.rstrip('/') + '/' + site)) if not site or __common.has_magic(site) is True: out = self.fsh.list_files("%s" % ( config_path_site.rstrip('/') + '/' + site)) return out else: if site_exist is False: __LOG.log_die("File %s: not found in %s" % (site, config_path_site)) else: out = self.fsh.list_files("%s" % ( config_path_site.rstrip('/') + '/' + site)) return out, site, site_exist
def list_sites(self, directory, site=''): """ List site into sites-available or site-enabled directory. ``directory`` is required and must be set in conf.d/*/services.conf. In this case, ``*`` must be your env. ``site`` could be empty or wildcard for now, glob characters are not allowed right now. ToDo: accept glob character to ``site``. """ config = {} # Filesystem operations callback (fsh) is required. if not hasattr(self, 'fsh'): self.load_callbacks('fsh') config = __config.get_config('services.conf', [self.systemtype]).get_section('apache2')[1] valid_directory = ['available', 'enabled'] if directory not in valid_directory: __LOG.log_die("%s: not a valid path." % (directory)) config_path_site = config["path_sites_%s" % (directory)] site_exist = self.fsh.file_exists("%s" % (config_path_site.rstrip('/') + '/' + site)) if not site or site == '*': out = self.fsh.list_files("%s" % ( config_path_site.rstrip('/') + '/' + site)) return out else: if site_exist is False: __LOG.log_die("File %s: not found in %s" % (site, config_path_site)) else: out = self.fsh.list_files("%s" % ( config_path_site.rstrip('/') + '/' + site)) return out, site, site_exist