Tools page using REST SFA API
[unfold.git] / portal / templates / slice-tab-experiment.html
index 96c7734..bfa9cee 100644 (file)
@@ -1,20 +1,76 @@
 <div class="col-md-10 col-md-offset-1">
-       {% if ple_resources or iotlab_resources or nitos_resources or nitos_paris_resources%}
-               <h2>How to access your reserved resources</h2>
-       {% endif %}
-       {% if ple_resources %}
+<script type="text/javascript">
+    $(document).ready(function() {
+        console.log('{{platforms}}');
+           {% for platform in platforms %}
+        // /sfa/Describe?hrn=onelab.upmc.projectx.slicex&platform[]={{platform}}&type=slice
+        $.post("/sfa/Describe",{'hrn':'{{slicename}}', 'type':'slice', 'platform':['{{platform}}']}, function( data ) {
+            if('parsed' in data['{{platform}}'] && 'rspec' in data['{{platform}}']['parsed']){
+                rspec = data['{{platform}}']['parsed']['rspec'];
+                if('node' in rspec){
+                    jQuery.each( rspec['node'], function( i, node ) {
+                        render_node('{{platform}}',node);
+                    });
+                }
+            }
+        });
+           {% endfor %}
+    });
+    
+    function render_node(platform, node){
+        console.log(platform,node);
+        if('@component_manager_id' in node){
+            // urn:publicid:IDN+ple+authority+cm
+            t_urn = node['@component_manager_id'].split('+');
+            //if(t_urn[1].indexOf(":") > -1)
+            testbed = t_urn[1];
+            if(!$('#'+testbed).length){
+                testbed = 'default';
+            }
+        }else{
+            testbed = 'default';
+        }
+        if('services' in node && 'login' in node['services']){
+            console.log(node['services']['login']);
+            login = node['services']['login'];
+            if('@port' in login && login['@port']!='22'){
+                $('#'+testbed).append("<p class='command'>$ ssh "+login['@username']+"@"+login['@hostname']+" -p "+login['@port']+"</p>");
+            }else{
+                $('#'+testbed).append("<p class='command'>$ ssh "+login['@username']+"@"+login['@hostname']+"</p>");
+            }
+       
+        }else if('@component_name' in node){
+            console.log(node['@component_name']);
+        }else{
+            console.log(node);
+        }
+        $("#access").show();
+
+        $('#'+testbed).show();
+        if($('#'+testbed+'_header').length){
+            $('#'+testbed+'_header').show();
+        }
+        if($('#'+testbed+'_footer').length){
+            $('#'+testbed+'_footer').show();
+        }
+    }
+</script>
+<div id="access" style="display:none;">
+    <h2>How to access your reserved resources</h2>
+</div>
+<div id="default">
+</div>
+<div id="ple_header" style="display:none;">
        <h3>PlanetLab Europe</h3>
        
        <p>
                PlanetLab Europe resources are accessible directly via SSH. Your SSH public key is deployed automatically
                on the reserved nodes. To access your slice on a resource just type the following command:
        </p>
-       <p class="command">
-       {%for resource in ple_resources %}
-               <b>Resource</b><br>
-               $ ssh {{ple_slicename}}@{{resource}}<br>
-       {%endfor%}
-       </p>
+</div>
+<div id="ple" style="display:none;">
+</div>
+<div id="ple_footer" style="display:none;">
        <p><strong>NOTE:</strong> Your original slicename <b>{{slicename}}</b> has been converted to PlanetLab specific format <b>{{ple_slicename}}</b> in order to do SSH.</p>
        <p>
                Be aware that after you reserve a PlanetLab Europe resource your slice will be deployed with a delay of about 15 minutes, 
             <i>This bash script will be deployed on all PLE nodes of your slice</i>
         </div>
         <textarea style="width:100%; height:100px;" id="initscript_code"></textarea><br>
+<!-- TODO !!!
+        <div>
+            <select>
+                <option>All</option>
+                <option>node1</option>
+                <option>node2</option>
+            </select>
+        </div>
+-->
         <button name="deploy" class="btn btn-success btn-sm" onclick="deploy('{{slicename}}');">Deploy</button>
         <button name="delete" class="btn btn-danger btn-xs" onclick="del('{{slicename}}');">Delete</button>
     </div>
     <script type="text/javascript">
     $(document).ready(function() {
-        $.post("/initscript/get/",{'slice_hrn':'onelab.upmc.express'}, function( data ) {
+        $.post("/initscript/get/",{'slice_hrn':'{{slicename}}'}, function( data ) {
             console.log(data);
             jQuery('#initscript_code').val(data['initscript_code']);
         });
     }
     </script>
     <br>
-       {% endif %}
-
-       {% if iotlab_resources %}       
+</div>
+<div id="iotlab_header" style="display:none;">
        <h3>FIT IoT-Lab</h3>
        <p>FIT IoT-Lab resources are accessible directly via SSH and <a href="https://www.iot-lab.info/testbed/" target="_blank">web GUI.</a>
                To acess IoT-Lab resources using web GUI, use the same login and  password of OneLab portal. To acess Iot-Lab resources using SSH type
                the following command:
        </p>
-       <p class="command">
-               ssh {{iot_login}}@grenoble.iot-lab.info
-       </p>
-       {% endif %}
-       {% if nitos_resources or nitos_paris_resources %}
-       <h3>NITOS</h3>
+</div>
+<div id="iotlab" style="display:none;">
+</div>
+<div id="nitos_header" style="display:none;">
+       <h3>NITOS Volos (Greece)</h3>
        
        <p>
         NITOS resources are not directly accessible. You will need to log in on a gateway server and from there access the node.
         You will find the ssh commands to connect to NITOS nodes below:
        </p>
-
-       {% if nitos_resources %}        
        <h4>NITLab</h4>
        <p class="command">
            $ ssh {{slicename}}@nitlab.inf.uth.gr #nodes 001-040<br>
         $ ssh {{slicename}}@nitlab2.inf.uth.gr #nodes 041-049<br>
         $ ssh {{slicename}}@nitlab3.inf.uth.gr #nodes > 049
     </p>
-       
+</div>
+<div id="nitos" style="display:none;">
        <p>Loading an OMF-compatible image on your resource:</p>
        <p class="command">
-       {%for resource in nitos_resources %}
                <b>Resource</b><br>
         $ omf6 stat -t {{resource}} #check the status of the node<br>
         $ omf6 tell -a on -t {{resource}}  #turn on/off the node <br>
        $ omf6 load -i baseline.ndz -t {{resource}}  #for orbit-like node (002-009) use "baseline_orbit.ndz"<br>
-               $ ssh root@{{resource}}  #ssh to the node<br>
-       {%endfor%}
        </p>
+</div>
+<div id="nitos_footer" style="display:none;">
     <p><b>NOTE:</b> Nodes 002-009 are orbit-like nodes. For these nodes use "baseline_orbit.ndz". All these images come with OMF5.4 resource controller. To do OMF6 experiments use "baseline_omf6_1_1.ndz" and  "baseline_orbit_omf6_1_1.ndz" for grid nodes and orbit nodes respectively. </p>
-       {% endif %}
-
+</div>
        {% if nitos_paris_resources %}
        <h4>FIT NITOS-Lab Paris</h4>
         <p class="command">
        $ ssh root@{{resource}}  #ssh to the node<br><br>
        {%endfor%}
        </p>
-       {%endif%}
 
        <p>
                On the node itself you will have to modify the file /etc/omf-resctl-5.3/omf-resctl.yaml (OMF5.4 only) according to your slice settings and then