Revision 2dd5390e

b/lib/cmdlib.py
1502 1502
  @type vcpus: string
1503 1503
  @param vcpus: the count of VCPUs the instance has
1504 1504
  @type nics: list
1505
  @param nics: list of tuples (ip, mac, mode, link, net, netinfo) representing
1506
      the NICs the instance has
1505
  @param nics: list of tuples (name, uuid, ip, mac, mode, link, net, netinfo)
1506
      representing the NICs the instance has
1507 1507
  @type disk_template: string
1508 1508
  @param disk_template: the disk template of the instance
1509 1509
  @type disks: list
1510
  @param disks: the list of (size, mode) pairs
1510
  @param disks: list of tuples (name, uuid, size, mode)
1511 1511
  @type bep: dict
1512 1512
  @param bep: the backend parameters for the instance
1513 1513
  @type hvp: dict
......
1537 1537
  }
1538 1538
  if nics:
1539 1539
    nic_count = len(nics)
1540
    for idx, (ip, mac, mode, link, net, netinfo) in enumerate(nics):
1540
    for idx, (name, _, ip, mac, mode, link, net, netinfo) in enumerate(nics):
1541 1541
      if ip is None:
1542 1542
        ip = ""
1543
      env["INSTANCE_NIC%d_NAME" % idx] = name
1543 1544
      env["INSTANCE_NIC%d_IP" % idx] = ip
1544 1545
      env["INSTANCE_NIC%d_MAC" % idx] = mac
1545 1546
      env["INSTANCE_NIC%d_MODE" % idx] = mode
......
1561 1562

  
1562 1563
  if disks:
1563 1564
    disk_count = len(disks)
1564
    for idx, (size, mode) in enumerate(disks):
1565
    for idx, (name, size, mode) in enumerate(disks):
1566
      env["INSTANCE_DISK%d_NAME" % idx] = name
1565 1567
      env["INSTANCE_DISK%d_SIZE" % idx] = size
1566 1568
      env["INSTANCE_DISK%d_MODE" % idx] = mode
1567 1569
  else:
......
1598 1600
  if nic.network:
1599 1601
    nobj = lu.cfg.GetNetwork(nic.network)
1600 1602
    netinfo = objects.Network.ToDict(nobj)
1601
  return (nic.ip, nic.mac, mode, link, nic.network, netinfo)
1603
  return (nic.name, nic.uuid, nic.ip, nic.mac, mode, link, nic.network, netinfo)
1602 1604

  
1603 1605

  
1604 1606
def _NICListToTuple(lu, nics):
......
1648 1650
    "vcpus": bep[constants.BE_VCPUS],
1649 1651
    "nics": _NICListToTuple(lu, instance.nics),
1650 1652
    "disk_template": instance.disk_template,
1651
    "disks": [(disk.size, disk.mode) for disk in instance.disks],
1653
    "disks": [(disk.name, disk.size, disk.mode)
1654
              for disk in instance.disks],
1652 1655
    "bep": bep,
1653 1656
    "hvp": hvp,
1654 1657
    "hypervisor_name": instance.hypervisor,
......
9456 9459
  dev_data = objects.Disk(dev_type=constants.LD_LV, size=size,
9457 9460
                          logical_id=(vgnames[0], names[0]),
9458 9461
                          params={})
9462
  dev_data.uuid = lu.cfg.GenerateUniqueID(lu.proc.GetECId())
9459 9463
  dev_meta = objects.Disk(dev_type=constants.LD_LV,
9460 9464
                          size=constants.DRBD_META_SIZE,
9461 9465
                          logical_id=(vgnames[1], names[1]),
9462 9466
                          params={})
9467
  dev_meta.uuid = lu.cfg.GenerateUniqueID(lu.proc.GetECId())
9463 9468
  drbd_dev = objects.Disk(dev_type=constants.LD_DRBD8, size=size,
9464 9469
                          logical_id=(primary, secondary, port,
9465 9470
                                      p_minor, s_minor,
9466 9471
                                      shared_secret),
9467 9472
                          children=[dev_data, dev_meta],
9468 9473
                          iv_name=iv_name, params={})
9474
  drbd_dev.uuid = lu.cfg.GenerateUniqueID(lu.proc.GetECId())
9469 9475
  return drbd_dev
9470 9476

  
9471 9477

  
......
9527 9533
                                      "disk/%d" % disk_index,
9528 9534
                                      minors[idx * 2], minors[idx * 2 + 1])
9529 9535
      disk_dev.mode = disk[constants.IDISK_MODE]
9536
      disk_dev.name = disk.get(constants.IDISK_NAME, None)
9530 9537
      disks.append(disk_dev)
9531 9538
  else:
9532 9539
    if secondary_nodes:
......
9587 9594
      size = disk[constants.IDISK_SIZE]
9588 9595
      feedback_fn("* disk %s, size %s" %
9589 9596
                  (disk_index, utils.FormatUnit(size, "h")))
