- if self.get("controller_ip") and self.get("controller_port"):
- controller_ip = self.get("controller_ip")
- controller_port = self.get("controller_port")
- self.info("Assigning the controller to the %s" % self.get("bridge_name"))
- cmd = "ovs-vsctl set-controller %s tcp:%s:%s" %\
- (self.get("bridge_name"), controller_ip, controller_port)
- out = err = ""
- (out, err), proc = self.node.run(cmd, self.ovs_checks,
- sudo = True,
- stdout = "stdout",
- stderr = "stderr")
- if err != "":
- self.debug("SSH connection refusing in assign_contr")
- raise RuntimeError, msg
- self.info("Controller assigned")
+
+ if not (self.get("controller_ip") and self.get("controller_port")):
+ msg = "No assignment in one or both attributes"
+ self.error(msg)
+ raise AttributeError, msg
+
+ cmd = "ovs-vsctl set-controller %s tcp:%s:%s" %\
+ (self.get("bridge_name"), self.get("controller_ip"), self.get("controller_port"))
+ out = err = ""
+ (out, err), proc = self.node.run(cmd, self.ovs_checks,
+ sudo = True,
+ stdout = "stdout",
+ stderr = "stderr")
+
+ if err != "":
+ msg = "SSH connection in the method assign_controller"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ self.info("Controller assigned to the bridge %s" % self.get("bridge_name"))