<s> import os <EOL> from oslo_config import cfg <EOL> import six <EOL> from cloudbaseinit . plugins . common . userdataplugins import base <EOL> from cloudbaseinit . plugins . common import userdatautils <EOL> from cloudbaseinit . utils import encoding <EOL> opts = [ <EOL> cfg . StrOpt ( '<STR_LIT>' , default = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> CONF = cfg . CONF <EOL> CONF . register_opts ( opts ) <EOL> class HeatPlugin ( base . BaseUserDataPlugin ) : <EOL> _heat_user_data_filename = "<STR_LIT>" <EOL> def __init__ ( self ) : <EOL> super ( HeatPlugin , self ) . __init__ ( "<STR_LIT>" ) <EOL> def _check_dir ( self , file_name ) : <EOL> dir_name = os . path . dirname ( file_name ) <EOL> if not os . path . exists ( dir_name ) : <EOL> os . makedirs ( dir_name ) <EOL> def process ( self , part ) : <EOL> file_name = os . path . join ( CONF . heat_config_dir , part . get_filename ( ) ) <EOL> self . _check_dir ( file_name ) <EOL> encoding . write_file ( file_name , part . get_payload ( ) ) <EOL> if part . get_filename ( ) == self . _heat_user_data_filename : <EOL> payload = part . get_payload ( ) <EOL> if isinstance ( payload , six . text_type ) : <EOL> payload = payload . encode ( ) <EOL> return userdatautils . execute_user_data_script ( payload ) </s>
