Fixes bug 925644: move dotfiles into dir

Moves ~/.novaclient_cached_*_uuids into ~/.novaclient/*-uuid-cache

Change-Id: I7dcd3678118f6c59ce81f83862c20da94d90bb74
This commit is contained in:
Dean Troyer 2012-02-06 11:28:46 -06:00
parent 5f89c8487d
commit 7601bef9ef
2 changed files with 15 additions and 3 deletions

View File

@ -20,11 +20,15 @@ Base utilities to build API operation managers and objects on top of.
"""
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 @@ class Manager(utils.HookableMixin):
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)

View File

@ -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}) )