Ensure the exist of writer path

When the writer path does not exist, the cloudkitty-writer will
fail when trying to create file in writer path.
And the cloudkitty also does not ensure the exist of default
path(/var/lib/cloudkitty/states/).
This patch ensure the writer path always exists.

Change-Id: Ic9ed41482615e405d6f99a3148e7d220e4c64260
This commit is contained in:
tianmaofu
2016-12-15 07:40:31 +00:00
parent 513eaf6d80
commit cd994fb0c6

View File

@@ -16,6 +16,7 @@
# @author: Stéphane Albert
#
from oslo_config import cfg
from oslo_utils import fileutils
from stevedore import named
from cloudkitty import state
@@ -42,6 +43,8 @@ class WriteOrchestrator(object):
self._tenant_id = tenant_id
self._storage = storage
self._basepath = basepath
if self._basepath:
fileutils.ensure_tree(self._basepath)
self._period = period
self._sm = state.DBStateManager(self._tenant_id,
'writer_status')