On Mon, Jun 29, 2009 at 02:41:17PM +0100, Guido Trotter wrote:
>
> If an ident member of an IdentKeyVal relationship starts with no_ or -,
> handle it the same way we do for a key. Some unittests are added to
> check that check_ident_key_val behaves as expected.
>
> This patch also changes ForceDictType to, for now, fail on such an
> entry, and the same to happen when creating an instance or modifying its
> nics or disks.
>
> This behavior will be used later on to allow deletion of os entries in
> os parameters.
>
> Signed-off-by: Guido Trotter <[email protected]>
LGTM, two small corrections:
> --- a/scripts/gnt-backup
> +++ b/scripts/gnt-backup
> @@ -104,6 +104,9 @@ def ImportInstance(opts, args):
> nics = [{}] * nic_max
> for nidx, ndict in opts.nics.items():
> nidx = int(nidx)
> + if not isinstance(ndict, dict):
> + msg = "Invalid nic/%d value: expected dict got %s" % (nidx, ndict)
dict, got (add a comma)
> + raise errors.OpPrereqError(msg)
> nics[nidx] = ndict
> elif opts.no_nics:
> # no nics
> @@ -132,7 +135,10 @@ def ImportInstance(opts, args):
> disks = [{}] * disk_max
> for didx, ddict in opts.disks:
> didx = int(didx)
> - if "size" not in ddict:
> + if not isinstance(ddict, dict):
> + msg = "Invalid disk/%d value: expected dict got %s" % (didx, ddict)
same here.
> + raise errors.OpPrereqError(msg)
> + elif "size" not in ddict:
> raise errors.OpPrereqError("Missing size for disk %d" % didx)
> try:
> ddict["size"] = utils.ParseUnit(ddict["size"])
> diff --git a/scripts/gnt-instance b/scripts/gnt-instance
> index 12152e8..72ee722 100755
> --- a/scripts/gnt-instance
> +++ b/scripts/gnt-instance
> @@ -302,6 +302,9 @@ def AddInstance(opts, args):
> nics = [{}] * nic_max
> for nidx, ndict in opts.nics:
> nidx = int(nidx)
> + if not isinstance(ndict, dict):
> + msg = "Invalid nic/%d value: expected dict got %s" % (nidx, ndict)
same here
> + raise errors.OpPrereqError(msg)
> nics[nidx] = ndict
> elif opts.no_nics:
> # no nics
> @@ -330,7 +333,10 @@ def AddInstance(opts, args):
> disks = [{}] * disk_max
> for didx, ddict in opts.disks:
> didx = int(didx)
> - if "size" not in ddict:
> + if not isinstance(ddict, dict):
> + msg = "Invalid disk/%d value: expected dict got %s" % (didx, ddict)
same here
> + raise errors.OpPrereqError(msg)
> + elif "size" not in ddict:
> raise errors.OpPrereqError("Missing size for disk %d" % didx)
thanks!
iustin