a 'Dg@stddlZddlZddlZddlmZddlmZddlmZm Z ddl m Z ddl m Z eeZGdddZdS) N)Optional)Distro)PathsRunners)events) DataSourcec@seZdZd!eeeeeee j dddZ e ddZ d"dd Zd d Zd#d dZddZe ddZddZddZd$ddZddZd%ddZd&ddZd'dd ZdS)(CloudN) datasourcepathscfgdistrorunnersreportercCs@||_||_||_||_||_|dur6tjdddd}||_dS)Nzunnamed-cloud-reporterF)name descriptionZreporting_enabled)r r r _cfg_runnersrReportEventStackr)selfr r r r r rr3/usr/lib/python3.9/site-packages/cloudinit/cloud.py__init__ s zCloud.__init__cCs t|jSN)copydeepcopyrrrrrr 6sz Cloud.cfgFcCs|j|||||S)aRun a function gated by a named semaphore for a desired frequency. The typical case for this method would be to limit running of the provided func to a single well-defined frequency: PER_INSTANCE, PER_BOOT or PER_ONCE The semaphore provides a gate that persists across cloud-init boot stage boundaries so multiple modules can share this state even if they happen to be run in different boot stages or across reboots. )rrun)rrZfunctorargsZfreqZ clear_on_failrrrr;s z Cloud.runcCs6|jj|}tj|s2tdtj||dS|S)Nz-No template found in %s for template named %s)r Z template_tplospathisfileLOGZwarningdirname)rrfnrrrget_template_filenameIs   zCloud.get_template_filenameTcCs |j|Sr)r get_userdata)rZ apply_filterrrrr%UszCloud.get_userdatacCs |jSr)r get_instance_idrrrrr&XszCloud.get_instance_idcCs|jjSr)r launch_indexrrrrr'[szCloud.launch_indexcCs |jSr)r get_public_ssh_keysrrrrr(_szCloud.get_public_ssh_keyscCs |jSr)r get_localerrrrr)bszCloud.get_localecCs|jj||dS)N)fqdn metadata_only)r get_hostname)rr*r+rrrr,eszCloud.get_hostnamecCs |j|Sr)r device_name_to_devicerrrrrr-jszCloud.device_name_to_devicecCs |j|Sr)r get_ipath_curr.rrrr/mszCloud.get_ipath_curcCs |j|Sr)r get_cpathr.rrrr0pszCloud.get_cpathcCs |j|Sr)r get_ipathr.rrrr1sszCloud.get_ipath)N)NF)T)FF)N)N)N)__name__ __module__ __qualname__rrdictrrrrrrpropertyr rr$r%r&r'r(r)r,r-r/r0r1rrrrrs0        r)rZloggingrtypingrZcloudinit.distrosrZcloudinit.helpersrrZcloudinit.reportingrZcloudinit.sourcesrZ getLoggerr2r!rrrrrs