Author: jfthomps
Date: Fri Apr 29 15:34:22 2011
New Revision: 1097842

URL: http://svn.apache.org/viewvc?rev=1097842&view=rev
Log:
VCL-463
VCL-30
VCL-432
VCL-458

xmlrpcWrappers.php:
-modified XMLRPCprocessBlockTime - added check for existance of 'subimages' in 
array before using it; default to 1 for $compsPerAlloc if it does not exist
-added XMLRPCautoCapture

privileges.php:
-modified getResourcePrivRowHTML - added code to not print manageMapping 
checkbox for serverprofile type
-modified AJsubmitAddResourcePriv - added checks for server profiles

vcl.css: added .rederrormsg and .noicon

states.php:
-added serverProfiles
-added connectmethodDialogContent
-added jsonImageConnectMethods
-added AJaddImageConnectMethod
-added AJremImageConnectMethod
-added AJsaveServerProfile
-added AJserverProfileData
-added AJdelServerProfile
-added jsonProfileGroupingGroups
-added jsonProfileGroupingProfiles
-added AJaddGroupToProfile
-added AJremGroupFromProfile
-added AJaddProfileToGroup
-added AJremProfileFromGroup
-added AJserverProfileStoreData
-added AJdeployServer
-added AJconfirmDeleteRequest
-added AJsubmitDeleteRequest
-added AJsetImageProduction
-added AJsubmitSetImageProduction
-added AJeditRequest
-added AJsubmitEditRequest
-added AJrebootRequest
-added AJreinstallRequest
-removed editRequest
-removed confirmEditRequest
-removed submitEditRequest
-removed confirmDeleteRequest
-removed submitDeleteRequest
-added startCheckpoint
-added submitCheckpoint

requests.php:
-added STARTMINUTEERR
-modified newReservation - added labels to now and later radiobuttons so that 
text can be clicked to select
-modified submitRequest - allow any users with "View Debug Information" 
permission to select any revision of an image
-modified viewRequests - major overhaul to allow most functions to stay on this 
page and popup dialogs to handle events
        -changed all buttons to dijit buttons
        -reservations get 3 buttons: Connect, Delete, 'More Options' - 'More 
Options' is a drop down menu with some subset of 'Edit', 'End Reservation & 
Create Image', 'Create Image', 'Reboot', and 'Reinstall'
        -added handling of server requests
        -collapsed debug information into a single column that displays the 
request id - hovering over the id pops up a box with additional info
        -provide a refresh continuation for all cases except having no 
reservations at all
        -print an end reservation dijit dialog
        -print an edit reservation dijit dialog
        -print a reboot/reinstall dijit dialog
-modified viewRequestInfo - use dijit dialog to confirm deleting of 
reservation; then send back to time table if came from there
-converted editRequest to AJeditRequest
-removed confirmEditRequest - confirmation done via javascript now
-converted submitEditRequest to AJsubmitEditRequest
-removed printEditNewUpdate - separated out into its own selectable option 
under 'More Options'
-converted confirmDeleteRequest to AJconfirmDeleteRequest 
-converted confirmDeleteRequestProduction to AJconfirmDeleteRequestProduction 
-converted submitDeleteRequest to AJsubmitDeleteRequest 
-added AJrebootRequest
-added AJreinstallRequest
-modified printReserveItems:
        -print startday/hour/minute errors
        -added labels to duration and until radio buttons so text can be clicked
        -added onChange events to automatically select radio buttons if items 
under that radio button are modified
        -changed specify end time entry to selectable date and time widgets
-modified processRequestInput:
        -added checks to minute, meridian
        -added check that end time must be after start time

images.php:
-removed bits of long time commented out code
-added startCheckpoint - handles online image capture
-modified editOrAddImage - added editing of connect methods to advanced 
options; also added dijit dialog to confirm connect methods that much be 
manually added
-added connectmethodDialogContent
-added jsonImageConnectMethods
-added AJaddImageConnectMethod
-added AJremImageConnectMethod
-modified imageClickThroughAgreement - added processing of comments
-modified submitAddImage - updated so it can be called from another function 
without printing anything so that it can be used from the autocapture API 
function
-modified updateExistingImage - updated so it can be called from another 
function without printing anything so that it can be used from the autocapture 
API function
-added submitCheckpoint
-added AJsetImageProduction
-added AJsubmitSetImageProduction
-modified addImage - added autocapture field to imagerevision insert query

utils.php:
-modified initGlobals - added serverProfiles to include switch statement
-modified getImages - added installtype and connectmethods to returned data
-added getImageConnectMethods
-modified addOwnedResources - added serverprofiles
-modified getResourcesFromGroups - added serverprofiles
-modified getUsersGroupPerms - check to see if $inlist is empty, and if so 
return an empty array
-modified isAvailable:
        -added $vmhostcheckdone flag so that the temporary table doesn't get 
dropped/created for each iteration of the loop for cluster reservations
        -set $virtual = 0 when editing a reservation so that it will be defined 
later (VCL-458)
        -added check to return earlier if modifying a reservation and no 
computers are available
        -added a DROP TEMPORARY TABLE IF EXISTS before creating it to ensure we 
don't try to create it a 2nd time
-modified schCheckMaintenance - don't check maintenance entries that are in the 
past
-modified getRequestInfo:
        -added $returnNULL parameter - set to 1 if just want function to return 
NULL if the request no longer exists
        -added serverrequest to returned data - 1 if server request, 0 if not
-modified deleteRequest - also delete from serverrequest if reservation is a 
server request
-modified getUserRequests - added these fields to returned data: userid, 
server, serverowner, vmhostid, serverrequestid, fixedIP, fixedMAC, 
serveradmingroupid, serveradmingroup, serverlogingroupid, serverlogingroup, and 
monitored
-modified showTimeTable - pass additional info in viewRequestInfo continuation 
so that it can send user back to viewing time table
-modified requestIsReady - include current state = checkpoint, last state = 
inuse
-modified prettyDatetime - added flag to include year
-added getConnectMethods
-modified xmlrpccall - added XMLRPCautoCapture
-modified sendHeaders - changed shib logout iframe to be https
-modified getNavMenu - added section for server profiles
-modified getDojoHTML:
        -added/updated dojo includes for newRequest, viewRequests, 
