Author: jfthomps
Date: Fri Sep 26 17:28:09 2014
New Revision: 1627833

URL: http://svn.apache.org/r1627833
Log:
VCL-174 - NAT - support for sites that have small IP address ranges
VCL-780 - combine new reservation and current reservations pages

computer.php:
-modified fieldWidth: added nathost 
-modified fieldDisplayName: added nathost and natenabled fields
-modified extraResourceFilters: added section for changing NAT
-modified addEditDialogHTML, AJsaveResource, validateResourceData, and 
addResource: added sections for natenabled and nathostid
-modified addResource: $values array for adding multiple computers was missing 
predictivemoduleid
-added AJcompNATchange
-added AJsubmitCompNATchange

states.php: added AJcompNATchange and AJsubmitCompNATchange to resource section

utils.php:
-modified getComputers: added natenabled and nathostid to returned data
-added getNAThosts

computer.js:
-modified colformatter: added natenabled
-modified addNewResource: added nathostid
-added toggleNAT
-modified inlineEditResourceCB, resetEditResource, saveResource, and 
saveResourceCB: added natenabled and nathostid
-added confirmNATchange

Modified:
    vcl/trunk/web/.ht-inc/computer.php
    vcl/trunk/web/.ht-inc/states.php
    vcl/trunk/web/.ht-inc/utils.php
    vcl/trunk/web/js/resources/computer.js

Modified: vcl/trunk/web/.ht-inc/computer.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/computer.php?rev=1627833&r1=1627832&r2=1627833&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/computer.php (original)
+++ vcl/trunk/web/.ht-inc/computer.php Fri Sep 26 17:28:09 2014
@@ -93,6 +93,7 @@ class Computer extends Resource {
                                $w = 8.5;
                                break;
                        case 'vmhost':
+                       case 'nathost':
                                $w = 8;
                                break;
                        case 'location':
@@ -154,6 +155,10 @@ class Computer extends Resource {
                                return 'Provisioning Engine';
                        case 'predictivemodule':
                                return 'Predictive Loading Module';
+                       case 'natenabled':
+                               return 'Connect Using NAT';
+                       case 'nathost':
+                               return 'NAT Host';
                }
                return ucfirst($field);
        }
