3 \me @sUdZddlZddlmZddlmZmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZd d d d dgZdd d dd gZejeZdddedegedgdgdZe e eZee eeddddZdS)z/Disable EC2 Metadata: Disable AWS EC2 metadata.N)dedent)subputil)Cloud)Config) MetaSchema get_meta_doc) ALL_DISTROS) PER_ALWAYSZrouteaddz-hostz169.254.169.254ZrejectipZprohibitZcc_disable_ec2_metadatazDisable EC2 MetadatazDisable AWS EC2 Metadataz This module can disable the ec2 datasource by rejecting the route to ``169.254.169.254``, the usual route to the datasource. This module is disabled by default.zdisable_ec2_metadata: truedisable_ec2_metadata)idnametitle descriptionZdistrosZ frequencyZexamplesZactivate_by_schema_keys)rcfgcloudargsreturncCsdtj|dd}|rTd}tjdr&t}ntjdr6t}ntjddStj|ddn tjd|dS)Nr Fr ZifconfigzJNeither "route" nor "ip" command found, unable to manipulate routing table)Zcapturez=Skipping module named %s, disabling the ec2 route not enabled) rZget_cfg_option_boolrZwhich REJECT_CMD_IP REJECT_CMD_IFLOGerrordebug)rrrrZdisabledZ reject_cmdr-/usr/lib/python3.6/cc_disable_ec2_metadata.pyhandle-s  r)__doc__ZloggingtextwraprZ cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarrZcloudinit.distrosr Zcloudinit.settingsr rrZ getLogger__name__rmetastrlistrrrrr s,