Commit 8a348b15 authored by Christos Stavrakakis's avatar Christos Stavrakakis Committed by Klaus Aehlig

Export device UUIDs to hooks and OS scripts

Export UUIDs and names of instance NICs and disks to the environment
of OS scripts and instance related hooks.
Signed-off-by: default avatarChristos Stavrakakis <cstavr@grnet.gr>
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent df5e2a28
......@@ -2523,6 +2523,9 @@ def OSEnvironment(instance, inst_os, debug=0):
real_disk = _OpenRealBD(disk)
result["DISK_%d_PATH" % idx] = real_disk.dev_path
result["DISK_%d_ACCESS" % idx] = disk.mode
result["DISK_%d_UUID" % idx] = disk.uuid
if disk.name:
result["DISK_%d_NAME" % idx] = disk.name
if constants.HV_DISK_TYPE in instance.hvparams:
result["DISK_%d_FRONTEND_TYPE" % idx] = \
instance.hvparams[constants.HV_DISK_TYPE]
......@@ -2535,6 +2538,9 @@ def OSEnvironment(instance, inst_os, debug=0):
# NICs
for idx, nic in enumerate(instance.nics):
result["NIC_%d_MAC" % idx] = nic.mac
result["NIC_%d_UUID" % idx] = nic.uuid
if nic.name:
result["NIC_%d_NAME" % idx] = nic.name
if nic.ip:
result["NIC_%d_IP" % idx] = nic.ip
result["NIC_%d_MODE" % idx] = nic.nicparams[constants.NIC_MODE]
......
......@@ -620,8 +620,9 @@ class LUInstanceCreate(LogicalUnit):
vcpus=self.be_full[constants.BE_VCPUS],
nics=NICListToTuple(self, self.nics),
disk_template=self.op.disk_template,
disks=[(d[constants.IDISK_NAME], d[constants.IDISK_SIZE],
d[constants.IDISK_MODE]) for d in self.disks],
disks=[(d[constants.IDISK_NAME], d.get("uuid", ""),
d[constants.IDISK_SIZE], d[constants.IDISK_MODE])
for d in self.disks],
bep=self.be_full,
hvp=self.hv_full,
hypervisor_name=self.op.hypervisor,
......
......@@ -94,10 +94,12 @@ def BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status,
}
if nics:
nic_count = len(nics)
for idx, (name, _, ip, mac, mode, link, net, netinfo) in enumerate(nics):
for idx, (name, uuid, ip, mac, mode, link, net, netinfo) in enumerate(nics):
if ip is None:
ip = ""
env["INSTANCE_NIC%d_NAME" % idx] = name
if name:
env["INSTANCE_NIC%d_NAME" % idx] = name
env["INSTANCE_NIC%d_UUID" % idx] = uuid
env["INSTANCE_NIC%d_IP" % idx] = ip
env["INSTANCE_NIC%d_MAC" % idx] = mac
env["INSTANCE_NIC%d_MODE" % idx] = mode
......@@ -119,8 +121,10 @@ def BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status,
if disks:
disk_count = len(disks)
for idx, (name, size, mode) in enumerate(disks):
env["INSTANCE_DISK%d_NAME" % idx] = name
for idx, (name, uuid, size, mode) in enumerate(disks):
if name:
env["INSTANCE_DISK%d_NAME" % idx] = name
env["INSTANCE_DISK%d_UUID" % idx] = uuid
env["INSTANCE_DISK%d_SIZE" % idx] = size
env["INSTANCE_DISK%d_MODE" % idx] = mode
else:
......@@ -169,7 +173,7 @@ def BuildInstanceHookEnvByObject(lu, instance, override=None):
"vcpus": bep[constants.BE_VCPUS],
"nics": NICListToTuple(lu, instance.nics),
"disk_template": instance.disk_template,
"disks": [(disk.name, disk.size, disk.mode)
"disks": [(disk.name, disk.uuid, disk.size, disk.mode)
for disk in instance.disks],
"bep": bep,
"hvp": hvp,
......
......@@ -76,6 +76,12 @@ DISK_%N_ACCESS
This is how the hypervisor will export the instance disks: either
read-write (``rw``) or read-only (``ro``).
DISK_%N_UUID
The uuid associated with the N-th disk of the instance.
DISK_%N_NAME
(Optional) The name, if any, associated with the N-th disk of the instance.
DISK_%N_FRONTEND_TYPE
(Optional) If applicable to the current hypervisor type: the type
of the device exported by the hypervisor. For example, the Xen HVM
......@@ -96,6 +102,12 @@ NIC_COUNT
NIC_%N_MAC
The MAC address associated with this interface.
NIC_%N_UUID
The uuid associated with the N-th NIC of the instance.
NIC_%N_NAME
(Optional) The name, if any, associated with the N-th NIC of the instance.
NIC_%N_IP
The IP address, if any, associated with the N-th NIC of the
instance.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment