Revision c4402c5d tools/cfgupgrade

b/tools/cfgupgrade
394 394
  UpgradeInstanceIndices(config_data)
395 395

  
396 396

  
397
def DowngradeInstances(config_data):
398
  if "instances" not in config_data:
399
    raise Error("Cannot find the 'instances' key in the configuration!")
400
  for (iname, iobj) in config_data["instances"].items():
401
    DowngradeNicParamsVLAN(iobj["nics"], iname)
397
def DowngradeNDParams(ndparams):
398
  for param in ["ovs", "ovs_link", "ovs_name"]:
399
    if param in ndparams:
400
      del ndparams[param]
401

  
402

  
403
def DowngradeNicParams(nicparams):
404
  if "vlan" in nicparams:
405
    del nicparams["vlan"]
402 406

  
403 407

  
404
def DowngradeNicParamsVLAN(nics, owner):
405
  for nic in nics:
406
    vlan = nic["nicparams"].get("vlan", None)
407
    if vlan:
408
      logging.warning("Instance with name %s found. Removing VLAN information"
409
                      " %s.", owner, vlan)
410
      del nic["nicparams"]["vlan"]
408
def DowngradeHVParams(hvparams):
409
  for hv in ["xen-pvm", "xen-hvm"]:
410
    if hv not in hvparams:
411
      continue
412
    for param in ["cpuid", "soundhw"]:
413
      if param in hvparams[hv]:
414
        del hvparams[hv][param]
415

  
416

  
417
def DowngradeCluster(config_data):
418
  cluster = config_data["cluster"]
419
  DowngradeNDParams(cluster["ndparams"])
420
  DowngradeNicParams(cluster["nicparams"][constants.PP_DEFAULT])
421
  DowngradeHVParams(cluster["hvparams"])
422

  
423

  
424
def DowngradeNodeGroups(config_data):
425
  for (_, ngobj) in config_data["nodegroups"].items():
426
    DowngradeNDParams(ngobj["ndparams"])
427

  
428

  
429
def DowngradeNodes(config_data):
430
  for (_, nobj) in config_data["nodes"].items():
431
    DowngradeNDParams(nobj["ndparams"])
432

  
433

  
434
def DowngradeInstances(config_data):
435
  for (_, iobj) in config_data["instances"].items():
436
    DowngradeHVParams(iobj["hvparams"])
437
    for nic in iobj["nics"]:
438
      DowngradeNicParams(nic["nicparams"])
411 439

  
412 440

  
413 441
def DowngradeAll(config_data):
......
415 443
  # it can be removed when updating to the next version.
416 444
  config_data["version"] = version.BuildVersion(DOWNGRADE_MAJOR,
417 445
                                                DOWNGRADE_MINOR, 0)
446
  DowngradeCluster(config_data)
447
  DowngradeNodeGroups(config_data)
448
  DowngradeNodes(config_data)
418 449
  DowngradeInstances(config_data)
419 450

  
420 451

  

Also available in: Unified diff