confirmEditOrAddImage, viewRequestInfo, startCheckpoint, and serverProfiles
        -added/updated header javascript for viewRequests, viewRequestInfo, and 
serverProfiles

requests.js:
-modified RPCwrapper - changed handleAs from json-comment-filtered to json
-added selectLater
-added selectDuration
-added selectLength
-added selectEnding
-added setOpenEnd
-modified resRefresh - no longer reload page if detailreqid does not exist; 
only submit reqid with data if it exists
-added endReservation
-added endReservationCB
-added submitDeleteReservation
-added editReservation
-added editReservationCB
-added hideEditResDlg
-added editResOpenEnd
-added submitEditReservation
-added submitEditReservationCB
-added checkResGone
-added resGone
-added hideRebReinstResDlg
-added rebootRequest
-added reinstallRequest
-added submitRebReinstReservation

images.js:
-added RPCwrapper
-updated all functions using dojo.xhrPost to call RPCwrapper instead
-added addConnectMethod
-added addConnectMethod2
-added addConnectMethod3
-added addConnectMethodCB
-added remConnectMethod
-added remConnectMethodCB
-added updateConnectMethod

initial add of serverprofiles.php
initial add of serverprofiles.js

Added:
    incubator/vcl/trunk/web/.ht-inc/serverprofiles.php
    incubator/vcl/trunk/web/js/serverprofiles.js
Modified:
    incubator/vcl/trunk/web/.ht-inc/images.php
    incubator/vcl/trunk/web/.ht-inc/privileges.php
    incubator/vcl/trunk/web/.ht-inc/requests.php
    incubator/vcl/trunk/web/.ht-inc/states.php
    incubator/vcl/trunk/web/.ht-inc/utils.php
    incubator/vcl/trunk/web/.ht-inc/xmlrpcWrappers.php
    incubator/vcl/trunk/web/css/vcl.css
    incubator/vcl/trunk/web/js/images.js
    incubator/vcl/trunk/web/js/requests.js

