def __unpack_and_run():
 script_keys = get_instance_metadata_attribute('startup_loader_files')
 key_list = (script_keys.split('+') if script_keys else [])
 unpack_files(key_list)
 if script_keys:
  clear_instance_metadata('startup_loader_files')
 startup_command = get_instance_metadata_attribute('startup_command')
 if (not startup_command):
  sys.stderr.write('No "startup_command" metadata key.\n')
  raise SystemExit('No "startup_command" metadata key.')
 command = ('chmod gou+rx /opt/spinnaker/install/*.sh; ' + startup_command.replace('+', ' '))
 with open('__startup_script__.sh', 'w') as f:
  f.write('#!/bin/bash\ncd /opt/spinnaker/install\n{command}\n'.format(command=command))
 os.chmod('__startup_script__.sh', 365)
 write_instance_metadata('startup-script', '/opt/spinnaker/install/__startup_script__.sh')
 clear_instance_metadata('startup_command')
 p = subprocess.Popen(command, shell=True, close_fds=True)
 p.wait()
 return p.returncode

def __unpack_and_run ( ) : script_keys = get_instance_metadata_attribute ( 'startup_loader_files' ) key_list = ( script_keys . split ( '+' ) if script_keys else [ ] ) unpack_files ( key_list ) if script_keys : clear_instance_metadata ( 'startup_loader_files' ) startup_command = get_instance_metadata_attribute ( 'startup_command' ) if ( not startup_command ) : sys . stderr . write ( 'No "startup_command" metadata key.\n' ) raise SystemExit ( 'No "startup_command" metadata key.' ) command = ( 'chmod gou+rx /opt/spinnaker/install/*.sh; ' + startup_command . replace ( '+' , ' ' ) ) with open ( '__startup_script__.sh' , 'w' ) as f : f . write ( '#!/bin/bash\ncd /opt/spinnaker/install\n{command}\n' . format ( command = command ) ) os . chmod ( '__startup_script__.sh' , 365 ) write_instance_metadata ( 'startup-script' , '/opt/spinnaker/install/__startup_script__.sh' ) clear_instance_metadata ( 'startup_command' ) p = subprocess . Popen ( command , shell = True , close_fds = True ) p . wait ( ) return p . returncode
unpack the files from metadata .