Merge "Capture exception for JSON load in virt.storage_users"
This commit is contained in:
commit
9f24f0d40f
@ -17,9 +17,13 @@ import json
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from nova.openstack.common.gettextutils import _
|
||||||
|
from nova.openstack.common import log as logging
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
TWENTY_FOUR_HOURS = 3600 * 24
|
TWENTY_FOUR_HOURS = 3600 * 24
|
||||||
@ -53,7 +57,11 @@ def register_storage_use(storage_path, hostname):
|
|||||||
id_path = os.path.join(storage_path, 'compute_nodes')
|
id_path = os.path.join(storage_path, 'compute_nodes')
|
||||||
if os.path.exists(id_path):
|
if os.path.exists(id_path):
|
||||||
with open(id_path) as f:
|
with open(id_path) as f:
|
||||||
d = json.loads(f.read())
|
try:
|
||||||
|
d = json.loads(f.read())
|
||||||
|
except ValueError:
|
||||||
|
LOG.warning(_("Cannot decode JSON from %(id_path)s"),
|
||||||
|
{"id_path": id_path})
|
||||||
|
|
||||||
d[hostname] = time.time()
|
d[hostname] = time.time()
|
||||||
|
|
||||||
@ -87,7 +95,11 @@ def get_storage_users(storage_path):
|
|||||||
id_path = os.path.join(storage_path, 'compute_nodes')
|
id_path = os.path.join(storage_path, 'compute_nodes')
|
||||||
if os.path.exists(id_path):
|
if os.path.exists(id_path):
|
||||||
with open(id_path) as f:
|
with open(id_path) as f:
|
||||||
d = json.loads(f.read())
|
try:
|
||||||
|
d = json.loads(f.read())
|
||||||
|
except ValueError:
|
||||||
|
LOG.warning(_("Cannot decode JSON from %(id_path)s"),
|
||||||
|
{"id_path": id_path})
|
||||||
|
|
||||||
recent_users = []
|
recent_users = []
|
||||||
for node in d:
|
for node in d:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user