def check_for_processes(cls): pdir = cinv.get_base_dir("process") pfile = os.path.join(pdir, "__init__.py") if os.path.exists(pfile): exists = True else: exists = False return exists
def network_list(cls): networks = [] base_dir = os.path.join(cinv.get_base_dir("db"), "net-ipv4") for entry in os.listdir(base_dir): # With or without the mask is the question... # network = cls(entry) # networks.append("%s/%s" % (entry, network.mask)) networks.append("%s" % (entry)) return networks
def host_list(cls, host_type=None, tags=[]): hosts = [] if host_type: if host_type not in HOST_TYPES: raise Error("Host type must be one of %s" % (" ".join(HOST_TYPES))) base_dir = os.path.join(cinv.get_base_dir("db"), "host") if not os.path.isdir(base_dir): return [] for entry in os.listdir(base_dir): if host_type: host = cls(entry) if host.host_type == host_type: hosts.append(entry) else: hosts.append(entry) # Only show hosts matching all tags (but can contain other tags) if len(tags) > 0: hosts_with_tags = [] for host in hosts: host_object = cls(host) has_tags = True for tag in tags: if not tag in host_object.tag.keys(): has_tags = False break if has_tags: hosts_with_tags.append(host) hosts = hosts_with_tags return hosts
def get_base_dir(): return cinv.get_base_dir("db/mac")
def get_base_dir(network): return os.path.join(cinv.get_base_dir("db"), "net-ipv4", network)
def get_base_dir(fqdn): return os.path.join(cinv.get_base_dir("db"), "host", fqdn)