On Fri, Sep 18, 2009 at 11:46 AM, Flavio Silvestrow
<[email protected]> wrote:
> On Thu, Sep 17, 2009 at 09:43:21PM +0100, Guido Trotter wrote:
>> we could do perhaps
>> from ganeti import errors as ganeti_errors
>
> Done (see interdiff below).
>
>> and
>> from nbma import errors (see below)
>> so we can define our own errors.
>
> I'll leave it as is for now and change when we have our own errors
> module, if that's ok.
>
>> > + if context not in CONTEXTS:
>> > + raise errors.ConfigurationError("Invalid context '%s'" % context)
>> > +
>>
>> ConfigurationError is used to symbolize an error in the Ganeti configuration.
>> We should really use separate errors, in nbma!
>
> Using ParameterError instead of ConfigurationError (see interdiff
> below).
>
>> LGTM for the rest!!
>
> Thanks!
>
>
> Interdiff:
>
> ---
> lib/networktables.py | 18 +++++++++---------
> 1 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/lib/networktables.py b/lib/networktables.py
> index cf3679b..4828c45 100644
> --- a/lib/networktables.py
> +++ b/lib/networktables.py
> @@ -30,7 +30,7 @@ src_ip:dest_addr mapping.
> """
>
>
> -from ganeti import errors
> +from ganeti import errors as ganeti_errors
> from ganeti import utils
>
>
> @@ -45,11 +45,11 @@ def _CheckValidContext(context):
> @type context: str
> @param context: one of CONTEXTS
>
> - �...@raise errors.ConfigurationError: if a check fails
> + �...@raise ganeti_errors.ParameterError: invalid context
>
> """
> if context not in CONTEXTS:
> - raise errors.ConfigurationError("Invalid context '%s'" % context)
> + raise ganeti_errors.ParameterError("Invalid context '%s'" % context)
>
>
> def RemoveNetworkEntry(ip_address, context, iface):
> @@ -62,7 +62,7 @@ def RemoveNetworkEntry(ip_address, context, iface):
> @type iface: str
> @param iface: network interface to use
>
> - �...@raise errors.Commanderror: if an error occurs during removal
> + �...@raise ganeti_errors.Commanderror: if an error occurs during removal
Here and in other places:
@raise L{ganeti.errors.Commanderror}: ...
(so it's fully qualified inside the ganeti package, which we're not in now :)
Then please can you report the full patch, so I can git-am it :)
Thanks,
Guido
>
> """
> _CheckValidContext(context)
> @@ -73,7 +73,7 @@ def RemoveNetworkEntry(ip_address, context, iface):
> # 2: non-existent entry, we're fine with that
> # something else: unknown, raise error
> if result.exit_code not in (0, 2):
> - raise errors.CommandError("Can't remove network entry")
> + raise ganeti_errors.CommandError("Can't remove network entry")
>
>
> def UpdateNetworkEntry(ip_address, dest_address, context, iface):
> @@ -88,7 +88,7 @@ def UpdateNetworkEntry(ip_address, dest_address, context,
> iface):
> @type iface: str
> @param iface: network interface to use
>
> - �...@raise errors.CommandError: if an error occurs when updating an entry
> + �...@raise ganeti_errors.CommandError: if an error occurs when updating an
> entry
>
> """
> _CheckValidContext(context)
> @@ -104,7 +104,7 @@ def UpdateNetworkEntry(ip_address, dest_address, context,
> iface):
> dest_token, dest_address, "dev", iface,
> extra_args])
> if result.failed:
> - raise errors.CommandError("Could not update table, error %s" %
> + raise ganeti_errors.CommandError("Could not update table, error %s" %
> result.output)
>
>
> @@ -120,14 +120,14 @@ def UpdateNetworkTable(instances, context, iface):
> @type iface: str
> @param iface: network interface to use
>
> - �...@raise errors.CommandError: if an error occurs when listing a table
> + �...@raise ganeti_errors.CommandError: if an error occurs when listing a
> table
>
> """
> _CheckValidContext(context)
> # Check the local table
> result = utils.RunCmd(["ip", context, "show", "dev", iface])
> if result.failed:
> - raise errors.CommandError("Could not list table, error %s" %
> + raise ganeti_errors.CommandError("Could not list table, error %s" %
> result.output)
> table = result.output.splitlines()
>
--
Guido Trotter
Google - Sysops Team
Google Ireland Ltd. : Registered in Ireland with company number 368047.
Gordon House, Barrow Street, Dublin 4, Ireland.