← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~chad.smith/cloud-init:set-hostname-before-network into cloud-init:master

 


Diff comments:

> diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
> index d2f1b77..120c3cc 100644
> --- a/cloudinit/cmd/main.py
> +++ b/cloudinit/cmd/main.py
> @@ -354,7 +355,17 @@ def main_init(name, args):
>      LOG.debug("[%s] %s will now be targeting instance id: %s. new=%s",
>                mode, name, iid, init.is_new_instance())
>  
> -    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
> +    if mode == sources.DSMODE_LOCAL:
> +        # Before network comes up, set any configured hostname to allow
> +        # dhcp clients to advertize this hostname to any DDNS services
> +        # lp:1746455.
> +        cloud = init.cloudify()
> +        (hostname, _fqdn) = util.get_hostname_fqdn(

These functions and the cloud/datasource.get_hostname methods are unfortunately different beasts. The util function returns a tuple of hostname/fqdn-hostname. The cloud/datasource methods only return a hostname or a fully-qualified hostname if you specify fqdn=True.

> +            init.cfg, cloud, metadata_only=True)
> +        if hostname:  # Either metadata or user-data provided hostname content

There is probably a better parameter name I could use in util.get_hostname_fqdn. Util.get_hostname actualy checks user-data 'hostname' in the cfg dict prior to falling back into the cloud/datasource to query  metadata['local-hostname']. So, really both are being checked and if neither cfg['hostname'] nor ds.metadata['local-hostname'] exist, then the util returns None, None.

> +            cc_set_hostname.handle(
> +                'pre-network-set-hostname', init.cfg, cloud, LOG, None)
> +    init.apply_network_config(bring_up=bring_up)
>  
>      if mode == sources.DSMODE_LOCAL:
>          if init.datasource.dsmode != mode:


-- 
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/339720
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:set-hostname-before-network into cloud-init:master.


References