diff --git a/lib/backend.py b/lib/backend.py index 5b2bebde89a039ebb895fe7f08e76deb128fbab6..501696994736e18f9d07e2a4c11667a6181b6c32 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1,7 +1,7 @@ # # -# 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: diff --git a/lib/cmdlib.py b/lib/cmdlib.py index b45389309e8643b9433e53ae7cb297216eda1126..deee80e0ee7b1768a671d394045bc999ed02b428 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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 diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index b7e9b9bf453bc6b7bead5624c83cf7f2a9dc31a1..eed96400e1795af56774b913048a6b5ca355214a 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -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.