Skip to content

Commit

Permalink
Fixes bug 925644: move dotfiles into dir
Browse files Browse the repository at this point in the history
Moves ~/.novaclient_cached_*_uuids into ~/.novaclient/*-uuid-cache

Change-Id: I7dcd3678118f6c59ce81f83862c20da94d90bb74
  • Loading branch information
Dean Troyer committed Feb 14, 2012
1 parent 5f89c84 commit 7601bef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions novaclient/base.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/nova.bash_completion
Expand Up @@ -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}) )
Expand Down

0 comments on commit 7601bef

Please sign in to comment.