Modified: incubator/vcl/trunk/web/.ht-inc/images.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/images.php?rev=1097842&r1=1097841&r2=1097842&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/images.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/images.php Fri Apr 29 15:34:22 2011
@@ -730,6 +730,67 @@ function startImage() {
 
 
////////////////////////////////////////////////////////////////////////////////
 ///
+/// \fn startCheckpoint()
+///
+/// \brief prints page prompting user for image revision comments
+///
+////////////////////////////////////////////////////////////////////////////////
+function startCheckpoint() {
+       global $user;
+       $requestid = getContinuationVar("requestid");
+
+       $data = getRequestInfo($requestid);
+       $disableUpdate = 1;
+       $imageid = '';
+       foreach($data["reservations"] as $res) {
+               if($res["forcheckout"]) {
+                       $imageid = $res["imageid"];
+                       $revisionid = $res['imagerevisionid'];
+                       break;
+               }
+       }
+       print "<H2>Create New Revision of an Online Image</H2>\n";
+       print "This process will create a new revision of the image while ";
+       print "still keeping the reservation online and active.<br><br>\n";
+
+       # input for imagerevision comments
+       $revisions = getImageRevisions($imageid);
+       print "<h3>New Revision Comments</h3>\n";
+       print "Enter any notes for yourself and other admins about the current 
";
+       print "state of the image.<br>\nThese are optional and are not visible 
";
+       print "to end users:<br>\n";
+       print "<form action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
+       print "<textarea dojoType=\"dijit.form.Textarea\" name=comments ";
+       print "style=\"width: 400px; text-align: left;\"\">\n\n</textarea>\n";
+       print "<h3>Previous Revision Comments</h3>\n";
+       if(array_key_exists($revisionid, $revisions))
+               $comments = $revisions[$revisionid]['comments'];
+       else {
+               $keys = array_keys($revisions);
+               if(count($keys)) {
+                       $key = array_pop($keys);
+                       $comments = $revisions[$key]['comments'];
+               }
+               else
+                       $comments = '';
+       }
+       if(preg_match('/\w/', $comments)) {
+               print "These are the comments from the previous revision ";
+               print "({$revisions[$revisionid]['revision']}):<br>\n";
+               print "{$revisions[$revisionid]['comments']}<br><br>\n";
+       }
+       else
+               print "The previous revision did not have any comments.<br>\n";
+       $cdata = array('requestid' => $requestid,
+                      'nextmode' => 'submitCheckpoint');
+       $cont = addContinuationsEntry('imageClickThroughAgreement', $cdata, 
SECINDAY, 0);
+       print "<br><br><INPUT type=\"submit\" value=\"Submit\">\n";
+       print "<INPUT type=\"hidden\" name=\"continuation\" value=\"$cont\">\n";
+       print "</FORM>\n";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
 /// \fn submitImageButton
 ///
 /// \brief wrapper for confirmDeleteImage, editOrAddImage(0), and
@@ -813,18 +874,6 @@ function editOrAddImage($state) {
        printSubmitErr(IMGOWNERERR);
        print "</TD>\n";
        print "  </TR>\n";
-       /*print "  <TR>\n";
-       print "    <TH align=right>Platform:</TH>\n";
-       print "    <TD>\n";
-       printSelectInput("platformid", $platforms, $data["platformid"]);
-       print "    </TD>\n";
-       print "  </TR>\n";
-       print "  <TR>\n";
-       print "    <TH align=right>OS:</TH>\n";
-       print "    <TD>\n";
-       printSelectInput("osid", $oslist, $data["osid"]);
-       print "    </TD>\n";
-       print "  </TR>\n";*/
        print "  <TR>\n";
        print "    <TD colspan=3>\n";
        print "<fieldset>\n";
@@ -848,8 +897,8 @@ function editOrAddImage($state) {
                print "<fieldset>\n";
                print "<legend>Revision Comments</legend>\n";
                print "Notes for yourself and other admins about how the image 
";
-               print "was setup/installed.<br>\nThese are optional and not 
visible to end ";
-               print "users.<br>\n";
+               print "was setup/installed.<br>\nThese are optional and are not 
visible ";
+               print "to end users.<br>\n";
                print "<textarea dojoType=\"dijit.form.Textarea\" name=comments 
";
                print "style=\"width: 400px; text-align: 
left;\"\">{$data['comments']}\n\n";
                print "</textarea>\n";
@@ -913,7 +962,7 @@ function editOrAddImage($state) {
                print "  <TR>\n";
                print "    <TH align=right>Estimated Reload Time (min):</TH>\n";
                print "    <TD><INPUT type=text name=reloadtime value=\"";
-               print $data["reloadtime"] . "\" maxlength=3></TD>\n";
+               print $data["reloadtime"] . "\" maxlength=3 size=4></TD>\n";
                print "    <TD>";
                printSubmitErr(RELOADTIMEERR);
                print "</TD>\n";
@@ -958,14 +1007,29 @@ function editOrAddImage($state) {
                print "  </TR>\n";
        }
        print "  <TR>\n";
+       print "    <TH style=\"vertical-align:top; 
text-align:right;\">Connection methods:</TH>\n";
+       print "    <TD>\n";
+       print "    <div id=\"connectmethodlist\">\n";
+       foreach($data['connectmethods'] AS $method)
+               print "$method<br>\n";
+       print "    </div>\n";
+       $cont = addContinuationsEntry('connectmethodDialogContent', 
array('imageid' => $data['imageid']));
+       $url = BASEURL . SCRIPT . "?continuation=$cont";
+       print "    <div dojoType=\"dijit.form.DropDownButton\" 
id=\"connectmethoddlg\">\n";
+       print "      <span>Modify Connection Methods</span>";
+       print "      <div dojoType=\"dijit.TooltipDialog\" 
href=\"$url\"></div>\n";
+       print "    <div>\n";
+       print "    </TD>\n";
+       print "  </TR>\n";
+       print "  <TR>\n";
        print "    <TD colspan=3 id=hide3><hr></TD>\n";
        print "  </TR>\n";
        print "</TABLE>\n";
        if(! $state) {
                $cont = addContinuationsEntry('subimageDialogContent', 
array('imageid' => $data['imageid']));
+               $url = BASEURL . SCRIPT . "?continuation=$cont";
                print "<div dojoType=\"dijit.form.DropDownButton\" 
id=\"subimagebtn\">";
                print "  <span>Manage Subimages</span>\n";
-               $url = BASEURL . SCRIPT . "?continuation=$cont";
                print "  <div dojoType=\"dijit.TooltipDialog\" 
id=\"subimagedlg\" href=\"$url\"></div>\n";
                print "</div>\n";
 
@@ -1007,6 +1071,35 @@ function editOrAddImage($state) {
        print "<div id=revisiondiv>\n";
        print getRevisionHTML($data['imageid']);
        print "</div>\n";
+
+       print "<div dojoType=dijit.Dialog\n";
+       print "      id=\"autoconfirmdlg\"\n";
+       print "      title=\"Confirm Manual Install\"\n";
+       print "      duration=250\n";
+       print "      draggable=true>\n";
+       print "<strong><span 
id=\"autoconfirmcontent\"></span></strong><br><br>\n";
+       print "This method cannot be automatically added to the image by VCL. 
The<br>\n";
+       print "image must be created with the software for this method already 
installed.<br>\n";
+       print "If this image already has software for this method installed in 
it, please<br>\n";
+       print "click <strong>Software is Manually Installed</strong>. 
Otherwise, click cancel.<br><br>\n";
+       print "   <div align=\"center\">\n";
+       print "   <button dojoType=\"dijit.form.Button\">\n";
+       print "     Software is Manually Installed\n";
+       print "    <script type=\"dojo/method\" event=\"onClick\">\n";
+       print "       dijit.byId('autoconfirmdlg').hide();\n";
+       print "       addConnectMethod3();\n";
+       print "       dijit.byId('connectmethoddlg').openDropDown();\n";
+       print "     </script>\n";
+       print "   </button>\n";
+       print "   <button dojoType=\"dijit.form.Button\">\n";
+       print "     Cancel\n";
+       print "    <script type=\"dojo/method\" event=\"onClick\">\n";
+       print "       dijit.byId('autoconfirmdlg').hide();\n";
+       print "       dijit.byId('connectmethoddlg').openDropDown();\n";
+       print "     </script>\n";
+       print "   </button>\n";
+       print "   </div>\n";
+       print "</div>\n";
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -1093,6 +1186,220 @@ function getRevisionHTML($imageid) {
 
 
////////////////////////////////////////////////////////////////////////////////
 ///
+/// \fn connectmethodDialogContent()
+///
+/// \brief prints content to fill in the dojo dialog for managing subimages
+///
+////////////////////////////////////////////////////////////////////////////////
+function connectmethodDialogContent() {
+       $imageid = getContinuationVar('imageid');
+       $methods = getConnectMethods($imageid);
+       $curmethods = getImageConnectMethods($imageid);
+
+       $h  = "<h3>Modify Connection Methods</h3>";
+       $cdata = array('imageid' => $imageid);
+       $cont = addContinuationsEntry('jsonImageConnectMethods', $cdata);
+       $h .= "<div dojoType=\"dojo.data.ItemFileWriteStore\" url=\"" . BASEURL;
+       $h .= SCRIPT . "?continuation=$cont\" jsid=\"cmstore\" id=\"cmstore\">";
+       $h .= "</div>\n";
+       if(count($methods) == count($curmethods))
+               $disabled = 'disabled="true"';
+       else
+               $disabled = '';
+       $h .= "<div dojoType=\"dijit.form.Select\" id=\"addcmsel\" ";
+       $h .= "store=\"cmstore\" query=\"{active: 0}\" $disabled></div>";
+       $h .= "<button dojoType=\"dijit.form.Button\" id=\"addcmbtn\" 
$disabled>";
+       $h .= "Add Method";
+       $h .= "<script type=\"dojo/method\" event=onClick>";
+       $h .= "addConnectMethod();";
+       $h .= "</script>";
+       $h .= "</button><br>";
+       $h .= "<h3>Current Methods</h3>";
+       $h .= "<select id=\"curmethodsel\" multiple size=5>";
+       foreach($curmethods as $id => $method)
+               $h .= "<option value=\"$id\">$method</option>";
+       $h .= "</select><br>";
+       $h .= "<button dojoType=\"dijit.form.Button\" id=\"remcmbtn\">";
+       $h .= "Remove Selected Methods(s)";
+       $h .= "<script type=\"dojo/method\" event=onClick>";
+       $h .= "remConnectMethod();";
+       $h .= "</script>";
+       $h .= "</button><br>";
+       $h .= "<div id=\"cmerror\" class=\"rederrormsg\"></div>\n";
+       $adminimages = getUserResources(array("imageAdmin"), 
array("administer"));
+       $adminids = array_keys($adminimages["image"]);
+       $data = array('imageid' => $imageid,
+                     'methods' => $methods);
+       $cont = addContinuationsEntry('AJaddImageConnectMethod', $data, 3600, 
1, 0);
+       $h .= "<INPUT type=hidden id=addcmcont value=\"$cont\">";
+       $cont = addContinuationsEntry('AJremImageConnectMethod', $data, 3600, 
1, 0);
+       $h .= "<INPUT type=hidden id=remcmcont value=\"$cont\">";
+       $h .= "NOTE: Connection Method changes take effect immediately; you 
do<br>";
+       $h .= "<strong>not</strong> need to click \"Confirm Changes\" to submit 
them.";
+       print $h;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn jsonImageConnectMethods()
+///
+/// \brief gets list of connect methods used for specified image and sends them
+/// in json format
+///
+////////////////////////////////////////////////////////////////////////////////
+function jsonImageConnectMethods() {
+       $imageid = getContinuationVar('imageid');
+       $methods = getConnectMethods($imageid);
+       $curmethods = getImageConnectMethods($imageid);
+       $items = array();
+       foreach($methods as $id => $method) {
+               if(array_key_exists($id, $curmethods))
+                       $active = 1;
+               else
+                       $active = 0;
+               $items[] = "{name:'$id', "
+                        .  "display:'{$method['description']}', "
+                        .  "autoprovisioned:'{$method['autoprovisioned']}', "
+                        .  "active:$active}";
+       }
+       $data = implode(',', $items);
+       header('Content-Type: text/json; charset=utf-8');
+       $data = "{} && {label:'display',identifier:'name',items:[$data]}";
+       print $data;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJaddImageConnectMethod()
+///
+/// \brief adds a subimage to an image
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJaddImageConnectMethod() {
+       $imageid = getContinuationVar('imageid');
+       $methods = getContinuationVar('methods');
+       $curmethods = getImageConnectMethods($imageid);
+       $newid = processInputVar('newid', ARG_NUMERIC);
+       if(! array_key_exists($newid, $methods)) {
+               $arr = array('error' => 'invalidmethod',
+                       'msg' => 'Invalid method submitted.');
+               sendJSON($arr);
+               return;
+       }
+       # delete any current entries for method and image (including disabled)
+       $query = "DELETE FROM connectmethodmap "
+              . "WHERE imageid = $imageid AND "
+              .       "connectmethodid = $newid AND "
+              .       "autoprovisioned IS NULL";
+       doQuery($query, 101);
+
+       # check to see if enabled for OStype or OS
+       $query = "SELECT cm.connectmethodid "
+                        . "FROM connectmethodmap cm, "
+                        .      "image i "
+                        . "LEFT JOIN OS o ON (o.id = i.OSid) "
+                        . "LEFT JOIN OStype ot ON (ot.name = o.type) "
+                        . "WHERE i.id = $imageid AND "
+                        .       "cm.autoprovisioned IS NULL AND "
+                        .       "cm.connectmethodid = $newid AND "
+                        .       "cm.disabled = 0 AND "
+                        .       "(cm.OStypeid = ot.id OR "
+                        .        "cm.OSid = o.id)";
+       $qh = doQuery($query, 101);
+       if(! (mysql_num_rows($qh))) {
+               # add entry for method and image
+               $query = "INSERT INTO connectmethodmap "
+                      .        "(connectmethodid, "
+                      .        "imageid, "
+                      .        "disabled) "
+                      . "VALUES "
+                      .        "($newid, "
+                      .        "$imageid, "
+                      .        "0)";
+               doQuery($query, 101);
+       }
+
+       #   return success
+       $subimages[] = $newid;
+       $data = array('imageid' => $imageid,
+                     'methods' => $methods);
+       $addcont = addContinuationsEntry('AJaddImageConnectMethod', $data, 
3600, 1, 0);
+       $remcont = addContinuationsEntry('AJremImageConnectMethod', $data, 
3600, 1, 0);
+       $name = $methods[$newid]['description'];
+       $arr = array('newid' => $newid,
+                    'name' => $name,
+                    'addcont' => $addcont,
+                    'remcont' => $remcont);
+       sendJSON($arr);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJremImageConnectMethod()
+///
+/// \brief removes subimages from an image
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJremImageConnectMethod() {
+       $imageid = getContinuationVar('imageid');
+       $methods = getContinuationVar('methods');
+       $curmethods = getImageConnectMethods($imageid);
+       $remidlist = mysql_real_escape_string(processInputVar('ids', 
ARG_STRING));
+       $remids = explode(',', $remidlist);
+       foreach($remids as $id) {
+               if(! is_numeric($id)) {
+                       $arr = array('error' => 'invalidinput',
+                                    'msg' => 'Non-numeric data was submitted 
for a connection method id.');
+                       sendJSON($arr);
+                       return;
+               }
+       }
+       # delete any current entries for method and image
+       $query = "DELETE FROM connectmethodmap "
+              . "WHERE imageid = $imageid AND "
+              .       "connectmethodid IN ($remidlist) AND "
+              .       "autoprovisioned IS NULL";
+       doQuery($query, 101);
+       # query to see if enabled for OStype or OS
+       $insvals = array();
+       foreach($remids as $id) {
+               $query = "SELECT cm.connectmethodid "
+                                . "FROM connectmethodmap cm, "
+                                .      "image i "
+                                . "LEFT JOIN OS o ON (o.id = i.OSid) "
+                                . "LEFT JOIN OStype ot ON (ot.name = o.type) "
+                                . "WHERE i.id = $imageid AND "
+                                .       "cm.autoprovisioned IS NULL AND "
+                                .       "cm.connectmethodid = $id AND "
+                                .       "cm.disabled = 0 AND "
+                                .       "(cm.OStypeid = ot.id OR "
+                                .        "cm.OSid = o.id)";
+               $qh = doQuery($query, 101);
+               if(mysql_num_rows($qh))
+                       # if so, add disabled entry for image and method
+                       $insvals[] = "($id, $imageid, 1)";
+       }
+       if(count($insvals)) {
+               $allinsvals = implode(',', $insvals);
+               $query = "INSERT INTO connectmethodmap "
+                      .        "(connectmethodid, " 
+                      .        "imageid, "
+                      .        "disabled) "
+                      . "VALUES $allinsvals";
+               doQuery($query, 101);
+       }
+
+       $data = array('imageid' => $imageid,
+                     'methods' => $methods);
+       $addcont = addContinuationsEntry('AJaddImageConnectMethod', $data, 
3600, 1, 0);
+       $remcont = addContinuationsEntry('AJremImageConnectMethod', $data, 
3600, 1, 0);
+       $arr = array('addcont' => $addcont,
+                    'remcont' => $remcont);
+       sendJSON($arr);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
 /// \fn subimageDialogContent()
 ///
 /// \brief prints content to fill in the dojo dialog for managing subimages
@@ -1372,12 +1679,6 @@ function confirmEditOrAddImage($state) {
        print "<H2>$title</H2>\n";
        print "$question<br><br>\n";
        print "<TABLE>\n";
-       if(! $state) {
-               /*print "  <TR>\n";
-               print "    <TH align=right>Short Name:</TH>\n";
-               print "    <TD>" . $data["name"] . "</TD>\n";
-               print "  </TR>\n";*/
-       }
        print "  <TR>\n";
        print "    <TH align=right>Name:</TH>\n";
        print "    <TD>" . $data["prettyname"] . "</TD>\n";
@@ -1386,14 +1687,6 @@ function confirmEditOrAddImage($state) {
        print "    <TH align=right>Owner:</TH>\n";
        print "    <TD>" . $data["owner"] . "</TD>\n";
        print "  </TR>\n";
-       /*print "  <TR>\n";
-       print "    <TH align=right>Platform:</TH>\n";
-       print "    <TD>" . $platforms[$data["platformid"]] . "</TD>\n";
-       print "  </TR>\n";
-       print "  <TR>\n";
-       print "    <TH align=right>OS:</TH>\n";
-       print "    <TD>" . $oslist[$data["osid"]]["prettyname"] . "</TD>\n";
-       print "  </TR>\n";*/
        print "  <TR>\n";
        print "    <TD colspan=2>\n";
        print "<br><strong>Image Description</strong>:<br>\n";
@@ -1562,6 +1855,11 @@ function imageClickThrough() {
 function imageClickThroughAgreement() {
        global $clickThroughText;
        $data = getContinuationVar();
+       $comments = processInputVar('comments', ARG_STRING, '');
+       $comments = htmlspecialchars($comments);
+       if(get_magic_quotes_gpc())
+               $comments = stripslashes($comments);
+       $data['comments'] = mysql_real_escape_string($comments);
        $nextmode = $data['nextmode'];
        $multicall = getContinuationVar('multicall', 0);
        unset($data['nextmode']);
@@ -1604,9 +1902,10 @@ function imageClickThroughAgreement() {
 /// \brief adds the image and notifies user
 ///
 
////////////////////////////////////////////////////////////////////////////////
-function submitAddImage() {
+function submitAddImage($data=array(), $autocaptured=0) {
        global $user, $clickThroughText;
-       $data = getContinuationVar();
+       if(empty($data))
+               $data = getContinuationVar();
 
        // get platformid and osid
        $requestdata = getRequestInfo($data['requestid']);
@@ -1614,6 +1913,7 @@ function submitAddImage() {
        $data["platformid"] = 
$imagedata[$requestdata["reservations"][0]["imageid"]]["platformid"];
        $data["osid"] = 
$imagedata[$requestdata["reservations"][0]["imageid"]]["osid"];
        $data["basedoffrevisionid"] = 
$requestdata["reservations"][0]["imagerevisionid"];
+       $data["autocaptured"] = $autocaptured;
 
        // add estimated reload time
        $data["reloadtime"] = 20;
@@ -1662,6 +1962,9 @@ function submitAddImage() {
                doQuery($query, 101);
        }
 
+       if($autocaptured)
+               return 1;
+
        print "<H2>Add Image</H2>\n";
        print "The image creation process has been started.  It normally takes 
";
        print "about 25 minutes to complete (though can sometimes be more than 
";
@@ -1672,6 +1975,7 @@ function submitAddImage() {
        print "group on the <a href=\"" . BASEURL . SCRIPT;
        print "?mode=viewImageOptions\">Manage Images</a> page if you have ";
        print "sufficient access or have your computing support add it for 
you.<br>\n";
+       return 1;
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -1696,8 +2000,8 @@ function updateExistingImageComments() {
        print "<H2>Update Existing Image</H2>\n";
        print "<h3>New Revision Comments</h3>\n";
        print "Enter any notes for yourself and other admins about how the 
image ";
-       print "was setup/installed.<br>\nThese are optional and not visible to 
end ";
-       print "users:<br>\n";
+       print "was setup/installed.<br>\nThese are optional and are not visible 
";
+       print "to end users:<br>\n";
        print "<form action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
        print "<textarea dojoType=\"dijit.form.Textarea\" name=comments ";
        print "style=\"width: 400px; text-align: left;\"\">\n\n</textarea>\n";
@@ -1736,11 +2040,11 @@ function updateExistingImageComments() {
 /// notifies the user that the imaging process has started
 ///
 
////////////////////////////////////////////////////////////////////////////////
-function updateExistingImage() {
+function updateExistingImage($requestid=0, $userid=0, $comments='', 
$autocaptured=0) {
        global $user, $clickThroughText;
-       $requestid = getContinuationVar("requestid");
+       $requestid = getContinuationVar("requestid", $requestid);
        $fromAgreement = getContinuationVar('fromAgreement', 0);
-       $comments = processInputVar("comments", ARG_STRING);
+       $comments = processInputVar("comments", ARG_STRING, $comments);
        $comments = preg_replace("/\r/", '', $comments);
        $comments = htmlspecialchars($comments);
        #$comments = preg_replace("/\n/", '<br>', $comments);
@@ -1749,6 +2053,9 @@ function updateExistingImage() {
                $comments = stripslashes($comments);
        $comments = mysql_real_escape_string($comments);
 
+       if($userid == 0)
+               $userid = $user['id'];
+
        $data = getRequestInfo($requestid);
        foreach($data["reservations"] as $res) {
                if($res["forcheckout"]) {
@@ -1757,9 +2064,10 @@ function updateExistingImage() {
                }
        }
        $imageData = getImages(0, $imageid);
-       if($imageData[$imageid]['ownerid'] != $user['id']) {
-               editOrAddImage(1);
-               return;
+       if($imageData[$imageid]['ownerid'] != $userid) {
+               if(! $autocaptured)
+                       editOrAddImage(1);
+               return 0;
        }
        // set the test flag on the image in the image table
        $query = "UPDATE image SET test = 1 WHERE id = $imageid";
@@ -1785,15 +2093,17 @@ function updateExistingImage() {
               .        "deleted, "
               .        "production, "
               .        "comments, "
-              .        "imagename) "
+              .        "imagename, "
+              .        "autocaptured) "
               . "VALUES ($imageid, "
               .        "$newrevision, "
-              .        "{$user['id']}, "
+              .        "$userid, "
               .        "NOW(), "
               .        "1, "
               .        "0, "
               .        "'$comments', "
-              .        "'$newname')";
+              .        "'$newname', "
+              .        "$autocaptured)";
        doQuery($query, 101);
        $qh = doQuery("SELECT LAST_INSERT_ID() FROM imagerevision", 101);
        $row = mysql_fetch_row($qh);
@@ -1818,13 +2128,16 @@ function updateExistingImage() {
                       .        "accepted, "
                       .        "agreement) "
                       . "VALUES "
-                      .        "({$user['id']}, "
+                      .        "($userid, "
                       .        "$imageid, "
                       .        "NOW(), "
                       .        "'$agreement')";
                doQuery($query, 101);
        }
 
+       if($autocaptured)
+               return 1;
+
        print "<H2>Update Image</H2>\n";
        print "The image creation process has been started.  It normally takes 
";
        print "about 20-25 minutes to complete.  You will be notified by email 
";
@@ -1840,7 +2153,125 @@ function updateExistingImage() {
        print "</li>\n";
        print "<li>Test the environment to make sure it works correctly</li>\n";
        print "<li>After you are satisfied that it works correctly, click the ";
-       print "<strong>End</strong> button on the Current Reservations 
page</li>\n";
+       print "<strong>Delete</strong> button on the Current Reservations 
page</li>\n";
+       print "<li>You will be prompted to make the revision production or just 
end ";
+       print "the reservation</li>\n";
+       print "<li>Select the <strong>Make this the production 
revision</strong> ";
+       print "radio button</li> and click <strong>Submit</strong></li>\n";
+       print "</ol>\n";
+       print "Once the revision is made production, everyone that selects it 
will ";
+       print "get the new revision<br>\n";
+       return 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn submitCheckpoint()
+///
+/// \brief sets test flag on image to 1, sets state of request to 'checkpoint'
+/// and notifies the user that the imaging process has started
+///
+////////////////////////////////////////////////////////////////////////////////
+function submitCheckpoint() {
+       global $user, $clickThroughText;
+       $requestid = getContinuationVar("requestid");
+       $fromAgreement = getContinuationVar('fromAgreement', 0);
+       $comments = getContinuationVar("comments");
+       $comments = preg_replace("/\r/", '', $comments);
+       #$comments = preg_replace("/\n/", '<br>', $comments);
+       $comments = preg_replace("/\n/", '', $comments);
+
+       $data = getRequestInfo($requestid);
+       foreach($data["reservations"] as $res) {
+               if($res["forcheckout"]) {
+                       $imageid = $res["imageid"];
+                       break;
+               }
+       }
+       // set the test flag on the image in the image table
+       $query = "UPDATE image SET test = 1 WHERE id = $imageid";
+       doQuery($query, 101);
+
+       # add entry to imagerevision table
+       $query = "SELECT revision, "
+              .        "imagename "
+              . "FROM imagerevision "
+              . "WHERE imageid = $imageid "
+              . "ORDER BY revision DESC "
+              . "LIMIT 1";
+       $qh = doQuery($query, 101);
+       $row = mysql_fetch_assoc($qh);
+       $newrevision = $row['revision'] + 1;
+       $newname = preg_replace("/{$row['revision']}$/",
+                               $newrevision, $row['imagename']);
+       $query = "INSERT INTO imagerevision "
+              .        "(imageid, "
+              .        "revision, "
+              .        "userid, "
+              .        "datecreated, "
+              .        "deleted, "
+              .        "production, "
+              .        "comments, "
+              .        "imagename, "
+              .        "autocaptured) "
+              . "VALUES ($imageid, "
+              .        "$newrevision, "
+              .        "{$user['id']}, "
+              .        "NOW(), "
+              .        "1, "
+              .        "0, "
+              .        "'$comments', "
+              .        "'$newname', "
+              .        "0)";
+       doQuery($query, 101);
+       $qh = doQuery("SELECT LAST_INSERT_ID() FROM imagerevision", 101);
+       $row = mysql_fetch_row($qh);
+       $imagerevisionid = $row[0];
+
+       # update request and reservation
+       $query = "UPDATE request rq, "
+              .        "reservation rs "
+              . "SET rs.imagerevisionid = $imagerevisionid, "
+              .     "rq.stateid = 24,"
+              .     "rq.forimaging = 1 "
+              . "WHERE rq.id = $requestid AND "
+              .       "rq.id = rs.requestid AND "
+              .       "rs.imageid = $imageid";
+       doQuery($query, 101);
+
+       if($fromAgreement) {
+               $agreement = strip_tags(sprintf($clickThroughText, ""));
+               $query = "INSERT INTO clickThroughs "
+                      .        "(userid, "
+                      .        "imageid, "
+                      .        "accepted, "
+                      .        "agreement) "
+                      . "VALUES "
+                      .        "({$user['id']}, "
+                      .        "$imageid, "
+                      .        "NOW(), "
+                      .        "'$agreement')";
+               doQuery($query, 101);
+       }
+
+       print "<H2>Create New Revision of an Online Image</H2>\n";
+       print "The image creation process has been started. It normally takes ";
+       print "about 20-25 minutes to complete. You will be notified by email ";
+       print "when the image has been created. Afterward, you have the option 
to ";
+       print "set the new revision be the production one. There are a few 
steps ";
+       print "you would need to follow to make it the production revision of 
the ";
+       print "image:";
+       print "<ol class=numbers>\n";
+       print "<li>Make a new reservation for the environment (it will have the 
";
+       print "same name in the drop-down list).</li>\n";
+       print "<li>After clicking <strong>Submit</strong> on the New 
Reservations ";
+       print "page, you will be prompted to select the revision of the 
environment ";
+       print "you want</li>\n";
+       print "<li>Select the most recent revision and click 
<strong>Submit</strong>";
+       print "</li>\n";
+       print "<li>Test the environment to make sure it works correctly</li>\n";
+       print "<li>After you are satisfied that it works correctly, click the ";
+       print "<strong>Delete</strong> button on the Current Reservations 
page</li>\n";
        print "<li>You will be prompted to make the revision production or just 
end ";
        print "the reservation</li>\n";
        print "<li>Select the <strong>Make this the production 
revision</strong> ";
@@ -1896,6 +2327,38 @@ function setImageProduction() {
 
 
////////////////////////////////////////////////////////////////////////////////
 ///
+/// \fn AJsetImageProduction()
+///
+/// \brief prompts user if really ready to set image to production
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJsetImageProduction() {
+       $requestid = getContinuationVar('requestid');
+       $data = getRequestInfo($requestid);
+       foreach($data["reservations"] as $res) {
+               if($res["forcheckout"]) {
+                       $prettyimage = $res["prettyimage"];
+                       break;
+               }
+       }
+       $title = "<big><strong>Change Test Image to 
Production</strong></big><br><br>\n";
+       $text  = "This will update the <b>$prettyimage</b> ";
+       $text .= "environment to be the newly created revision so that people 
will ";
+       $text .= "start getting it when they checkout the environment.  It will 
also ";
+       $text .= "cause all the blades that currently have this image preloaded 
to be ";
+       $text .= "reloaded with this new image.  Are you sure the image works ";
+       $text .= "correctly?<br>\n";
+       $cdata = array('requestid' => $requestid);
+       $cont = addContinuationsEntry('AJsubmitSetImageProduction', $cdata, 
SECINDAY, 0, 0);
+       $text = preg_replace("/(.{1,60}[ \n])/", '\1<br>', $text);
+       $data = array('content' => $title . $text,
+                     'cont' => $cont,
+                     'btntxt' => 'Submit');
+       sendJSON($data);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
 /// \fn submitSetImageProduction()
 ///
 /// \brief sets request state to 'makeproduction', notifies user that
@@ -1920,6 +2383,46 @@ function submitSetImageProduction() {
 
 
////////////////////////////////////////////////////////////////////////////////
 ///
+/// \fn AJsubmitSetImageProduction()
+///
+/// \brief sets request state to 'makeproduction', notifies user that
+/// "productioning" process has started
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJsubmitSetImageProduction() {
+       $requestid = getContinuationVar('requestid');
+       $data = getRequestInfo($requestid);
+       foreach($data["reservations"] as $res) {
+               if($res["forcheckout"]) {
+                       $prettyimage = $res["prettyimage"];
+                       break;
+               }
+       }
+       $query = "UPDATE request SET stateid = 17 WHERE id = $requestid";
+       doQuery($query, 101);
+       $content = "<b>$prettyimage</b> is now in the process of being updated "
+                . "to use the newly created image revision. <br>";
+       $content = preg_replace("/(.{1,60}[ \n])/", '\1<br>', $content);
+       $a = "var dlg = new dijit.Dialog({"
+          .    "title: \"Change Test Image to Production\","
+          .    "id: \"toproddlg\""
+          . "});"
+               . "var content = '$content"
+          . "<div align=\"center\">"
+          . "<button dojoType=\"dijit.form.Button\">"
+          .   "Close"
+          .   "<script type=\"dojo/method\" event=\"onClick\">"
+          .   "dijit.byId(\"toproddlg\").destroy();"
+          .   "</script>"
+               .   "</button>"
+          .   "</div>';"
+          . "dlg.set(\"content\", content);"
+          . "dlg.show();";
+       print $a;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
 /// \fn confirmDeleteImage()
 ///
 /// \brief prints a form to confirm the deletion of an image
@@ -1954,10 +2457,6 @@ function confirmDeleteImage() {
        print "<H2>$title</H2>\n";
        print "$question<br><br>\n";
        print "<TABLE>\n";
-       /*print "  <TR>\n";
-       print "    <TH align=right>Short Name:</TH>\n";
-       print "    <TD>" . $images[$imageid]["name"] . "</TD>\n";
-       print "  </TR>\n";*/
        print "  <TR>\n";
        print "    <TH align=right>Long Name:</TH>\n";
        print "    <TD>" . $images[$imageid]["prettyname"] . "</TD>\n";
@@ -2060,10 +2559,6 @@ function viewImageDetails() {
        print "<DIV align=center>\n";
        print "<H2>Image Details</H2>\n";
        print "<TABLE>\n";
-       /*print "  <TR>\n";
-       print "    <TH align=right>Short Name:</TH>\n";
-       print "    <TD>" . $images[$imageid]["name"] . "</TD>\n";
-       print "  </TR>\n";*/
        print "  <TR>\n";
        print "    <TH align=right>Long Name:</TH>\n";
        print "    <TD>" . $images[$imageid]["prettyname"] . "</TD>\n";
@@ -2370,11 +2865,8 @@ function processImageInput($checks=1) {
        $mode = processInputVar("mode", ARG_STRING);
        $return["imageid"] = processInputVar("imageid" , ARG_NUMERIC, 
getContinuationVar('imageid'));
        $return['requestid'] = getContinuationVar('requestid');
-       #$return["name"] = processInputVar("name", ARG_STRING);
        $return["prettyname"] = processInputVar("prettyname", ARG_STRING);
        $return["owner"] = processInputVar("owner", ARG_STRING, 
"{$user["unityid"]}@{$user['affiliation']}");
-       #$return["platformid"] = processInputVar("platformid", ARG_NUMERIC);
-       #$return["osid"] = processInputVar("osid", ARG_NUMERIC);
        $return["minram"] = processInputVar("minram", ARG_NUMERIC, 64);
        $return["minprocnumber"] = processInputVar("minprocnumber", 
ARG_NUMERIC);
        $return["minprocspeed"] = processInputVar("minprocspeed", ARG_NUMERIC, 
500);
@@ -2406,16 +2898,6 @@ function processImageInput($checks=1) {
                return $return;
        }
        
-       /*if($mode != "confirmAddImage" &&
-          (strlen($return["name"]) > 30 || strlen($return["name"]) < 2)) {
-          $submitErr |= NAMEERR;
-          $submitErrMsg[NAMEERR] = "Short Name must be from 2 to 30 
characters";
-       }
-       if(! ($submitErr & NAMEERR) &&
-          checkForImageName($return["name"], "short", $return["imageid"])) {
-          $submitErr |= NAMEERR;
-          $submitErrMsg[NAMEERR] = "An image already exists with this name.";
-       }*/
        if(preg_match('/-/', $return["prettyname"]) ||
                strlen($return["prettyname"]) > 60 || 
strlen($return["prettyname"]) < 2) {
           $submitErr |= PRETTYNAMEERR;
@@ -2505,8 +2987,6 @@ function updateImage($data) {
        $query = "UPDATE image "
               . "SET prettyname = '{$data["prettyname"]}', "
               .     "ownerid = $ownerid, "
-              /*.     "platformid = {$data["platformid"]}, "
-              .     "OSid = {$data["osid"]}, "*/
               .     "minram = {$data["minram"]}, "
               .     "minprocnumber = {$data["minprocnumber"]}, "
               .     "minprocspeed = {$data["minprocspeed"]}, "
@@ -2662,13 +3142,15 @@ function addImage($data) {
               .        "datecreated, "
               .        "production, "
               .        "imagename, "
-              .        "comments) "
+              .        "comments, "
+              .        "autocaptured) "
               . "VALUES ($imageid, "
               .        "{$user['id']}, "
               .        "NOW(), "
               .        "1, "
               .        "'$name', "
-              .        "'{$data['comments']}')";
+              .        "'{$data['comments']}', "
+              .        "{$data['autocaptured']})";
        doQuery($query, 101);
 
        // add entry in resource table

Modified: incubator/vcl/trunk/web/.ht-inc/privileges.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/privileges.php?rev=1097842&r1=1097841&r2=1097842&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/privileges.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/privileges.php Fri Apr 29 15:34:22 2011
@@ -1847,8 +1847,10 @@ function getResourcePrivRowHTML($privnam
                }
                // if group type is schedule, don't print available or 
manageMapping checkboxes
                // if group type is managementnode, don't print available 
checkbox
+               // if group type is serverprofile, don't print manageMapping 
checkbox
                elseif(($grptype == 'schedule' && ($type == 'available' || 
$type == 'manageMapping')) ||
-                     ($grptype == 'managementnode' && $type == 'available')) {
+                     ($grptype == 'managementnode' && $type == 'available') ||
+                     ($grptype == 'serverprofile' && $type == 
'manageMapping')) {
                        $text .= "<TD><img src=images/blank.gif></TD>\n";
                }
                else {
@@ -2505,14 +2507,16 @@ function AJsubmitAddResourcePriv() {
                return;
        }
        $newgroupid = processInputVar("newgroupid", ARG_NUMERIC);
-       $privs = array("computerAdmin","mgmtNodeAdmin",  "imageAdmin", 
"scheduleAdmin");
+       $privs = array("computerAdmin", "mgmtNodeAdmin", "imageAdmin",
+                      "scheduleAdmin", "serverProfileAdmin");
        $resourcesgroups = getUserResources($privs, array("manageGroup"), 1);
 
        if(! array_key_exists($newgroupid, $resourcesgroups['image']) &&
           ! array_key_exists($newgroupid, $resourcesgroups['computer']) &&
           ! array_key_exists($newgroupid, $resourcesgroups['managementnode']) 
&&
-          ! array_key_exists($newgroupid, $resourcesgroups['schedule'])) {
-               $text = "You do not have rights manage the specified resource 
group.";
+          ! array_key_exists($newgroupid, $resourcesgroups['schedule']) &&
+          ! array_key_exists($newgroupid, $resourcesgroups['serverprofile'])) {
+               $text = "You do not have rights to manage the specified 
resource group.";
                print "addResourceGroupPaneHide(); ";
                print "alert('$text');";
                return;


Reply via email to