Revision e5398c3a qa/qa_config.py

b/qa/qa_config.py
40 40
_VCLUSTER_BASEDIR_KEY = "vcluster-basedir"
41 41
_ENABLED_DISK_TEMPLATES_KEY = "enabled-disk-templates"
42 42

  
43
# The path of an optional JSON Patch file (as per RFC6902) that modifies QA's
44
# configuration.
45
_PATCH_JSON = os.path.join(os.path.dirname(__file__), "qa-patch.json")
46

  
43 47
#: QA configuration (L{_QaConfig})
44 48
_config = None
45 49

  
......
261 265
    """
262 266
    data = serializer.LoadJson(utils.ReadFile(filename))
263 267

  
268
    # Patch the document using JSON Patch (RFC6902) in file _PATCH_JSON, if
269
    # available
270
    try:
271
      patch = serializer.LoadJson(utils.ReadFile(_PATCH_JSON))
272
      if patch:
273
        mod = __import__("jsonpatch", fromlist=[])
274
        data = mod.apply_patch(data, patch)
275
    except IOError:
276
      pass
277
    except ImportError:
278
      raise qa_error.Error("If you want to use the QA JSON patching feature,"
279
                           " you need to install Python modules"
280
                           " 'jsonpatch' and 'jsonpointer'.")
281

  
264 282
    result = cls(dict(map(_ConvertResources,
265 283
                          data.items()))) # pylint: disable=E1103
266 284
    result.Validate()

Also available in: Unified diff