class TestGetErrorMessage(MAASTestCase): scenarios = [ ('auth', dict( exception=PowerAuthError('auth'), message="Could not authenticate to node's BMC: auth", )), ('conn', dict( exception=PowerConnError('conn'), message="Could not contact node's BMC: conn", )), ('setting', dict( exception=PowerSettingError('setting'), message="Missing or invalid power setting: setting", )), ('tool', dict( exception=PowerToolError('tool'), message="Missing power tool: tool", )), ('action', dict( exception=PowerActionError('action'), message="Failed to complete power action: action", )), ('unknown', dict( exception=PowerError('unknown error'), message="Failed talking to node's BMC: unknown error", )), ] def test_return_msg(self): self.assertEqual(self.message, get_error_message(self.exception))
def _get_ip_address(self, power_address, ip_address): """Get the IP address of the AMT BMC.""" # The user specified power_address overrides any automatically # determined ip_address. if is_power_parameter_set( power_address) and not is_power_parameter_set(ip_address): return power_address elif is_power_parameter_set(ip_address): return ip_address else: raise PowerSettingError( "No IP address provided. " "Please update BMC configuration and try again.")