From 18ffc0fe13aa3c58fdd6926551ebe4569fc0125f Mon Sep 17 00:00:00 2001 From: Stephen Shirley <diamond@google.com> Date: Mon, 31 Jan 2011 17:07:08 +0100 Subject: [PATCH] Enforce that new node groups have unique names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stephen Shirley <diamond@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- lib/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/config.py b/lib/config.py index a639fd878..86b98fc56 100644 --- a/lib/config.py +++ b/lib/config.py @@ -942,6 +942,16 @@ class ConfigWriter: if check_uuid: self._EnsureUUID(group, ec_id) + try: + existing_uuid = self._UnlockedLookupNodeGroup(group.name) + except errors.OpPrereqError: + pass + else: + raise errors.OpPrereqError("Desired group name '%s' already exists as a" + " node group (UUID: %s)" % + (group.name, existing_uuid), + errors.ECODE_EXISTS) + group.serial_no = 1 group.ctime = group.mtime = time.time() group.UpgradeConfig() -- GitLab