'add node' dialog can create reservable nodes
[plewww.git] / planetlab / includes / plc_functions.php
index 43a384d..8de54c5 100644 (file)
@@ -75,6 +75,7 @@ function l_actions_download ()                { return "/db/nodes/node_downloads.php"; }
 function l_register_node ()            { return "/registerwizard/index.php"; }
 function l_pcu_add ()                  { return "/registerwizard/index.php/register/stage1_addpcu"; }
 function l_pcu ($pcu_id)               { return "/db/sites/pcu.php?id=$pcu_id"; }
+function l_pcu_href ($pcu_id, $text)           { return href(l_pcu($pcu_id), $text); }
 
 function l_nodes ()                    { return "/db/nodes/index.php"; }
 function l_nodes_peer ($peer_id)       { return "/db/nodes/index.php?peerscope=$peer_id"; }
@@ -431,6 +432,16 @@ function plc_debug ($message,$object) {
   print "</pre>";
 }
 
+function plc_debug_txt ($message,$txt) {
+  print "<br />" . $message . "<pre>";
+  $txt=str_replace(" ","&lt;SPC&gt;",$txt);
+  $txt=str_replace("\t","&lt;TAB&gt;",$txt);
+  $txt=str_replace("\n","&lt;LF&gt;",$txt);
+  $txt=str_replace("\r","&lt;CR&gt;",$txt);
+  print $txt . "&lt;EOF&gt;";
+  print "</pre>";
+}
+
 $plc_prof_start=0.;
 $plc_prof_time=0.;
 $plc_prof_counter=0;
@@ -499,6 +510,18 @@ function plc_redirect ($url) {
   exit ();
 }
 
+//////////////////// the options for an nodetype - suitable for plekit/form
+function node_type_selectors ($api,$nodetype) {
+  $builtin_types = array ( "regular" => "Regular/Shared",
+                          "reservable" => "Reservable (requires to get leases)");
+  foreach ($builtin_types as $value=>$display) {
+    $selector=array('display'=>$display, 'value'=>$value);
+    if ($value == $nodetype) $selector['selected']=true;
+    $selectors []= $selector;
+  }
+  return $selectors;
+}
+
 //////////////////// the options for an interface - suitable for plekit/form
 //>>> GetNetworkMethods()
 //[u'static', u'dhcp', u'proxy', u'tap', u'ipmi', u'unknown']