From 7601bef9ef70ce69f544e0ffda904a04552bc38c Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 6 Feb 2012 11:28:46 -0600 Subject: [PATCH] Fixes bug 925644: move dotfiles into dir Moves ~/.novaclient_cached_*_uuids into ~/.novaclient/*-uuid-cache Change-Id: I7dcd3678118f6c59ce81f83862c20da94d90bb74 --- novaclient/base.py | 16 ++++++++++++++-- tools/nova.bash_completion | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/novaclient/base.py b/novaclient/base.py index 5894e0769..ae3f044de 100644 --- a/novaclient/base.py +++ b/novaclient/base.py @@ -20,11 +20,15 @@ """ import contextlib +import errno import os from novaclient import exceptions from novaclient import utils +UUID_CACHE_DIR = "~/.novaclient" + + # Python 2.4 compat try: all @@ -100,9 +104,17 @@ def uuid_cache(self, obj_class, mode): Delete is not handled because listings are assumed to be performed often enough to keep the UUID cache reasonably up-to-date. """ + uuid_cache_dir = os.path.expanduser(UUID_CACHE_DIR) + try: + os.makedirs(uuid_cache_dir, 0755) + except OSError as e: + if e.errno == errno.EEXIST: + pass + else: + raise + resource = obj_class.__name__.lower() - filename = os.path.expanduser("~/.novaclient_cached_%s_uuids" % - resource) + filename = uuid_cache_dir + "/%s-uuid-cache" % resource try: self._uuid_cache = open(filename, mode) diff --git a/tools/nova.bash_completion b/tools/nova.bash_completion index 6bbbc268d..0ad5ddb13 100644 --- a/tools/nova.bash_completion +++ b/tools/nova.bash_completion @@ -7,7 +7,7 @@ _nova() opts="$(nova bash_completion)" - UUID_CACHE=~/.novaclient_cached_*_uuids + UUID_CACHE=~/.novaclient/*-uuid-cache opts+=" "$(cat $UUID_CACHE 2> /dev/null | tr '\n' ' ') COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )