forked from uncloud/uncloud
Added --conf-dir, --etcd-{host,port,ca_cert,cert_cert,cert_key} parameters to cli and settings is now accessbile through uncloud.shared.shared.settings
This commit is contained in:
parent
e6d22a73c5
commit
c3b42aabc6
19 changed files with 176 additions and 154 deletions
|
|
@ -9,7 +9,6 @@ import bitmath
|
|||
from uuid import uuid4
|
||||
|
||||
from . import logger
|
||||
from uncloud.common.settings import settings
|
||||
from uncloud.common.shared import shared
|
||||
|
||||
arg_parser = argparse.ArgumentParser('filescanner', add_help=False)
|
||||
|
|
@ -53,7 +52,7 @@ def track_file(file, base_dir, host):
|
|||
file_path = file_path.relative_to(owner)
|
||||
creation_date = time.ctime(os.stat(file_str).st_ctime)
|
||||
|
||||
entry_key = os.path.join(settings['etcd']['file_prefix'], str(uuid4()))
|
||||
entry_key = os.path.join(shared.settings['etcd']['file_prefix'], str(uuid4()))
|
||||
entry_value = {
|
||||
'filename': str(file_path),
|
||||
'owner': owner,
|
||||
|
|
@ -70,7 +69,7 @@ def track_file(file, base_dir, host):
|
|||
|
||||
def main(arguments):
|
||||
hostname = arguments['hostname']
|
||||
base_dir = settings['storage']['file_dir']
|
||||
base_dir = shared.settings['storage']['file_dir']
|
||||
# Recursively Get All Files and Folder below BASE_DIR
|
||||
files = glob.glob('{}/**'.format(base_dir), recursive=True)
|
||||
files = [pathlib.Path(f) for f in files if pathlib.Path(f).is_file()]
|
||||
|
|
@ -78,7 +77,7 @@ def main(arguments):
|
|||
# Files that are already tracked
|
||||
tracked_files = [
|
||||
pathlib.Path(os.path.join(base_dir, f.value['owner'], f.value['filename']))
|
||||
for f in shared.etcd_client.get_prefix(settings['etcd']['file_prefix'], value_in_json=True)
|
||||
for f in shared.etcd_client.get_prefix(shared.settings['etcd']['file_prefix'], value_in_json=True)
|
||||
if f.value['host'] == hostname
|
||||
]
|
||||
untracked_files = set(files) - set(tracked_files)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue