Commit 55ec5c5e authored by Michael Hanselmann's avatar Michael Hanselmann

Merge branch 'stable-2.2' into devel-2.2

* stable-2.2:
  cmdlib: Fix type of “name” parameter for tag operations
  rlib2: Set tag operation param “name” to None for cluster tags
  Fix OS_VARIANT variable setting
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parents bc8bbda1 bf2ace9f
#
#
# Copyright (C) 2006, 2007 Google Inc.
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -1952,9 +1952,11 @@ def OSFromDisk(name, base_dir=None):
return payload
def OSCoreEnv(inst_os, os_params, debug=0):
def OSCoreEnv(os_name, inst_os, os_params, debug=0):
"""Calculate the basic environment for an os script.
@type os_name: str
@param os_name: full operating system name (including variant)
@type inst_os: L{objects.OS}
@param inst_os: operating system for which the environment is being built
@type os_params: dict
......@@ -1977,7 +1979,7 @@ def OSCoreEnv(inst_os, os_params, debug=0):
# OS variants
if api_version >= constants.OS_API_V15:
try:
variant = inst_os.name.split('+', 1)[1]
variant = os_name.split('+', 1)[1]
except IndexError:
variant = inst_os.supported_variants[0]
result['OS_VARIANT'] = variant
......@@ -2004,7 +2006,7 @@ def OSEnvironment(instance, inst_os, debug=0):
cannot be found
"""
result = OSCoreEnv(inst_os, instance.osparams, debug=debug)
result = OSCoreEnv(instance.os, inst_os, instance.osparams, debug=debug)
result['INSTANCE_NAME'] = instance.name
result['INSTANCE_OS'] = instance.os
......@@ -2541,7 +2543,7 @@ def ValidateOS(required, osname, checks, osparams):
if constants.OS_VALIDATE_PARAMETERS in checks:
_CheckOSPList(tbv, osparams.keys())
validate_env = OSCoreEnv(tbv, osparams)
validate_env = OSCoreEnv(osname, tbv, osparams)
result = utils.RunCmd([tbv.verify_script] + checks, env=validate_env,
cwd=tbv.path)
if result.failed:
......
......@@ -9739,7 +9739,8 @@ class LUGetTags(TagsLU):
"""
_OP_PARAMS = [
("kind", _NoDefault, _TElemOf(constants.VALID_TAG_TYPES)),
("name", _NoDefault, _TNonEmptyString),
# Name is only meaningful for nodes and instances
("name", _NoDefault, _TMaybeString),
]
REQ_BGL = False
......@@ -9798,7 +9799,8 @@ class LUAddTags(TagsLU):
"""
_OP_PARAMS = [
("kind", _NoDefault, _TElemOf(constants.VALID_TAG_TYPES)),
("name", _NoDefault, _TNonEmptyString),
# Name is only meaningful for nodes and instances
("name", _NoDefault, _TMaybeString),
("tags", _NoDefault, _TListOf(_TNonEmptyString)),
]
REQ_BGL = False
......@@ -9831,7 +9833,8 @@ class LUDelTags(TagsLU):
"""
_OP_PARAMS = [
("kind", _NoDefault, _TElemOf(constants.VALID_TAG_TYPES)),
("name", _NoDefault, _TNonEmptyString),
# Name is only meaningful for nodes and instances
("name", _NoDefault, _TMaybeString),
("tags", _NoDefault, _TListOf(_TNonEmptyString)),
]
REQ_BGL = False
......
......@@ -1122,10 +1122,10 @@ class _R_Tags(baserlib.R_Generic):
"""
baserlib.R_Generic.__init__(self, items, queryargs, req)
if self.TAG_LEVEL != constants.TAG_CLUSTER:
self.name = items[0]
if self.TAG_LEVEL == constants.TAG_CLUSTER:
self.name = None
else:
self.name = ""
self.name = items[0]
def GET(self):
"""Returns a list of tags.
......
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