Revision 73e0328b lib/cmdlib.py

b/lib/cmdlib.py
751 751

  
752 752
  """
753 753
  hooks_nics = []
754
  c_nicparams = lu.cfg.GetClusterInfo().nicparams[constants.PP_DEFAULT]
754
  cluster = lu.cfg.GetClusterInfo()
755 755
  for nic in nics:
756 756
    ip = nic.ip
757 757
    mac = nic.mac
758
    filled_params = objects.FillDict(c_nicparams, nic.nicparams)
758
    filled_params = cluster.SimpleFillNIC(nic.nicparams)
759 759
    mode = filled_params[constants.NIC_MODE]
760 760
    link = filled_params[constants.NIC_LINK]
761 761
    hooks_nics.append((ip, mac, mode, link))
......
827 827
  return mc_now < mc_should
828 828

  
829 829

  
830
def _CheckNicsBridgesExist(lu, target_nics, target_node,
831
                               profile=constants.PP_DEFAULT):
830
def _CheckNicsBridgesExist(lu, target_nics, target_node):
832 831
  """Check that the brigdes needed by a list of nics exist.
833 832

  
834 833
  """
835
  c_nicparams = lu.cfg.GetClusterInfo().nicparams[profile]
836
  paramslist = [objects.FillDict(c_nicparams, nic.nicparams)
837
                for nic in target_nics]
834
  cluster = lu.cfg.GetClusterInfo()
835
  paramslist = [cluster.SimpleFillNIC(nic.nicparams) for nic in target_nics]
838 836
  brlist = [params[constants.NIC_LINK] for params in paramslist
839 837
            if params[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED]
840 838
  if brlist:
......
2332 2330
    # validate params changes
2333 2331
    if self.op.beparams:
2334 2332
      utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES)
2335
      self.new_beparams = objects.FillDict(
2336
        cluster.beparams[constants.PP_DEFAULT], self.op.beparams)
2333
      self.new_beparams = cluster.SimpleFillBE(self.op.beparams)
2337 2334

  
2338 2335
    if self.op.nicparams:
2339 2336
      utils.ForceDictType(self.op.nicparams, constants.NICS_PARAMETER_TYPES)
2340
      self.new_nicparams = objects.FillDict(
2341
        cluster.nicparams[constants.PP_DEFAULT], self.op.nicparams)
2337
      self.new_nicparams = cluster.SimpleFillNIC(self.op.nicparams)
2342 2338
      objects.NIC.CheckParameterSyntax(self.new_nicparams)
2343 2339
      nic_errors = []
2344 2340

  
......
4816 4812
      iout = []
4817 4813
      i_hv = cluster.FillHV(instance, skip_globals=True)
4818 4814
      i_be = cluster.FillBE(instance)
4819
      i_nicp = [objects.FillDict(cluster.nicparams[constants.PP_DEFAULT],
4820
                                 nic.nicparams) for nic in instance.nics]
4815
      i_nicp = [cluster.SimpleFillNIC(nic.nicparams) for nic in instance.nics]
4821 4816
      for field in self.op.output_fields:
4822 4817
        st_match = self._FIELDS_STATIC.Matches(field)
4823 4818
        if field in self._SIMPLE_FIELDS:
......
6470 6465

  
6471 6466
    """
6472 6467
    # hvparams
6473
    hv_defs = cluster.GetHVDefaults(self.op.hypervisor, self.op.os_type)
6468
    hv_defs = cluster.SimpleFillHV(self.op.hypervisor, self.op.os_type, {})
6474 6469
    for name in self.op.hvparams.keys():
6475 6470
      if name in hv_defs and hv_defs[name] == self.op.hvparams[name]:
6476 6471
        del self.op.hvparams[name]
6477 6472
    # beparams
6478
    be_defs = cluster.beparams.get(constants.PP_DEFAULT, {})
6473
    be_defs = cluster.SimpleFillBE({})
