← Back to team overview

cloud-init team mailing list archive

Re: Code for Hypervisor detection

 

Hi,

On 8/13/21 4:50 PM, SUDHAKAR REDDY KHANDI wrote:
Hi
Thank you so much for spending time answering my questions. Much
appreciated.


I could see , cloud-init is looking into the config file below and finding
out it is an Azure cloud.But, on first boot,  who will generate this file
?

I have no idea how that works in Debian/Ubuntu or other distros. For SUSE images openSUSE & SLES we build the configuration with the settings into the images.

On first boot, cloud-init is supposed to go over all the datasource list
and find out which one matches right.

Only if not configured in cloud.cfg or the kernel command line. If a list is specified then that list will be used, and only that list.

I don't see this happening. It is
magically finding out that it is an azure cloud. Can someone explain how
cloud-init will detect the cloud-platform ?

ds-identify contains the following comment:

#     search:   determine which source or sources should be used
#               and write the result (datasource_list) to
#               /run/cloud-init/cloud.cfg

You'll have to do the legwork and read the code. If there is specific code that you have a problem with understanding then please point to the lines that give you trouble.

Later,
Robert


if it is through config file,
who will be responsible for generating this config file ?

azureuser@sudhakar-newvm:/run/cloud-init$ cat
/etc/cloud/cloud.cfg.d/90_dpkg.cfg
# to update this file, run dpkg-reconfigure cloud-init
datasource_list: [ Azure ]


this is log file at  /var/log/cloud-init.log

2021-08-13 20:21:35,332 - util.py[DEBUG]: Cloud-init v.
21.2-3-g899bfaa9-0ubuntu2~18.04.1 running 'init-local' at Fri, 13 Aug 2021
20:21:35 +0000. Up 15.81 second
s.
2021-08-13 20:21:35,332 - main.py[DEBUG]: No kernel command line url found.
2021-08-13 20:21:35,332 - main.py[DEBUG]: Closing stdin.
2021-08-13 20:21:35,335 - util.py[DEBUG]: Writing to
/var/log/cloud-init.log - ab: [644] 0 bytes
2021-08-13 20:21:35,336 - util.py[DEBUG]: Changing the ownership of
/var/log/cloud-init.log to 102:4
2021-08-13 20:21:35,336 - util.py[DEBUG]: Attempting to remove
/var/lib/cloud/instance/boot-finished
2021-08-13 20:21:35,336 - util.py[DEBUG]: Attempting to remove
/var/lib/cloud/data/no-net
2021-08-13 20:21:35,337 - handlers.py[DEBUG]: start:
init-local/check-cache: attempting to read from cache [check]
2021-08-13 20:21:35,337 - util.py[DEBUG]: Reading from
/var/lib/cloud/instance/obj.pkl (quiet=False)
2021-08-13 20:21:35,337 - stages.py[DEBUG]: no cache found
2021-08-13 20:21:35,337 - handlers.py[DEBUG]: finish:
init-local/check-cache: SUCCESS: no cache found
2021-08-13 20:21:35,337 - util.py[DEBUG]: Attempting to remove
/var/lib/cloud/instance
2021-08-13 20:21:35,340 - stages.py[DEBUG]: Using distro class <class
'cloudinit.distros.ubuntu.Distro'>

*2021-08-13 20:21:35,340 - __init__.py[DEBUG]: Looking for data source in:
['Azure', 'None'], via packages ['', 'cloudinit.sources'] that matches
dependencies ['FILESYSTEM']


how azure datasource magically came up here ?*
2021-08-13 20:21:35,456 - __init__.py[DEBUG]: Searching for local data
source in: ['DataSourceAzure']
2021-08-13 20:21:35,456 - handlers.py[DEBUG]: start:
init-local/search-Azure: searching for local data from DataSourceAzure
2021-08-13 20:21:35,456 - __init__.py[DEBUG]: Seeing if we can get any data
from <class 'cloudinit.sources.DataSourceAzure.DataSourceAzure'>
2021-08-13 20:21:35,457 - __init__.py[DEBUG]: Update datasource metadata
and network config due to events: New instance first boot
2021-08-13 20:21:35,457 - handlers.py[DEBUG]: start: azure-ds/_get_data:
_get_data
2021-08-13 20:21:35,457 - handlers.py[DEBUG]: start:
azure-ds/check-platform-viability: found azure asset tag

Regards
Sudhakar Reddy.K

On Fri, Aug 13, 2021 at 4:42 AM Robert Schweikert <rjschwei@xxxxxxxx> wrote:



On 8/12/21 5:03 PM, SUDHAKAR REDDY KHANDI wrote:
Note the auto detection mode exists twice, once in the
code executed by the generator, i.e. tools/ds-identify and once in the
Python code where we look for the data source.

Thanks for the reply. if you don't mind can you point the source  code
for
" Python code where we look for the data source."


cloudinit/sources/__init__.py

contains: find_source()


-Sudhakar Reddy.K

On Thu, Aug 12, 2021 at 1:57 PM Robert Schweikert <rjschwei@xxxxxxxx>
wrote:

Hi,

On 8/12/21 4:25 PM, SUDHAKAR REDDY KHANDI wrote:
Hi

I am new to cloud-init.I have been trying to find out how cloud-init
detects the cloud-platform (AZR/AWS/etc). someone point me where this
code
is present(assume no datasource_list is configured)

Please, let me know how cloud-init uses the "datasource_list" config?
is
it
a hint to cloud-init that it is a so-and-so cloud platform ?

cloud-init checks the config and uses whatever is configure. If this
does not exist in the configuration cloud-init will fall back to auto
detection mode. Note the auto detection mode exists twice, once in the
code executed by the generator, i.e. tools/ds-identify and once in the
Python code where we look for the data source.

HTH,
Robert


Regards
Sudhakar



--
Robert Schweikert                   MAY THE SOURCE BE WITH YOU
Distinguished Engineer                       LINUX
Technical Team Lead Public Cloud
rjschwei@xxxxxxxx
IRC: robjo

--
Mailing list: https://launchpad.net/~cloud-init
Post to     : cloud-init@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~cloud-init
More help   : https://help.launchpad.net/ListHelp



--
Robert Schweikert                   MAY THE SOURCE BE WITH YOU
Distinguished Engineer                       LINUX
Technical Team Lead Public Cloud
rjschwei@xxxxxxxx
IRC: robjo




--
Robert Schweikert                   MAY THE SOURCE BE WITH YOU
Distinguished Engineer                       LINUX
Technical Team Lead Public Cloud
rjschwei@xxxxxxxx
IRC: robjo

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


References