LGTM, thanks

On Fri, Oct 24, 2014, 1:32 PM 'Petr Pudlak' via ganeti-devel <
[email protected]> wrote:

> .... instead of a string. This reduces the chance of programmer errors
> and also eliminates the need to include comma separators everywhere.
>
> Signed-off-by: Petr Pudlak <[email protected]>
> ---
>  lib/hypervisor/hv_xen.py | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py
> index 07464bb..3677691 100644
> --- a/lib/hypervisor/hv_xen.py
> +++ b/lib/hypervisor/hv_xen.py
> @@ -588,29 +588,31 @@ class XenHypervisor(hv_base.BaseHypervisor):
>            (nic_type, constants.HT_HVM_VIF_IOEMU)
>
>      for idx, nic in enumerate(instance.nics):
> -      nic_str = "mac=%s%s" % (nic.mac, nic_type_str)
> +      nic_args = {}
> +      nic_args["mac"] = "%s%s" % (nic.mac, nic_type_str)
>
>        ip = getattr(nic, "ip", None)
>        if ip is not None:
> -        nic_str += ", ip=%s" % ip
> +        nic_args["ip"] = ip
>
>        if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
> -        nic_str += ", bridge=%s" % nic.nicparams[constants.NIC_LINK]
> +        nic_args["bridge"] = nic.nicparams[constants.NIC_LINK]
>        elif nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_OVS:
> -        nic_str += ", bridge=%s" % nic.nicparams[constants.NIC_LINK]
> +        nic_args["bridge"] = nic.nicparams[constants.NIC_LINK]
>          if nic.nicparams[constants.NIC_VLAN]:
> -          nic_str += "%s" % nic.nicparams[constants.NIC_VLAN]
> +          nic_args["bridge"] += nic.nicparams[constants.NIC_VLAN]
>
>        if nic.name and \
>              nic.name.startswith(constants.INSTANCE_COMMUNICATION_NIC_
> PREFIX):
>          tap = hv_base.GenerateTapName()
> -        nic_str += ", vifname=%s" % tap
> +        nic_args["vifname"] = tap
>          nic.name = tap
>
>        if hvp[constants.HV_VIF_SCRIPT]:
> -        nic_str += ", script=%s" % hvp[constants.HV_VIF_SCRIPT]
> +        nic_args["script"] = hvp[constants.HV_VIF_SCRIPT]
>
> -      vif_data.append("'%s'" % nic_str)
> +      nic_str = ", ".join(["%s=%s" % p for p in nic_args.items()])
> +      vif_data.append("'%s'" % (nic_str, ))
>        self._WriteNICInfoFile(instance, idx, nic)
>
>      config.write("vif = [%s]\n" % ",".join(vif_data))
> --
> 2.1.0.rc2.206.gedb03e5
>
>

Reply via email to