← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:dhclient-hook-on-azure-only into cloud-init:master

 


Diff comments:

> diff --git a/tools/hook-dhclient b/tools/hook-dhclient
> index d099979..6a4626c 100755
> --- a/tools/hook-dhclient
> +++ b/tools/hook-dhclient
> @@ -1,9 +1,24 @@
>  #!/bin/sh
>  # This script writes DHCP lease information into the cloud-init run directory
>  # It is sourced, not executed.  For more information see dhclient-script(8).
> +is_azure() {
> +    local dmi_path="/sys/class/dmi/id/board_vendor" vendor=""
> +    if [ -e "$dmi_path" ] && read vendor < "$dmi_path"; then

Ah, uh...obviously remember to set dmi_path, because I forgot that in my comment :)

> +        [ "$vendor" = "Microsoft Corporation" ] && return 0
> +    fi
> +    return 1
> +}
>  
> -case "$reason" in
> -   BOUND) cloud-init dhclient-hook up "$interface";;
> -   DOWN|RELEASE|REBOOT|STOP|EXPIRE)
> -      cloud-init dhclient-hook down "$interface";;
> -esac
> +is_enabled() {
> +    # only execute hooks if cloud-init is enabled and on azure
> +    [ -e /run/cloud-init/enabled ] || return 1
> +    is_azure
> +}
> +
> +if is_enabled; then
> +   case "$reason" in
> +      BOUND) cloud-init dhclient-hook up "$interface";;
> +      DOWN|RELEASE|REBOOT|STOP|EXPIRE)
> +         cloud-init dhclient-hook down "$interface";;
> +   esac
> +fi


-- 
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/303303
Your team cloud init development team is requested to review the proposed merge of ~smoser/cloud-init:dhclient-hook-on-azure-only into cloud-init:master.


References