Remove REQ_CLUSTER from opcode handling code
authorMichael Hanselmann <hansmi@google.com>
Thu, 12 Jun 2008 10:18:39 +0000 (10:18 +0000)
committerMichael Hanselmann <hansmi@google.com>
Thu, 12 Jun 2008 10:18:39 +0000 (10:18 +0000)
It's not needed anymore now that all opcodes require a cluster. Cluster
initialization was the only exception.

Reviewed-by: iustinp

lib/cmdlib.py
lib/mcpu.py

index 1baef52..86f6da2 100644 (file)
@@ -54,14 +54,13 @@ class LogicalUnit(object):
     - implement Exec
     - implement BuildHooksEnv
     - redefine HPATH and HTYPE
-    - optionally redefine their run requirements (REQ_CLUSTER,
-      REQ_MASTER); note that all commands require root permissions
+    - optionally redefine their run requirements (REQ_MASTER); note that all
+      commands require root permissions
 
   """
   HPATH = None
   HTYPE = None
   _OP_REQP = []
-  REQ_CLUSTER = True
   REQ_MASTER = True
 
   def __init__(self, processor, op, cfg, sstore):
@@ -82,15 +81,15 @@ class LogicalUnit(object):
       if attr_val is None:
         raise errors.OpPrereqError("Required parameter '%s' missing" %
                                    attr_name)
-    if self.REQ_CLUSTER:
-      if not cfg.IsCluster():
-        raise errors.OpPrereqError("Cluster not initialized yet,"
-                                   " use 'gnt-cluster init' first.")
-      if self.REQ_MASTER:
-        master = sstore.GetMasterNode()
-        if master != utils.HostInfo().name:
-          raise errors.OpPrereqError("Commands must be run on the master"
-                                     " node %s" % master)
+
+    if not cfg.IsCluster():
+      raise errors.OpPrereqError("Cluster not initialized yet,"
+                                 " use 'gnt-cluster init' first.")
+    if self.REQ_MASTER:
+      master = sstore.GetMasterNode()
+      if master != utils.HostInfo().name:
+        raise errors.OpPrereqError("Commands must be run on the master"
+                                   " node %s" % master)
 
   def __GetSSH(self):
     """Returns the SshRunner object
index 6411df5..6619273 100644 (file)
@@ -117,7 +117,7 @@ class Processor(object):
     if lu_class is None:
       raise errors.OpCodeUnknown("Unknown opcode")
 
-    if lu_class.REQ_CLUSTER and self.cfg is None:
+    if self.cfg is None:
       self.cfg = config.ConfigWriter()
       self.sstore = ssconf.SimpleStore()
     if self.cfg is not None:
@@ -162,7 +162,7 @@ class Processor(object):
     if lu_class is None:
       raise errors.OpCodeUnknown("Unknown opcode")
 
-    if lu_class.REQ_CLUSTER and self.cfg is None:
+    if self.cfg is None:
       self.cfg = config.ConfigWriter()
       self.sstore = ssconf.SimpleStore()
     #do_hooks = lu_class.HPATH is not None