Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
Archivo: mac.py Proyecto: bhyvex/cinv
 def get_base_dir():
     return cinv.get_base_dir("db/mac")
Ejemplo n.º 8
0
 def get_base_dir(network):
     return os.path.join(cinv.get_base_dir("db"), "net-ipv4", network)
Ejemplo n.º 9
0
 def get_base_dir(network):
     return os.path.join(cinv.get_base_dir("db"), "net-ipv4", network)
Ejemplo n.º 10
0
 def get_base_dir(fqdn):
     return os.path.join(cinv.get_base_dir("db"), "host", fqdn)
Ejemplo n.º 11
0
 def get_base_dir():
     return cinv.get_base_dir("db/mac")
Ejemplo n.º 12
0
 def get_base_dir(fqdn):
     return os.path.join(cinv.get_base_dir("db"), "host", fqdn)