You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2008/12/12 19:20:18 UTC
svn commit: r726079 [30/32] - in /incubator/vcl/tags/import: ./
managementnode/ managementnode/bin/ managementnode/etc/
managementnode/etc/vcl/ managementnode/legacy_vcl_vbs_scripts/
managementnode/lib/ managementnode/lib/VCL/ managementnode/lib/VCL/Mo...
Added: incubator/vcl/tags/import/web/.ht-inc/vcldocs.php
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/vcldocs.php?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/vcldocs.php (added)
+++ incubator/vcl/tags/import/web/.ht-inc/vcldocs.php Fri Dec 12 10:20:10 2008
@@ -0,0 +1,397 @@
+<?php
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+// docreaders:
+// 1 - admin
+
+$docreaders = array(1);
+$doceditors = array(1);
+$actions['mode']['viewdocs'] = "viewDocs";
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn viewDocs()
+///
+/// \brief prints a page to select which VCL docs to view
+///
+////////////////////////////////////////////////////////////////////////////////
+function viewDocs() {
+ global $user, $docreaders, $viewmode;
+ if(! (in_array("userGrant", $user["privileges"]) ||
+ in_array("resourceGrant", $user["privileges"]) ||
+ in_array("nodeAdmin", $user["privileges"]) ||
+ in_array($user['id'], $docreaders)))
+ return;
+ $item = getContinuationVar("item", processInputVar('item', ARG_STRING));
+
+ switch($item) {
+ case "xmlrpcapi":
+ showXmlrpcapi();
+ return;
+ case "xmlrpcexample":
+ showXmlrpcExample();
+ return;
+ default:
+ if(! empty($item)) {
+ showDatabaseDoc($item);
+ return;
+ }
+ }
+
+ $query = "SELECT name, title FROM documentation ORDER BY title";
+ $qh = doQuery($query, 101);
+ $docs = array();
+ while($row = mysql_fetch_assoc($qh))
+ $docs[$row['name']] = $row['title'];
+
+ if($viewmode == ADMIN_DEVELOPER || in_array($user['id'], $doceditors)) {
+ $cdata = array('submode' => 'newpage');
+ $cont = addContinuationsEntry('editdoc', $cdata);
+ print "[ <a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
+ print "New page</a> ";
+ print "]<br>\n";
+ }
+ if(count($docs)) {
+ print "<h2>Main Documentation</h2>\n";
+ foreach($docs as $key => $val) {
+ print "<a href=\"" . BASEURL . SCRIPT . "?mode=viewdocs&item=$key\">";
+ print "$val</a><br>\n";
+ }
+ }
+ if(in_array($user['id'], $docreaders)) {
+ print "<h2>API Documentation</h2>\n";
+ print "<a href=\"" . BASEURL . SCRIPT . "?mode=viewdocs&item=xmlrpcapi\">";
+ print "XML RPC API</a><br>\n";
+ print "<a href=\"" . BASEURL . SCRIPT . "?mode=viewdocs&item=xmlrpcexample\">";
+ print "XML RPC API Example Code</a><br>\n";
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn showXmlrpcapi()
+///
+/// \brief prints XML RPC API docs
+///
+////////////////////////////////////////////////////////////////////////////////
+function showXmlrpcapi() {
+ $text = file_get_contents(".ht-inc/xmlrpcdocs/xmlrpcWrappers_8php.html");
+ $text = preg_replace('/xmlrpcWrappers_8php.html/', '', $text);
+ $replace = BASEURL . SCRIPT . "?mode=viewdocs&item=xmlrpcexample";
+ $text = preg_replace('/xmlrpc__example_8php-example.html/', $replace, $text);
+ $text = preg_replace('~^<\!DOCTYPE.*</head><body>~s', '', $text);
+ $text = preg_replace('~<h1>/afs.*</h1>~', '', $text);
+ $text = preg_replace('~</body>\n</html>$~', '', $text);
+ print $text;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn showXmlrpcExample()
+///
+/// \brief prints XML RPC API example
+///
+////////////////////////////////////////////////////////////////////////////////
+function showXmlrpcExample() {
+ $text = file_get_contents(".ht-inc/xmlrpcdocs/xmlrpc__example_8php-example.html");
+ $replace = BASEURL . SCRIPT . "?mode=viewdocs&item=xmlrpcapi";
+ $text = preg_replace('/xmlrpcWrappers_8php.html/', $replace, $text);
+ $text = preg_replace('~^<\!DOCTYPE.*</head><body>~s', '', $text);
+ $text = preg_replace('~<h1>xmlrpc_example\.php</h1>~', '', $text);
+ $text = preg_replace('~</body>\n</html>$~', '', $text);
+ print $text;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn showDatabaseDoc($item)
+///
+/// \param $item - name of a documentation item
+///
+/// \brief prints out documentation for $item
+///
+////////////////////////////////////////////////////////////////////////////////
+function showDatabaseDoc($item) {
+ global $viewmode, $user;
+ $query = "SELECT title, data FROM documentation WHERE name = '$item'";
+ $qh = doQuery($query, 101);
+ if(! ($row = mysql_fetch_assoc($qh))) {
+ print "<h2>Online Documentation</h2>\n";
+ print "Failed to retrieve documentation for \"$item\".<br>\n";
+ return;
+ }
+ if($viewmode == ADMIN_DEVELOPER || in_array($user['id'], $doceditors)) {
+ $cdata = array('item' => $item,
+ 'submode' => 'newpage');
+ $cont = addContinuationsEntry('editdoc', $cdata);
+ print "[ <a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
+ print "New page</a> ";
+ $cdata = array('item' => $item,
+ 'submode' => 'editpage');
+ $cont = addContinuationsEntry('editdoc', $cdata);
+ print "| <a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
+ print "Edit page</a> ";
+ $cdata = array('item' => $item);
+ $cont = addContinuationsEntry('confirmdeletedoc', $cdata);
+ print "| <a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
+ print "Delete page</a> ";
+ print "]<br>\n";
+ }
+ print "<div class=vcldocpage>\n";
+ print "<h2>{$row['title']}</h2>\n";
+ print $row['data'];
+ print "</div\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn editDoc()
+///
+/// \brief prints a page for editing a documentation item
+///
+////////////////////////////////////////////////////////////////////////////////
+function editDoc() {
+ global $viewmode, $user;
+ $item = getContinuationVar('item');
+ if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) {
+ showDatabaseDoc($item);
+ return;
+ }
+ $submode = getContinuationVar('submode');
+ if($submode == 'editfurther' || $submode == 'titleerror') {
+ $row['title'] = getContinuationVar('title');
+ $row['data'] = rawurldecode(getContinuationVar('data'));
+ $newedit = getContinuationVar('newedit');
+ }
+ elseif($submode == 'editpage') {
+ $query = "SELECT title, data FROM documentation WHERE name = '$item'";
+ $qh = doQuery($query, 101);
+ if(! ($row = mysql_fetch_assoc($qh))) {
+ print "<h2>Online Documentation</h2>\n";
+ print "Failed to retrieve documentation for \"$item\".<br>\n";
+ return;
+ }
+ $newedit = 'edit';
+ }
+ else {
+ $row['title'] = "";
+ $row['data'] = "";
+ $newedit = 'new';
+ }
+ print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
+ print "<INPUT type=submit value=\"Confirm Changes\"><br><br>\n";
+ print "<big>Title</big>:<INPUT type=text name=title value=\"{$row['title']}\">";
+ if($submode == 'titleerror') {
+ print "<font color=red>Title cannot be empty</font>";
+ }
+ print "<br>\n";
+ $edit = new FCKeditor('data');
+ $edit->BasePath = BASEURL . '/fckeditor/';
+ $edit->Value = $row['data'];
+ $edit->Height = '600';
+ $edit->ToolbarSet = 'VCLDocs';
+ $edit->Create();
+ $cdata = array('item' => $item,
+ 'newedit' => $newedit);
+ $cont = addContinuationsEntry('confirmeditdoc', $cdata);
+ print "<INPUT type=hidden name=continuation value=\"$cont\">\n";
+ print "<INPUT type=submit value=\"Confirm Changes\">\n";
+ print "</FORM>\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn confirmEditDoc()
+///
+/// \brief prints a page asking the user to confirm the changes to the page;
+/// includes a link to go back and edit further
+///
+////////////////////////////////////////////////////////////////////////////////
+function confirmEditDoc() {
+ global $viewmode, $mysql_link_vcl, $contdata;
+ $item = getContinuationVar('item');
+ $newedit = getContinuationVar('newedit');
+ if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) {
+ showDatabaseDoc($item);
+ return;
+ }
+ $title = processInputVar('title', ARG_STRING);
+ if(get_magic_quotes_gpc()) {
+ $data = stripslashes($_POST['data']);
+ $submitdata = rawurlencode(mysql_real_escape_string($data, $mysql_link_vcl));
+ }
+ else {
+ $submitdata = rawurlencode(mysql_real_escape_string($_POST['data'], $mysql_link_vcl));
+ $data = $_POST['data'];
+ }
+ if(empty($title)) {
+ $contdata['title'] = "";
+ $contdata['data'] = rawurlencode($data);
+ $contdata['submode'] = 'titleerror';
+ editDoc();
+ return;
+ }
+ $cdata = array('item' => $item,
+ 'title' => $title,
+ 'data' => $submitdata,
+ 'newedit' => $newedit);
+ $cont = addContinuationsEntry('submiteditdoc', $cdata, SECINDAY, 0, 0);
+ print "[ <a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
+ print "Save Changes</a> ";
+ $cdata['data'] = rawurlencode($data);
+ $cdata['submode'] = 'editfurther';
+ $cont = addContinuationsEntry('editdoc', $cdata, SECINDAY, 0, 0);
+ print "| <a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
+ print "Edit Further</a> ]<br>\n";
+
+ print "<h2>$title</h2>\n";
+ print $data;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn submitEditDoc()
+///
+/// \brief saves submitted changes to a documentation item
+///
+////////////////////////////////////////////////////////////////////////////////
+function submitEditDoc() {
+ global $viewmode, $mysql_link_vcl;
+ $item = getContinuationVar('item');
+ $newedit = getContinuationVar('newedit');
+ if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) {
+ showDatabaseDoc($item);
+ return;
+ }
+ $title = getContinuationVar('title');
+ $data = rawurldecode(getContinuationVar('data'));
+ $name = ereg_replace('[^-A-Za-z0-9_]', '', $title);
+ $query = "SELECT name FROM documentation WHERE name = '$name'";
+ $qh = doQuery($query, 101);
+ $count = 1;
+ $basename = $name;
+ while(mysql_num_rows($qh)) {
+ $name = $basename . $count;
+ $count++;
+ $query = "SELECT name FROM documentation WHERE name = '$name'";
+ $qh = doQuery($query, 101);
+ }
+ if($newedit == 'edit') {
+ $query = "SELECT name FROM documentation WHERE name = '$item'";
+ $qh = doQuery($query, 101);
+ if(! ($row = mysql_fetch_assoc($qh))) {
+ print "<h2>Online Documentation</h2>\n";
+ print "Failed to retrieve documentation for \"$item\".<br>\n";
+ return;
+ }
+ $query = "UPDATE documentation "
+ . "SET name = '$name', "
+ . "title = '$title', "
+ . "data = '$data' "
+ . "WHERE name = '$item'";
+ }
+ else {
+ $query = "INSERT INTO documentation "
+ . "(name, "
+ . "title, "
+ . "data) "
+ . "VALUES "
+ . "('$name', "
+ . "'$title', "
+ . "'$data')";
+ }
+ doQuery($query, 101);
+ if(mysql_affected_rows($mysql_link_vcl)) {
+ print "Page successfully updated.<br>\n";
+ }
+ else
+ print "No changes were made to the page.<br>\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn confirmDeleteDoc()
+///
+/// \brief prints a confirmation page about deleting a documentation item
+///
+////////////////////////////////////////////////////////////////////////////////
+function confirmDeleteDoc() {
+ global $viewmode;
+ $item = getContinuationVar('item');
+ if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) {
+ showDatabaseDoc($item);
+ return;
+ }
+ $query = "SELECT title, data FROM documentation WHERE name = '$item'";
+ $qh = doQuery($query, 101);
+ if(! ($row = mysql_fetch_assoc($qh))) {
+ print "<h2>Online Documentation</h2>\n";
+ print "Failed to retrieve documentation for \"$item\".<br>\n";
+ return;
+ }
+ print "Are you sure you want to delete the following documentation ";
+ print "page?<br>\n";
+ print "<font color=red>Note: the document will be unrecoverable</font>";
+ print "<br>\n";
+ print "<table>\n";
+ print "<tr><td>\n";
+ print "<form action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
+ $cdata = array('item' => $item);
+ $cont = addContinuationsEntry('submitdeletedoc', $cdata, SECINDAY, 0, 0);
+ print "<input type=hidden name=continuation value=$cont>\n";
+ print "<input type=submit value=\"Delete Page\">\n";
+ print "</form>\n";
+ print "</td><td>\n";
+ print "<form action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
+ $cont = addContinuationsEntry('viewdocs', $cdata);
+ print "<input type=hidden name=continuation value=$cont>\n";
+ print "<input type=submit value=\"View Page\">\n";
+ print "</form>\n";
+ print "</td></tr>\n";
+ print "</table>\n";
+ print "<h2>{$row['title']}</h2>\n";
+ print $row['data'];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn submitDeleteDoc()
+///
+/// \brief deletes a documentation item
+///
+////////////////////////////////////////////////////////////////////////////////
+function submitDeleteDoc() {
+ global $viewmode;
+ $item = getContinuationVar('item');
+ if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) {
+ showDatabaseDoc($item);
+ return;
+ }
+ $query = "SELECT title FROM documentation WHERE name = '$item'";
+ $qh = doQuery($query, 101);
+ if(! ($row = mysql_fetch_assoc($qh))) {
+ print "<h2>Online Documentation</h2>\n";
+ print "Failed to retrieve documentation for \"$item\".<br>\n";
+ return;
+ }
+ $query = "DELETE FROM documentation WHERE name = '$item'";
+ doQuery($query, 101);
+ print "The page titled <strong>{$row['title']}</strong> has been deleted.";
+ print "<br>\n";
+}
+?>
Added: incubator/vcl/tags/import/web/.ht-inc/vcldphpcall.pl
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/vcldphpcall.pl?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/vcldphpcall.pl (added)
+++ incubator/vcl/tags/import/web/.ht-inc/vcldphpcall.pl Fri Dec 12 10:20:10 2008
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+use LWP::Simple;
+use lib '/tmp/WDDX-1.02/blib/lib';
+use WDDX;
+
+my $function = "getUserResources";
+my $arg1 = "imageAdmin:imageCheckOut";
+my $arg2 = "available:";
+my $arg3 = 0;
+my $arg4 = 0;
+my $arg5 = 21;
+
+my $doc = get("http://webtest.people.engr.ncsu.edu/jfthomps/vcl/index.php?mode=vcldquery&key=1234&query=$function,$arg1,$arg2,$arg3,$arg4,$arg5");
+
+$doc_id = new WDDX;
+$wddx_obj = $doc_id->deserialize($doc);
+$value = $wddx_obj->as_hashref();
+
+@keys = $wddx_obj->keys();
+
+foreach my $key (keys %{ $value->{"data"} }) {
+ print "---------------------------------------------\n";
+ print "$key\n";
+ foreach my $key2 (keys %{ $value->{"data"}->{$key} }) {
+ print "\t$key2 => " . $value->{"data"}->{$key}->{$key2} . "\n";
+ }
+}
Added: incubator/vcl/tags/import/web/.ht-inc/vm.php
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/vm.php?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/vm.php (added)
+++ incubator/vcl/tags/import/web/.ht-inc/vm.php Fri Dec 12 10:20:10 2008
@@ -0,0 +1,841 @@
+<?php
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * \file vm.php
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn editVMInfo()
+///
+/// \brief prints a page for editing VM Hosts and VM Host Profiles
+///
+////////////////////////////////////////////////////////////////////////////////
+function editVMInfo() {
+ global $viewmode;
+ print "<h2>Manage Virtual Hosts</h2>\n";
+
+ $profiles = getVMProfiles();
+ if($viewmode == ADMIN_DEVELOPER) {
+ print "<div id=\"mainTabContainer\" dojoType=\"dijit.layout.TabContainer\"\n";
+ print " style=\"width:650px;height:600px\">\n";
+
+ print "<div id=\"vmhosts\" dojoType=\"dijit.layout.ContentPane\" title=\"VM Hosts\">\n";
+ }
+
+ print "<div dojoType=\"dijit.Dialog\"\n";
+ print " id=\"messages\">\n";
+ print "<span id=messagestext></span>";
+ print "<button id=\"messagesokbtn\"></button>\n";
+ print "<button onclick=\"dijit.byId('messages').hide()\">Cancel</button>\n";
+ print "</div>\n";
+
+ $newmsg = "To create a new Virtual Host, change the state of a computer to<br>\n"
+ . "'vmhostinuse' under Manage Computers->Computer Utilities.<br><br>\n";
+ $vmhosts = getVMHostData();
+ $resources = getUserResources(array("computerAdmin"), array("administer"));
+ foreach($vmhosts as $key => $value) {
+ if(! array_key_exists($value['computerid'], $resources['computer']))
+ unset($vmhosts[$key]);
+ }
+ if(empty($vmhosts)) {
+ print "You do not have access to manage any existing virtual hosts.<br><br>\n";
+ print $newmsg;
+ return;
+ }
+ print $newmsg;
+ print "Select a Virtual Host:<br>\n";
+ printSelectInput("vmhostid", $vmhosts, -1, 0, 0, 'vmhostid');
+ $cont = addContinuationsEntry('vmhostdata');
+ print "<button dojoType=\"dijit.form.Button\" id=\"fetchCompGrpsButton\">\n";
+ print " Configure Host\n";
+ print " <script type=\"dojo/method\" event=onClick>\n";
+ print " getVMHostData('$cont');\n";
+ print " </script>\n";
+ print "</button><br><br>\n";
+ print "<div id=vmhostdata class=hidden>\n";
+ print "<table summary=\"\">\n";
+ print " <tr>\n";
+ print " <th align=right>VM limit:</th>\n";
+ print " <td>\n";
+ $cont = addContinuationsEntry('updateVMlimit');
+ print " <input dojoType=\"dijit.form.NumberSpinner\"\n";
+ print " constraints=\"{min:1,max:" . MAXVMLIMIT . "}\"\n";
+ print " maxlength=\"3\"\n";
+ print " id=\"vmlimit\"\n";
+ print " onChange=\"updateVMlimit('$cont')\">\n";
+ print " </td>\n";
+ print " </tr>\n";
+ #$cont = addContinuationsEntry('changeVMprofile');
+ print " <tr>\n";
+ print " <th align=right>VM Profile:</th>\n";
+ print " <td>\n";
+ #printSelectInput("vmprofileid", $profiles, -1, 0, 0, 'vmprofileid', "onchange=changeVMprofile('$cont')");
+ print " <div dojoType=\"dijit.TitlePane\" id=vmprofile></div>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ /*if(! empty($data['vmkernalnic'])) {
+ print " <tr>\n";
+ print " <th align=right>VM Kernal NIC:</th>\n";
+ print " <td>{$data['vmkernalnic']}</td>\n";
+ print " </tr>\n";
+ }*/
+ print "</table><br><br>\n";
+
+ print "<div id=movevms class=hidden>\n";
+ print "The followig VM(s) will removed from this host at the listed ";
+ print "time(s):<br>\n";
+ print "<select name=movevmssel multiple id=movevmssel size=3>\n";
+ print "</select><br>\n";
+ print "<button dojoType=\"dijit.form.Button\" id=\"cancelBtn\">\n";
+ print " <div>Cancel Removing of Selected VMs</div>\n";
+ print " <script type=\"dojo/method\" event=onClick>\n";
+ $cont = addContinuationsEntry('AJcancelVMmove');
+ print " cancelVMmove('$cont');\n";
+ print " </script>\n";
+ print "</button>\n";
+ print "<br><br></div>\n";
+
+ print "<table summary=\"\"><tbody><tr>\n";
+
+ # select for vms on host
+ print "<td valign=top>\n";
+ print "VMs assigned to host:<br>\n";
+ print "<select name=currvms multiple id=currvms size=15 onChange=showVMstate()>\n";
+ print "</select><br>\n";
+ print "State of selected vm:<br>\n";
+ print "<span id=vmstate></span>\n";
+ print "</td>\n";
+ # transfer buttons
+ print "<td style=\"vertical-align: middle;\">\n";
+ print "<button dojoType=\"dijit.form.Button\" id=\"addBtn1\">\n";
+ print " <div style=\"width: 50px;\"><-Add</div>\n";
+ print " <script type=\"dojo/method\" event=onClick>\n";
+ $cont = addContinuationsEntry('AJvmToHost');
+ print " vmToHost('$cont');\n";
+ print " </script>\n";
+ print "</button>\n";
+ print "<br>\n";
+ print "<br>\n";
+ print "<br>\n";
+ print "<button dojoType=\"dijit.form.Button\" id=\"remBtn1\">\n";
+ print " <div style=\"width: 50px;\">Remove</div>\n";
+ print " <script type=\"dojo/method\" event=onClick>\n";
+ $cont = addContinuationsEntry('AJvmFromHost');
+ print " vmFromHost('$cont');\n";
+ print " </script>\n";
+ print "</button>\n";
+ print "</td>\n";
+ # select for unassigned vms
+ print "<td valign=top>\n";
+ print "Unassigned VMs:<br>\n";
+ print "<select name=freevms multiple id=freevms size=20>\n";
+ print "</select>\n";
+ print "</td>\n";
+ print "</tr><tbody/></table>\n";
+ print "</div><br><br>\n";
+
+ /*print "<div dojoType=\"dijit.Dialog\"\n";
+ print " id=\"profileDlg\"\n";
+ print " title=\"Change Profile\">\n";
+ print "You have selected to change the VM Profile for this host.<br>\n";
+ print "Doing this will attempt to move any future reservations on the<br>\n";
+ print "host's VMs to other VMs and will submit a reload reservation for this<br>\n";
+ print "host after any active reservations on its VMs.<br><br>\n";
+ print "Are you sure you want to do this?<br><br>\n";
+ print "<button onclick=\"submitChangeProfile()\">Update VM Profile</button>\n";
+ print "<button onclick=\"dijit.byId('profileDlg').hide()\">Cancel</button>\n";
+ print "<input type=hidden id=changevmcont>\n";
+ print "</div>\n";*/
+ print "</div>\n";
+
+ if($viewmode != ADMIN_DEVELOPER)
+ return;
+ print "<div id=\"vmprofiles\" dojoType=\"dijit.layout.ContentPane\" title=\"VM Host Profiles\">\n";
+ print "<br>Select a profile to configure:<br>\n";
+ printSelectInput("profileid", $profiles, -1, 0, 0, 'profileid');
+ $cont = addContinuationsEntry('AJprofiledata');
+ print "<button dojoType=\"dijit.form.Button\" id=\"fetchProfilesBtn\">\n";
+ print " Configure Profile\n";
+ print " <script type=\"dojo/method\" event=onClick>\n";
+ print " getVMprofileData('$cont');\n";
+ print " </script>\n";
+ print "</button>";
+ $cont = addContinuationsEntry('AJnewProfile');
+ print "<button dojoType=\"dijit.form.Button\" id=\"newProfilesBtn\">\n";
+ print " New Profile...\n";
+ print " <script type=\"dojo/method\" event=onClick>\n";
+ print " newProfile('$cont');\n";
+ print " </script>\n";
+ print "</button>";
+ print "<br><br>\n";
+
+ print "<div id=vmprofiledata class=hidden>\n";
+ $cont = addContinuationsEntry('AJdelProfile');
+ print "<button dojoType=\"dijit.form.Button\" id=\"delProfilesBtn\">\n";
+ print " Delete this Profile\n";
+ print " <script type=\"dojo/method\" event=onClick>\n";
+ print " delProfile('$cont');\n";
+ print " </script>\n";
+ print "</button><br><br>";
+ $cont = addContinuationsEntry('AJupdateVMprofileItem');
+ print "(Click a value to edit it)<br>\n";
+ print "<input type=hidden id=pcont value=\"$cont\">\n";
+ print "<table summary=\"\">\n";
+ print " <tr>\n";
+ print " <th align=right>Name:</th>\n";
+ print " <td><span id=pname dojoType=\"dijit.InlineEditBox\" onChange=\"updateProfile('pname', 'name');\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>Type:</th>\n";
+ print " <td><select id=ptype dojoType=\"dijit.form.FilteringSelect\" searchAttr=\"name\" onchange=\"updateProfile('ptype', 'vmtypeid');\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>Image:</th>\n";
+ print " <td><span id=pimage dojoType=\"dijit.form.FilteringSelect\" searchAttr=\"name\" onchange=\"updateProfile('pimage', 'imageid');\" style=\"width: 420px\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>NAS Share:</th>\n";
+ print " <td><span id=pnasshare dojoType=\"dijit.InlineEditBox\" onChange=\"updateProfile('pnasshare', 'nasshare');\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>Data Store Path:</th>\n";
+ print " <td><span id=pdspath dojoType=\"dijit.InlineEditBox\" onChange=\"updateProfile('pdspath', 'datastorepath');\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>VM Path:</th>\n";
+ print " <td><span id=pvmpath dojoType=\"dijit.InlineEditBox\" onChange=\"updateProfile('pvmpath', 'vmpath');\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>Virtual Switch 0:</th>\n";
+ print " <td><span id=pvs0 dojoType=\"dijit.InlineEditBox\" onChange=\"updateProfile('pvs0', 'virtualswitch0');\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>Virtual Switch 1:</th>\n";
+ print " <td><span id=pvs1 dojoType=\"dijit.InlineEditBox\" onChange=\"updateProfile('pvs1', 'virtualswitch1');\"></span></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <th align=right>VM Disk:</th>\n";
+ print " <td><select id=pvmdisk dojoType=\"dijit.form.FilteringSelect\" searchAttr=\"name\" onchange=\"updateProfile('pvmdisk', 'vmdisk');\"></span></td>\n";
+ print " </tr>\n";
+ print "</table>\n";
+ print "</div>\n";
+ print "</div>\n";
+
+ print "</div>\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn vmhostdata()
+///
+/// \brief prints json formatted data with information about the submitted VM
+/// host
+///
+////////////////////////////////////////////////////////////////////////////////
+function vmhostdata() {
+ $vmhostid = processInputVar('vmhostid', ARG_NUMERIC);
+ $ret = '';
+ $data = getVMHostData($vmhostid);
+
+ $resources = getUserResources(array("computerAdmin"), array("administer"));
+ if(! array_key_exists($data[$vmhostid]['computerid'], $resources['computer'])) {
+ $arr = array('failed' => 'noaccess');
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+
+ # get vms assigned to vmhost
+ $query = "SELECT c.id, "
+ . "c.hostname, "
+ . "s.name AS state, "
+ . "c.vmhostid "
+ . "FROM computer c, "
+ . "state s "
+ . "WHERE c.type = 'virtualmachine' AND "
+ . "c.stateid = s.id AND "
+ . "(vmhostid IS NULL OR "
+ . "vmhostid NOT IN (SELECT id FROM vmhost) OR "
+ . "c.vmhostid = $vmhostid) "
+ . "ORDER BY c.hostname";
+ $qh = doQuery($query, 101);
+ $ids = array();
+ $allvms = array();
+ $currvms = array();
+ $freevms = array();
+ while($row = mysql_fetch_assoc($qh)) {
+ if($row['vmhostid'] == $vmhostid) {
+ $ids[$row['id']] = $row['hostname'];
+ $currvms[$row['id']] = array('id' => $row['id'],
+ 'name' => $row['hostname'],
+ 'state' => $row['state']);
+ $allvms[] = array('id' => $row['id'],
+ 'name' => $row['hostname'],
+ 'inout' => 1);
+ }
+ else {
+ $freevms[] = array('id' => $row['id'],
+ 'name' => $row['hostname']);
+ $allvms[] = array('id' => $row['id'],
+ 'name' => $row['hostname'],
+ 'inout' => 0);
+ }
+ }
+ uasort($allvms, "sortKeepIndex");
+ uasort($currvms, "sortKeepIndex");
+ uasort($freevms, "sortKeepIndex");
+
+ $keys = array_keys($ids);
+ $movevms = array();
+ if(! empty($keys)) {
+ $keys = join(',', $keys);
+ $query = "SELECT rq.id, "
+ . "DATE_FORMAT(rq.start, '%l:%i%p %c/%e/%y') AS start, "
+ . "rs.computerid "
+ . "FROM request rq, "
+ . "reservation rs "
+ . "WHERE rs.requestid = rq.id AND "
+ . "rs.computerid IN ($keys) AND "
+ . "(rq.stateid = 18 OR "
+ . "rq.laststateid = 18) AND "
+ . "rq.start > NOW()";
+ $qh = doQuery($query, 101);
+ while($row = mysql_fetch_assoc($qh)) {
+ $movevms[] = array('id' => $row['id'],
+ 'time' => strtolower($row['start']),
+ 'hostname' => $currvms[$row['computerid']]['name']);
+ unset($currvms[$row['computerid']]);
+ }
+ uasort($movevms, "sortKeepIndex");
+ $movevms = array_merge($movevms);
+ }
+
+ $allvms = array_merge($allvms);
+ $currvms = array_merge($currvms);
+ $freevms = array_merge($freevms);
+ $cont = addContinuationsEntry('AJchangeVMprofile', array(), 3600, 1, 0);
+ $arr = array('vmlimit' => $data[$vmhostid]['vmlimit'],
+ 'profile' => $data[$vmhostid]['vmprofiledata'],
+ 'continuation' => $cont,
+ 'allvms' => $allvms,
+ 'currvms' => $currvms,
+ 'freevms' => $freevms,
+ 'movevms' => $movevms);
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn getVMHostData($id)
+///
+/// \param $id - (optional) a host id about which to get data
+///
+/// \return an array where each key is a vmhost id and each element is an array
+/// with these values:\n
+/// \b computerid - id of computer\n
+/// \b name - hostname of computer\n
+/// \b hostname - hostname of computer\n
+/// \b vmlimit - maximum number of vm's host can handle\n
+/// \b vmprofileid - id of vm profile\n
+/// \b vmkernalnic - name of kernel nic\n
+/// \b vmprofiledata - array of data about the vm's profile as returned from
+/// getVMProfiles
+///
+/// \brief builds a array of information about the vmhosts
+///
+////////////////////////////////////////////////////////////////////////////////
+function getVMHostData($id='') {
+ $profiles = getVMProfiles();
+ $query = "SELECT vh.id, "
+ . "vh.computerid, "
+ . "c.hostname AS name, "
+ . "c.hostname, "
+ . "vh.vmlimit, "
+ . "vh.vmprofileid, "
+ #. "vp.profilename, "
+ . "vh.vmkernalnic "
+ . "FROM vmhost vh, "
+ . "vmprofile vp, "
+ . "computer c "
+ . "WHERE vh.vmprofileid = vp.id AND "
+ . "vh.computerid = c.id";
+ if(! empty($id))
+ $query .= " AND vh.id = $id";
+ $qh = doQuery($query, 101);
+ $ret = array();
+ while($row = mysql_fetch_assoc($qh)) {
+ $ret[$row['id']] = $row;
+ $ret[$row['id']]['vmprofiledata'] = $profiles[$row['vmprofileid']];
+ }
+ uasort($ret, 'sortKeepIndex');
+ return $ret;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn updateVMlimit()
+///
+/// \brief updates the vmlimit for the submitted vmhostid
+///
+////////////////////////////////////////////////////////////////////////////////
+function updateVMlimit() {
+ global $mysql_link_vcl;
+ $vmhostid = processInputVar('vmhostid', ARG_NUMERIC);
+
+ $data = getVMHostData($vmhostid);
+ $resources = getUserResources(array("computerAdmin"), array("administer"));
+ if(! array_key_exists($data[$vmhostid]['computerid'], $resources['computer'])) {
+ print 'You do not have access to manage this host.';
+ return;
+ }
+
+ $newlimit = processInputVar('newlimit', ARG_NUMERIC);
+ if($newlimit < 0 || $newlimit > MAXVMLIMIT) {
+ print "ERROR: newlimit out of range";
+ return;
+ }
+ $query = "UPDATE vmhost SET vmlimit = $newlimit WHERE id = $vmhostid";
+ $qh = doQuery($query, 101);
+ if(mysql_affected_rows($mysql_link_vcl))
+ print "SUCCESS";
+ else
+ print "ERROR: failed to update vmlimit";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJvmToHost()
+///
+/// \brief adds vm's to a vmhost; prints json data with:\n
+/// \b vms - array of vm's successfully added\n
+/// \b fails - array of vm's that couldn't be added for some reason\n
+/// \b addrem - 1
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJvmToHost() {
+ $hostid = processInputVar('hostid', ARG_NUMERIC);
+
+ $hostdata = getVMHostData($hostid);
+ $resources = getUserResources(array("computerAdmin"), array("administer"));
+ if(! array_key_exists($hostdata[$hostid]['computerid'], $resources['computer'])) {
+ $arr = array('failed' => 'nohostaccess');
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+
+ # find out how many vms are currently on the host
+ $query = "SELECT COUNT(id) "
+ . "FROM computer "
+ . "WHERE vmhostid = $hostid";
+ $qh = doQuery($query, 101);
+ $row = mysql_fetch_row($qh);
+ if($row[0] >= $hostdata[$hostid]['vmlimit']) {
+ $arr = array('failed' => 'vmlimit');
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+
+ $adds = array();
+ $fails = array();
+
+ $vmlistids = processInputVar('listids', ARG_STRING);
+ $vmids = explode(',', $vmlistids);
+
+ # get data about submitted vms to add
+ $query = "SELECT id, hostname, vmhostid "
+ . "FROM computer "
+ . "WHERE id in ($vmlistids)";
+ $qh = doQuery($query, 101);
+ $vmdata = array();
+ while($row = mysql_fetch_assoc($qh)) {
+ if(! array_key_exists($row['id'], $resources['computer'])) {
+ $fails[] = array('id' => $row['id'], 'name' => $row['hostname'], 'reason' => 'noaccess');
+ unset_by_val($row['id'], $vmids);
+ continue;
+ }
+ $vmdata[$row['id']] = $row;
+ }
+
+ # build list of vm hosts
+ $query = "SELECT id FROM vmhost";
+ $vmhosts = array();
+ $qh = doQuery($query, 101);
+ while($row = mysql_fetch_assoc($qh))
+ $vmhosts[$row['id']] = 1;
+
+ # check to see if there any submitted vms have a hostid of an existing vm host
+ foreach($vmids as $compid) {
+ if(! array_key_exists($vmdata[$compid]['vmhostid'], $vmhosts)) {
+ $query = "UPDATE computer "
+ . "SET vmhostid = $hostid, "
+ . "stateid = 2 "
+ . "WHERE id = $compid";
+ doQuery($query, 101);
+ $adds[] = array('id' => $compid, 'name' => $vmdata[$compid]['hostname'], 'state' => 'available');
+ }
+ else
+ $fails[] = array('id' => $compid, 'name' => $vmdata[$compid]['hostname'], 'reason' => 'otherhost');
+ }
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $arr = array('vms' => $adds, 'fails' => $fails, 'addrem' => 1);
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJvmFromHost()
+///
+/// \brief removes vm's from a host by adding reservations for them in the
+/// tomaintenance state; prints json data with:\n
+/// \b vms - vm's that successfully had reservastions created to move them off\n
+/// \b checks - vm's that have reservations on them that can be removed in the
+/// future by adding a future tomaintenance reservation\n
+/// \b addrem - 0\n
+/// \b cont - a new continuation for submitting the future tomaintenance
+/// reservations
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJvmFromHost() {
+ $hostid = processInputVar('hostid', ARG_NUMERIC);
+
+ $hostdata = getVMHostData($hostid);
+ $resources = getUserResources(array("computerAdmin"), array("administer"));
+ if(! array_key_exists($hostdata[$hostid]['computerid'], $resources['computer'])) {
+ $arr = array('failed' => 'nohostaccess');
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+
+ $fails = array();
+ $vmlistids = processInputVar('listids', ARG_STRING);
+ $vmids = explode(',', $vmlistids);
+ $rems = array();
+ $checks = array();
+ $vclreloadid = getUserlistID('vclreload');
+ $start = getReloadStartTime();
+ $end = $start + SECINMONTH;
+ $start = unixToDatetime($start);
+ $end = unixToDatetime($end);
+ foreach($vmids as $compid) {
+ $compdata = getComputers(0, 0, $compid);
+ if(! array_key_exists($compid, $resources['computer'])) {
+ $fails[] = array('id' => $compid,
+ 'name' => $compdata[$compid]['hostname'],
+ 'reason' => 'noaccess');
+ continue;
+ }
+ # try to remove reservations off of computer
+ if(($compdata[$compid]['state'] == 'available' ||
+ $compdata[$compid]['state'] == 'maintenance' ||
+ $compdata[$compid]['state'] == 'failed') &&
+ moveReservationsOffComputer($compid)) {
+ // if no reservations on computer, submit reload
+ # reservation so vm gets stopped on host
+ $reqid = simpleAddRequest($compid, 4, 3, $start, $end, 18, $vclreloadid);
+ $rems[] = array('id' => $compid,
+ 'hostname' => $compdata[$compid]['hostname'],
+ 'reqid' => $reqid,
+ 'time' => 'immediately');
+ }
+ else {
+ # existing reservation on computer, find end time and prompt user
+ # if ok to wait until then to move it
+ $query = "SELECT DATE_FORMAT(rq.end, '%l:%i%p %c/%e/%y') AS end, "
+ . "rq.end AS end2 "
+ . "FROM request rq, "
+ . "reservation rs "
+ . "WHERE rs.requestid = rq.id AND "
+ . "rs.computerid = $compid AND "
+ . "rq.stateid NOT IN (1,5,12) "
+ . "ORDER BY end DESC "
+ . "LIMIT 1";
+ $qh = doQuery($query, 101);
+ if($row = mysql_fetch_assoc($qh)) {
+ $checks[] = array('id' => $compid,
+ 'hostname' => $compdata[$compid]['hostname'],
+ 'end' => strtolower($row['end']),
+ 'end2' => $row['end2']);
+ }
+ else
+ $rems[] = array('id' => $compid);
+ }
+ }
+ if(count($checks))
+ $cont = addContinuationsEntry('AJvmFromHostDelayed', $checks, 120, 1, 0);
+ else
+ $cont = '';
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $arr = array('vms' => $rems,
+ 'checks' => $checks,
+ 'fails' => $fails,
+ 'addrem' => 0,
+ 'cont' => $cont);
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJvmFromHostDelayed()
+///
+/// \brief submits future tomaintenance reservations for vm's saved in the
+/// continuation
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJvmFromHostDelayed() {
+ $data = getContinuationVar();
+ $vclreloadid = getUserlistID('vclreload');
+ foreach($data as $comp) {
+ $end = datetimeToUnix($comp['end2']) + SECINMONTH;
+ $end = unixToDatetime($end);
+ simpleAddRequest($comp['id'], 4, 3, $comp['end2'], $end, 18, $vclreloadid);
+ }
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $cont = addContinuationsEntry('vmhostdata');
+ $arr = array('msg' => 'SUCCESS', 'cont' => $cont);
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJchangeVMprofile()
+///
+/// \brief stub function for changing the vm profile of a vm host
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJchangeVMprofile() {
+ $hostid = processInputVar('hostid', ARG_NUMERIC);
+ $oldprofileid = processInputVar('oldprofileid', ARG_NUMERIC);
+ $newprofileid = processInputVar('newprofileid', ARG_NUMERIC);
+ # add security checks
+ # try to remove reservations off of each vm
+ // if no reservations on any vms, create reload reservation
+ # else try to create reservation to handle in future
+ # else return error message
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $cont = addContinuationsEntry('AJchangeVMprofile', array(), 3600, 1, 0);
+ $arr = array('msg' => 'function not implemented', 'continuation' => $cont);
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJcancelVMmove()
+///
+/// \brief cancels tomaintenance reservations that had been submitted to move
+/// a vm off of a vmhost
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJcancelVMmove() {
+ $hostid = processInputVar('hostid', ARG_NUMERIC);
+
+ $hostdata = getVMHostData($hostid);
+ $resources = getUserResources(array("computerAdmin"), array("administer"));
+ if(! array_key_exists($hostdata[$hostid]['computerid'], $resources['computer'])) {
+ $arr = array('failed' => 'nohostaccess');
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+
+ $fails = array();
+ $requestids = processInputVar('listids', ARG_STRING);
+ $now = time();
+ $msg = 'FAIL';
+ foreach(explode(',', $requestids) AS $reqid) {
+ $request = getRequestInfo($reqid);
+ if(! array_key_exists($request['reservations'][0]['computerid'], $resources['computer'])) {
+ $fails[] = array('id' => $request['reservations'][0]['computerid'],
+ 'name' => $request['reservations'][0]['hostname'],
+ 'reason' => 'noaccess');
+ continue;
+ }
+ if(datetimeToUnix($request["start"]) < $now) {
+ # set stateid and laststateid for each request to deleted
+ $query = "UPDATE request "
+ . "SET stateid = 1, "
+ . "laststateid = 1 "
+ . "WHERE id = $reqid";
+ doQuery($query, 101);
+ }
+ else {
+ $query = "DELETE FROM request WHERE id = $reqid";
+ doQuery($query, 101);
+ $query = "DELETE FROM reservation WHERE requestid = $reqid";
+ doQuery($query, 101);
+ }
+ $msg = 'SUCCESS';
+ }
+
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $cont = addContinuationsEntry('vmhostdata');
+ $arr = array('msg' => $msg, 'cont' => $cont, 'fails' => $fails);
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJprofiledata()
+///
+/// \param $profileid - (optional) id of a vm profile
+///
+/// \brief prints json data about a submitted or passed in vm profile with these
+/// fields:\n
+/// \b profile - array returned from getVMProfiles\n
+/// \b types - array of vm types\n
+/// \b vmdisk - array of vm disk options\n
+/// \b images - array of images
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJprofileData($profileid="") {
+ global $viewmode;
+ if($viewmode != ADMIN_DEVELOPER) {
+ $arr = array('failed' => 'noaccess');
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+ $profileid = processInputVar('profileid', ARG_NUMERIC, $profileid);
+ $profiledata = getVMProfiles($profileid);
+ foreach($profiledata[$profileid] AS $key => $value) {
+ if(is_null($value))
+ $profiledata[$profileid][$key] = '';
+ }
+ $types = getVMtypes();
+ $allimages = getImages();
+ $images = array();
+ foreach($allimages as $key => $image)
+ $images[] = array('id' => $key, 'name' => $image['prettyname']);
+ $imagedata = array('identifier' => 'id', 'items' => $images);
+
+ $types2 = array();
+ foreach($types as $id => $val) {
+ $types2[] = array('id' => $id, 'name' => $val);
+ }
+ $typedata = array('identifier' => 'id', 'items' => $types2);
+
+ $vmdiskitems = array();
+ $vmdiskitems[] = array('id' => 'localdisk', 'name' => 'localdisk');
+ $vmdiskitems[] = array('id' => 'networkdisk', 'name' => 'networkdisk');
+ $vmdisk = array('identifier' => 'id', 'items' => $vmdiskitems);
+
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $arr = array('profile' => $profiledata[$profileid],
+ 'types' => $typedata,
+ 'vmdisk' => $vmdisk,
+ 'images' => $imagedata);
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJupdateVMprofileItem()
+///
+/// \brief updates the submitted item for the submitted vm profile and prints
+/// javascript to keep the global curprofile object updated
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJupdateVMprofileItem() {
+ global $viewmode;
+ if($viewmode != ADMIN_DEVELOPER) {
+ print "alert('You do not have access to manage this vm profile.');";
+ return;
+ }
+ $profileid = processInputVar('profileid', ARG_NUMERIC);
+ $item = processInputVar('item', ARG_STRING);
+ $newvalue = processInputVar('newvalue', ARG_STRING);
+ if($newvalue == '')
+ $newvalue2 = 'NULL';
+ else {
+ if(get_magic_quotes_gpc()) {
+ $newvalue2 = stripslashes($newvalue);
+ $newvalue2 = mysql_escape_string($newvalue2);
+ }
+ $newvalue2 = "'$newvalue2'";
+ }
+
+ $profile = getVMProfiles($profileid);
+ if($profile[$profileid][$item] == $newvalue)
+ return;
+ $query = "UPDATE vmprofile "
+ . "SET `$item` = $newvalue2 "
+ . "WHERE id = $profileid";
+ doQuery($query, 101);
+ print "curprofile.$item = '$newvalue';";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJnewProfile()
+///
+/// \brief creates a new vmprofile entry using just the submitted new name and
+/// the defaults for the rest of the fields; calls AJprofileData
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJnewProfile() {
+ $newprofile = processInputVar('newname', ARG_STRING);
+ if(get_magic_quotes_gpc()) {
+ $newprofile = stripslashes($newprofile);
+ $newprofile = mysql_escape_string($newprofile);
+ }
+ # TODO add check for existing name
+ $query = "SELECT id FROM vmprofile WHERE profilename = '$newprofile'";
+ $qh = doQuery($query, 101);
+ if($row = mysql_fetch_assoc($qh)) {
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $arr = array('failed' => 'exists');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+ $query = "INSERT INTO vmprofile (profilename) VALUES ('$newprofile')";
+ doQuery($query, 101);
+ $qh = doQuery("SELECT LAST_INSERT_ID() FROM vmprofile", 101);
+ $row = mysql_fetch_row($qh);
+ $newid = $row[0];
+ AJprofileData($newid);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJdelProfile()
+///
+/// \brief deletes the submitted vm profile
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJdelProfile() {
+ global $viewmode;
+ if($viewmode != ADMIN_DEVELOPER) {
+ $arr = array('failed' => 'noaccess');
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+ return;
+ }
+ $profileid = processInputVar('profileid', ARG_NUMERIC);
+ $query = "DELETE FROM vmprofile WHERE id = $profileid";
+ doQuery($query, 101);
+ header('Content-Type: text/json-comment-filtered; charset=utf-8');
+ $arr = array('SUCCESS');
+ print '/*{"items":' . json_encode($arr) . '}*/';
+}
+
+?>
Added: incubator/vcl/tags/import/web/.ht-inc/xmlrpcWrappers.php
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/xmlrpcWrappers.php?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/xmlrpcWrappers.php (added)
+++ incubator/vcl/tags/import/web/.ht-inc/xmlrpcWrappers.php Fri Dec 12 10:20:10 2008
@@ -0,0 +1,470 @@
+<?php
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * \file
+ * The functions listed here are for making VCL requests from other applications.
+ * They are implemented according to the XML RPC spec defined at
+ * http://www.xmlrpc.com/ \n
+ * There is one function called \b XMLRPCtest() that can be used during
+ * initial development to get started without actually making a request.\n
+ * \n
+ * The URL you will use to submit RPC calls is\n\n
+ * https://vcl.ncsu.edu/scheduling/index.php?mode=xmlrpccall\n\n
+ * Your application must connect using HTTPS.\n\n
+ * Internal to the VCL code, "Reservations" are called "Requests"; therefore,
+ * "request" is used instead of "reservation" in this documentation and in the
+ * RPC functions.
+ * \n
+ * <h2>API Version 2</h2>
+ * This is the current version of the API. It should be used for any new code
+ * development. Any older code needs to be migrated to this version.\n\n
+ * Authentication is handled by 2 additional HTTP headers you will need to
+ * send:\n
+ * \b X-User - the userid you would use to log in to the VCL site, followed
+ * by the at sign (@), followed by your affiliation\n
+ * example: myuserid\@NCSU -
+ * currently, you need to contact vcl_help@ncsu.edu to find out your
+ * affiliation, but in the future there will be an API method of obtaining
+ * this\n
+ * \b X-Pass - the password you would use to log in to the VCL site\n
+ * \n
+ * There is one other additional HTTP header you must send:\n
+ * \b X-APIVERSION - set this to 2\n\n
+ *
+ * <h2>API Version 1</h2>
+ * This version is being phased out in favor of version 2. Documentation is
+ * provided for those currently using version 1 who are not ready to switch
+ * to using version 2.\n\n
+ * To connect to VCL with XML RPC, you will need to obtain a key. Contact
+ * vcl_help@ncsu.edu to get one.\n
+ *
+ * Authentication is handled by 2 additional HTTP headers you will need to
+ * send:\n
+ * \b X-User - use the same id you would use to log in to the VCL site\n
+ * \b X-Pass - the key mentioned above\n
+ * \n
+ * There is one other additional HTTP header you must send:\n
+ * \b X-APIVERSION - set this to 1\n
+ */
+
+/// \example xmlrpc_example.php
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCaffiliations()
+///
+/// \return an array of affiliation arrays, each with 2 indices:\n
+/// \b id - id of the affiliation\n
+/// \b name - name of the affiliation
+///
+/// \brief gets all of the affilations for which users can log in to VCL
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCaffiliations() {
+ $affils = getAffiliations();
+ $return = array();
+ foreach($affils as $key => $val) {
+ $tmp = array('id' => $key, 'name' => $val);
+ array_push($return, $tmp);
+ }
+ return $return;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCgetImages()
+///
+/// \return an array of image arrays, each with 2 indices:\n
+/// \b id - id of the image\n
+/// \b name - name of the image
+///
+/// \brief gets the images to which the user has acces
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCgetImages() {
+ $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
+ $resources["image"] = removeNoCheckout($resources["image"]);
+ $return = array();
+ foreach($resources['image'] as $key => $val) {
+ $tmp = array('id' => $key, 'name' => $val);
+ array_push($return, $tmp);
+ }
+ return $return;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCaddRequest($imageid, $start, $length, $foruser)
+///
+/// \param $imageid - id of an image
+/// \param $start - "now" or unix timestamp for start of reservation; will
+/// use a floor function to round down to the nearest 15 minute increment
+/// for actual reservation
+/// \param $length - length of reservation in minutes (must be in 15 minute
+/// increments)
+/// \param $foruser - (optional) login to be used when setting up the account
+/// on the reserved machine - CURRENTLY, THIS IS UNSUPPORTED
+///
+/// \return an array with at least one index named '\b status' which will have
+/// one of these values:\n
+/// \b error - error occurred; there will be 2 additional elements in the array:
+/// \li \b errorcode - error number\n
+/// \li \b errormsg - error string\n
+///
+/// \b notavailable - no computers were available for the request\n
+/// \b success - there will be an additional element in the array:
+/// \li \b requestid - identifier that should be passed to later calls when
+/// acting on the request
+///
+/// \brief tries to make a request
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCaddRequest($imageid, $start, $length, $foruser='') {
+ global $user;
+ $imageid = processInputData($imageid, ARG_NUMERIC);
+ $start = processInputData($start, ARG_STRING, 1);
+ $length = processInputData($length, ARG_NUMERIC);
+ #$foruser = processInputData($foruser, ARG_STRING, 1);
+
+ // make sure user didn't submit a request for an image he
+ // doesn't have access to
+ $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
+ $validImageids = array_keys($resources['image']);
+ if(! in_array($imageid, $validImageids)) {
+ return array('status' => 'error',
+ 'errorcode' => 3,
+ 'errormsg' => "access denied to $imageid");
+ }
+
+ # validate $start
+ if($start != 'now' && ! is_numeric($start)) {
+ return array('status' => 'error',
+ 'errorcode' => 4,
+ 'errormsg' => "received invalid input");
+ }
+
+ # validate $length
+ $maxtimes = getUserMaxTimes();
+ if($maxtimes['initial'] < $length) {
+ return array('status' => 'error',
+ 'errorcode' => 6,
+ 'errormsg' => "max allowed initial length is {$maxtimes['initial']} minutes");
+ }
+
+ $nowfuture = 'future';
+ if($start == 'now') {
+ $start = time();
+ $nowfuture = 'now';
+ }
+ else
+ if($start < (time() - 30))
+ return array('status' => 'error',
+ 'errorcode' => 5,
+ 'errormsg' => "start time is in the past");
+ $start = unixFloor15($start);
+ $end = $start + $length * 60;
+ if($end % (15 * 60))
+ $end = unixFloor15($end) + (15 * 60);
+
+ $max = getMaxOverlap($user['id']);
+ if(checkOverlap($start, $end, $max)) {
+ return array('status' => 'error',
+ 'errorcode' => 7,
+ 'errormsg' => "reservation overlaps with another one you "
+ . "have, and you are allowed $max "
+ . "overlapping reservations at a time");
+ }
+
+ $images = getImages();
+ $rc = isAvailable($images, $imageid, $start, $end, '');
+ if($rc < 1) {
+ addLogEntry($nowfuture, unixToDatetime($start),
+ unixToDatetime($end), 0, $imageid);
+ return array('status' => 'notavailable');
+ }
+ $return['requestid']= addRequest();
+ $return['status'] = 'success';
+ return $return;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCgetRequestStatus($requestid)
+///
+/// \param $requestid - id of a request
+///
+/// \return an array with at least one index named '\b status' which will have
+/// one of these values:\n
+/// \b error - error occurred; there will be 2 additional elements in the array:
+/// \li \b errorcode - error number\n
+/// \li \b errormsg - error string\n
+///
+/// \b ready - request is ready\n
+/// \b failed - request failed to load properly\n
+/// \b timedout - request timed out (user didn't connect before timeout
+/// expired)\n
+/// \b loading - request is still loading; there will be an additional element
+/// in the array:
+/// \li \b time - the estimated wait time (in minutes) for loading to complete\n
+///
+/// \b future - start time of request is in the future
+///
+/// \brief determines and returns the status of the request
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCgetRequestStatus($requestid) {
+ global $user;
+ $requestid = processInputData($requestid, ARG_NUMERIC);
+ $userRequests = getUserRequests('all', $user['id']);
+ $found = 0;
+ foreach($userRequests as $req) {
+ if($req['id'] == $requestid) {
+ $request = $req;
+ $found = 1;
+ break;
+ }
+ }
+ if(! $found)
+ return array('status' => 'error',
+ 'errorcode' => 1,
+ 'errormsg' => 'unknown requestid');
+
+ $now = time();
+ # request is ready
+ if(requestIsReady($request))
+ return array('status' => 'ready');
+ # request failed
+ elseif($request["currstateid"] == 5)
+ return array('status' => 'failed');
+ # other cases where the reservation start time has been reached
+ elseif(datetimeToUnix($request["start"]) < $now) {
+ # request has timed out
+ if($request["currstateid"] == 12 ||
+ $request["currstateid"] == 11 ||
+ ($request["currstateid"] == 14 &&
+ $request["laststateid"] == 11)) {
+ return array('status' => 'timedout');
+ }
+ # computer is loading
+ else {
+ $imageid = $request['imageid'];
+ $images = getImages(0, $imageid);
+ $remaining = 1;
+ $computers = getComputers(0, 0, $request['computerid']);
+ if(isComputerLoading($request, $computers)) {
+ if(datetimeToUnix($request["daterequested"]) >=
+ datetimeToUnix($request["start"]))
+ $startload = datetimeToUnix($request["daterequested"]);
+ else
+ $startload = datetimeToUnix($request["start"]);
+ $imgLoadTime = getImageLoadEstimate($imageid);
+ if($imgLoadTime == 0)
+ $imgLoadTime = $images[$imageid]['reloadtime'] * 60;
+ $tmp = ($imgLoadTime - ($now - $startload)) / 60;
+ $remaining = sprintf("%d", $tmp) + 1;
+ if($remaining < 1) {
+ $remaining = 1;
+ }
+ }
+ return array('status' => 'loading', 'time' => $remaining);
+ }
+ }
+ # reservation is in the future
+ else
+ return array('status' => 'future');
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCgetRequestConnectData($requestid, $remoteIP)
+///
+/// \param $requestid - id of a request
+/// \param $remoteIP - ip address of connecting user's computer
+///
+/// \return an array with at least one index named '\b status' which will have
+/// one of these values\n
+/// \b error - error occurred; there will be 2 additional elements in the array:
+/// \li \b errorcode - error number\n
+/// \li \b errormsg - error string\n
+///
+/// \b ready - request is ready; there will be 3 additional elements in the
+/// array:
+/// \li \b serverIP - address of the reserved machine
+/// \li \b user - user to use when connecting to the machine
+/// \li \b password - password to use when connecting to the machine
+///
+/// \b notready - request is not ready for connection
+///
+/// \brief if request is ready, adds the connecting user's computer to the
+/// request and returns info about how to connect to the computer
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCgetRequestConnectData($requestid, $remoteIP) {
+ global $user;
+ $requestid = processInputData($requestid, ARG_NUMERIC);
+ $remoteIP = processInputData($remoteIP, ARG_STRING, 1);
+ if(! preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', $remoteIP, $matches) ||
+ $matches[1] < 1 || $matches[1] > 223 ||
+ $matches[2] > 255 ||
+ $matches[3] > 255 ||
+ $matches[4] > 255) {
+ return array('status' => 'error',
+ 'errorcode' => 2,
+ 'errormsg' => 'invalid IP address');
+ }
+ $userRequests = getUserRequests('all', $user['id']);
+ $found = 0;
+ foreach($userRequests as $req) {
+ if($req['id'] == $requestid) {
+ $request = $req;
+ $found = 1;
+ break;
+ }
+ }
+ if(! $found)
+ return array('status' => 'error',
+ 'errorcode' => 1,
+ 'errormsg' => 'unknown requestid');
+
+ // FIXME - add support for cluster requests
+ if(requestIsReady($request)) {
+ $requestData = getRequestInfo($requestid);
+ $query = "UPDATE reservation "
+ . "SET remoteIP = '$remoteIP' "
+ . "WHERE requestid = $requestid";
+ $qh = doQuery($query, 101);
+ addChangeLogEntry($requestData["logid"], $remoteIP);
+ $serverIP = $requestData["reservations"][0]["reservedIP"];
+ $passwd = $requestData["reservations"][0]["password"];
+ if($requestData["forimaging"])
+ $thisuser = 'Administrator';
+ else
+ if(preg_match('/(.*)@(.*)/', $user['unityid'], $matches))
+ $thisuser = $matches[1];
+ else
+ $thisuser = $user['unityid'];
+ return array('status' => 'ready',
+ 'serverIP' => $serverIP,
+ 'user' => $thisuser,
+ 'password' => $passwd);
+ }
+ return array('status' => 'notready');
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCendRequest($requestid)
+///
+/// \param $requestid - id of a request
+///
+/// \return an array with at least one index named 'status' which will have
+/// one of these values\n
+/// \b error - error occurred; there will be 2 additional elements in the array:
+/// \li \b errorcode - error number\n
+/// \li \b errormsg - error string\n
+///
+/// \b success - request was successfully ended\n
+///
+/// \brief ends/deletes a request
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCendRequest($requestid) {
+ global $user;
+ $requestid = processInputData($requestid, ARG_NUMERIC);
+ $userRequests = getUserRequests('all', $user['id']);
+ $found = 0;
+ foreach($userRequests as $req) {
+ if($req['id'] == $requestid) {
+ $request = getRequestInfo($requestid);
+ $found = 1;
+ break;
+ }
+ }
+ if(! $found)
+ return array('status' => 'error',
+ 'errorcode' => 1,
+ 'errormsg' => 'unknown requestid');
+
+ deleteRequest($request);
+ return array('status' => 'success');
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCgetRequestIds()
+///
+/// \return an array with at least one index named 'status' which will have
+/// one of these values\n
+/// \b error - error occurred; there will be 2 additional elements in the array:
+/// \li \b errorcode - error number\n
+/// \li \b errormsg - error string\n
+///
+/// \b success - request was successfully ended; there will be an additional
+/// element whose index is 'requests' which is an array of arrays, each having
+/// these elements (or empty if no existing requests):\n
+/// \li \b requestid - id of the request\n
+/// \li \b imageid - id of the image\n
+/// \li \b imagename - name of the image\n
+/// \li \b start - unix timestamp of start time\n
+/// \li \b end - unix timestamp of end time
+///
+/// \brief gets information about all of user's requests
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCgetRequestIds() {
+ global $user;
+ $requests = getUserRequests("all");
+ if(empty($requests))
+ return array('status' => 'success', 'requests' => array());
+ $ret = array();
+ foreach($requests as $req) {
+ $start = datetimeToUnix($req['start']);
+ $end = datetimeToUnix($req['end']);
+ $tmp = array('requestid' => $req['id'],
+ 'imageid' => $req['imageid'],
+ 'imagename' => $req['prettyimage'],
+ 'start' => $start,
+ 'end' => $end);
+ array_push($ret, $tmp);
+ }
+ return array('status' => 'success', 'requests' => $ret);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn XMLRPCtest($string)
+///
+/// \param $string - a string
+///
+/// \return an array with 3 indices:\n
+/// \b status - will be 'success'\n
+/// \b message - will be 'RPC call worked successfully'\n
+/// \b string - contents of $string (after being sanatized)
+///
+/// \brief this is a test function that call be called when getting XML RPC
+/// calls to this site to work
+///
+////////////////////////////////////////////////////////////////////////////////
+function XMLRPCtest($string) {
+ $string = processInputData($string, ARG_STRING);
+ return array('status' => 'success',
+ 'message' => 'RPC call worked successfully',
+ 'string' => $string);
+}
+?>
Added: incubator/vcl/tags/import/web/.ht-inc/xmlrpc_example.php
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/xmlrpc_example.php?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/xmlrpc_example.php (added)
+++ incubator/vcl/tags/import/web/.ht-inc/xmlrpc_example.php Fri Dec 12 10:20:10 2008
@@ -0,0 +1,112 @@
+<?php
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+session_start();
+
+$url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
+print "<a href=\"$url?state=test\">Test</a><br>\n";
+print "<a href=\"$url?state=listimages\">List Available Images</a><br>\n";
+print "<a href=\"$url?state=addrequest\">Add request for Maple 10</a><br>\n";
+print "<a href=\"$url?state=requeststatus\">Get status of request</a><br>\n";
+print "<a href=\"$url?state=connectdata\">Get connection data</a><br>\n";
+print "<a href=\"$url?state=endrequest\">End request</a><br>\n";
+
+print "<pre>\n";
+
+// test
+if($_GET['state'] == 'test') {
+ $rc = remoteVCLCall('XMLRPCtest', array('foo'));
+ print_r($rc);
+}
+// list images
+elseif($_GET['state'] == 'listimages') {
+ $rc = remoteVCLCall('XMLRPCgetImages', array());
+ print_r($rc);
+}
+// add request
+elseif($_GET['state'] == 'addrequest') {
+ $rc = remoteVCLCall('XMLRPCaddRequest', array(98, 'now', 60));
+ if($rc['status'] == 'success') {
+ print "request id is {$rc['requestid']}<br>\n";
+ $_SESSION['requestid'] = $rc['requestid'];
+ }
+ else {
+ print_r($rc);
+ }
+}
+// get request status
+elseif($_GET['state'] == 'requeststatus') {
+ if(! array_key_exists('requestid', $_SESSION)) {
+ print "no request created<br>\n";
+ exit;
+ }
+ $rc = remoteVCLCall('XMLRPCgetRequestStatus', array($_SESSION['requestid']));
+ print "current status of request {$_SESSION['requestid']} is {$rc['status']}";
+}
+// get connection data
+elseif($_GET['state'] == 'connectdata') {
+ if(! array_key_exists('requestid', $_SESSION)) {
+ print "no request created<br>\n";
+ exit;
+ }
+ $rc = remoteVCLCall('XMLRPCgetRequestConnectData', array($_SESSION['requestid'], $_SERVER["REMOTE_ADDR"]));
+ if($rc['status'] == 'ready')
+ print_r($rc);
+ else
+ print "status of request is {$rc['status']}";
+}
+// end request
+elseif($_GET['state'] == 'endrequest') {
+ if(! array_key_exists('requestid', $_SESSION)) {
+ print "no request created<br>\n";
+ exit;
+ }
+ $rc = remoteVCLCall('XMLRPCendRequest', array($_SESSION['requestid']));
+ if($rc['status'] == 'error')
+ print_r($rc);
+ else {
+ print "request ended<br>\n";
+ unset($_SESSION['requestid']);
+ }
+}
+print "</pre>\n";
+
+function remoteVCLCall($method, $args) {
+ $request = xmlrpc_encode_request($method, $args);
+ $header = "Content-Type: text/xml\r\n";
+ $header .= "X-User: userid\r\n"; // user your userid here
+ $header .= "X-Pass: password\r\n"; // user your password here
+ $header .= "X-APIVERSION: 1"; // this is to allow for future changes to the api
+ $context = stream_context_create(
+ array(
+ 'http' => array(
+ 'method' => "POST",
+ 'header' => $header,
+ 'content' => $request
+ )
+ )
+ );
+ $file = file_get_contents("https://vcl.ncsu.edu/scheduling/index.php?mode=xmlrpccall", false, $context);
+ $response = xmlrpc_decode($file);
+ if(xmlrpc_is_fault($response)) {
+ trigger_error("xmlrpc: {$response['faultString']} ({$response['faultCode']})");
+ exit;
+ }
+ return $response;
+}
+?>
Added: incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/doxygen.css
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/doxygen.css?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/doxygen.css (added)
+++ incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/doxygen.css Fri Dec 12 10:20:10 2008
@@ -0,0 +1,374 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
+ font-family: Geneva, Arial, Helvetica, sans-serif;
+}
+BODY,TD {
+ font-size: 90%;
+}
+H1 {
+ text-align: center;
+ font-size: 160%;
+}
+H2 {
+ font-size: 120%;
+}
+H3 {
+ font-size: 100%;
+}
+CAPTION { font-weight: bold }
+DIV.qindex {
+ width: 100%;
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ padding: 2px;
+ line-height: 140%;
+}
+DIV.nav {
+ width: 100%;
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ padding: 2px;
+ line-height: 140%;
+}
+DIV.navtab {
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ margin-right: 15px;
+ padding: 2px;
+}
+TD.navtab {
+ font-size: 70%;
+}
+A.qindex {
+ text-decoration: none;
+ font-weight: bold;
+ color: #1A419D;
+}
+A.qindex:visited {
+ text-decoration: none;
+ font-weight: bold;
+ color: #1A419D
+}
+A.qindex:hover {
+ text-decoration: none;
+ background-color: #ddddff;
+}
+A.qindexHL {
+ text-decoration: none;
+ font-weight: bold;
+ background-color: #6666cc;
+ color: #ffffff;
+ border: 1px double #9295C2;
+}
+A.qindexHL:hover {
+ text-decoration: none;
+ background-color: #6666cc;
+ color: #ffffff;
+}
+A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff }
+A.el { text-decoration: none; font-weight: bold }
+A.elRef { font-weight: bold }
+A.code:link { text-decoration: none; font-weight: normal; color: #0000FF}
+A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF}
+A.codeRef:link { font-weight: normal; color: #0000FF}
+A.codeRef:visited { font-weight: normal; color: #0000FF}
+A:hover { text-decoration: none; background-color: #f2f2ff }
+DL.el { margin-left: -1cm }
+.fragment {
+ font-family: monospace, fixed;
+ font-size: 95%;
+}
+PRE.fragment {
+ border: 1px solid #CCCCCC;
+ background-color: #f5f5f5;
+ margin-top: 4px;
+ margin-bottom: 4px;
+ margin-left: 2px;
+ margin-right: 8px;
+ padding-left: 6px;
+ padding-right: 6px;
+ padding-top: 4px;
+ padding-bottom: 4px;
+}
+DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
+
+DIV.groupHeader {
+ margin-left: 16px;
+ margin-top: 12px;
+ margin-bottom: 6px;
+ font-weight: bold;
+}
+DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% }
+BODY {
+ background: white;
+ color: black;
+ margin-right: 20px;
+ margin-left: 20px;
+}
+TD.indexkey {
+ background-color: #e8eef2;
+ font-weight: bold;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px;
+ border: 1px solid #CCCCCC;
+}
+TD.indexvalue {
+ background-color: #e8eef2;
+ font-style: italic;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px;
+ border: 1px solid #CCCCCC;
+}
+TR.memlist {
+ background-color: #f0f0f0;
+}
+P.formulaDsp { text-align: center; }
+IMG.formulaDsp { }
+IMG.formulaInl { vertical-align: middle; }
+SPAN.keyword { color: #008000 }
+SPAN.keywordtype { color: #604020 }
+SPAN.keywordflow { color: #e08000 }
+SPAN.comment { color: #800000 }
+SPAN.preprocessor { color: #806020 }
+SPAN.stringliteral { color: #002080 }
+SPAN.charliteral { color: #008080 }
+.mdescLeft {
+ padding: 0px 8px 4px 8px;
+ font-size: 80%;
+ font-style: italic;
+ background-color: #FAFAFA;
+ border-top: 1px none #E0E0E0;
+ border-right: 1px none #E0E0E0;
+ border-bottom: 1px none #E0E0E0;
+ border-left: 1px none #E0E0E0;
+ margin: 0px;
+}
+.mdescRight {
+ padding: 0px 8px 4px 8px;
+ font-size: 80%;
+ font-style: italic;
+ background-color: #FAFAFA;
+ border-top: 1px none #E0E0E0;
+ border-right: 1px none #E0E0E0;
+ border-bottom: 1px none #E0E0E0;
+ border-left: 1px none #E0E0E0;
+ margin: 0px;
+}
+.memItemLeft {
+ padding: 1px 0px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: solid;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memItemRight {
+ padding: 1px 8px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: solid;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memTemplItemLeft {
+ padding: 1px 0px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: none;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memTemplItemRight {
+ padding: 1px 8px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: none;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memTemplParams {
+ padding: 1px 0px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: solid;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ color: #606060;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.search { color: #003399;
+ font-weight: bold;
+}
+FORM.search {
+ margin-bottom: 0px;
+ margin-top: 0px;
+}
+INPUT.search { font-size: 75%;
+ color: #000080;
+ font-weight: normal;
+ background-color: #e8eef2;
+}
+TD.tiny { font-size: 75%;
+}
+a {
+ color: #1A41A8;
+}
+a:visited {
+ color: #2A3798;
+}
+.dirtab { padding: 4px;
+ border-collapse: collapse;
+ border: 1px solid #84b0c7;
+}
+TH.dirtab { background: #e8eef2;
+ font-weight: bold;
+}
+HR { height: 1px;
+ border: none;
+ border-top: 1px solid black;
+}
+
+/* Style for detailed member documentation */
+.memtemplate {
+ font-size: 80%;
+ color: #606060;
+ font-weight: normal;
+}
+.memnav {
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ margin-right: 15px;
+ padding: 2px;
+}
+.memitem {
+ padding: 4px;
+ background-color: #eef3f5;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #dedeee;
+ -moz-border-radius: 8px 8px 8px 8px;
+}
+.memname {
+ white-space: nowrap;
+ font-weight: bold;
+}
+.memdoc{
+ padding-left: 10px;
+}
+.memproto {
+ background-color: #d5e1e8;
+ width: 100%;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #84b0c7;
+ font-weight: bold;
+ -moz-border-radius: 8px 8px 8px 8px;
+}
+.paramkey {
+ text-align: right;
+}
+.paramtype {
+ white-space: nowrap;
+}
+.paramname {
+ color: #602020;
+ font-style: italic;
+ white-space: nowrap;
+}
+/* End Styling for detailed member documentation */
+
+/* for the tree view */
+.ftvtree {
+ font-family: sans-serif;
+ margin:0.5em;
+}
+.directory { font-size: 9pt; font-weight: bold; }
+.directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; }
+.directory > h3 { margin-top: 0; }
+.directory p { margin: 0px; white-space: nowrap; }
+.directory div { display: none; margin: 0px; }
+.directory img { vertical-align: -30%; }
Added: incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/doxygen.png
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/doxygen.png?rev=726079&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/doxygen.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/examples.html
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/examples.html?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/examples.html (added)
+++ incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/examples.html Fri Dec 12 10:20:10 2008
@@ -0,0 +1,31 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<title>VCL XML RPC: Examples</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.5.3 -->
+<h1>VCL XML RPC Examples</h1>Here is a list of all examples:<ul>
+<li><a class="el" href="xmlrpc__example_8php-example.html">xmlrpc_example.php</a>
+</ul>
+<hr size="1"><address style="text-align: right;"><small>Generated on Wed Dec 19 11:28:46 2007 for VCL XML RPC by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
+</body>
+</html>
Added: incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/files.html
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/files.html?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/files.html (added)
+++ incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/files.html Fri Dec 12 10:20:10 2008
@@ -0,0 +1,31 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<title>VCL XML RPC: File Index</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.5.3 -->
+<h1>VCL XML RPC File List</h1>Here is a list of all documented files with brief descriptions:<table>
+ <tr><td class="indexkey">/afs/eos.ncsu.edu/engrwww/vcl.ncsu/scheduling/.ht-inc/<a class="el" href="xmlrpcWrappers_8php.html">xmlrpcWrappers.php</a></td><td class="indexvalue"></td></tr>
+</table>
+<hr size="1"><address style="text-align: right;"><small>Generated on Wed Dec 19 11:28:46 2007 for VCL XML RPC by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
+</body>
+</html>
Added: incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/globals.html
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/globals.html?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/globals.html (added)
+++ incubator/vcl/tags/import/web/.ht-inc/xmlrpcdocs/globals.html Fri Dec 12 10:20:10 2008
@@ -0,0 +1,52 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<title>VCL XML RPC: Class Members</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.5.3 -->
+<div class="tabs">
+ <ul>
+ <li class="current"><a href="globals.html"><span>All</span></a></li>
+ <li><a href="globals_func.html"><span>Functions</span></a></li>
+ </ul>
+</div>
+Here is a list of all documented file members with links to the documentation:
+<p>
+<ul>
+<li>XMLRPCaddRequest()
+: <a class="el" href="xmlrpcWrappers_8php.html#e6f9d40f20e08994fa3d82c8dd12bdf5">xmlrpcWrappers.php</a>
+<li>XMLRPCendRequest()
+: <a class="el" href="xmlrpcWrappers_8php.html#dfdaad6201dbcaaf5c2249a2c38437cc">xmlrpcWrappers.php</a>
+<li>XMLRPCgetImages()
+: <a class="el" href="xmlrpcWrappers_8php.html#e2c01a27349e7a7788a42cfb5fe0d5ab">xmlrpcWrappers.php</a>
+<li>XMLRPCgetRequestConnectData()
+: <a class="el" href="xmlrpcWrappers_8php.html#f8b8c718ea7ea9cc973602a2fe9ae20e">xmlrpcWrappers.php</a>
+<li>XMLRPCgetRequestIds()
+: <a class="el" href="xmlrpcWrappers_8php.html#815cd48d7d8c85754b2091313c02ccec">xmlrpcWrappers.php</a>
+<li>XMLRPCgetRequestStatus()
+: <a class="el" href="xmlrpcWrappers_8php.html#131560f1aa7577bd1da62d5b7e228e4c">xmlrpcWrappers.php</a>
+<li>XMLRPCtest()
+: <a class="el" href="xmlrpcWrappers_8php.html#c3e09831835663a8bd79aab3f0ea3e69">xmlrpcWrappers.php</a>
+</ul>
+<hr size="1"><address style="text-align: right;"><small>Generated on Wed Dec 19 11:28:46 2007 for VCL XML RPC by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
+</body>
+</html>