Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio n. 7
0
File: mac.py Progetto: bhyvex/cinv
 def get_base_dir():
     return cinv.get_base_dir("db/mac")
Esempio n. 8
0
 def get_base_dir(network):
     return os.path.join(cinv.get_base_dir("db"), "net-ipv4", network)
Esempio n. 9
0
 def get_base_dir(network):
     return os.path.join(cinv.get_base_dir("db"), "net-ipv4", network)
Esempio n. 10
0
 def get_base_dir(fqdn):
     return os.path.join(cinv.get_base_dir("db"), "host", fqdn)
Esempio n. 11
0
 def get_base_dir():
     return cinv.get_base_dir("db/mac")
Esempio n. 12
0
 def get_base_dir(fqdn):
     return os.path.join(cinv.get_base_dir("db"), "host", fqdn)