added: new method for load json file instead of yaml because of the performance issues
This commit is contained in:
parent
286897835c
commit
69643472c2
@ -19,7 +19,7 @@
|
||||
main module
|
||||
"""
|
||||
|
||||
import yaml
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import logging
|
||||
@ -375,9 +375,9 @@ class NodeManager(object):
|
||||
self.nodes = {}
|
||||
self.fuel_init()
|
||||
if nodes_json:
|
||||
self.nodes_json = tools.load_yaml_file(nodes_json)
|
||||
self.nodes_json = tools.load_json_file(nodes_json)
|
||||
else:
|
||||
self.nodes_json = yaml.load(self.get_nodes_json())
|
||||
self.nodes_json = json.loads(self.get_nodes_json())
|
||||
self.nodes_init()
|
||||
# apply soft-filter on all nodes
|
||||
for node in self.nodes.values():
|
||||
|
@ -26,6 +26,7 @@ import threading
|
||||
from multiprocessing import Process, Queue, BoundedSemaphore
|
||||
import subprocess
|
||||
import yaml
|
||||
import json
|
||||
from flock import FLock
|
||||
from tempfile import gettempdir
|
||||
from pipes import quote
|
||||
@ -172,6 +173,23 @@ def get_dir_structure(rootdir):
|
||||
return dir
|
||||
|
||||
|
||||
def load_json_file(filename):
|
||||
"""
|
||||
Loads json data from file
|
||||
"""
|
||||
logger = logging.getLogger(__name__)
|
||||
try:
|
||||
with open(filename, 'r') as f:
|
||||
return json.load(f)
|
||||
except IOError as e:
|
||||
logger.critical("I/O error(%s): file: %s; msg: %s" %
|
||||
(e.errno, e.filename, e.strerror))
|
||||
sys.exit(1)
|
||||
except ValueError:
|
||||
logger.critical("Could not convert data")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def load_yaml_file(filename):
|
||||
"""
|
||||
Loads yaml data from file
|
||||
|
Loading…
x
Reference in New Issue
Block a user