Revision 4167825b

b/lib/cmdlib.py
545 545
    ourselves in the post-run node list.
546 546

  
547 547
    """
548
    env = {
549
      "CLUSTER": self.op.cluster_name,
550
      "MASTER": self.hostname.name,
551
      }
552
    return env, [], [self.hostname.name]
548
    return {}, [], [self.hostname.name]
553 549

  
554 550
  def CheckPrereq(self):
555 551
    """Verify that the passed name is a valid one.
......
615 611
    hostname = self.hostname
616 612

  
617 613
    # set up the simple store
618
    ss = ssconf.SimpleStore()
614
    self.sstore = ss = ssconf.SimpleStore()
619 615
    ss.SetKey(ss.SS_HYPERVISOR, self.op.hypervisor_type)
620 616
    ss.SetKey(ss.SS_MASTER_NODE, hostname.name)
621 617
    ss.SetKey(ss.SS_MASTER_IP, clustername.ip)
......
643 639
    _InitSSHSetup(hostname.name)
644 640

  
645 641
    # init of cluster config file
646
    cfgw = config.ConfigWriter()
642
    self.cfg = cfgw = config.ConfigWriter()
647 643
    cfgw.InitConfig(hostname.name, hostname.ip, self.secondary_ip,
648 644
                    sshkey, self.op.mac_prefix,
649 645
                    self.op.vg_name, self.op.def_bridge)
b/lib/mcpu.py
170 170
    self.callfn = callfn
171 171
    self.lu = lu
172 172
    self.op = lu.op
173
    self.hpath = self.lu.HPATH
174 173
    self.env, node_list_pre, node_list_post = self._BuildEnv()
175

  
176 174
    self.node_list = {constants.HOOKS_PHASE_PRE: node_list_pre,
177 175
                      constants.HOOKS_PHASE_POST: node_list_post}
178 176

  
......
198 196
    else:
199 197
      lu_nodes_pre = lu_nodes_post = []
200 198

  
199
    return env, frozenset(lu_nodes_pre), frozenset(lu_nodes_post)
200

  
201
  def _RunWrapper(self, node_list, hpath, phase):
202
    """Simple wrapper over self.callfn.
203

  
204
    This method fixes the environment before doing the rpc call.
205

  
206
    """
207
    env = self.env.copy()
208
    env["GANETI_HOOKS_PHASE"] = phase
209
    env["GANETI_HOOKS_PATH"] = hpath
201 210
    if self.lu.sstore is not None:
202 211
      env["GANETI_CLUSTER"] = self.lu.sstore.GetClusterName()
203 212
      env["GANETI_MASTER"] = self.lu.sstore.GetMasterNode()
204 213

  
205
    for key in env:
206
      if not isinstance(env[key], str):
207
        env[key] = str(env[key])
214
    env = dict([(str(key), str(val)) for key, val in env.iteritems()])
208 215

  
209
    return env, frozenset(lu_nodes_pre), frozenset(lu_nodes_post)
216
    return self.callfn(node_list, hpath, phase, env)
210 217

  
211 218
  def RunPhase(self, phase):
212 219
    """Run all the scripts for a phase.
......
219 226
      # we're in the cluster init phase and the rpc client part can't
220 227
      # even attempt to run, or this LU doesn't do hooks at all
221 228
      return
222
    self.env["GANETI_HOOKS_PHASE"] = str(phase)
223
    results = self.callfn(self.node_list[phase], self.hpath, phase, self.env)
229
    hpath = self.lu.HPATH
230
    results = self._RunWrapper(self.node_list[phase], hpath, phase)
224 231
    if phase == constants.HOOKS_PHASE_PRE:
225 232
      errs = []
226 233
      if not results:

Also available in: Unified diff