added user_image screen, removed image stuff from node wizard
smbaker [Fri, 16 Nov 2012 21:32:43 +0000 (13:32 -0800)]
apps/gacksadmin/Makefile
apps/gacksadmin/action.php
apps/gacksadmin/gacks_functions.php
apps/gacksadmin/user_image.php [new file with mode: 0644]
apps/gacksadmin/user_nodelist.php
apps/gacksadmin/wizard.php

index 648209b..de7702a 100644 (file)
@@ -1,6 +1,6 @@
 RPM_DIR = RPMS
 
-GACKS_PHP = accounts.php account.php action.php add_account.php invoices.php reservations.php reservation_set.php nodestatus.php weekly.php wizard.php user_reservations.php user_service_level.php user_confirm_service.php gackstable.php user_add_reservation.php user_persons.php user_summary.php user_nodelist.php
+GACKS_PHP = accounts.php account.php action.php add_account.php invoices.php reservations.php reservation_set.php nodestatus.php weekly.php wizard.php user_reservations.php user_service_level.php user_confirm_service.php gackstable.php user_add_reservation.php user_persons.php user_summary.php user_nodelist.php user_image.php
 GACKS_JS = popup.js gackstable.js
 GACKS_MODULE = gacks.module vicci.module
 GACKS_INCLUDE = gacks_functions.php gacksclient.php
index 9d6b05a..05c9708 100644 (file)
@@ -163,6 +163,15 @@ try {
             break;
         }
 
+        case 'set-image': {
+            $account_name = $_POST['account_name'];
+            $image = $_POST['image'];
+            set_slice_image($api, $account_name, $image);
+            drupal_set_message('Image Set');
+            plc_redirect(l_gacks_image());
+            break;
+        }
+
         case 'set-account': {
             $account_name = $_POST['account_name'];
             $url = $_POST['url'];
index 8a553c7..9972cb3 100644 (file)
@@ -413,9 +413,9 @@ function account_selectors($plcapi, $person_id, $account_name)
     return $selectors;
 }
 
