Author: jfthomps Date: Wed Nov 5 19:16:37 2014 New Revision: 1636937 URL: http://svn.apache.org/r1636937 Log: VCL-776 - rework resource code to have a base class for all resources and inheriting classes for each resource type
computer.php: modified AJsaveResource: fixed bug where no vmhost entry was
being created in case of changing state of computer from maintenance to
vmhostinuse when provisioning is None
Modified:
vcl/trunk/web/.ht-inc/computer.php
Modified: vcl/trunk/web/.ht-inc/computer.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/computer.php?rev=1636937&r1=1636936&r2=1636937&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/computer.php (original)
+++ vcl/trunk/web/.ht-inc/computer.php Wed Nov 5 19:16:37 2014
@@ -96,6 +96,9 @@ class Computer extends Resource {
case 'nathost':
$w = 8;
break;
+ case 'type':
+ $w = 7;
+ break;
case 'location':
$w = 9;
break;
@@ -976,13 +979,33 @@ class Computer extends Resource {
}
$data['stateid'] = $olddata['stateid'];
# prevent state from being updated directly
}
- elseif(count($vmids)) {
- $query = "UPDATE computer "
- . "SET stateid = 2, "
- . "notes = '' "
- . "WHERE id in
($allids)";
- doQuery($query);
- $multirefresh = 1;
+ else {
+ if(count($vmids)) {
+ $query = "UPDATE computer "
+ . "SET stateid = 2, "
+ . "notes = '' "
+ . "WHERE id in
($allids)";
+ doQuery($query);
+ $multirefresh = 1;
+ }
+ if(! array_key_exists('vmprofileid',
$olddata) ||
+ $olddata['vmprofileid'] == '') {
+ $query = "INSERT INTO vmhost "
+ . "(computerid, "
+ . "vmlimit, "
+ . "vmprofileid) "
+ . "VALUES
({$data['rscid']}, "
+ . "5, "
+ .
"{$data['vmprofileid']})";
+ doQuery($query);
+ }
+ elseif($olddata['vmprofileid'] !=
$data['vmprofileid']) {
+ $query = "UPDATE vmhost "
+ . "SET vmprofileid =
{$data['vmprofileid']} "
+ . "WHERE computerid =
{$data['rscid']} AND "
+ . "vmprofileid =
{$olddata['vmprofileid']}";
+ doQuery($query);
+ }
}
}
elseif($olddata['stateid'] != 20 && $data['stateid'] ==
20) {
