Commit 31ca841c authored by Iustin Pop's avatar Iustin Pop
Browse files

Merge branch 'devel-2.1' into master


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarBalazs Lecz <leczb@google.com>
parents 6b997854 c47478f9
...@@ -1863,7 +1863,7 @@ def _TryOSFromDisk(name, base_dir=None): ...@@ -1863,7 +1863,7 @@ def _TryOSFromDisk(name, base_dir=None):
return False, ("File '%s' under path '%s' is not executable" % return False, ("File '%s' under path '%s' is not executable" %
(filename, os_dir)) (filename, os_dir))
variants = None variants = []
if constants.OS_VARIANTS_FILE in os_files: if constants.OS_VARIANTS_FILE in os_files:
variants_file = os_files[constants.OS_VARIANTS_FILE] variants_file = os_files[constants.OS_VARIANTS_FILE]
try: try:
......
...@@ -2760,14 +2760,14 @@ class LUDiagnoseOS(NoHooksLU): ...@@ -2760,14 +2760,14 @@ class LUDiagnoseOS(NoHooksLU):
for osl in os_data.values(): for osl in os_data.values():
valid = valid and osl and osl[0][1] valid = valid and osl and osl[0][1]
if not valid: if not valid:
variants = None variants = set()
break break
if calc_variants: if calc_variants:
node_variants = osl[0][3] node_variants = osl[0][3]
if variants is None: if variants is None:
variants = node_variants variants = set(node_variants)
else: else:
variants = [v for v in variants if v in node_variants] variants.intersection_update(node_variants)
for field in self.op.output_fields: for field in self.op.output_fields:
if field == "name": if field == "name":
...@@ -2780,7 +2780,7 @@ class LUDiagnoseOS(NoHooksLU): ...@@ -2780,7 +2780,7 @@ class LUDiagnoseOS(NoHooksLU):
for node_name, nos_list in os_data.items(): for node_name, nos_list in os_data.items():
val[node_name] = nos_list val[node_name] = nos_list
elif field == "variants": elif field == "variants":
val = variants val = list(variants)
else: else:
raise errors.ParameterError(field) raise errors.ParameterError(field)
row.append(val) row.append(val)
...@@ -4175,8 +4175,7 @@ class LUStartupInstance(LogicalUnit): ...@@ -4175,8 +4175,7 @@ class LUStartupInstance(LogicalUnit):
# check hypervisor parameter syntax (locally) # check hypervisor parameter syntax (locally)
cluster = self.cfg.GetClusterInfo() cluster = self.cfg.GetClusterInfo()
utils.ForceDictType(self.hvparams, constants.HVS_PARAMETER_TYPES) utils.ForceDictType(self.hvparams, constants.HVS_PARAMETER_TYPES)
filled_hvp = objects.FillDict(cluster.hvparams[instance.hypervisor], filled_hvp = cluster.FillHV(instance)
instance.hvparams)
filled_hvp.update(self.hvparams) filled_hvp.update(self.hvparams)
hv_type = hypervisor.GetHypervisor(instance.hypervisor) hv_type = hypervisor.GetHypervisor(instance.hypervisor)
hv_type.CheckParameterSyntax(filled_hvp) hv_type.CheckParameterSyntax(filled_hvp)
...@@ -5450,15 +5449,15 @@ class TLMigrateInstance(Tasklet): ...@@ -5450,15 +5449,15 @@ class TLMigrateInstance(Tasklet):
target_node = secondary_nodes[0] target_node = secondary_nodes[0]
# check memory requirements on the secondary node # check memory requirements on the secondary node
_CheckNodeFreeMemory(self, target_node, "migrating instance %s" % _CheckNodeFreeMemory(self.lu, target_node, "migrating instance %s" %
instance.name, i_be[constants.BE_MEMORY], instance.name, i_be[constants.BE_MEMORY],
instance.hypervisor) instance.hypervisor)
# check bridge existance # check bridge existance
_CheckInstanceBridgesExist(self, instance, node=target_node) _CheckInstanceBridgesExist(self.lu, instance, node=target_node)
if not self.cleanup: if not self.cleanup:
_CheckNodeNotDrained(self, target_node) _CheckNodeNotDrained(self.lu, target_node)
result = self.rpc.call_instance_migratable(instance.primary_node, result = self.rpc.call_instance_migratable(instance.primary_node,
instance) instance)
result.Raise("Can't migrate, please use failover", result.Raise("Can't migrate, please use failover",
...@@ -5647,7 +5646,7 @@ class TLMigrateInstance(Tasklet): ...@@ -5647,7 +5646,7 @@ class TLMigrateInstance(Tasklet):
self.feedback_fn("* checking disk consistency between source and target") self.feedback_fn("* checking disk consistency between source and target")
for dev in instance.disks: for dev in instance.disks:
if not _CheckDiskConsistency(self, dev, target_node, False): if not _CheckDiskConsistency(self.lu, dev, target_node, False):
raise errors.OpExecError("Disk %s is degraded or not fully" raise errors.OpExecError("Disk %s is degraded or not fully"
" synchronized on target node," " synchronized on target node,"
" aborting migrate." % dev.iv_name) " aborting migrate." % dev.iv_name)
...@@ -6105,9 +6104,15 @@ class LUCreateInstance(LogicalUnit): ...@@ -6105,9 +6104,15 @@ class LUCreateInstance(LogicalUnit):
# TODO: make the ip check more flexible and not depend on the name check # TODO: make the ip check more flexible and not depend on the name check
raise errors.OpPrereqError("Cannot do ip checks without a name check", raise errors.OpPrereqError("Cannot do ip checks without a name check",
errors.ECODE_INVAL) errors.ECODE_INVAL)
# check disk information: either all adopt, or no adopt
# check nics' parameter names
for nic in self.op.nics:
utils.ForceDictType(nic, constants.INIC_PARAMS_TYPES)
# check disks. parameter names and consistent adopt/no-adopt strategy
has_adopt = has_no_adopt = False has_adopt = has_no_adopt = False
for disk in self.op.disks: for disk in self.op.disks:
utils.ForceDictType(disk, constants.IDISK_PARAMS_TYPES)
if "adopt" in disk: if "adopt" in disk:
has_adopt = True has_adopt = True
else: else:
...@@ -8243,6 +8248,7 @@ class LUSetInstanceParams(LogicalUnit): ...@@ -8243,6 +8248,7 @@ class LUSetInstanceParams(LogicalUnit):
# Disk validation # Disk validation
disk_addremove = 0 disk_addremove = 0
for disk_op, disk_dict in self.op.disks: for disk_op, disk_dict in self.op.disks:
utils.ForceDictType(disk_dict, constants.IDISK_PARAMS_TYPES)
if disk_op == constants.DDM_REMOVE: if disk_op == constants.DDM_REMOVE:
disk_addremove += 1 disk_addremove += 1
continue continue
...@@ -8296,6 +8302,7 @@ class LUSetInstanceParams(LogicalUnit): ...@@ -8296,6 +8302,7 @@ class LUSetInstanceParams(LogicalUnit):
# NIC validation # NIC validation
nic_addremove = 0 nic_addremove = 0
for nic_op, nic_dict in self.op.nics: for nic_op, nic_dict in self.op.nics:
utils.ForceDictType(nic_dict, constants.INIC_PARAMS_TYPES)
if nic_op == constants.DDM_REMOVE: if nic_op == constants.DDM_REMOVE:
nic_addremove += 1 nic_addremove += 1
continue continue
......
...@@ -585,6 +585,18 @@ NICS_PARAMETER_TYPES = { ...@@ -585,6 +585,18 @@ NICS_PARAMETER_TYPES = {
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys()) NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
IDISK_SIZE = "size"
IDISK_MODE = "mode"
IDISK_PARAMS = frozenset([IDISK_SIZE, IDISK_MODE])
IDISK_PARAMS_TYPES = {IDISK_SIZE: VTYPE_SIZE, IDISK_MODE: VTYPE_STRING}
INIC_MAC = "mac"
INIC_IP = "ip"
INIC_MODE = "mode"
INIC_LINK = "link"
INIC_BRIDGE = "bridge"
INIC_PARAMS = frozenset([INIC_MAC, INIC_IP, INIC_MODE, INIC_LINK, INIC_BRIDGE])
INIC_PARAMS_TYPES = dict([(name, VTYPE_STRING) for name in INIC_PARAMS])
# Hypervisor constants # Hypervisor constants
HT_XEN_PVM = "xen-pvm" HT_XEN_PVM = "xen-pvm"
HT_FAKE = "fake" HT_FAKE = "fake"
......
...@@ -42,7 +42,7 @@ class FakeHypervisor(hv_base.BaseHypervisor): ...@@ -42,7 +42,7 @@ class FakeHypervisor(hv_base.BaseHypervisor):
""" """
CAN_MIGRATE = True CAN_MIGRATE = True
_ROOT_DIR = constants.RUN_DIR + "/ganeti-fake-hypervisor" _ROOT_DIR = constants.RUN_GANETI_DIR + "/fake-hypervisor"
def __init__(self): def __init__(self):
hv_base.BaseHypervisor.__init__(self) hv_base.BaseHypervisor.__init__(self)
......
...@@ -193,7 +193,7 @@ class RpcResult(object): ...@@ -193,7 +193,7 @@ class RpcResult(object):
else: else:
ec = errors.OpExecError ec = errors.OpExecError
if ecode is not None: if ecode is not None:
args = (msg, prereq) args = (msg, ecode)
else: else:
args = (msg, ) args = (msg, )
raise ec(*args) # pylint: disable-msg=W0142 raise ec(*args) # pylint: disable-msg=W0142
......
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