OpenSecurity/bin/opensecurityd.pyw
changeset 93 8fe521017397
parent 91 a26757850ea9
child 98 4820361279cc
     1.1 --- a/OpenSecurity/bin/opensecurityd.pyw	Mon Mar 10 13:01:08 2014 +0100
     1.2 +++ b/OpenSecurity/bin/opensecurityd.pyw	Mon Mar 10 15:23:16 2014 +0100
     1.3 @@ -64,6 +64,7 @@
     1.4      '/sdvms/(.*)/start',                'os_sdvm_start',        # http://localhost:8080/sdvms/[VMNAME]/start                    GET
     1.5      '/sdvms/(.*)/stop',                 'os_sdvm_stop',         # http://localhost:8080/sdvms/[VMNAME]/stop                     GET
     1.6      '/sdvms/(.*)',                      'os_sdvm',              # http://localhost:8080/sdvms/[VMNAME]                          GET, DELETE
     1.7 +    '/setup',                           'os_setup',             # http://localhost:8080/setup                                   GET
     1.8      '/vms',                             'os_vms',               # http://localhost:8080/vms                                     GET
     1.9      '/vms/(.*)',                        'os_vm',                # http://localhost:8080/vms/[VMNAME]                            GET
    1.10      '/update_template',                 'os_update_template',   # http://localhost:8080/update_template                         GET
    1.11 @@ -122,7 +123,16 @@
    1.12          download_initial_image_script = '/OpenSecurity/bin/download_initial_image.sh \'' + machine_folder + '\''
    1.13          Cygwin.bashExecute(download_initial_image_script, wait_return = False, stdout = trace_file, stderr = trace_file) 
    1.14  
    1.15 -        return trace_file_name
    1.16 +        page = """
    1.17 +        <html>
    1.18 +        <head></head>
    1.19 +        <body>
    1.20 +        Fetch OpenSecurity image log ({0}):<br/>
    1.21 +        <iframe src="file://{0}" width="100%" height="100%"></iframe>
    1.22 +        </body>
    1.23 +        </head>
    1.24 +        """
    1.25 +        return page.format(trace_file_name)
    1.26  
    1.27  
    1.28  class os_init:
    1.29 @@ -142,7 +152,16 @@
    1.30          initial_import_script = '/OpenSecurity/bin/initial_vm.sh \'' + vm_image + '\''
    1.31          Cygwin.bashExecute(initial_import_script, wait_return = False, stdout = trace_file, stderr = trace_file) 
    1.32  
    1.33 -        return trace_file_name
    1.34 +        page = """
    1.35 +        <html>
    1.36 +        <head></head>
    1.37 +        <body>
    1.38 +        Import initial OpenSecurity image log ({0}):<br/>
    1.39 +        <iframe src="file://{0}" width="100%" height="100%"></iframe>
    1.40 +        </body>
    1.41 +        </head>
    1.42 +        """
    1.43 +        return page.format(trace_file_name)
    1.44  
    1.45  
    1.46  class os_root:
    1.47 @@ -259,6 +278,31 @@
    1.48          return name
    1.49              
    1.50  
    1.51 +class os_setup:
    1.52 +    """OpenSecurity '/setup' handler
    1.53 +    
    1.54 +    - GET: Give user some info how to setup the OpenSecurity envvironment
    1.55 +    """
    1.56 +    
    1.57 +    def GET(self):
    1.58 +
    1.59 +        log_call(web.ctx.environ)
    1.60 +
    1.61 +        page = """
    1.62 +        <html>
    1.63 +        <body>
    1.64 +        <h1>Setup OpenSecurity</h1>
    1.65 +        In order to setup OpenSecurity an inital VM image has to be downloaded and imported:<br/>
    1.66 +        <ul>
    1.67 +            <li>Download initial VM image: <a href="/fetch_initial_image">fetch_initial_image</a>
    1.68 +            <li>Import initial VM: <a href="/init">init</a>
    1.69 +        </ul>
    1.70 +        </body>
    1.71 +        </html>
    1.72 +        """
    1.73 +        return page
    1.74 +
    1.75 +
    1.76  class os_terminate:
    1.77      """OpenSecurity '/terminate' handler
    1.78