← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~chad.smith/cloud-init:bug/1776701-openstack-local-no-probe-on-ec2 into cloud-init:master

 

If not already done so, we should update the OpenStack datasource docs to indicate which product strings/chassis ids are used to positively identify OpenStack datasource on VMs and containers.

Diff comments:

> diff --git a/cloudinit/sources/DataSourceOpenStack.py b/cloudinit/sources/DataSourceOpenStack.py
> index 1a12a3f..e7b0b41 100644
> --- a/cloudinit/sources/DataSourceOpenStack.py
> +++ b/cloudinit/sources/DataSourceOpenStack.py
> @@ -205,6 +209,25 @@ def read_metadata_service(base_url, ssl_details=None,
>      return reader.read_v2()
>  
>  
> +def detect_openstack():
> +    """Return True when a potential OpenStack platform is detected."""
> +    cpu_arch = os.uname()[4]
> +    if not re.match(r'i.86|x86_64', cpu_arch):
> +        return True  # Non-Intel cpus don't properly report dmi product names
> +    product_name = util.read_dmi_data('system-product-name')
> +    if product_name in ('OpenStack Nova', 'OpenStack Compute'):

Magic values, move to top of file in a variable?

> +        return True
> +    elif util.read_dmi_data('chassis-asset-tag') == 'OpenTelekomCloud':
> +        return True

Same here

> +    elif os.path.exists('/proc/1/environ'):
> +        environ_content = util.load_file('/proc/1/environ')
> +        env_items = re.split(r'\0|=', environ_content)
> +        pid1_environ = dict(zip(env_items[::2], env_items[1::2]))
> +        if pid1_environ.get('product_name') == 'OpenStack Nova':
> +            return True
> +    return False
> +
> +
>  # Used to match classes to dependencies
>  datasources = [
>      (DataSourceOpenStackLocal, (sources.DEP_FILESYSTEM,)),


-- 
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/347937
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:bug/1776701-openstack-local-no-probe-on-ec2 into cloud-init:master.


References