Hi!

On Thu, Feb 14, 2013 at 3:06 PM, Dimitris Aragiorgis <[email protected]>wrote:

> This gets all network info from config_data and parses
> all instances and their NICs and makes the substitution.
>
> Signed-off-by: Dimitris Aragiorgis <[email protected]>
> ---
>  tools/cfgupgrade |   13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/tools/cfgupgrade b/tools/cfgupgrade
> index bccb34e..d538284 100755
> --- a/tools/cfgupgrade
> +++ b/tools/cfgupgrade
> @@ -110,6 +110,18 @@ def UpgradeGroups(config_data):
>      if not networks:
>        group["networks"] = {}
>

lint complains: before and after the UpgradeInstances function should be 2
blank lines instead of one. I will fix this before pushing the patch, but
in general, please run 'make lint' on your patches before sending them.
Thanks!


> +def UpgradeInstances(config_data):
> +  network2uuid = dict((n["name"], n["uuid"])
> +                      for n in config_data["networks"].values())
> +  for inst in config_data["instances"].values():
> +    for nic in inst["nics"]:
> +      name = nic.get("network", None)
> +      if name:
> +        uuid = network2uuid.get(name, None)
> +        if uuid:
> +          print("NIC with network name %s found."
> +                " Substituting with uuid %s." % (name, uuid))
> +          nic["network"] = uuid
>
>  def main():
>    """Main program.
> @@ -294,6 +306,7 @@ def main():
>
>    UpgradeNetworks(config_data)
>    UpgradeGroups(config_data)
> +  UpgradeInstances(config_data)
>
>    try:
>      logging.info("Writing configuration file to %s",
> options.CONFIG_DATA_PATH)
> --
> 1.7.10.4
>
>
LGTM

Reply via email to