6479 6474
    for name in self.op.beparams.keys():
6480 6475
      if name in be_defs and be_defs[name] == self.op.beparams[name]:
6481 6476
        del self.op.beparams[name]
6482 6477
    # nic params
6483
    nic_defs = cluster.nicparams.get(constants.PP_DEFAULT, {})
6478
    nic_defs = cluster.SimpleFillNIC({})
6484 6479
    for nic in self.op.nics:
6485 6480
      for name in constants.NICS_PARAMETERS:
6486 6481
        if name in nic and name in nic_defs and nic[name] == nic_defs[name]:
......
6514 6509

  
6515 6510
    # check hypervisor parameter syntax (locally)
6516 6511
    utils.ForceDictType(self.op.hvparams, constants.HVS_PARAMETER_TYPES)
6517
    filled_hvp = objects.FillDict(cluster.GetHVDefaults(self.op.hypervisor,
6518
                                                        self.op.os_type),
6519
                                  self.op.hvparams)
6512
    filled_hvp = cluster.SimpleFillHV(self.op.hypervisor, self.op.os_type,
6513
                                      self.op.hvparams)
6520 6514
    hv_type = hypervisor.GetHypervisor(self.op.hypervisor)
6521 6515
    hv_type.CheckParameterSyntax(filled_hvp)
6522 6516
    self.hv_full = filled_hvp
......
6525 6519

  
6526 6520
    # fill and remember the beparams dict
6527 6521
    utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES)
6528
    self.be_full = objects.FillDict(cluster.beparams[constants.PP_DEFAULT],
6529
                                    self.op.beparams)
6522
    self.be_full = cluster.SimpleFillBE(self.op.beparams)
6530 6523

  
6531 6524
    # now that hvp/bep are in final format, let's reset to defaults,
6532 6525
    # if told to do so
......
6599 6592
      if link:
6600 6593
        nicparams[constants.NIC_LINK] = link
6601 6594

  
6602
      check_params = objects.FillDict(cluster.nicparams[constants.PP_DEFAULT],
6603
                                      nicparams)
6595
      check_params = cluster.SimpleFillNIC(nicparams)
6604 6596
      objects.NIC.CheckParameterSyntax(check_params)
6605 6597
      self.nics.append(objects.NIC(mac=mac, ip=nic_ip, nicparams=nicparams))
6606 6598

  
......
8382 8374
    if self.op.nics:
8383 8375
      args['nics'] = []
8384 8376
      nic_override = dict(self.op.nics)
8385
      c_nicparams = self.cluster.nicparams[constants.PP_DEFAULT]
8386 8377
      for idx, nic in enumerate(self.instance.nics):
8387 8378
        if idx in nic_override:
8388 8379
          this_nic_override = nic_override[idx]
......
8399 8390
        if idx in self.nic_pnew:
8400 8391
          nicparams = self.nic_pnew[idx]
8401 8392
        else:
8402
          nicparams = objects.FillDict(c_nicparams, nic.nicparams)
8393
          nicparams = self.cluster.SimpleFillNIC(nic.nicparams)
8403 8394
        mode = nicparams[constants.NIC_MODE]
8404 8395
        link = nicparams[constants.NIC_LINK]
8405 8396
        args['nics'].append((ip, mac, mode, link))
......
9699 9690
    for iinfo, beinfo in i_list:
9700 9691
      nic_data = []
9701 9692
      for nic in iinfo.nics:
9702
        filled_params = objects.FillDict(
9703
            cluster_info.nicparams[constants.PP_DEFAULT],
9704
            nic.nicparams)
9693
        filled_params = cluster_info.SimpleFillNIC(nic.nicparams)
9705 9694
        nic_dict = {"mac": nic.mac,
9706 9695
                    "ip": nic.ip,
9707 9696
                    "mode": filled_params[constants.NIC_MODE],

Also available in: Unified diff