syndicate checkbox page, wip
smbaker [Mon, 26 Nov 2012 04:41:18 +0000 (20:41 -0800)]
apps/gacksadmin/092-gacks [new file with mode: 0644]
apps/gacksadmin/gacks_functions.php
apps/gacksadmin/user_syndicate.php [new file with mode: 0644]

diff --git a/apps/gacksadmin/092-gacks b/apps/gacksadmin/092-gacks
new file mode 100644 (file)
index 0000000..b69ebbf
--- /dev/null
@@ -0,0 +1,12 @@
+# -*-python-*-
+# rely on default for tag_types roles, as this defaults to admin-only
+########
+
+########
+gacks_slice_tags = [
+    { 'tagname' : 'enable_syndicate',
+      'description' : 'Enable syndicate shared file system',
+      'category' : 'slice/syndicate'} ,
+]
+
+for slice_type in gacks_slice_tags: SetTagType (slice_type)
\ No newline at end of file
index 0713e60..4e6f2ee 100644 (file)
@@ -32,6 +32,7 @@ function l_gacks_wizard ()         { return "/db/gacks/wizard.php"; }
 function l_gacks_nodelist ($account_name=NULL)         { return "/db/gacks/user_nodelist.php?account_name=$account_name"; }
 function l_gacks_nodelist_download ($acctname) { return "/db/gacks/action.php?action=download-nodelist&account_name=$acctname&format=CSV"; }
 function l_gacks_image ()         { return "/db/gacks/user_image.php"; }
+function l_gacks_syndicate ()     { return "/db/gacks/user_syndicate.php"; }
 function l_gacks_user_reservations() { return "/db/gacks/user_reservations.php"; }
 function l_gacks_edit($item)       { return "/db/gacks/edit.php"; }
 function l_gacks_delete($item)     { $timeStart=$item['timeStart']; $timeStop=$item['timeStop']; $id=$item['id']; $lastAllocator=end($item['allocatorHRNs']); return "/db/gacks/action.php?action=delete-reservation&timeStart=$timeStart&timeStop=$timeStop&resource_id=$id&lastAllocator=$lastAllocator"; }
@@ -646,9 +647,9 @@ function date_combo($form, $name, &$y, &$m, &$d, $url)
     return $m_combo . $d_combo . $y_combo;
 }
 
-function get_slice_image($api, $slicename)
+function get_slice_tag($api, $slicename, $tagname)
 {
-    $image_tags = $api->GetSliceTags(array("tagname" => "vref", "name" => $slicename));
+    $image_tags = $api->GetSliceTags(array("tagname" => $tagname, "name" => $slicename));
     if (count($image_tags) > 0) {
         return $image_tags[0]['value'];
     } else {
@@ -656,9 +657,9 @@ function get_slice_image($api, $slicename)
     }
 }
 
-function set_slice_image($api, $slicename, $value)
+function set_slice_tag($api, $slicename, $tagname, $value)
 {
-    $tags = $api->GetSliceTags(array("tagname" => "vref", "name" => $slicename));
+    $tags = $api->GetSliceTags(array("tagname" => $tagname, "name" => $slicename));
     if (count($tags) > 0) {
         if (!$value) {
             $api->DeleteSliceTag($tags[0]['slice_tag_id']);
@@ -670,6 +671,16 @@ function set_slice_image($api, $slicename, $value)
     }
 }
 
+function get_slice_image($api, $slicename)
+{
+    return get_slice_tag($api, $slicename, "vref");
+}
+
+function set_slice_image($api, $slicename, $value)
+{
+    set_slice_tag($api, $slicename, "vref", $value);
+}
+
 function get_slice_headnode($api, $slicename)
 {
     $ipList_tags = $api->GetSliceTags(array("tagname" => "vsys_ipList", "name" => $slicename));
@@ -740,6 +751,10 @@ function manage_slivers_tabs()
                                'url'=>l_gacks_image(),
                                'bubble'=>"Select image to use in this slice");
 
+    $tabs['Shared Filesystem'] = array('method'=>'GET',
+                                'url'=>l_gacks_syndicate(),
+                                'bubble'=>"Enabled access to Syndicate shared filesystem");
+
     return $tabs;
 }
 
diff --git a/apps/gacksadmin/user_syndicate.php b/apps/gacksadmin/user_syndicate.php
new file mode 100644 (file)
index 0000000..6b013d4
--- /dev/null
@@ -0,0 +1,89 @@
+<?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('Manage Slivers: Syndicate Shared Filesystem');
+include 'plc_header.php';
+
+$tabs = manage_slivers_tabs();
+$_GET['active_line_tab'] = "Shared Filesystem";
+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();
+
+    if (False) {
+        $syndicate_options=array('checked'=>'checked');
+    } else {
+        $syndicate_options=array();
+    }
+
+    print "<br>";
+    print $form->checkbox_html('syndicate-control', 'yes', $syndicate_options);
+    print "Enable Syndicate Shared Filesystem<br><br>";
+
+    print $form->submit_html("submit", "submit");
+
+    $form->end();
+}
+
+print "</div>";
+$nifty->end();
+
+include 'plc_footer.php';
+
+?>
+
+