@@ -176,6 +181,24 @@ class Computer extends Resource {
                $h .= "<span>" . _("Actions for selected computers") . 
"</span>\n";
                $h .= "<div dojoType=\"dijit.Menu\" id=\"actionmenu\">\n";
 
+               # change NAT
+               $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
+               $h .= "    <span>Change NAT</span>\n";
+               $h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
+               $h .= "         style=\"background-color: white; padding: 5px; 
border: 1px solid black;\">\n";
+               $extra = array('onChange' => "toggleNAT('newnatenabled', 
'newnathostid');");
+               $h .= labeledFormItem('newnatenabled', 'Connect Using NAT', 
'check', '', '', '1', '', '', $extra);
+               $nathosts = getNAThosts(0, 1);
+               $disabled = array('disabled' => 'true');
+               $h .= labeledFormItem('newnathostid', 'NAT Host', 'select', 
$nathosts,
+                                     '', '', '', '', $disabled);
+               $cdata = $this->basecdata;
+               $cont = addContinuationsEntry('AJcompNATchange', $cdata);
+               $h .= "      <input type=\"hidden\" id=\"natchangecont\" 
value=\"$cont\"><br>\n";
+               $h .= dijitButton('', 'Confirm NAT Change', 
'confirmNATchange();', 0);
+               $h .= "    </div>\n";
+               $h .= "  </div>\n";
+
                # change predictive loading module
                $premodules = getPredictiveModules();
                $h .= "  <div dojoType=\"dijit.PopupMenuItem\">\n";
@@ -634,6 +657,16 @@ class Computer extends Resource {
                $vals = getPredictiveModules();
                $h .= labeledFormItem('predictivemoduleid', 'Predictive Loading 
Module', 'select', $vals);
 
+               # NAT
+               $h .= "<div class=\"boxedoptions\">\n";
+               # use NAT
+               $extra = array('onChange' => "toggleNAT('natenabled', 
'nathostid');");
+               $h .= labeledFormItem('natenabled', 'Connect Using NAT', 
'check', '', '', '1', '', '', $extra);
+               # NAT host
+               $nathosts = getNAThosts(0, 1);
+               $h .= labeledFormItem('nathostid', 'NAT Host', 'select', 
$nathosts);
+               $h .= "</div>\n"; # NAT
+
                # compid
                $h .= "<div id=\"compidspan\">\n";
                $h .= "<label for=\"compid\">Computer ID:</label>\n";
@@ -788,6 +821,30 @@ class Computer extends Resource {
                                        $updates[] = "eth1macaddress = 
'{$data['eth1macaddress']}'";
                        }
 
+                       # NAT
+                       if($data['natenabled'] != $olddata['natenabled']) {
+                               if($data['natenabled']) {
+                                       $query = "INSERT INTO natmap "
+                                              .        "(computerid, "
+                                              .        "nathostid) "
+                                              . "VALUES ({$data['rscid']}, "
+                                              .        "{$data['nathostid']})";
+                                       doQuery($query);
+                               }
+                               else {
+                                       $query = "DELETE FROM natmap "
+                                              . "WHERE computerid = 
{$data['rscid']}";
+                                       doQuery($query);
+                               }
+                       }
+                       elseif($data['natenabled'] &&
+                          $olddata['nathostid'] != $data['nathostid']) {
+                               $query = "UPDATE natmap "
+                                      . "SET nathostid = {$data['nathostid']} "
+                                      . "WHERE computerid = {$data['rscid']}";
+                               doQuery($query);
+                       }
+
                        # other fields
                        $fields = array('type', 'IPaddress', 'privateIPaddress',
                                        'provisioningid', 'platformid', 
'scheduleid', 'ram',
@@ -1470,6 +1527,8 @@ class Computer extends Resource {
        /// \b procspeed\n
        /// \b network\n
        /// \b predictivemoduleid - id of module to use when preloading nodes\n
+       /// \b natenabled - 1 to use NAT for this computer, 0 not to\n
+       /// \b nathostid - id of NAT host for this computer\n
        /// \b location - free string describing location\n
        /// \b mode - 'edit' or 'add'\n
        /// \b addmode - 'single' or 'multiple'\n
@@ -1519,6 +1578,8 @@ class Computer extends Resource {
                $return['procspeed'] = processInputVar('procspeed', 
ARG_NUMERIC);
                $return['network'] = processInputVar('network', ARG_NUMERIC);
                $return['predictivemoduleid'] = 
processInputVar('predictivemoduleid', ARG_NUMERIC);
+               $return['natenabled'] = processInputVar('natenabled', 
ARG_NUMERIC);
+               $return['nathostid'] = processInputVar('nathostid', 
ARG_NUMERIC);
                $return['location'] = processInputVar('location', ARG_STRING);
                $addmode = processInputVar('addmode', ARG_STRING);
 
@@ -1810,6 +1871,18 @@ class Computer extends Resource {
                        $return['error'] = 1;
                        $errormsg[] = "Invalid value submitted for Predictive 
Loading Module";
                }
+               # natenabled
+               if($return['natenabled'] != 0 && $return['natenabled'] != 1) {
+                       $return['error'] = 1;
+                       $errormsg[] = "Invalid value for Connect Using NAT";
+               }
+               # nathostid
+               $nathosts = getNAThosts();
+               if(($return['natenabled'] && $return['nathostid'] == 0) ||
+                  ($return['nathostid'] != 0 && ! 
array_key_exists($return['nathostid'], $nathosts))) {
+                       $return['error'] = 1;
+                       $errormsg[] = "Invalid value submitted for NAT Host";
+               }
                # location
                if(! preg_match('/^([-a-zA-Z0-9_\. ,@#\(\)]{0,255})$/', 
$return['location'])) {
                        $return['error'] = 1;
@@ -1972,6 +2045,16 @@ class Computer extends Resource {
                                       .        "{$data['vmprofileid']})";
                                doQuery($query);
                        }
+
+                       # NAT
+                       if($data['natenabled']) {
+                               $query = "INSERT INTO natmap "
+                                      .        "(computerid, "
+                                      .        "nathostid) "
+                                      . "VALUES ($rscid, "
+                                      .        "{$data['nathostid']})";
+                               doQuery($query);
+                       }
                
                        // add entry in resource table
                        $query = "INSERT INTO resource "
@@ -2006,7 +2089,8 @@ class Computer extends Resource {
                                                   $data['scheduleid'], 
$data['ram'],
                                                   $data['cores'],      
$data['procspeed'],
                                                   $data['network'],    
$noimageid,
-                                                  $norevid,         
"'{$data['location']}'");
+                                                  $norevid,         
"'{$data['location']}'",
+                                                  $data['predictivemoduleid']);
                
                                $query = "INSERT INTO computer ("
                                       . implode(', ', $keys) . ") VALUES ("
@@ -2026,6 +2110,16 @@ class Computer extends Resource {
                                               .        
"{$data['vmprofileid']})";
                                        doQuery($query);
                                }
+
+                               # NAT
+                               if($data['natenabled']) {
+                                       $query = "INSERT INTO natmap "
+                                              .        "(computerid, "
+                                              .        "nathostid) "
+                                              . "VALUES ($rscid, "
+                                              .        "{$data['nathostid']})";
+                                       doQuery($query);
+                               }
                        
                                // add entry in resource table
                                $query = "INSERT INTO resource "
@@ -3976,12 +4070,6 @@ class Computer extends Resource {
                        $msg .= "</span>\n";
                }
 
-               # clear user resource cache for this type
-               $key = getKey(array(array($this->restype . "Admin"), 
array("administer"), 0, 1, 0));
-               unset($_SESSION['userresources'][$key]);
-               $key = getKey(array(array($this->restype . "Admin"), 
array("administer"), 0, 0, 0));
-               unset($_SESSION['userresources'][$key]);
-
                $ret = array('status' => 'success',
                             'title' => "Change Provisioning Engine",
                             'clearselection' => 1,
@@ -4054,10 +4142,7 @@ class Computer extends Resource {
                $predictivename = getContinuationVar('predictivemodulename');
                $compids = getContinuationVar('compids');
 
-               $startcheck = time() + 900;
-               $startcheckdt = unixToDatetime($startcheck);
                $allids = implode(',', $compids);
-
                $query = "UPDATE computer "
                       . "SET predictivemoduleid = $predictivemoduleid "
                       . "WHERE id in ($allids)";
@@ -4071,12 +4156,6 @@ class Computer extends Resource {
                        $msg .= "{$compdata[$compid]}<br>\n";
                $msg .= "<br>";
 
-               # clear user resource cache for this type
-               $key = getKey(array(array($this->restype . "Admin"), 
array("administer"), 0, 1, 0));
-               unset($_SESSION['userresources'][$key]);
-               $key = getKey(array(array($this->restype . "Admin"), 
array("administer"), 0, 0, 0));
-               unset($_SESSION['userresources'][$key]);
-
                $ret = array('status' => 'success',
                             'title' => "Change Predictive Loading Module",
                             'clearselection' => 0,
@@ -4087,6 +4166,114 @@ class Computer extends Resource {
 
        
/////////////////////////////////////////////////////////////////////////////
        ///
+       /// \fn AJcompNATchange()
+       ///
+       /// \brief confirms changing provisioning engine of submitted computers
+       ///
+       
/////////////////////////////////////////////////////////////////////////////
+       function AJcompNATchange() {
+               $natenabled = processInputVar('natenabled', ARG_NUMERIC);
+               $nathostid = processInputVar('nathostid', ARG_NUMERIC);
+               $nathosts = getNAThosts();
+               if(($natenabled != 0 && $natenabled != 1) ||
+                  ($nathostid != 0 && ! array_key_exists($nathostid, 
$nathosts))) {
+                       $ret = array('status' => 'error',
+                                    'errormsg' => 'Invalid value submitted.');
+                       sendJSON($ret);
+                       return;
+               }
+               $compids = $this->validateCompIDs();
+               if(array_key_exists('error', $compids)) {
+                       $ret = array('status' => 'error', 'errormsg' => 
$compids['msg']);
+                       sendJSON($ret);
+                       return;
+               }
+               if(count($compids) == 0) {
+                       $ret = array('status' => 'noaction');
+                       sendJSON($ret);
+                       return;
+               }
+
+               $tmp = getUserResources(array($this->restype . "Admin"), 
array("administer"), 0, 1);
+               $computers = $tmp['computer'];
+
+               if($natenabled) {
+                       $msg  = "<strong>Enable</strong> Connect Using NAT and 
set the NAT ";
+                       $msg .= "host<br>to 
<strong>{$nathosts[$nathostid]['hostname']}";
+                       $msg .= "</strong> for the following 
computers?<br><br>";
+               }
+               else {
+                       $msg  = "<strong>Disable</strong> Connect Using NAT for 
the following ";
+                       $msg .= "computers?<br><br>";
+               }
+               $complist = '';
+               foreach($compids as $compid)
+                       $complist .= $computers[$compid] . "<br>\n";
+               $complist .= "<br>\n";
+
+               $cdata = $this->basecdata;
+               $cdata['compids'] = $compids;
+               $cdata['natenabled'] = $natenabled;
+               $cdata['nathostid'] = $nathostid;
+               $cont = addContinuationsEntry('AJsubmitCompNATchange', $cdata, 
SECINDAY, 1, 0);
+               $ret = array('status' => 'success',
+                            'title' => "Connect Using NAT Change",
+                            'btntxt' => 'Submit Connect Using NAT Change',
+                            'cont' => $cont,
+                            'actionmsg' => $msg,
+                            'complist' => $complist);
+               sendJSON($ret);
+       }
+
+       
/////////////////////////////////////////////////////////////////////////////
+       ///
+       /// \fn AJsubmitCompNATchange
+       ///
+       /// \brief changes provisioning engine of submitted computers
+       ///
+       
/////////////////////////////////////////////////////////////////////////////
+       function AJsubmitCompNATchange() {
+               $natenabled = getContinuationVar('natenabled');
+               $nathostid = getContinuationVar('nathostid');
+               $compids = getContinuationVar('compids');
+
+               $allids = implode(',', $compids);
+               $query = "DELETE FROM natmap "
+                      . "WHERE computerid IN ($allids)";
+               doQuery($query);
+               if($natenabled) {
+                       $query = "INSERT INTO natmap "
+                              . "SELECT id, "
+                              .        "$nathostid "
+                              . "FROM computer "
+                              . "WHERE id IN ($allids)";
+                       doQuery($query);
+               }
+
+               $resources = getUserResources(array($this->restype . "Admin"), 
array("administer"));
+               $compdata = $resources[$this->restype];
+
+               $msg = "Connect Using NAT was <strong>";
+               if($natenabled)
+                       $msg .= "Enabled";
+               else
+                       $msg .= "Disabled";
+               $msg .= "</strong> for the following computers:<br><br>\n";
+               foreach($compids as $compid)
+                       $msg .= "{$compdata[$compid]}<br>\n";
+               $msg .= "<br>";
+
+               $ret = array('status' => 'success',
+                            'title' => "Change Connect Using NAT",
+                            'clearselection' => 0,
+                            'refreshcount' => 1,
+                            'nathostid' => $nathostid, # todo
+                            'msg' => $msg);
+               sendJSON($ret);
+       }
+
+       
/////////////////////////////////////////////////////////////////////////////
+       ///
        /// \fn AJcompScheduleChange()
        ///
        /// \brief confirms changing schedule of submitted computers

Modified: vcl/trunk/web/.ht-inc/states.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/states.php?rev=1627833&r1=1627832&r2=1627833&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/states.php (original)
+++ vcl/trunk/web/.ht-inc/states.php Fri Sep 26 17:28:09 2014
@@ -199,6 +199,8 @@ $noHTMLwrappers = array('sendRDPfile',
                         'AJsubmitCompProvisioningChange',
                         'AJcompPredictiveModuleChange',
                         'AJsubmitCompPredictiveModuleChange',
+                        'AJcompNATchange',
+                        'AJsubmitCompNATchange',
                         'AJsubmitCompStateChange',
                         'AJsubmitComputerStateLater',
                         'AJconnectRequest',
@@ -614,6 +616,8 @@ $actions['mode']['AJcompProvisioningChan
 $actions['mode']['AJsubmitCompProvisioningChange'] = 
"AJsubmitCompProvisioningChange";
 $actions['mode']['AJcompPredictiveModuleChange'] = 
"AJcompPredictiveModuleChange";
 $actions['mode']['AJsubmitCompPredictiveModuleChange'] = 
"AJsubmitCompPredictiveModuleChange";
+$actions['mode']['AJcompNATchange'] = "AJcompNATchange";
+$actions['mode']['AJsubmitCompNATchange'] = "AJsubmitCompNATchange";
 $actions['mode']['AJsubmitCompStateChange'] = "AJsubmitCompStateChange";
 $actions['mode']['AJsubmitComputerStateLater'] = "AJsubmitComputerStateLater";
 $actions['mode']['jsonImageConnectMethods'] = "jsonImageConnectMethods";
@@ -670,6 +674,8 @@ $actions['pages']['AJcompProvisioningCha
 $actions['pages']['AJsubmitCompProvisioningChange'] = "resource";
 $actions['pages']['AJcompPredictiveModuleChange'] = "resource";
 $actions['pages']['AJsubmitCompPredictiveModuleChange'] = "resource";
+$actions['pages']['AJcompNATchange'] = "resource";
+$actions['pages']['AJsubmitCompNATchange'] = "resource";
 $actions['pages']['AJsubmitCompStateChange'] = "resource";
 $actions['pages']['AJsubmitComputerStateLater'] = "resource";
 $actions['pages']['jsonImageConnectMethods'] = "resource";

Modified: vcl/trunk/web/.ht-inc/utils.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1627833&r1=1627832&r2=1627833&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Fri Sep 26 17:28:09 2014
@@ -8121,12 +8121,16 @@ function sortAvailableTimesByStart($a, $
 /// \b provisioningid - id of provisioning engine\n
 /// \b provisioning - pretty name of provisioning engine\n
 /// \b vmprofileid - if vmhost, id of vmprofile
-/// need to be used to manage computer
+/// need to be used to manage computer\n
+/// \b natenabled - 0 or 1; if NAT is enabled for this computer\n
+/// \b nathostid - id from nathost table if NAT is enabled or empty string if
+/// not
 ///
 /// \brief builds an array of computers
 ///
 
////////////////////////////////////////////////////////////////////////////////
 function getComputers($sort=0, $includedeleted=0, $compid="") {
+       $nathosts = getNAThosts();
        $return = array();
        $query = "SELECT c.id AS id, "
               .        "st.name AS state, "
@@ -8163,7 +8167,8 @@ function getComputers($sort=0, $included
               .        "pr.prettyname AS provisioning, "
               .        "vh2.vmprofileid, "
               .        "c.predictivemoduleid, "
-              .        "m.prettyname AS predictivemodule "
+              .        "m.prettyname AS predictivemodule, "
+              .        "nh.id AS nathostid "
               . "FROM state st, "
               .      "platform p, "
               .      "schedule sc, "
@@ -8179,6 +8184,8 @@ function getComputers($sort=0, $included
               . "LEFT JOIN computer c2 ON (c2.id = vh.computerid) "
               . "LEFT JOIN image next ON (c.nextimageid = next.id) "
               . "LEFT JOIN provisioning pr ON (c.provisioningid = pr.id) "
+              . "LEFT JOIN natmap nm ON (nm.computerid = c.id) "
+              . "LEFT JOIN nathost nh ON (nm.nathostid = nh.id) "
               . "WHERE c.stateid = st.id AND "
               .       "c.platformid = p.id AND "
               .       "c.scheduleid = sc.id AND "
@@ -8196,6 +8203,14 @@ function getComputers($sort=0, $included
        $query .= "ORDER BY c.hostname";
        $qh = doQuery($query, 180);
        while($row = mysql_fetch_assoc($qh)) {
+               if(is_null($row['nathostid'])) {
+                       $row['natenabled'] = 0;
+                       $row['nathost'] = '';
+               }
+               else {
+                       $row['natenabled'] = 1;
+                       $row['nathost'] = 
$nathosts[$row['nathostid']]['hostname'];
+               }
                $return[$row['id']] = $row;
        }
        if($sort) {
@@ -8607,6 +8622,42 @@ function getUsedBlockComputerids($start,
        return $compids;
 }
 
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn getNAThosts($id=0, $sort=0)
+///
+/// \param $id - (optional) only get info for this NAT host
+/// \param $sort - (optional) 1 to sort; 0 not to
+///
+/// \return an array with info about the NAT hosts; each element's index is the
+/// id from the table; each element has the following items\n
+/// \b hostname\n
+/// \b natIP - IP to which users will connect
+///
+/// \brief builds an array of NAT hosts
+///
+////////////////////////////////////////////////////////////////////////////////
+function getNAThosts($id=0, $sort=0) {
+       $nathosts = array();
+       $query = "SELECT n.id, "
+              .        "n.natIP, "
+              .        "COALESCE(c.hostname, m.hostname) AS hostname "
+              . "FROM nathost n "
+              . "LEFT JOIN resource r ON (n.resourceid = r.id) "
+              . "LEFT JOIN resourcetype rt ON (r.resourcetypeid = rt.id) "
+              . "LEFT JOIN computer c ON (c.id = r.subid AND rt.name = 
'computer') "
+              . "LEFT JOIN managementnode m ON (m.id = r.subid AND rt.name = 
'managementnode')";
+       if($id)
+               $query .= " WHERE n.id = $id";
+       $qh = doQuery($query);
+       while($row = mysql_fetch_assoc($qh))
+               $nathosts[$row['id']] = $row;
+       if($sort)
+               uasort($nathosts, "sortKeepIndex");
+       return $nathosts;
+}
+
 
////////////////////////////////////////////////////////////////////////////////
 ///
 /// \fn getBlockTimeData($start, $end)

Modified: vcl/trunk/web/js/resources/computer.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/computer.js?rev=1627833&r1=1627832&r2=1627833&view=diff
==============================================================================
--- vcl/trunk/web/js/resources/computer.js (original)
+++ vcl/trunk/web/js/resources/computer.js Fri Sep 26 17:28:09 2014
@@ -93,7 +93,8 @@ Computer.prototype.colformatter = functi
        else if(obj.field == 'notes' && value) {
                return value.replace('@', '<br>').replace(/\n/g, '<br>');
        }
-       else if(obj.field == 'deleted') {
+       else if(obj.field == 'deleted' ||
+               obj.field == 'natenabled') {
                if(value == "0")
                        return '<span class="rederrormsg">false</span>';
                if(value == "1")
@@ -515,6 +516,7 @@ function addNewResource(title) {
        dojo.addClass('vmprofilespan', 'hidden');
        dojo.addClass('curimgspan', 'hidden');
        dojo.addClass('compidspan', 'hidden');
+       dijit.byId('nathostid').set('disabled', true);
        dijit.byId('addeditdlg').show();
 }
 
@@ -545,6 +547,15 @@ function toggleAddMultiple() {
        recenterDijitDialog('addeditdlg');
 }
 
+function toggleNAT(chkid, selid) {
+       if(dijit.byId(chkid).checked) {
+               dijit.byId(selid).set('disabled', false);
+       }
+       else {
+               dijit.byId(selid).set('disabled', true);
+       }
+}
+
 function inlineEditResourceCB(data, ioArgs) {
        dojo.addClass('singlemultiplediv', 'hidden');
        toggleAddSingle();
@@ -603,6 +614,15 @@ function inlineEditResourceCB(data, ioAr
                dijit.byId('predictivemoduleid').set('value', 
data.items.data.predictivemoduleid);
                dojo.byId('compid').innerHTML = data.items.data.id;
                dijit.byId('location').set('value', data.items.data.location);
+               if(data.items.data.natenabled == 1) {
+                       dijit.byId('natenabled').set('checked', true);
+                       dijit.byId('nathostid').set('disabled', false);
+                       dijit.byId('nathostid').set('value', 
data.items.data.nathostid);
+               }
+               else {
+                       dijit.byId('natenabled').set('checked', false);
+                       dijit.byId('nathostid').set('disabled', true);
+               }
                dojo.byId('addeditdlgerrmsg').innerHTML = '';
                dijit.byId('addeditdlg').show();
        }
@@ -707,6 +727,8 @@ function resetEditResource() {
        dojo.removeClass('vmprofilespan', 'hidden');
        dojo.removeClass('curimgspan', 'hidden');
        dojo.removeClass('compidspan', 'hidden');
+       dijit.byId('natenabled').set('checked', false);
+       dijit.byId('nathostid').set('disabled', true);
 }
 
 function saveResource() {
@@ -750,6 +772,13 @@ function saveResource() {
        data['scheduleid'] = dijit.byId('scheduleid').get('value');
        data['network'] = dijit.byId('network').get('value');
        data['predictivemoduleid'] = 
dijit.byId('predictivemoduleid').get('value');
+       data['natenabled'] = dijit.byId('natenabled').get('value');
+       if(data['natenabled'] == 1)
+               data['nathostid'] = dijit.byId('nathostid').get('value');
+       else {
+               data['natenabled'] = 0;
+               data['nathostid'] = 0;
+       }
        data['addmode'] = dijit.byId('mode').get('value');
 
        dijit.byId('addeditbtn').set('disabled', true);
@@ -835,6 +864,8 @@ function saveResourceCB(data, ioArgs) {
                                        resourcegrid.store.setValue(item, 
'predictivemodule', data.items.data.predictivemodule);
                                        resourcegrid.store.setValue(item, 
'location', data.items.data.location);
                                        resourcegrid.store.setValue(item, 
'provisioning', data.items.data.provisioning);
+                                       resourcegrid.store.setValue(item, 
'natenabled', data.items.data.natenabled);
+                                       resourcegrid.store.setValue(item, 
'nathost', data.items.data.nathost);
                                },
                                onComplete: function(items, result) {
                                        // when call resourcegrid.sort 
directly, the table contents disappear; not sure why
@@ -918,6 +949,19 @@ function confirmPredictiveModuleChange()
        confirmAction(data);
 }
 
+function confirmNATchange() {
+       var data = {continuation: dojo.byId('natchangecont').value};
+       if(dijit.byId('newnatenabled').get('value') == 1) {
+               data['natenabled'] = 1;
+               data['nathostid'] = dijit.byId('newnathostid').get('value');
+       }
+       else {
+               data['natenabled'] = 0;
+               data['nathostid'] = 0;
+       }
+       confirmAction(data);
+}
+
 function generateDHCPdata(type) {
        var data = {continuation: dojo.byId(type + 'dhcpcont').value,
                    type: type};


Reply via email to