Revision 07e68848 lib/cmdlib/node.py

b/lib/cmdlib/node.py
112 112
      raise errors.OpPrereqError("Cannot pass a node group when a node is"
113 113
                                 " being readded", errors.ECODE_INVAL)
114 114

  
115
    if self.op.ndparams:
116
      ovs = self.op.ndparams.get(constants.ND_OVS, None)
117
      ovs_name = self.op.ndparams.get(constants.ND_OVS_NAME, None)
118
      ovs_link = self.op.ndparams.get(constants.ND_OVS_LINK, None)
119

  
120
      # OpenvSwitch: Warn user if link is missing
121
      if ovs and not ovs_link:
122
        self.LogInfo("No physical interface for OpenvSwitch was given."
123
                     " OpenvSwitch will not have an outside connection. This"
124
                     " might not be what you want.")
125
      # OpenvSwitch: Fail if parameters are given, but OVS is not enabled.
126
      if not ovs and (ovs_name or ovs_link):
127
        raise errors.OpPrereqError("OpenvSwitch name or link were given, but"
128
                                   " OpenvSwitch is not enabled. Please enable"
129
                                   " OpenvSwitch with --ovs",
130
                                   errors.ECODE_INVAL)
131

  
132 115
  def BuildHooksEnv(self):
133 116
    """Build hooks env.
134 117

  
......
319 302
        raise errors.OpPrereqError("Checks on node PVs failed: %s" %
320 303
                                   "; ".join(errmsgs), errors.ECODE_ENVIRON)
321 304

  
305
  def _InitOpenVSwitch(self):
306
    filled_ndparams = self.cfg.GetClusterInfo().FillND(
307
      self.new_node, self.cfg.GetNodeGroup(self.new_node.group))
308

  
309
    ovs = filled_ndparams.get(constants.ND_OVS, None)
310
    ovs_name = filled_ndparams.get(constants.ND_OVS_NAME, None)
311
    ovs_link = filled_ndparams.get(constants.ND_OVS_LINK, None)
312

  
313
    if ovs:
314
      if not ovs_link:
315
        self.LogInfo("No physical interface for OpenvSwitch was given."
316
                     " OpenvSwitch will not have an outside connection. This"
317
                     " might not be what you want.")
318

  
319
      result = self.rpc.call_node_configure_ovs(
320
                 self.new_node.name, ovs_name, ovs_link)
321
      result.Raise("Failed to initialize OpenVSwitch on new node")
322

  
322 323
  def Exec(self, feedback_fn):
323 324
    """Adds the new node to the cluster.
324 325

  
......
392 393
                      (verifier, nl_payload[failed]))
393 394
        raise errors.OpExecError("ssh/hostname verification failed")
394 395

  
395
    # OpenvSwitch initialization on the node
396
    ovs = self.new_node.ndparams.get(constants.ND_OVS, None)
397
    ovs_name = self.new_node.ndparams.get(constants.ND_OVS_NAME, None)
398
    ovs_link = self.new_node.ndparams.get(constants.ND_OVS_LINK, None)
399

  
400
    if ovs:
401
      result = self.rpc.call_node_configure_ovs(
402
                 self.new_node.name, ovs_name, ovs_link)
396
    self._InitOpenVSwitch()
403 397

  
404 398
    if self.op.readd:
405 399
      self.context.ReaddNode(self.new_node)

Also available in: Unified diff