-function find_selector($needle, $selectors)
+function &find_selector($needle, &$selectors)
 {
-    foreach ($selectors as $selector) {
+    foreach ($selectors as &$selector) {
         if ($selector['value']==$needle) {
             return $selector;
         }
@@ -423,9 +423,9 @@ function find_selector($needle, $selectors)
     return NULL;
 }
 
-function select_selector($needle, $selectors)
+function select_selector($needle, &$selectors)
 {
-    $selector = find_selector($needle, $selectors);
+    $selector = &find_selector($needle, $selectors);
     if ($selector) {
         $selector["selected"] = True;
     }
@@ -657,6 +657,20 @@ function get_slice_image($api, $slicename)
     }
 }
 
+function set_slice_image($api, $slicename, $value)
+{
+    $tags = $api->GetSliceTags(array("tagname" => "vref", "name" => $slicename));
+    if (count($tags) > 0) {
+        if (!$value) {
+            $api->DeleteSliceTag($tags[0]['slice_tag_id']);
+        } else if ($tags[0]['slice_tag_id'] != $value) {
+            $api->UpdateSliceTag($tags[0]['slice_tag_id'], $value);
+        }
+    } else {
+        $api->AddSliceTag($slicename, "vref", $value);
+    }
+}
+
 function get_slice_headnode($api, $slicename)
 {
     $ipList_tags = $api->GetSliceTags(array("tagname" => "vsys_ipList", "name" => $slicename));
diff --git a/apps/gacksadmin/user_image.php b/apps/gacksadmin/user_image.php
new file mode 100644 (file)
index 0000000..5c3817a
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+
+// this must occur before linetabs.php, or linetabs won't work. I have no idea why.
+drupal_add_js("misc/popup.js");
+
+// Require login
+require_once 'plc_login.php';
+
+// Get session and API handles
+require_once 'plc_session.php';
+global $plc, $api, $adm;
+
+// Common functions
+require_once 'plc_functions.php';
+require_once 'plc_peers.php';
+require_once 'gacks_functions.php';
+require_once 'gacksclient.php';
+require_once 'linetabs.php';
+require_once 'table.php';
+require_once 'details.php';
+require_once 'toggle.php';
+require_once 'form.php';
+require_once 'nifty.php';
+
+// find person roles
+$_person= $plc->person;
+$_person_id = $plc->person['person_id'];
+$_roles= $_person['role_ids'];
+
+// Print header
+require_once 'plc_drupal.php';
+drupal_set_title('Node Wizard');
+include 'plc_header.php';
+
+$tabs['Show Nodes'] = array('method'=>'GET',
+                           'url'=>l_gacks_nodelist(),
+                           'bubble'=>"Show nodes in your slice");
+
+$tabs['Add Nodes'] = array('method'=>'GET',
+                           'url'=>l_gacks_wizard(),
+                           'bubble'=>"Add nodes to your slice");
+
+$tabs['Select Image'] = array('method'=>'GET',
+                           'url'=>l_gacks_image(),
+                           'bubble'=>"Select image to use in this slice");
+
+$_GET['active_line_tab'] = "Select Image";
+plekit_linetabs($tabs);
+
+$nifty=new PlekitNifty ('sliceimage','objects-list','big');
+$nifty->start();
+print '<div style="width: 640px; margin-left: auto; margin-right: auto;">';
+
+//print "<br>";
+$account_name = get_account_name($api, $_person_id);
+
+if ($account_name != NULL) {
+    $gacksapi = new GACKSAPI();
+
+    $image = get_slice_image($api, $account_name);
+    if (!$image) {
+        $image = "";
+    }
+
+    $image_selectors = array();
+    $image_selectors []= array("display"=>"Default PlanetLab image", "value"=>"");
+    $image_selectors []= array("display"=>"Hadoop", "value"=>"hadoop");
+    $image_selectors []= array("display"=>"MPI", "value"=>"mpi");
+    if (!in_array($image, array("", "hadoop", "mpi"))) {
+        $image_selectors []= array("display"=> $image, "value"=> $image);
+    }
+    select_selector($image, $image_selectors);
+
+    $form = new PlekitForm(l_gacks_actions(), array("action"=>"set-image",
+                                                    "account_name"=> $account_name));
+    $form->start();
+
+    print "<br><br>Select a preconfigured image for your slice:<br>";
+    print $form->select_html("image", $image_selectors);
+    print "<br><br>";
+    print $form->submit_html("submit", "submit");
+
+    $form->end();
+}
+
+print "</div>";
+$nifty->end();
+
+include 'plc_footer.php';
+
+?>
+
+
index da494a6..d92c436 100644 (file)
@@ -40,6 +40,10 @@ $tabs['Add Nodes'] = array('method'=>'GET',
                            'url'=>l_gacks_wizard(),
                            'bubble'=>"Add nodes to your slice");
 
+$tabs['Select Image'] = array('method'=>'GET',
+                           'url'=>l_gacks_image(),
+                           'bubble'=>"Select image to use in this slice");
+
 plekit_linetabs($tabs);
 
 $nifty=new PlekitNifty ('nodewizard','objects-list','big');
index a0b43da..6ecaa5f 100644 (file)
@@ -40,6 +40,11 @@ $tabs['Add Nodes'] = array('method'=>'GET',
                            'url'=>l_gacks_wizard(),
                            'bubble'=>"Add nodes to your slice");
 
+$tabs['Select Image'] = array('method'=>'GET',
+                           'url'=>l_gacks_image(),
+                           'bubble'=>"Select image to use in this slice");
+
+$_GET['active_line_tab'] = "Add Nodes";
 plekit_linetabs($tabs);
 
 $nifty=new PlekitNifty ('nodewizard','objects-list','big');
@@ -98,8 +103,6 @@ EOF;
     print "<br><br>Choose what to do with your existing slivers: <br>";
     print " " . $form->radio_html("expand", "0") . " replace current slivers<br>";
     print " " . $form->radio_html("expand", "1", array("checked" => TRUE)) . " keep current slivers and add these slivers<br>";
-    print "<br><br>You can also select a preconfigured image to use with your slice:<br>";
-    print $form->select_html("image", $image_selectors);
     print "<br><br>";
     print $form->submit_html("submit", "submit");
     print "<br><br>";