9590
      disks.append(objects.Disk(dev_type=dev_type, size=size,
9591
                                logical_id=logical_id_fn(idx, disk_index, disk),
9592
                                iv_name="disk/%d" % disk_index,
9593
                                mode=disk[constants.IDISK_MODE],
9594
                                params=params))
9597
      disk_dev = objects.Disk(dev_type=dev_type, size=size,
9598
                              logical_id=logical_id_fn(idx, disk_index, disk),
9599
                              iv_name="disk/%d" % disk_index,
9600
                              mode=disk[constants.IDISK_MODE],
9601
                              params=params)
9602
      disk_dev.name = disk.get(constants.IDISK_NAME, None)
9603
      disk_dev.uuid = lu.cfg.GenerateUniqueID(lu.proc.GetECId())
9604
      disks.append(disk_dev)
9595 9605

  
9596 9606
  return disks
9597 9607

  
......
10044 10054
    check_params = cluster.SimpleFillNIC(nicparams)
10045 10055
    objects.NIC.CheckParameterSyntax(check_params)
10046 10056
    net_uuid = cfg.LookupNetwork(net)
10047
    nics.append(objects.NIC(mac=mac, ip=nic_ip,
10048
                            network=net_uuid, nicparams=nicparams))
10057
    name = nic.get(constants.INIC_NAME, None)
10058
    nic_obj = objects.NIC(mac=mac, ip=nic_ip, name=name,
10059
                          network=net_uuid, nicparams=nicparams)
10060
    nic_obj.uuid = cfg.GenerateUniqueID(ec_id)
10061
    nics.append(nic_obj)
10049 10062

  
10050 10063
  return nics
10051 10064

  
......
10082 10095
                                 op.disk_template), errors.ECODE_INVAL)
10083 10096

  
10084 10097
    data_vg = disk.get(constants.IDISK_VG, default_vg)
10098
    name = disk.get(constants.IDISK_NAME, None)
10085 10099
    new_disk = {
10086 10100
      constants.IDISK_SIZE: size,
10087 10101
      constants.IDISK_MODE: mode,
10088 10102
      constants.IDISK_VG: data_vg,
10103
      constants.IDISK_NAME: name,
10089 10104
      }
10090 10105

  
10091 10106
    if constants.IDISK_METAVG in disk:
......
10440 10455
      vcpus=self.be_full[constants.BE_VCPUS],
10441 10456
      nics=_NICListToTuple(self, self.nics),
10442 10457
      disk_template=self.op.disk_template,
10443
      disks=[(d[constants.IDISK_SIZE], d[constants.IDISK_MODE])
10444
             for d in self.disks],
10458
      disks=[(d[constants.IDISK_NAME], d[constants.IDISK_SIZE],
10459
             d[constants.IDISK_MODE]) for d in self.disks],
10445 10460
      bep=self.be_full,
10446 10461
      hvp=self.hv_full,
10447 10462
      hypervisor_name=self.op.hypervisor,
......
14028 14043

  
14029 14044
    # create a fake disk info for _GenerateDiskTemplate
14030 14045
    disk_info = [{constants.IDISK_SIZE: d.size, constants.IDISK_MODE: d.mode,
14031
                  constants.IDISK_VG: d.logical_id[0]}
14046
                  constants.IDISK_VG: d.logical_id[0],
14047
                  constants.IDISK_NAME: d.name}
14032 14048
                 for d in instance.disks]
14033 14049
    new_disks = _GenerateDiskTemplate(self, self.op.disk_template,
14034 14050
                                      instance.name, pnode, [snode],
......
14097 14113
    old_disks = _AnnotateDiskParams(instance, instance.disks, self.cfg)
14098 14114
    new_disks = [d.children[0] for d in instance.disks]
14099 14115

  
14100
    # copy over size and mode
14116
    # copy over size, mode and name
14101 14117
    for parent, child in zip(old_disks, new_disks):
14102 14118
      child.size = parent.size
14103 14119
      child.mode = parent.mode
14120
      child.name = parent.name
14104 14121

  
14105 14122
    # this is a DRBD disk, return its port to the pool
14106 14123
    # NOTE: this must be done right before the call to cfg.Update!
......
14210 14227
    mac = params[constants.INIC_MAC]
14211 14228
    ip = params.get(constants.INIC_IP, None)
14212 14229
    net = params.get(constants.INIC_NETWORK, None)
14230
    name = params.get(constants.INIC_NAME, None)
14213 14231
    net_uuid = self.cfg.LookupNetwork(net)
14214 14232
    #TODO: not private.filled?? can a nic have no nicparams??
14215 14233
    nicparams = private.filled
14216
    nobj = objects.NIC(mac=mac, ip=ip, network=net_uuid, nicparams=nicparams)
14234
    nobj = objects.NIC(mac=mac, ip=ip, network=net_uuid, name=name,
14235
                       nicparams=nicparams)
14236
    nobj.uuid = self.cfg.GenerateUniqueID(self.proc.GetECId())
14217 14237

  
14218 14238
    return (nobj, [
14219 14239
      ("nic.%d" % idx,

Also available in: Unified diff