Commit 35c0c8da authored by Iustin Pop's avatar Iustin Pop
Browse files

Convert bridges_exist to new style result

This was a very simple (boolean) RPC, so converting it to actually have
more value with the new style results was more difficult.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
parent e480923b
...@@ -574,11 +574,15 @@ def BridgesExist(bridges_list): ...@@ -574,11 +574,15 @@ def BridgesExist(bridges_list):
@return: C{True} if all of them exist, C{False} otherwise @return: C{True} if all of them exist, C{False} otherwise
""" """
missing = []
for bridge in bridges_list: for bridge in bridges_list:
if not utils.BridgeExists(bridge): if not utils.BridgeExists(bridge):
return False missing.append(bridge)
return True if missing:
return False, "Missing bridges %s" % (", ".join(missing),)
return True, None
def GetInstanceList(hypervisor_list): def GetInstanceList(hypervisor_list):
...@@ -610,11 +610,10 @@ def _CheckNicsBridgesExist(lu, target_nics, target_node, ...@@ -610,11 +610,10 @@ def _CheckNicsBridgesExist(lu, target_nics, target_node,
if params[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED] if params[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED]
if brlist: if brlist:
result = lu.rpc.call_bridges_exist(target_node, brlist) result = lu.rpc.call_bridges_exist(target_node, brlist)
result.Raise() msg = result.RemoteFailMsg()
if not if msg:
raise errors.OpPrereqError("One or more target bridges %s does not" raise errors.OpPrereqError("Error checking bridges on destination node"
" exist on destination node '%s'" % " '%s': %s" % (target_node, msg))
(brlist, target_node))
def _CheckInstanceBridgesExist(lu, instance, node=None): def _CheckInstanceBridgesExist(lu, instance, node=None):
...@@ -6166,10 +6165,9 @@ class LUSetInstanceParams(LogicalUnit): ...@@ -6166,10 +6165,9 @@ class LUSetInstanceParams(LogicalUnit):
if new_nic_mode == constants.NIC_MODE_BRIDGED: if new_nic_mode == constants.NIC_MODE_BRIDGED:
nic_bridge = new_filled_nic_params[constants.NIC_LINK] nic_bridge = new_filled_nic_params[constants.NIC_LINK]
result = self.rpc.call_bridges_exist(pnode, [nic_bridge]) result = self.rpc.call_bridges_exist(pnode, [nic_bridge])
result.Raise() msg = result.RemoteFailMsg()
if not if msg:
msg = ("Bridge '%s' doesn't exist on one of" msg = "Error checking bridges on node %s: %s" % (pnode, msg)
" the instance nodes" % nic_bridge)
if self.force: if self.force:
self.warn.append(msg) self.warn.append(msg)
else: else:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment