← Back to team overview

sts-sponsors team mailing list archive

Re: [Merge] ~cgrabowski/maas:fix_boot_params_on_deployment into maas:master

 

Review: Approve

+1

A couple of suggestions inline

Diff comments:

> diff --git a/src/maasserver/rpc/boot.py b/src/maasserver/rpc/boot.py
> index 0f2636c..c55c9c2 100644
> --- a/src/maasserver/rpc/boot.py
> +++ b/src/maasserver/rpc/boot.py
> @@ -49,19 +49,23 @@ def get_node_from_mac_or_hardware_uuid(mac=None, hardware_uuid=None):
>      Returns a Node object or None if no node with the given MAC address or
>      hardware UUID exists.
>      """
> -    if mac and hardware_uuid:
> -        node = Node.objects.filter(
> -            Q(
> +    if mac:
> +        if "-" in mac:
> +            mac = mac.replace("-", ":")

This should use normalise_macaddress (from maasserver.fields)

> +
> +        if hardware_uuid:
> +            node = Node.objects.filter(
> +                Q(
> +                    current_config__interface__type=INTERFACE_TYPE.PHYSICAL,
> +                    current_config__interface__mac_address=mac,
> +                )
> +                | Q(hardware_uuid__iexact=hardware_uuid)
> +            )
> +        else:
> +            node = Node.objects.filter(
>                  current_config__interface__type=INTERFACE_TYPE.PHYSICAL,
>                  current_config__interface__mac_address=mac,
>              )

The whole block could also be simplified a bit with:


if mac:
    mac = normalise_macaddress(mac)
    q = Q(
        current_config__interface__type=INTERFACE_TYPE.PHYSICAL,
        current_config__interface__mac_address=mac,
    )
    if hardware_uuid:
        q |= Q(hardware_uuid_iexact=hardware_uuid)
    node = Node.objects.filter(q)
elif hardare_uuid:
    ...

> -            | Q(hardware_uuid__iexact=hardware_uuid)
> -        )
> -    elif mac:
> -        node = Node.objects.filter(
> -            current_config__interface__type=INTERFACE_TYPE.PHYSICAL,
> -            current_config__interface__mac_address=mac,
> -        )
>      elif hardware_uuid:
>          node = Node.objects.filter(hardware_uuid__iexact=hardware_uuid)
>      else:


-- 
https://code.launchpad.net/~cgrabowski/maas/+git/maas/+merge/438942
Your team MAAS Committers is subscribed to branch maas:master.



References