vaultmanager/modules/VaultManagerKV.py
def kv_count(self, vault_addr, vault_token, paths, excluded=[]):
        """
        Method running the count function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param paths: Paths to count
        :type paths: list(str)
        :param excluded: Paths to exclude from count
        :type excluded: list(str)

        :return: dict
        """
        self.logger.debug("KV count starting")
        vault_client = self.connect_to_vault(
            vault_addr,
            vault_token
        )
        total_secrets = 0
        total_kv = 0
        count_dict = {}
        for path in paths:
            self.logger.debug("At path '" + path + "'")
            count_dict[path] = {"secrets_count": -1, "values_count": -1}
            all_secrets = vault_client.secrets_tree_list(path, excluded)
            self.logger.debug("\tSecrets count: " + str(len(all_secrets)))
            count_dict[path]["secrets_count"] = len(all_secrets)
            total_secrets += len(all_secrets)
            kv_count = 0
            for secret_path in all_secrets:
                kv_count += len(vault_client.read(secret_path))
            total_kv += kv_count
            self.logger.debug("\tValues count: " + str(kv_count))
            count_dict[path]["values_count"] = kv_count
        self.logger.debug("Total")
        self.logger.debug("\tSecrets count: " + str(total_secrets))
        self.logger.debug("\tValues count: " + str(total_kv))
        self.logger.info(json.dumps(count_dict, indent=4))
        return count_dict

        Method running the count function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param paths: Paths to count
        :type paths: list(str)
        :param excluded: Paths to exclude from count
        :type excluded: list(str)

        :return: dict
        
Method running the count function of KV module
Method running the count function of KV module
def kv_count(self, vault_addr, vault_token, paths, excluded=[]):
        self.logger.debug("KV count starting")
        vault_client = self.connect_to_vault(
            vault_addr,
            vault_token
        )
        total_secrets = 0
        total_kv = 0
        count_dict = {}
        for path in paths:
            self.logger.debug("At path '" + path + "'")
            count_dict[path] = {"secrets_count": -1, "values_count": -1}
            all_secrets = vault_client.secrets_tree_list(path, excluded)
            self.logger.debug("\tSecrets count: " + str(len(all_secrets)))
            count_dict[path]["secrets_count"] = len(all_secrets)
            total_secrets += len(all_secrets)
            kv_count = 0
            for secret_path in all_secrets:
                kv_count += len(vault_client.read(secret_path))
            total_kv += kv_count
            self.logger.debug("\tValues count: " + str(kv_count))
            count_dict[path]["values_count"] = kv_count
        self.logger.debug("Total")
        self.logger.debug("\tSecrets count: " + str(total_secrets))
        self.logger.debug("\tValues count: " + str(total_kv))
        self.logger.info(json.dumps(count_dict, indent=4))
        return count_dict
def kv_count ( self , vault_addr , vault_token , paths , excluded = [ ] ) : self . logger . debug ( "KV count starting" ) vault_client = self . connect_to_vault ( vault_addr , vault_token ) total_secrets = 0 total_kv = 0 count_dict = { } for path in paths : self . logger . debug ( "At path '" + path + "'" ) count_dict [ path ] = { "secrets_count" : - 1 , "values_count" : - 1 } all_secrets = vault_client . secrets_tree_list ( path , excluded ) self . logger . debug ( "\tSecrets count: " + str ( len ( all_secrets ) ) ) count_dict [ path ] [ "secrets_count" ] = len ( all_secrets ) total_secrets += len ( all_secrets ) kv_count = 0 for secret_path in all_secrets : kv_count += len ( vault_client . read ( secret_path ) ) total_kv += kv_count self . logger . debug ( "\tValues count: " + str ( kv_count ) ) count_dict [ path ] [ "values_count" ] = kv_count self . logger . debug ( "Total" ) self . logger . debug ( "\tSecrets count: " + str ( total_secrets ) ) self . logger . debug ( "\tValues count: " + str ( total_kv ) ) self . logger . info ( json . dumps ( count_dict , indent = 4 ) ) return count_dict
Method running the count function of KV module
Method running the count function of KV module
"""
        Method running the count function of KV module

        :param vault_addr: Vault instance URL
        :type vault_addr: str
        :param vault_token: Vault token
        :type vault_token: str
        :param paths: Paths to count
        :type paths: list(str)
        :param excluded: Paths to exclude from count
        :type excluded: list(str)

        :return: dict
        """
None
self
vault_addr
Vault instance URL
Vault instance URL
vault_token
None
paths
Paths to count
Paths to count
excluded
Paths to exclude from count
Paths to exclude from count