This repository has been archived on 2022-01-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2020-03-30 01:59:36 -04:00
|
|
|
import logging
|
|
|
|
|
import re
|
|
|
|
|
import warnings
|
|
|
|
|
##
|
|
|
|
|
import hvac.exceptions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger = logging.getLogger()
|
|
|
|
|
_mount_re = re.compile(r'^(?P<mount>.*)/')
|
|
|
|
|
|
|
|
|
|
|
2020-03-29 23:13:41 -04:00
|
|
|
class MountHandler(object):
|
2020-03-30 01:59:36 -04:00
|
|
|
internal_mounts = ('identity', 'sys')
|
|
|
|
|
|
2020-03-29 23:13:41 -04:00
|
|
|
def __init__(self, client, mounts_xml = None):
|
|
|
|
|
self.client = client
|
2020-03-30 01:59:36 -04:00
|
|
|
self.xml = mounts_xml
|
|
|
|
|
self.mounts = []
|
2020-03-29 23:13:41 -04:00
|
|
|
|
|
|
|
|
def getSysMounts(self):
|
2020-03-30 01:59:36 -04:00
|
|
|
try:
|
|
|
|
|
for mount, mount_info in self.client.sys.list_mounted_secrets_engines()['data'].items():
|
|
|
|
|
r = _mount_re.search(mount)
|
|
|
|
|
if r:
|
|
|
|
|
mount = r.group('mount')
|
|
|
|
|
if mount in self.internal_mounts:
|
|
|
|
|
continue
|
|
|
|
|
self.mounts.append(mount)
|
|
|
|
|
_logger.debug('Added mountpoint to mounts list: {0}'.format(mount))
|
|
|
|
|
except hvac.exceptions.Forbidden:
|
|
|
|
|
_logger.warning('Client does not have permission to read /sys/mounts.')
|
|
|
|
|
# TODO: xml parsing
|
|
|
|
|
|
|
|
|
|
return(None)
|
2020-03-29 23:13:41 -04:00
|
|
|
|
|
|
|
|
def print(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def search(self):
|
|
|
|
|
pass
|