def get_cloud_init_mime(cloud_init):
 if isinstance(cloud_init, six.string_types):
  cloud_init = json.loads(cloud_init)
 _cloud_init = email.mime.multipart.MIMEMultipart()
 if ('boothooks' in cloud_init):
  for (script_name, script) in six.iteritems(cloud_init['boothooks']):
   _script = email.mime.text.MIMEText(script, 'cloud-boothook')
   _cloud_init.attach(_script)
 if ('scripts' in cloud_init):
  for (script_name, script) in six.iteritems(cloud_init['scripts']):
   _script = email.mime.text.MIMEText(script, 'x-shellscript')
   _cloud_init.attach(_script)
 if ('cloud-config' in cloud_init):
  cloud_config = cloud_init['cloud-config']
  _cloud_config = email.mime.text.MIMEText(_safe_dump(cloud_config), 'cloud-config')
  _cloud_init.attach(_cloud_config)
 return _cloud_init.as_string()

def get_cloud_init_mime ( cloud_init ) : if isinstance ( cloud_init , six . string_types ) : cloud_init = json . loads ( cloud_init ) _cloud_init = email . mime . multipart . MIMEMultipart ( ) if ( 'boothooks' in cloud_init ) : for ( script_name , script ) in six . iteritems ( cloud_init [ 'boothooks' ] ) : _script = email . mime . text . MIMEText ( script , 'cloud-boothook' ) _cloud_init . attach ( _script ) if ( 'scripts' in cloud_init ) : for ( script_name , script ) in six . iteritems ( cloud_init [ 'scripts' ] ) : _script = email . mime . text . MIMEText ( script , 'x-shellscript' ) _cloud_init . attach ( _script ) if ( 'cloud-config' in cloud_init ) : cloud_config = cloud_init [ 'cloud-config' ] _cloud_config = email . mime . text . MIMEText ( _safe_dump ( cloud_config ) , 'cloud-config' ) _cloud_init . attach ( _cloud_config ) return _cloud_init . as_string ( )
get a mime multipart encoded string from a cloud-init dict .