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 2012/03/19 15:01:22 UTC
svn commit: r1302456 - in /incubator/vcl/trunk/web: .ht-inc/requests.php
.ht-inc/serverprofiles.php .ht-inc/utils.php js/requests.js
js/serverprofiles.js
Author: jfthomps
Date: Mon Mar 19 14:01:22 2012
New Revision: 1302456
URL: http://svn.apache.org/viewvc?rev=1302456&view=rev
Log:
VCL-385
Hide noimage from showing in the list of images in Edit Image Profiles
VCL-463
add ability to deploy images as servers
added names to server reservations; removed several items from current reservations for server reservations and added a details popup to show the additional info
requests.php:
-modified newReservation - missed this one on VCL-385 last time - if image name is "No Image" do not include it in the list of environments for check out
-modified viewRequests and added getViewRequestHTMLitem - broke out each element from the current reservations page to be generated by a call to getViewRequestHTMLitem to reduce duplicated code and make it easier to include different portions in different sections of the page
-modified AJeditRequest - added servername
-modified AJsubmitEditRequest - added processing of servername; added some extra code for determining when admin and login groups should be updated
serverprofiles.php:
-modified deployHTML - added Name section
-modified AJdeployServer - added profilename; changed usergroups to include all user groups instead of just the ones the user can manage
-modifed processProfileInput - added underscore as an allowed character in the profile name
utils.php:
-modified getRequestInfo - added servername to returned array
-modified getUserRequests - added servername to returned array
requests.js:
-modified hideEditResDlg - destroy servername widget if exists
-modified submitEditReservation - added servername to submitted data
serverprofiles.js:
-modified getServerProfileDataDeployCB - added deployname; get admin and login groups by either dijit select or normal select, depending on what exists
-modified submitDeploy - added deployname to submitted data
Modified:
incubator/vcl/trunk/web/.ht-inc/requests.php
incubator/vcl/trunk/web/.ht-inc/serverprofiles.php
incubator/vcl/trunk/web/.ht-inc/utils.php
incubator/vcl/trunk/web/js/requests.js
incubator/vcl/trunk/web/js/serverprofiles.js
Modified: incubator/vcl/trunk/web/.ht-inc/requests.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/requests.php?rev=1302456&r1=1302455&r2=1302456&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/requests.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/requests.php Mon Mar 19 14:01:22 2012
@@ -134,11 +134,14 @@ function newReservation() {
print "onChange=\"selectEnvironment();\" tabIndex=1 style=\"width: 400px\" ";
print "queryExpr=\"*\${0}*\" highlightMatch=\"all\" autoComplete=\"false\" ";
print "name=imageid>\n";
- foreach($resources['image'] as $id => $image)
+ foreach($resources['image'] as $id => $image) {
+ if($image == 'No Image')
+ continue;
if($id == $imageid)
print " <option value=\"$id\" selected>$image</option>\n";
else
print " <option value=\"$id\">$image</option>\n";
+ }
print " </select>\n";
}
else
@@ -856,55 +859,21 @@ function viewRequests() {
if(requestIsReady($requests[$i]) && $requests[$i]['useraccountready']) {
$connect = 1;
# request is ready, print Connect! and End buttons
- $text .= " <TD>\n";
- $text .= " <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
$cont = addContinuationsEntry('connectRequest', $cdata, SECINDAY);
- $text .= " <INPUT type=hidden name=continuation value=\"$cont\">\n";
- $text .= " <button type=submit dojoType=\"dijit.form.Button\">\n";
- $text .= " Connect!\n";
- $text .= " </button>\n";
- $text .= " </FORM>\n";
- $text .= " </TD>\n";
+ $text .= getViewRequestHTMLitem('connectbtn', $cont);
if($requests[$i]['serveradmin']) {
- $text .= " <TD>\n";
$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
- $text .= " <button dojoType=\"dijit.form.Button\">\n";
- $text .= " Delete\n";
- $text .= " <script type=\"dojo/method\" event=\"onClick\">\n";
- $text .= " endReservation('$cont');\n";
- $text .= " </script>\n";
- $text .= " </button>\n";
- $text .= " </TD>\n";
+ $text .= getViewRequestHTMLitem('deletebtn', $cont);
}
else
$text .= " <TD></TD>\n";
- $startstamp = datetimeToUnix($requests[$i]["start"]);
}
elseif($requests[$i]["currstateid"] == 5) {
# request has failed
- $text .= " <TD nowrap>\n";
- $text .= " <span class=scriptonly>\n";
- $text .= " <span class=compstatelink>";
- $text .= "<a onClick=\"showResStatusPane({$requests[$i]['id']}); ";
- $text .= "return false;\" href=\"#\">Reservation failed</a></span>\n";
- $text .= " </span>\n";
- $text .= " <noscript>\n";
- $text .= " <span class=scriptoff>\n";
- $text .= " <span class=compstatelink>";
- $text .= "Reservation failed</span>\n";
- $text .= " </span>\n";
- $text .= " </noscript>\n";
- $text .= " </TD>\n";
+ $text .= getViewRequestHTMLitem('failedblock', $requests[$i]['id']);
if($requests[$i]['serveradmin']) {
- $text .= " <TD>\n";
$cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
- $text .= " <button dojoType=\"dijit.form.Button\">\n";
- $text .= " Remove\n";
- $text .= " <script type=\"dojo/method\" event=\"onClick\">\n";
- $text .= " removeReservation('$cont');\n";
- $text .= " </script>\n";
- $text .= " </button>\n";
- $text .= " </TD>\n";
+ $text .= getViewRequestHTMLitem('removebtn', $cont);
}
else
$text .= " <TD></TD>\n";
@@ -918,24 +887,11 @@ function viewRequests() {
($requests[$i]["currstateid"] == 14 &&
$requests[$i]["laststateid"] == 11)) {
# request has timed out
- if($requests[$i]['forimaging'])
- $text .= " <TD colspan=2>\n";
- else
- $text .= " <TD>\n";
- $text .= " <span class=compstatelink>Reservation has ";
- $text .= "timed out</span>\n";
+ $text .= getViewRequestHTMLitem('timeoutblock');
$timedout = 1;
- $text .= " </TD>\n";
if($requests[$i]['serveradmin']) {
- $text .= " <TD>\n";
$cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
- $text .= " <button dojoType=\"dijit.form.Button\">\n";
- $text .= " Remove\n";
- $text .= " <script type=\"dojo/method\" event=\"onClick\">\n";
- $text .= " removeReservation('$cont');\n";
- $text .= " </script>\n";
- $text .= " </button>\n";
- $text .= " </TD>\n";
+ $text .= getViewRequestHTMLitem('removebtn', $cont);
}
else
$text .= " <TD></TD>\n";
@@ -962,18 +918,7 @@ function viewRequests() {
$remaining = 1;
}
}
- $text .= " <TD>\n";
- $text .= " <span class=scriptonly>\n";
- $text .= " <span class=compstatelink><i>";
- $text .= "<a onClick=\"showResStatusPane({$requests[$i]['id']}); ";
- $text .= "return false;\" href=\"#\">Pending...</a></i></span>\n";
- $text .= " </span>\n";
- $text .= " <noscript>\n";
- $text .= " <span class=scriptoff>\n";
- $text .= " <span class=compstatelink>";
- $text .= "<i>Pending...</i></span>\n";
- $text .= " </span>\n";
- $text .= " </noscript>\n";
+ $data = array('text' => '');
if($requests[$i]['currstateid'] != 26 &&
$requests[$i]['currstateid'] != 27 &&
$requests[$i]['currstateid'] != 28 &&
@@ -981,19 +926,12 @@ function viewRequests() {
($requests[$i]['laststateid'] != 26 &&
$requests[$i]['laststateid'] != 27 &&
$requests[$i]['laststateid'] != 28)))
- $text .= "<br>Est: $remaining min remaining\n";
+ $data['text'] = "<br>Est: $remaining min remaining\n";
+ $text .= getViewRequestHTMLitem('pendingblock', $requests[$i]['id'], $data);
$refresh = 1;
- $text .= " </TD>\n";
if($requests[$i]['serveradmin']) {
- $text .= " <TD>\n";
$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
- $text .= " <button dojoType=\"dijit.form.Button\">\n";
- $text .= " Delete\n";
- $text .= " <script type=\"dojo/method\" event=\"onClick\">\n";
- $text .= " endReservation('$cont');\n";
- $text .= " </script>\n";
- $text .= " </button>\n";
- $text .= " </TD>\n";
+ $text .= getViewRequestHTMLitem('deletebtn', $cont);
}
else
$text .= " <TD></TD>\n";
@@ -1003,15 +941,8 @@ function viewRequests() {
# reservation is in the future
$text .= " <TD></TD>\n";
if($requests[$i]['serveradmin']) {
- $text .= " <TD>\n";
$cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
- $text .= " <button dojoType=\"dijit.form.Button\">\n";
- $text .= " Delete\n";
- $text .= " <script type=\"dojo/method\" event=\"onClick\">\n";
- $text .= " endReservation('$cont');\n";
- $text .= " </script>\n";
- $text .= " </button>\n";
- $text .= " </TD>\n";
+ $text .= getViewRequestHTMLitem('deletebtn', $cont);
}
else
$text .= " <TD></TD>\n";
@@ -1022,53 +953,30 @@ function viewRequests() {
$imgcont = addContinuationsEntry('startImage', $cdata, SECINDAY);
$imgurl = BASEURL . SCRIPT . "?continuation=$imgcont";
if($requests[$i]['serveradmin']) {
- $text .= " <TD align=right>\n";
- $text .= " <div dojoType=\"dijit.form.DropDownButton\">\n";
- $text .= " <span>More Options...</span>\n";
- $text .= " <div dojoType=\"dijit.Menu\">\n";
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"Edit\"\n";
- $text .= " onClick=\"editReservation('$editcont');\">\n";
- $text .= " </div>\n";
+ $text .= getViewRequestHTMLitem('openmoreoptions');
+ $text .= getViewRequestHTMLitem('editoption', $editcont);
if(array_key_exists($imageid, $resources['image']) && ! $cluster && # imageAdmin access, not a cluster,
($requests[$i]['currstateid'] == 8 || $requests[$i]['laststateid'] == 8)) { # reservation has been in inuse state
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"End Reservation & Create Image\"\n";
- if($mode != 'AJviewRequests')
- $text .= " onClick=\"window.location.href='$imgurl';\">\n";
- else
- $text .= " onClick=\"window.location.href=\'$imgurl\';\">\n";
- $text .= " </div>\n";
+ $data = array('doescape' => 0);
+ if($mode == 'AJviewRequests')
+ $data['doescape'] = 1;
+ $text .= getViewRequestHTMLitem('endcreateoption', $imgurl, $data);
}
- /*else {
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"End Reservation & Create Image\" disabled>\n";
- $text .= " </div>\n";
- }*/
+ /*else
+ $text .= getViewRequestHTMLitem('endcreateoptiondisable');*/
// todo uncomment the following when live imaging works
// todo add a check to ensure it is a VM
/*if($requests[$i]['server'] && ($requests[$i]['currstateid'] == 8 ||
($requests[$i]['currstateid'] == 14 && $requests[$i]['laststateid'] == 8))) {
$cont = addContinuationsEntry('startCheckpoint', $cdata, SECINDAY);
$url = BASEURL . SCRIPT . "?continuation=$cont";
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"Create Image\"\n";
- if($mode != 'AJviewRequests')
- $text .= " onClick=\"window.location.href='$url';\">\n";
- else
- $text .= " onClick=\"window.location.href=\'$url\';\">\n";
- $text .= " </div>\n";
+ $data = array('doescape' => 0);
+ if($mode == 'AJviewRequests')
+ $data['doescape'] = 1;
+ $text .= getViewRequestHTMLitem('checkpointoption', $imgurl, $data);
}
- elseif($requests[$i]['server'] && $requests[$i]['currstateid'] == 24) {
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"Create Image\" disabled>\n";
- $text .= " </div>\n";
- }*/
+ elseif($requests[$i]['server'] && $requests[$i]['currstateid'] == 24)
+ $text .= getViewRequestHTMLitem('checkpointoptiondisable');*/
if(! $cluster &&
$requests[$i]['OSinstalltype'] != 'none' &&
$requests[$i]['currstateid'] != 13 &&
@@ -1084,31 +992,13 @@ function viewRequests() {
$requests[$i]['currstateid'] != 27 &&
$requests[$i]['laststateid'] != 27) {
$cont = addContinuationsEntry('AJrebootRequest', $cdata, SECINDAY);
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"Reboot\">\n";
- $text .= " <script type=\"dojo/method\" event=\"onClick\">\n";
- $text .= " rebootRequest('$cont');\n";
- $text .= " </script>\n";
- $text .= " </div>\n";
+ $text .= getViewRequestHTMLitem('rebootoption', $cont);
$cont = addContinuationsEntry('AJreinstallRequest', $cdata, SECINDAY);
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"Reinstall\">\n";
- $text .= " <script type=\"dojo/method\" event=\"onClick\">\n";
- $text .= " reinstallRequest('$cont');\n";
- $text .= " </script>\n";
- $text .= " </div>\n";
+ $text .= getViewRequestHTMLitem('reinstalloption', $cont);
}
else {
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"Reboot\" disabled>\n";
- $text .= " </div>\n";
- $text .= " <div dojoType=\"dijit.MenuItem\"\n";
- $text .= " iconClass=\"noicon\"\n";
- $text .= " label=\"Reinstall\" disabled>\n";
- $text .= " </div>\n";
+ $text .= getViewRequestHTMLitem('rebootoptiondisable');
+ $text .= getViewRequestHTMLitem('reinstalloptiondisable');
}
$text .= " </div>\n";
$text .= " </div>\n";
@@ -1120,29 +1010,47 @@ function viewRequests() {
else
$text .= " <TD></TD>\n";
+ # print name of server request
+ if($requests[$i]['server']) {
+ if($requests[$i]['servername'] == '')
+ $text .= getViewRequestHTMLitem('servername', $requests[$i]['prettyimage']);
+ else
+ $text .= getViewRequestHTMLitem('servername', $requests[$i]['servername']);
+ }
+
# print name of image, add (Testing) if it is the test version of an image
- $text .= " <TD>" . str_replace("'", "'", $requests[$i]["prettyimage"]);
- if($requests[$i]["test"])
- $text .= " (Testing)";
- $text .= "</TD>\n";
+ if(!$requests[$i]['server']) {
+ $data = array('addtest' => 0);
+ if($requests[$i]["test"])
+ $data['addtest'] = 1;
+ $text .= getViewRequestHTMLitem('imagename', $requests[$i]['prettyimage'], $data);
+ }
# print start time
- if(datetimeToUnix($requests[$i]["start"]) <
- datetimeToUnix($requests[$i]["daterequested"])) {
- $text .= " <TD>" . prettyDatetime($requests[$i]["daterequested"], 1) . "</TD>\n";
- }
- else {
- $text .= " <TD>" . prettyDatetime($requests[$i]["start"], 1) . "</TD>\n";
+ if(! $requests[$i]['server']) {
+ $data = array('start' => $requests[$i]['start'],
+ 'requested' => $requests[$i]['daterequested']);
+ $text .= getViewRequestHTMLitem('starttime', '', $data);
}
# print end time
- if($requests[$i]['server'] && $requests[$i]['end'] == '2038-01-01 00:00:00')
- $text .= " <TD>(none)</TD>\n";
- else
- $text .= " <TD>" . prettyDatetime($requests[$i]["end"], 1) . "</TD>\n";
+ $data = array('end' => $requests[$i]['end']);
+ $text .= getViewRequestHTMLitem('endtime', '', $data);
# print date requested
- $text .= " <TD>" . prettyDatetime($requests[$i]["daterequested"], 1) . "</TD>\n";
+ if(! $requests[$i]['server'])
+ $text .= getViewRequestHTMLitem('requesttime', $requests[$i]['daterequested']);
+
+ # print server request details
+ if($requests[$i]['server']) {
+ $data = array('owner' => getUserUnityID($requests[$i]['userid']),
+ 'requesttime' => $requests[$i]['daterequested'],
+ 'admingroup' => $requests[$i]['serveradmingroup'],
+ 'logingroup' => $requests[$i]['serverlogingroup'],
+ 'image' => $requests[$i]['prettyimage'],
+ 'starttime' => $requests[$i]['start']);
+ $text .= getViewRequestHTMLitem('serverdetails', $requests[$i]['id'], $data);
+ }
if(checkUserHasPerm('View Debug Information')) {
if(! is_null($requests[$i]['vmhostid'])) {
@@ -1155,19 +1063,19 @@ function viewRequests() {
$row = mysql_fetch_assoc($qh);
$vmhost = $row['hostname'];
}
- $text .= " <TD align=center><span id=\"req{$requests[$i]['id']}\">";
- $text .= "{$requests[$i]["id"]}</span>\n";
+ $text .= " <TD align=center><a id=\"req{$requests[$i]['id']}\" ";
+ $text .= "tabindex=0>{$requests[$i]["id"]}</a>\n";
$text .= "<div dojoType=\"vcldojo.HoverTooltip\" connectId=\"req{$requests[$i]['id']}\">";
- $text .= "Mgmt node: {$nodes[$requests[$i]["managementnodeid"]]['hostname']}<br>\n";
- $text .= "Computer ID: {$requests[$i]['computerid']}<br>\n";
- $text .= "Comp hostname: {$computers[$requests[$i]["computerid"]]["hostname"]}<br>\n";
- $text .= "Comp IP: {$requests[$i]["IPaddress"]}<br>\n";
- $text .= "Comp State ID: {$computers[$requests[$i]["computerid"]]["stateid"]}<br>\n";
- $text .= "Comp Type: {$requests[$i]['comptype']}<br>\n";
+ $text .= "<strong>Mgmt node</strong>: {$nodes[$requests[$i]["managementnodeid"]]['hostname']}<br>\n";
+ $text .= "<strong>Computer ID</strong>: {$requests[$i]['computerid']}<br>\n";
+ $text .= "<strong>Comp hostname</strong>: {$computers[$requests[$i]["computerid"]]["hostname"]}<br>\n";
+ $text .= "<strong>Comp IP</strong>: {$requests[$i]["IPaddress"]}<br>\n";
+ $text .= "<strong>Comp State ID</strong>: {$computers[$requests[$i]["computerid"]]["stateid"]}<br>\n";
+ $text .= "<strong>Comp Type</strong>: {$requests[$i]['comptype']}<br>\n";
if(! is_null($requests[$i]['vmhostid']))
- $text .= "VM Host: $vmhost<br>\n";
- $text .= "Current State ID: {$requests[$i]["currstateid"]}<br>\n";
- $text .= "Last State ID: {$requests[$i]["laststateid"]}<br>\n";
+ $text .= "<strong>VM Host</strong>: $vmhost<br>\n";
+ $text .= "<strong>Current State ID</strong>: {$requests[$i]["currstateid"]}<br>\n";
+ $text .= "<strong>Last State ID</strong>: {$requests[$i]["laststateid"]}<br>\n";
$text .= "</div></TD>\n";
}
$text .= " </TR>\n";
@@ -1250,11 +1158,10 @@ function viewRequests() {
$text .= "<table id=\"longreslisttable\" summary=\"lists server reservations you currently have\" cellpadding=5>\n";
$text .= " <TR>\n";
$text .= " <TD colspan=3></TD>\n";
- $text .= " <TH>Environment</TH>\n";
- $text .= " <TH>Starting</TH>\n";
+ $text .= " <TH>Name</TH>\n";
$text .= " <TH>Ending</TH>\n";
- $text .= " <TH>Initially requested</TH>\n";
$computers = getComputers();
+ $text .= " <TH>Details</TH>\n";
if(checkUserHasPerm('View Debug Information'))
$text .= " <TH>Req ID</TH>\n";
$text .= " </TR>\n";
@@ -1284,6 +1191,7 @@ function viewRequests() {
$text .= "this may have caused.\n";
}
+ # TODO problem with auto refresh not happening when server load not ready due to user account?
$cont = addContinuationsEntry('AJviewRequests', array(), SECINDAY);
$text .= "<INPUT type=hidden id=resRefreshCont value=\"$cont\">\n";
@@ -1481,6 +1389,233 @@ function viewRequests() {
////////////////////////////////////////////////////////////////////////////////
///
+/// \fn getViewRequestHTMLitem($item, $var1, $data)
+///
+/// \param $item - name of HTML section to be generated
+/// \param $var1 - generic variable to be used in HTML
+/// \param $data - an array of any extra data to be used in HTML
+///
+/// \return a string of HTML
+///
+/// \brief generates HTML for a specific portion of the current reservations
+/// page
+///
+////////////////////////////////////////////////////////////////////////////////
+function getViewRequestHTMLitem($item, $var1='', $data=array()) {
+ $r = '';
+ if($item == 'connectbtn') {
+ $r .= " <TD>\n";
+ $r .= " <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
+ $r .= " <INPUT type=hidden name=continuation value=\"$var1\">\n";
+ $r .= " <button type=submit dojoType=\"dijit.form.Button\">\n";
+ $r .= " Connect!\n";
+ $r .= " </button>\n";
+ $r .= " </FORM>\n";
+ $r .= " </TD>\n";
+ return $r;
+ }
+ if($item == 'deletebtn') {
+ $r .= " <TD>\n";
+ $r .= " <button dojoType=\"dijit.form.Button\">\n";
+ $r .= " Delete\n";
+ $r .= " <script type=\"dojo/method\" event=\"onClick\">\n";
+ $r .= " endReservation('$var1');\n";
+ $r .= " </script>\n";
+ $r .= " </button>\n";
+ $r .= " </TD>\n";
+ return $r;
+ }
+ if($item == 'failedblock') {
+ $r .= " <TD nowrap>\n";
+ $r .= " <span class=scriptonly>\n";
+ $r .= " <span class=compstatelink>";
+ $r .= "<a onClick=\"showResStatusPane($var1); return false;\" ";
+ $r .= "href=\"#\">Reservation failed</a></span>\n";
+ $r .= " </span>\n";
+ $r .= " <noscript>\n";
+ $r .= " <span class=scriptoff>\n";
+ $r .= " <span class=compstatelink>";
+ $r .= "Reservation failed</span>\n";
+ $r .= " </span>\n";
+ $r .= " </noscript>\n";
+ $r .= " </TD>\n";
+ return $r;
+ }
+ if($item == 'removebtn') {
+ $r .= " <TD>\n";
+ $r .= " <button dojoType=\"dijit.form.Button\">\n";
+ $r .= " Remove\n";
+ $r .= " <script type=\"dojo/method\" event=\"onClick\">\n";
+ $r .= " removeReservation('$var1');\n";
+ $r .= " </script>\n";
+ $r .= " </button>\n";
+ $r .= " </TD>\n";
+ return $r;
+ }
+ if($item == 'timeoutblock') {
+ $r .= " <TD>\n";
+ $r .= " <span class=compstatelink>Reservation has timed out</span>\n";
+ $r .= " </TD>\n";
+ return $r;
+ }
+ if($item == 'pendingblock') {
+ $r .= " <TD>\n";
+ $r .= " <span class=scriptonly>\n";
+ $r .= " <span class=compstatelink><i>";
+ $r .= "<a onClick=\"showResStatusPane($var1); ";
+ $r .= "return false;\" href=\"#\">Pending...</a></i></span>\n";
+ $r .= " </span>\n";
+ $r .= " <noscript>\n";
+ $r .= " <span class=scriptoff>\n";
+ $r .= " <span class=compstatelink>";
+ $r .= "<i>Pending...</i></span>\n";
+ $r .= " </span>\n";
+ $r .= " </noscript>\n";
+ if(! empty($data['text']))
+ $r .= " {$data['text']}";
+ $r .= " </TD>\n";
+ return $r;
+ }
+ if($item == 'openmoreoptions') {
+ $r .= " <TD align=right>\n";
+ $r .= " <div dojoType=\"dijit.form.DropDownButton\">\n";
+ $r .= " <span>More Options...</span>\n";
+ $r .= " <div dojoType=\"dijit.Menu\">\n";
+ return $r;
+ }
+ if($item == 'editoption') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"Edit\"\n";
+ $r .= " onClick=\"editReservation('$var1');\">\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'endcreateoption') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"End Reservation & Create Image\"\n";
+ if($data['doescape'])
+ $r .= " onClick=\"window.location.href=\'$var1\';\">\n";
+ else
+ $r .= " onClick=\"window.location.href='$var1';\">\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'endcreateoptiondisable') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"End Reservation & Create Image\" disabled\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'checkpointoption') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"Create Image\"\n";
+ if($data['doescape'])
+ $r .= " onClick=\"window.location.href=\'$var1\';\">\n";
+ else
+ $r .= " onClick=\"window.location.href='$var1';\">\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'checkpointoptiondisable') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"Create Image\" disabled\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'rebootoption') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"Reboot\">\n";
+ $r .= " <script type=\"dojo/method\" event=\"onClick\">\n";
+ $r .= " rebootRequest('$var1');\n";
+ $r .= " </script>\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'rebootoptiondisable') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"Reboot\" disabled>\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'reinstalloption') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"Reinstall\">\n";
+ $r .= " <script type=\"dojo/method\" event=\"onClick\">\n";
+ $r .= " reinstallRequest('$var1');\n";
+ $r .= " </script>\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'reinstalloptiondisable') {
+ $r .= " <div dojoType=\"dijit.MenuItem\"\n";
+ $r .= " iconClass=\"noicon\"\n";
+ $r .= " label=\"Reinstall\" disabled>\n";
+ $r .= " </div>\n";
+ return $r;
+ }
+ if($item == 'imagename') {
+ $r .= " <TD>" . str_replace("'", "'", $var1);
+ if($data['addtest'])
+ $r .= " (Testing)";
+ $r .= "</TD>\n";
+ return $r;
+ }
+ if($item == 'starttime') {
+ if(datetimeToUnix($data['start']) < datetimeToUnix($data['requested']))
+ $r .= " <TD>" . prettyDatetime($data['requested'], 1) . "</TD>\n";
+ else
+ $r .= " <TD>" . prettyDatetime($data['start'], 1) . "</TD>\n";
+ return $r;
+ }
+ if($item == 'endtime') {
+ if($data['end'] == '2038-01-01 00:00:00')
+ $r .= " <TD>(none)</TD>\n";
+ else
+ $r .= " <TD>" . prettyDatetime($data['end'], 1) . "</TD>\n";
+ return $r;
+ }
+ if($item == 'requesttime') {
+ $r .= " <TD>" . prettyDatetime($var1, 1) . "</TD>\n";
+ return $r;
+ }
+ if($item == 'servername') {
+ $r .= " <TD>$var1</TD>\n";
+ return $r;
+ }
+ if($item == 'serverdetails') {
+ $r .= "<TD>\n";
+ $r .= "<a id=\"serverdetails$var1\" tabindex=0>";
+ $r .= "<img alt=\"details\" src=\"images/list.gif\"></a>\n";
+ $r .= "<div dojoType=\"vcldojo.HoverTooltip\" connectId=\"";
+ $r .= "serverdetails$var1\">\n";
+ $r .= "<strong>Owner</strong>: {$data['owner']}<br>\n";
+ $r .= "<strong>Environment</strong>: {$data['image']}<br>\n";
+ $r .= "<strong>Start Time</strong>: " . prettyDatetime($data['starttime'], 1) . "<br>\n";
+ $r .= "<strong>Initially Requested</strong>: " . prettyDatetime($data['requesttime'], 1) . "<br>\n";
+ if(empty($data['admingroup']))
+ $r .= "<strong>Admin User Group</strong>: (none)<br>\n";
+ else
+ $r .= "<strong>Admin User Group</strong>: {$data['admingroup']}<br>\n";
+ if(empty($data['logingroup']))
+ $r .= "<strong>Access User Group</strong>: (none)\n";
+ else
+ $r .= "<strong>Access User Group</strong>: {$data['logingroup']}\n";
+ $r .= "</div>\n";
+ $r .= "</TD>\n";
+ return $r;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
/// \fn detailStatusHTML($reqid)
///
/// \param $reqid - a request id
@@ -1917,10 +2052,15 @@ function AJeditRequest() {
'modifystart' => 0,
'allowindefiniteend' => 0);
if($request['serverrequest']) {
+ if(empty($request['servername']))
+ $request['servername'] = $request['reservations'][0]['prettyimage'];
+ $h .= "Name: <input type=\"text\" name=\"servername\" id=\"servername\" ";
+ $h .= "dojoType=\"dijit.form.TextBox\" style=\"width: 400px\" ";
+ $h .= "value=\"{$request['servername']}\"><br>";
if($user['showallgroups'])
- $groups = getUserGroups(1);
+ $groups = getUserGroups();
else
- $groups = getUserGroups(1, $user['affiliationid']);
+ $groups = getUserGroups(0, $user['affiliationid']);
$h .= "Admin User Group: ";
if(USEFILTERINGSELECT && count($groups) < FILTERINGSELECTTHRESHOLD) {
$h .= "<select dojoType=\"dijit.form.FilteringSelect\" id=\"admingrpsel\" ";
@@ -2384,6 +2524,7 @@ function AJsubmitEditRequest() {
return;
}
$updategroups = 0;
+ $updateservername = 0;
if($request['serverrequest']) {
if($user['showallgroups'])
$groups = getUserGroups(1);
@@ -2400,9 +2541,30 @@ function AJsubmitEditRequest() {
'cont' => $cont));
return;
}
- if($admingroupid != $request['admingroupid'] ||
- $logingroupid != $request['logingroupid'])
+ $testadmingroupid = $admingroupid;
+ if($admingroupid == 0)
+ $testadmingroupid = '';
+ $testlogingroupid = $logingroupid;
+ if($logingroupid == 0)
+ $testlogingroupid = '';
+ if($testadmingroupid != $request['admingroupid'] ||
+ $testlogingroupid != $request['logingroupid'])
$updategroups = 1;
+ $servername = processInputVar('servername', ARG_STRING);
+ if(! preg_match('/^([-a-zA-Z0-9\. ]){3,255}$/', $servername)) {
+ $cdata = getContinuationVar();
+ $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0);
+ sendJSON(array('status' => 'error',
+ 'errmsg' => "The name can only contain letters, numbers, "
+ . "spaces, dashes(-), and periods(.) and can "
+ . "be from 3 to 255 characters long",
+ 'cont' => $cont));
+ return;
+ }
+ if($servername != $request['servername']) {
+ $servername = mysql_real_escape_string($servername);
+ $updateservername = 1;
+ }
}
// get semaphore lock
@@ -2512,6 +2674,10 @@ function AJsubmitEditRequest() {
elseif($rc > 0) {
updateRequest($requestid);
if($updategroups) {
+ if($admingroupid == 0)
+ $admingroupid = 'NULL';
+ if($logingroupid == 0)
+ $logingroupid = 'NULL';
$query = "UPDATE serverrequest "
. "SET admingroupid = $admingroupid, "
. "logingroupid = $logingroupid "
@@ -2522,6 +2688,12 @@ function AJsubmitEditRequest() {
. "WHERE id = $requestid";
doQuery($query, 101);
}
+ if($updateservername) {
+ $query = "UPDATE serverrequest "
+ . "SET name = '$servername' "
+ . "WHERE requestid = $requestid";
+ doQuery($query, 101);
+ }
sendJSON(array('status' => 'success'));
semUnlock();
return;
Modified: incubator/vcl/trunk/web/.ht-inc/serverprofiles.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/serverprofiles.php?rev=1302456&r1=1302455&r2=1302456&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/serverprofiles.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/serverprofiles.php Mon Mar 19 14:01:22 2012
@@ -91,6 +91,11 @@ function deployHTML() {
$h .= "<div id=\"deployprofilediv\">\n";
$h .= "<table summary=\"\">\n";
$h .= " <tr>\n";
+ $h .= " <th align=right>Name:</th>\n";
+ $h .= " <td><input type=\"text\" name=\"deployname\" id=\"deployname\" ";
+ $h .= "dojoType=\"dijit.form.TextBox\" style=\"width: 400px\"></td>\n";
+ $h .= " </tr>\n";
+ $h .= " <tr>\n";
$h .= " <th align=right>Environment:</th>\n";
$h .= " <td>\n";
$resources = getUserResources(array("imageAdmin", "imageCheckOut"));
@@ -678,6 +683,7 @@ function AJserverProfileStoreData() {
////////////////////////////////////////////////////////////////////////////////
function AJdeployServer() {
global $user, $remoteIP;
+ $profilename = processInputVar('name', ARG_STRING);
$profileid = processInputVar('profileid', ARG_NUMERIC);
$imageid = processInputVar('imageid', ARG_NUMERIC);
$resources = getUserResources(array("imageAdmin", "imageCheckOut"));
@@ -692,6 +698,15 @@ function AJdeployServer() {
sendJSON($data);
return;
}
+ if(! preg_match('/^([-a-zA-Z0-9_\. ]){0,255}$/', $profilename)) {
+ $cont = addContinuationsEntry('AJdeployServer', array(), SECINDAY, 1, 0);
+ $data = array('error' => 1,
+ 'cont' => $cont,
+ 'msg' => "The name can only contain letters, numbers, spaces, dashes(-), "
+ . "underscores(_), and periods(.) and can be up to 255 characters long");
+ sendJSON($data);
+ return;
+ }
$ipaddr = processInputVar('ipaddr', ARG_STRING);
$ipaddrArr = explode('.', $ipaddr);
if($ipaddr != '' && (! preg_match('/^(([0-9]){1,3}\.){3}([0-9]){1,3}$/', $ipaddr) ||
@@ -718,10 +733,11 @@ function AJdeployServer() {
return;
}
$admingroupid = processInputVar('admingroupid', ARG_NUMERIC);
- $usergroups = getUserEditGroups($user['id']);
- $extraadmingroups = getServerProfileGroups($user['id'], 'admin');
- if($admingroupid != 0 && ! array_key_exists($admingroupid, $usergroups) &&
- ! array_key_exists($admingroupid, $extraadmingroups)) {
+ $usergroups = getUserGroups();
+ /*$usergroups = getUserEditGroups($user['id']);
+ $extraadmingroups = getServerProfileGroups($user['id'], 'admin');*/
+ if($admingroupid != 0 && ! array_key_exists($admingroupid, $usergroups) /*&&
+ ! array_key_exists($admingroupid, $extraadmingroups)*/) {
$cont = addContinuationsEntry('AJdeployServer', array(), SECINDAY, 1, 0);
$data = array('error' => 1,
'cont' => $cont,
@@ -730,9 +746,9 @@ function AJdeployServer() {
return;
}
$logingroupid = processInputVar('logingroupid', ARG_NUMERIC);
- $extralogingroups = getServerProfileGroups($user['id'], 'login');
- if($logingroupid != 0 && ! array_key_exists($logingroupid, $usergroups) &&
- ! array_key_exists($logingroupid, $extralogingroups)) {
+ #$extralogingroups = getServerProfileGroups($user['id'], 'login');
+ if($logingroupid != 0 && ! array_key_exists($logingroupid, $usergroups) /*&&
+ ! array_key_exists($logingroupid, $extralogingroups)*/) {
$cont = addContinuationsEntry('AJdeployServer', array(), SECINDAY, 1, 0);
$data = array('error' => 1,
'cont' => $cont,
@@ -907,8 +923,17 @@ function AJdeployServer() {
. "WHERE requestid = $requestid";
doQuery($query);
$fields = array('requestid', 'serverprofileid');
- # TODO test deploying server with various combinations of profile items changed
$values = array($requestid, $profileid);
+ if($profilename == '') {
+ $fields[] = 'name';
+ $profilename = $images[$imageid]['prettyname'];
+ $values[] = "'$profilename'";
+ }
+ else {
+ $fields[] = 'name';
+ $profilename = mysql_real_escape_string($profilename);
+ $values[] = "'$profilename'";
+ }
if($ipaddr != '') {
$fields[] = 'fixedIP';
$values[] = "'$ipaddr'";
@@ -1090,9 +1115,9 @@ function processProfileInput() {
return $err;
}
- if(! preg_match('/^([-a-zA-Z0-9\. ]){3,255}$/', $ret['name'])) {
+ if(! preg_match('/^([-a-zA-Z0-9_\. ]){3,255}$/', $ret['name'])) {
$err['msg'] = "The name can only contain letters, numbers, spaces, dashes(-), "
- . "and periods(.) and can be from 3 to 255 characters long";
+ . "underscores(_), and periods(.) and can be from 3 to 255 characters long";
$err['field'] = 'name';
$err['error'] = 1;
return $err;
Modified: incubator/vcl/trunk/web/.ht-inc/utils.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=1302456&r1=1302455&r2=1302456&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/utils.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/utils.php Mon Mar 19 14:01:22 2012
@@ -4702,6 +4702,7 @@ function findManagementNode($compid, $st
/// \b test - test flag\n
/// \b forimaging - 0 if request is normal, 1 if it is for imaging\n
/// \b serverrequest - 0 if request is normal, 1 if it is a server request\n
+/// \b servername - name of server if server request\n
/// \b admingroupid - id of admin user group if server request\n
/// \b logingroupid - id of login user group if server request\n
/// \b fixedIP - possible fixed IP address if server request\n
@@ -4803,6 +4804,7 @@ function getRequestInfo($id, $returnNULL
$data['passwds'][$row['reservationid']][$data['userid']] = $row['password'];
}
$query = "SELECT id, "
+ . "name, "
. "admingroupid, "
. "logingroupid, "
. "fixedIP, "
@@ -4812,6 +4814,7 @@ function getRequestInfo($id, $returnNULL
$qh = doQuery($query, 101);
if($row = mysql_fetch_assoc($qh)) {
$data['serverrequest'] = 1;
+ $data['servername'] = $row['name'];
$data['admingroupid'] = $row['admingroupid'];
$data['logingroupid'] = $row['logingroupid'];
$data['fixedIP'] = $row['fixedIP'];
@@ -5168,6 +5171,7 @@ function getCompFinalReservationTime($co
/// \b vmhostid - if VM, id of host's entry in vmhost table, NULL otherwise\n
/// the following additional items if a server request (values will be NULL
/// if not a server request), some values can be NULL:\n
+/// \b servername - name of server request\n
/// \b serverrequestid - from server request table\n
/// \b fixedIP - if specified for request\n
/// \b fixedMAC - if specified for request\n
@@ -5231,6 +5235,7 @@ function getUserRequests($type, $id=0) {
. "rs.managementnodeid, "
. "rs.imagerevisionid, "
. "rq.test,"
+ . "sp.name AS servername, "
. "sp.requestid AS serverrequestid, "
. "sp.fixedIP, "
. "sp.fixedMAC, "
Modified: incubator/vcl/trunk/web/js/requests.js
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/js/requests.js?rev=1302456&r1=1302455&r2=1302456&view=diff
==============================================================================
--- incubator/vcl/trunk/web/js/requests.js (original)
+++ incubator/vcl/trunk/web/js/requests.js Mon Mar 19 14:01:22 2012
@@ -421,6 +421,8 @@ function hideEditResDlg() {
dijit.byId('openenddate').destroy();
if(dijit.byId('openendtime'))
dijit.byId('openendtime').destroy();
+ if(dijit.byId('servername'))
+ dijit.byId('servername').destroy();
if(dijit.byId('admingrpsel'))
dijit.byId('admingrpsel').destroy();
if(dijit.byId('logingrpsel'))
@@ -514,6 +516,8 @@ function submitEditReservation() {
var tmp = dijit.byId('day').value.match(/([0-9]{4})([0-9]{2})([0-9]{2})/);
var teststart = new Date(tmp[1], tmp[2] - 1, tmp[3], t.getHours(), t.getMinutes(), 0, 0);
}
+ if(dijit.byId('servername'))
+ data.servername = dijit.byId('servername').get('value');
if(dijit.byId('admingrpsel')) {
data.admingroupid = dijit.byId('admingrpsel').get('value');
data.logingroupid = dijit.byId('logingrpsel').get('value');
Modified: incubator/vcl/trunk/web/js/serverprofiles.js
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/js/serverprofiles.js?rev=1302456&r1=1302455&r2=1302456&view=diff
==============================================================================
--- incubator/vcl/trunk/web/js/serverprofiles.js (original)
+++ incubator/vcl/trunk/web/js/serverprofiles.js Mon Mar 19 14:01:22 2012
@@ -210,14 +210,19 @@ function getServerProfileDataDeployCB(da
alert('You do not have access to apply this server profile.');
return;
}
+ dijit.byId('deployname').set('value', data.items.name);
dojo.byId('appliedprofileid').value = data.items.id;
dijit.byId('deployimage').set('value', data.items.imageid);
//dijit.byId('deployfixedIP').set('value', data.items.fixedIP);
//dijit.byId('deployfixedMAC').set('value', data.items.fixedMAC);
- //dijit.byId('deployadmingroup').set('value', data.items.admingroupid);
- //dijit.byId('deploylogingroup').set('value', data.items.logingroupid);
- dojo.byId('deployadmingroup').value = data.items.admingroupid;
- dojo.byId('deploylogingroup').value = data.items.logingroupid;
+ if(dijit.byId('deployadmingroup'))
+ dijit.byId('deployadmingroup').set('value', data.items.admingroupid);
+ else
+ dojo.byId('deployadmingroup').value = data.items.admingroupid;
+ if(dijit.byId('deploylogingroup'))
+ dijit.byId('deploylogingroup').set('value', data.items.logingroupid);
+ else
+ dojo.byId('deploylogingroup').value = data.items.logingroupid;
dijit.byId('deploymonitored').set('value', parseInt(data.items.monitored));
}
@@ -643,6 +648,7 @@ function submitDeploy() {
}
var data = {continuation: cont,
profileid: dojo.byId('appliedprofileid').value};
+ data.name = dijit.byId('deployname').get('value');
if(dijit.byId('deployimage'))
data.imageid = dijit.byId('deployimage').get('value');
else