Author: jfthomps
Date: Thu Jun 2 21:14:11 2016
New Revision: 1746635
URL: http://svn.apache.org/viewvc?rev=1746635&view=rev
Log:
VCL-843 - Remove "VM limit"
vm.php:
-modified editVMInfo: removed row related to VM limit; added a line below the
list of assigned VMs that shows how many VMs are currently assigned
-modified vmhostdata: removed vmlimit from returned data
-modified getVMHostData: removed vmlimit from returned data
-removed updateVMlimit
-modified AJvmToHost: removed section that checks if the host has too many
assigned VMs
vm.js:
-modified VMHostDataCB: removed line that set vmlimit; added line that sets
assignedcnt to the number of currently assigned VMs
-removed updateVMlimit
-removed updateVMlimitCB
-modified vmToHost: removed section that checks for exceeding vmlimit
-modified vmToHostCB: removed section that checks for error code of vmlimit;
added line that sets assignedcnt to the number of currently assigned VMs
-modified vmFromHostCB: added line that sets assignedcnt to the number of
currently assigned VMs
Modified:
vcl/trunk/web/.ht-inc/vm.php
vcl/trunk/web/js/vm.js
Modified: vcl/trunk/web/.ht-inc/vm.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/vm.php?rev=1746635&r1=1746634&r2=1746635&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/vm.php (original)
+++ vcl/trunk/web/.ht-inc/vm.php Thu Jun 2 21:14:11 2016
@@ -71,18 +71,6 @@ function editVMInfo() {
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 " intermediateChanges=\"true\"\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";
@@ -114,6 +102,7 @@ function editVMInfo() {
print "VMs assigned to host:<br>\n";
print "<select name=currvms multiple id=currvms size=15
onChange=showVMstate()>\n";
print "</select><br>\n";
+ print "Assigned VMs: <span id=\"assignedcnt\">0</span><br>\n";
print "State of selected vm:<br>\n";
print "<span id=vmstate></span>\n";
print "<div id=\"noaccessdiv\" class=\"hidden\"><hr>VMs
assigned to ";
@@ -484,8 +473,7 @@ function vmhostdata() {
$noaccess = array_merge($noaccess);
$freevms = array_merge($freevms);
$cont = addContinuationsEntry('AJchangeVMprofile', array(), 3600, 1, 0);
- $arr = array('vmlimit' => $data[$vmhostid]['vmlimit'],
- 'profile' => $data[$vmhostid]['vmprofiledata'],
+ $arr = array('profile' => $data[$vmhostid]['vmprofiledata'],
'continuation' => $cont,
'allvms' => $allvms,
'currvms' => $currvms,
@@ -506,7 +494,6 @@ function vmhostdata() {
/// \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 vmprofiledata - array of data about the vm's profile as returned from
/// getVMProfiles
@@ -520,7 +507,6 @@ function getVMHostData($id='') {
. "vh.computerid, "
. "c.hostname AS name, "
. "c.hostname, "
- . "vh.vmlimit, "
. "vh.vmprofileid "
. "FROM vmhost vh, "
. "computer c "
@@ -543,67 +529,6 @@ function getVMHostData($id='') {
////////////////////////////////////////////////////////////////////////////////
///
-/// \fn updateVMlimit()
-///
-/// \brief updates the vmlimit for the submitted vmhostid
-///
-////////////////////////////////////////////////////////////////////////////////
-function updateVMlimit() {
- global $mysql_link_vcl;
- $vmhostid = processInputVar('vmhostid', ARG_NUMERIC);
- $newlimit = processInputVar('newlimit', ARG_NUMERIC);
-
- $data = getVMHostData($vmhostid);
-
- if($data[$vmhostid]['vmlimit'] == $newlimit) {
- sendJSON(array('status' => 'SUCCESS'));
- return;
- }
- $resources = getUserResources(array("computerAdmin"),
array("administer"));
- if(! array_key_exists($data[$vmhostid]['computerid'],
$resources['computer'])) {
- $rc = array('status' => 'ERROR',
- 'msg' => "You do not have access to manage this
host.");
- sendJSON($rc);
- return;
- }
-
- if($newlimit < 0 || $newlimit > MAXVMLIMIT) {
- $rc = array('status' => 'ERROR',
- 'msg' => "ERROR: newlimit out of range");
- sendJSON($rc);
- return;
- }
-
- # get number of vms assigned to vmhost
- $query = "SELECT COUNT(id) as assigned "
- . "FROM computer "
- . "WHERE type = 'virtualmachine' AND "
- . "vmhostid = $vmhostid AND "
- . "deleted = 0";
- $qh = doQuery($query, 101);
- $row = mysql_fetch_assoc($qh);
- if($row['assigned'] > $newlimit) {
- $rc = array('status' => 'LIMIT',
- 'msg' => "Cannot reduce VM limit below the current
number of assigned VMs",
- 'limit' => $row['assigned']);
- sendJSON($rc);
- return;
- }
-
- $query = "UPDATE vmhost SET vmlimit = $newlimit WHERE id = $vmhostid";
- $qh = doQuery($query, 101);
- if(mysql_affected_rows($mysql_link_vcl) == 0) {
- $rc = array('status' => 'ERROR',
- 'msg' => "ERROR: failed to update vmlimit",
- 'data' => $data);
- sendJSON($rc);
- return;
- }
- sendJSON(array('status' => 'SUCCESS'));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
/// \fn AJvmToHost()
///
/// \brief adds vm's to a vmhost; prints json data with:\n
@@ -622,17 +547,6 @@ function AJvmToHost() {
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']) {
- sendJSON(array('failed' => 'vmlimit'));
- return;
- }
-
$adds = array();
$fails = array();
Modified: vcl/trunk/web/js/vm.js
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/js/vm.js?rev=1746635&r1=1746634&r2=1746635&view=diff
==============================================================================
--- vcl/trunk/web/js/vm.js (original)
+++ vcl/trunk/web/js/vm.js Thu Jun 2 21:14:11 2016
@@ -58,7 +58,6 @@ function VMHostDataCB(data, ioArgs) {
document.body.style.cursor = 'default';
return;
}
- dojo.byId('vmlimit').value = data.items.vmlimit;
dojo.byId('vmhostdata').className = 'shown';
curprofileid = data.items.profileid;
@@ -102,6 +101,7 @@ function VMHostDataCB(data, ioArgs) {
for(var i = 0; i < data.items.currvms.length; i++) {
inobj.options[inobj.options.length] = new
Option(data.items.currvms[i].name, data.items.currvms[i].id);
}
+ dojo.byId('assignedcnt').innerHTML =
dojo.byId('currvms').options.length;
var outobj = dojo.byId('freevms');
for(var i = 0; i < data.items.freevms.length; i++) {
outobj.options[outobj.options.length] = new
Option(data.items.freevms[i].name, data.items.freevms[i].id);
@@ -134,32 +134,6 @@ function VMHostDataCB(data, ioArgs) {
document.body.style.cursor = 'default';
}
-function updateVMlimit(cont) {
- var hostid = dojo.byId('vmhostid').value;
- var newlimit = dojo.byId('vmlimit').value;
- document.body.style.cursor = 'wait';
-
- dojo.xhrPost({
- url: 'index.php',
- load: updateVMlimitCB,
- handleAs: "json",
- error: errorHandler,
- content: {continuation: cont,
- vmhostid: hostid,
- newlimit: newlimit},
- timeout: 15000
- });
-}
-
-function updateVMlimitCB(data, ioArgs) {
- if(data.items.status != 'SUCCESS') {
- if(data.items.status == 'LIMIT')
- dijit.byId('vmlimit').set('value', data.items.limit);
- alert(data.items.msg);
- }
- document.body.style.cursor = 'default';
-}
-
function showVMstate() {
var selobj = dojo.byId('currvms');
var cnt = 0;
@@ -237,14 +211,6 @@ function vmToHost(cont) {
listids.push(obj.options[i].value);
}
}
- //var limit = dijit.byId('vmlimit').value;
- var limit = dojo.byId('vmlimit').value;
- var currcnt = dojo.byId('currvms').options.length;
- if(limit < currcnt + listids.length) {
- alert('You\'re attempting to add more VMs to this host\nthan
the current VM limit. This is not allowed.');
- document.body.style.cursor = 'default';
- return;
- }
if(listids.length == 0) {
document.body.style.cursor = 'default';
@@ -267,8 +233,6 @@ function vmToHostCB(data, ioArgs) {
if(data.items.failed) {
if(data.items.failed == 'nohostaccess')
alert('You do not have access to manage this VM host.');
- else if(data.items.failed == 'vmlimit')
- alert('You\'re attempting to add more VMs to this
host\nthan the current VM limit. This is not allowed.');
document.body.style.cursor = 'default';
return;
}
@@ -342,6 +306,7 @@ function vmToHostCB(data, ioArgs) {
lastid = allvms[j].id;
}
}
+ dojo.byId('assignedcnt').innerHTML =
dojo.byId('currvms').options.length;
document.body.style.cursor = 'default';
if(fails.length) {
var msg = '';
@@ -480,6 +445,7 @@ function vmFromHostCB(data, ioArgs) {
var func = function() {vmFromHostDelayed(data.items.cont);};
setMessageWindow('Delayed Move', 'Move Later', content, func);
}
+ dojo.byId('assignedcnt').innerHTML =
dojo.byId('currvms').options.length;
document.body.style.cursor = 'default';
}