Revision 05f86716

b/lib/bootstrap.py
75 75
  This creates the nodepass file containing the shared password for
76 76
  the cluster and also generates the SSL certificate.
77 77

  
78
  Args:
79
    ss: A WritableSimpleStore
80

  
78 81
  """
79 82
  # Create pseudo random password
80 83
  randpass = sha.new(os.urandom(64)).hexdigest()
......
191 194
                               " executable." % constants.NODE_INITD_SCRIPT)
192 195

  
193 196
  # set up the simple store
194
  ss = ssconf.SimpleStore()
197
  ss = ssconf.WritableSimpleStore()
195 198
  ss.SetKey(ss.SS_HYPERVISOR, hypervisor_type)
196 199
  ss.SetKey(ss.SS_MASTER_NODE, hostname.name)
197 200
  ss.SetKey(ss.SS_MASTER_IP, clustername.ip)
b/lib/cmdlib.py
54 54
    - implement Exec
55 55
    - implement BuildHooksEnv
56 56
    - redefine HPATH and HTYPE
57
    - optionally redefine their run requirements (REQ_MASTER); note that all
58
      commands require root permissions
57
    - optionally redefine their run requirements:
58
        REQ_MASTER: the LU needs to run on the master node
59
        REQ_WSSTORE: the LU needs a writable SimpleStore
60

  
61
  Note that all commands require root permissions.
59 62

  
60 63
  """
61 64
  HPATH = None
62 65
  HTYPE = None
63 66
  _OP_REQP = []
64 67
  REQ_MASTER = True
68
  REQ_WSSTORE = False
65 69

  
66 70
  def __init__(self, processor, op, cfg, sstore):
67 71
    """Constructor for LogicalUnit.
......
849 853
  HPATH = "cluster-rename"
850 854
  HTYPE = constants.HTYPE_CLUSTER
851 855
  _OP_REQP = ["name"]
856
  REQ_WSSTORE = True
852 857

  
853 858
  def BuildHooksEnv(self):
854 859
    """Build hooks env.
......
1661 1666
  HPATH = "master-failover"
1662 1667
  HTYPE = constants.HTYPE_CLUSTER
1663 1668
  REQ_MASTER = False
1669
  REQ_WSSTORE = True
1664 1670
  _OP_REQP = []
1665 1671

  
1666 1672
  def BuildHooksEnv(self):
b/lib/mcpu.py
118 118

  
119 119
    if self.cfg is None:
120 120
      self.cfg = config.ConfigWriter()
121
      self.sstore = ssconf.SimpleStore()
121
      if lu_class.REQ_WSSTORE:
122
        self.sstore = ssconf.WritableSimpleStore()
123
      else:
124
        self.sstore = ssconf.SimpleStore()
122 125
    if self.cfg is not None:
123 126
      write_count = self.cfg.write_count
124 127
    else:
b/lib/ssconf.py
47 47
  Other particularities of the datastore:
48 48
    - keys are restricted to predefined values
49 49
    - values are small (<4k)
50
    - some keys are handled specially (read from the system, so
51
      we can't update them)
50
    - some keys are handled specially (read from the system)
52 51

  
53 52
  """
54 53
  _SS_FILEPREFIX = "ssconf_"
......
170 169
      raise errors.ConfigurationError("Failed to convert config version %s to"
171 170
                                      " int: '%s'" % (value, str(err)))
172 171

  
172
  def GetFileList(self):
173
    """Return the list of all config files.
174

  
175
    This is used for computing node replication data.
176

  
177
    """
178
    return [self.KeyToFilename(key) for key in self._VALID_KEYS]
179

  
180

  
181
class WritableSimpleStore(SimpleStore):
182
  """This is a read/write interface to SimpleStore, which is used rarely, when
183
  values need to be changed. Since WriteFile handles updates in an atomic way
184
  it should be fine to use two WritableSimpleStore at the same time, but in
185
  the future we might want to put additional protection for this class.
186

  
187
  A WritableSimpleStore cannot be used to update system-dependent values.
188

  
189
  """
190

  
173 191
  def SetKey(self, key, value):
174 192
    """Set the value of a key.
175 193

  
......
181 199
    utils.WriteFile(file_name, data="%s\n" % str(value),
182 200
                    uid=0, gid=0, mode=0400)
183 201

  
184
  def GetFileList(self):
185
    """Return the list of all config files.
186

  
187
    This is used for computing node replication data.
188

  
189
    """
190
    return [self.KeyToFilename(key) for key in self._VALID_KEYS]

Also available in: Unified diff