Commit fd5578ee authored by Klaus Aehlig's avatar Klaus Aehlig

Merge branch 'stable-2.8' into stable-2.9

* stable-2.8
  Improve job status assert affected by race condition
  Export and import Disk/NIC name
  Fix backup import in case NIC is inside a network
  Override get() method of ConfigParser

Conflicts:
	lib/cmdlib/instance.py: manually apply 0973f9ed on
	  the stable-2.9 version
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parents 3daaab6c e6e17529
......@@ -3061,6 +3061,8 @@ def FinalizeExport(instance, snap_disks):
config.set(constants.INISECT_INS, "nic%d_ip" % nic_count, "%s" % nic.ip)
config.set(constants.INISECT_INS, "nic%d_network" % nic_count,
"%s" % nic.network)
config.set(constants.INISECT_INS, "nic%d_name" % nic_count,
"%s" % nic.name)
for param in constants.NICS_PARAMETER_TYPES:
config.set(constants.INISECT_INS, "nic%d_%s" % (nic_count, param),
"%s" % nic.nicparams.get(param, None))
......@@ -3077,6 +3079,8 @@ def FinalizeExport(instance, snap_disks):
("%s" % disk.physical_id[1]))
config.set(constants.INISECT_INS, "disk%d_size" % disk_count,
("%d" % disk.size))
config.set(constants.INISECT_INS, "disk%d_name" % disk_count,
"%s" % disk.name)
config.set(constants.INISECT_INS, "disk_count", "%d" % disk_total)
......
......@@ -746,7 +746,12 @@ class LUInstanceCreate(LogicalUnit):
for idx in range(constants.MAX_DISKS):
if einfo.has_option(constants.INISECT_INS, "disk%d_size" % idx):
disk_sz = einfo.getint(constants.INISECT_INS, "disk%d_size" % idx)
disks.append({constants.IDISK_SIZE: disk_sz})
disk_name = einfo.get(constants.INISECT_INS, "disk%d_name" % idx)
disk = {
constants.IDISK_SIZE: disk_sz,
constants.IDISK_NAME: disk_name
}
disks.append(disk)
self.op.disks = disks
if not disks and self.op.disk_template != constants.DT_DISKLESS:
raise errors.OpPrereqError("No disk info specified and the export"
......@@ -758,10 +763,21 @@ class LUInstanceCreate(LogicalUnit):
for idx in range(constants.MAX_NICS):
if einfo.has_option(constants.INISECT_INS, "nic%d_mac" % idx):
ndict = {}
for name in list(constants.NICS_PARAMETERS) + ["ip", "mac"]:
for name in [constants.INIC_IP,
constants.INIC_MAC, constants.INIC_NAME]:
nic_param_name = "nic%d_%s" % (idx, name)
if einfo.has_option(constants.INISECT_INS, nic_param_name):
v = einfo.get(constants.INISECT_INS, nic_param_name)
v = einfo.get(constants.INISECT_INS, "nic%d_%s" % (idx, name))
ndict[name] = v
network = einfo.get(constants.INISECT_INS,
"nic%d_%s" % (idx, constants.INIC_NETWORK))
# in case network is given link and mode are inherited
# from nodegroup's netparams and thus should not be passed here
if network:
ndict[constants.INIC_NETWORK] = network
else:
for name in list(constants.NICS_PARAMETERS):
v = einfo.get(constants.INISECT_INS, "nic%d_%s" % (idx, name))
ndict[name] = v
nics.append(ndict)
else:
......
......@@ -1104,7 +1104,12 @@ class _JobProcessor(object):
"""
op = opctx.op
assert op.status == constants.OP_STATUS_WAITING
assert op.status in (constants.OP_STATUS_WAITING,
constants.OP_STATUS_CANCELING)
# The very last check if the job was cancelled before trying to execute
if op.status == constants.OP_STATUS_CANCELING:
return (constants.OP_STATUS_CANCELING, None)
timeout = opctx.GetNextLockTimeout()
......
......@@ -2202,7 +2202,8 @@ class Network(TaggableObject):
return obj
class SerializableConfigParser(ConfigParser.SafeConfigParser):
# need to inherit object in order to use super()
class SerializableConfigParser(ConfigParser.SafeConfigParser, object):
"""Simple wrapper over ConfigParse that allows serialization.
This class is basically ConfigParser.SafeConfigParser with two
......@@ -2224,6 +2225,23 @@ class SerializableConfigParser(ConfigParser.SafeConfigParser):
cfp.readfp(buf)
return cfp
def get(self, section, option, **kwargs):
value = None
try:
value = super(SerializableConfigParser, self).get(section, option,
**kwargs)
if value.lower() == constants.VALUE_NONE:
value = None
except ConfigParser.NoOptionError:
r = re.compile(r"(disk|nic)\d+_name")
match = r.match(option)
if match:
pass
else:
raise
return value
class LvmPvInfo(ConfigObject):
"""Information about an LVM physical volume (PV).
......
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