implemented chassis objects
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Jul 2016 14:27:46 +0000 (17:27 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Jul 2016 14:28:18 +0000 (17:28 +0300)
75 files changed:
ChangeLog
include/netxmsdb.h
include/nms_cscp.h
include/nxcldefs.h
sql/schema.in
src/java/client/META-INF/MANIFEST.MF
src/java/client/netxms-base/src/main/java/org/netxms/base/NXCPCodes.java
src/java/client/netxms-client/src/main/java/org/netxms/client/NXCObjectCreationData.java
src/java/client/netxms-client/src/main/java/org/netxms/client/NXCObjectModificationData.java
src/java/client/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objects/AbstractNode.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objects/AbstractObject.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objects/Chassis.java [new file with mode: 0644]
src/java/client/netxms-client/src/main/java/org/netxms/client/objects/Rack.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objects/RackElement.java [new file with mode: 0644]
src/java/netxms-eclipse/Core/META-INF/MANIFEST.MF
src/java/netxms-eclipse/Core/plugin.xml
src/java/netxms-eclipse/Core/tree [deleted file]
src/java/netxms-eclipse/ObjectBrowser.AdapterFactory/META-INF/MANIFEST.MF
src/java/netxms-eclipse/ObjectBrowser/META-INF/MANIFEST.MF
src/java/netxms-eclipse/ObjectBrowser/icons/chassis.png [new file with mode: 0644]
src/java/netxms-eclipse/ObjectBrowser/src/org/netxms/ui/eclipse/objectbrowser/api/ObjectAdapter.java
src/java/netxms-eclipse/ObjectManager/META-INF/MANIFEST.MF
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle.properties
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle_cs.properties
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle_de.properties
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle_es.properties
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle_fr.properties
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle_pt.properties
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle_ru.properties
src/java/netxms-eclipse/ObjectManager/OSGI-INF/l10n/bundle_zh_CN.properties
src/java/netxms-eclipse/ObjectManager/plugin.xml
src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/actions/CreateChassis.java [new file with mode: 0644]
src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateChassisDialog.java [new file with mode: 0644]
src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateInterfaceDialog.java
src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/propertypages/RackPlacement.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/elements/GeneralInfo.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/widgets/RackWidget.java
src/java/netxms-eclipse/Product/nxmc.product
src/server/core/Makefile.am
src/server/core/chassis.cpp [new file with mode: 0644]
src/server/core/cluster.cpp
src/server/core/netobj.cpp
src/server/core/netsrv.cpp
src/server/core/node.cpp
src/server/core/nxsl_classes.cpp
src/server/core/objects.cpp
src/server/core/session.cpp
src/server/core/syncer.cpp
src/server/include/nms_objects.h
src/server/include/nms_script.h
src/server/libnxsrv/messages.mc
src/server/tools/nxdbmgr/upgrade.cpp
webui/webapp/Core/META-INF/MANIFEST.MF
webui/webapp/Core/build.properties
webui/webapp/ObjectBrowser.AdapterFactory/META-INF/MANIFEST.MF
webui/webapp/ObjectBrowser/META-INF/MANIFEST.MF
webui/webapp/ObjectBrowser/icons/chassis.png [new file with mode: 0644]
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle.properties
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle_cs.properties
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle_de.properties
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle_es.properties
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle_fr.properties
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle_pt.properties
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle_ru.properties
webui/webapp/ObjectManager/OSGI-INF/l10n/bundle_zh_CN.properties
webui/webapp/ObjectManager/plugin.xml
webui/webapp/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/actions/CreateChassis.java [new file with mode: 0644]
webui/webapp/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateChassisDialog.java [new file with mode: 0644]
webui/webapp/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateInterfaceDialog.java
webui/webapp/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/propertypages/RackPlacement.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/elements/GeneralInfo.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/widgets/RackWidget.java
webui/webapp/PolicyManager/src/org/netxms/ui/eclipse/policymanager/actions/EditPolicy.java
webui/webapp/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/widgets/helpers/LogParserRuleEditor.java

index 56da913..629568a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
 *
 - New policy type: Log Parser
 - New server configuration parameter "JobRetryCount"
+- Chassis objects
 - In case of Policy deploy, Policy uninstall or File upload jobs fail they are scheduled for reinstallation(scheduled tasks)  "JobRetryCount" times. First time job is rescheduled in 10 minutes. Each next wait time is twice more than the previous time. 
 - If policy is known as installed on the node by the server and agent reposts that it is not installed it is being reinstalled.
 - Added configuration option to logparser to generate event only if regular expression have been matched exact count of the times in a predefined time period
index e11c070..3e4b872 100644 (file)
@@ -23,6 +23,6 @@
 #ifndef _netxmsdb_h
 #define _netxmsdb_h
 
-#define DB_FORMAT_VERSION   407
+#define DB_FORMAT_VERSION   408
 
 #endif
index 44f85e3..04e6426 100644 (file)
@@ -1126,6 +1126,8 @@ typedef struct
 #define VID_AUTH_TOKEN              ((UINT32)540)
 #define VID_REPOSITORY_ID           ((UINT32)541)
 #define VID_TOOLTIP_DCI_COUNT       ((UINT32)542)
+#define VID_CONTROLLER_ID           ((UINT32)543)
+#define VID_CHASSIS_ID              ((UINT32)544)
 
 // Base variabe for single threshold in message
 #define VID_THRESHOLD_BASE          ((UINT32)0x00800000)
index 65584ba..7661d16 100644 (file)
 #define OBJECT_RACK                  32
 #define OBJECT_ACCESSPOINT           33
 #define OBJECT_AGENTPOLICY_LOGPARSER 34
+#define OBJECT_CHASSIS               35
 
 /** Base value for custom object classes */
-#define OBJECT_CUSTOM               10000
+#define OBJECT_CUSTOM                10000
 
 /**
  * Object's status
index bf98b29..69e3d3e 100644 (file)
@@ -370,6 +370,28 @@ COMMENT_COLUMN(racks.id, 'Rack id form object_properties')
 COMMENT_COLUMN(racks.height, '')
 COMMENT_COLUMN(racks.top_bottom_num, '')
 
+/*
+** Chassis objects
+*/
+CREATE TABLE chassis
+(
+  id integer not null,
+  controller_id integer not null,
+  rack_id integer not null,
+  rack_image varchar(36) null,
+  rack_position integer not null,
+  rack_height integer not null,
+  PRIMARY KEY(id)
+) TABLE_TYPE;
+
+COMMENT_TABLE(chassis, 'Chassis')
+COMMENT_COLUMN(chassis.id, 'Chassis id form object_properties')
+COMMENT_COLUMN(chassis.controller_id, 'Id of node object providing management capabilities for this chassis')
+COMMENT_COLUMN(chassis.rack_id, 'Related rack object ID')
+COMMENT_COLUMN(chassis.rack_image, 'Image to be used in rack view')
+COMMENT_COLUMN(chassis.rack_position, 'Position in rack (in rack units)')
+COMMENT_COLUMN(chassis.rack_height, 'Height in rack (in rack units)')
+
 /*
 ** Nodes information
 */
@@ -412,6 +434,7 @@ CREATE TABLE nodes
   rack_position integer not null,
   rack_height integer not null,
   rack_id integer not null,
+  chassis_id integer not null,
   agent_cache_mode char(1) not null,
   last_agent_comm_time integer not null,
   syslog_msg_count SQL_INT64 not null,
@@ -457,6 +480,7 @@ COMMENT_COLUMN(nodes.rack_image, '')
 COMMENT_COLUMN(nodes.rack_position, '')
 COMMENT_COLUMN(nodes.rack_height, '')
 COMMENT_COLUMN(nodes.rack_id, '')
+COMMENT_COLUMN(nodes.chassis_id, 'ID of chassis object this node belongs to')
 COMMENT_COLUMN(nodes.agent_cache_mode, '')
 COMMENT_COLUMN(nodes.last_agent_comm_time, '')
 COMMENT_COLUMN(nodes.syslog_msg_count, 'Total number of received syslog messages')
index ef6194e..6e5cb7f 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Client Library API plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.clientlibrary;singleton:=true
-Bundle-Version: 2.0.10
+Bundle-Version: 2.1.0
 Bundle-Vendor: netxms.org
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ClassPath: lib/simple-xml-2.6.4.jar,
index fbd0ef7..1536d79 100644 (file)
@@ -914,6 +914,8 @@ public class NXCPCodes
    public static final long VID_AUTH_TOKEN = 540;
    public static final long VID_REPOSITORY_ID = 541;
    public static final long VID_TOOLTIP_DCI_COUNT = 542;
+   public static final long VID_CONTROLLER_ID = 543;
+   public static final long VID_CHASSIS_ID = 544;
 
        public static final long VID_ACL_USER_BASE = 0x00001000L;
        public static final long VID_ACL_USER_LAST = 0x00001FFFL;
index 3e9a9f3..153fa91 100644 (file)
@@ -66,6 +66,8 @@ public class NXCObjectCreationData
        private String deviceId;
        private int height;
        private int flags;
+       private long controllerId;
+       private long chassisId;
        
        /**
         * Constructor.
@@ -610,4 +612,36 @@ public class NXCObjectCreationData
    {
       this.flags = flags;
    }
+
+   /**
+    * @return the controllerId
+    */
+   public long getControllerId()
+   {
+      return controllerId;
+   }
+
+   /**
+    * @param controllerId the controllerId to set
+    */
+   public void setControllerId(long controllerId)
+   {
+      this.controllerId = controllerId;
+   }
+
+   /**
+    * @return the chassisId
+    */
+   public long getChassisId()
+   {
+      return chassisId;
+   }
+
+   /**
+    * @param chassisId the chassisId to set
+    */
+   public void setChassisId(long chassisId)
+   {
+      this.chassisId = chassisId;
+   }
 }
index 5981038..2ac33f3 100644 (file)
@@ -107,6 +107,8 @@ public class NXCObjectModificationData
    public static final long MODIFY_RACK_PLACEMENT     = 0x0400000000000000L;
    public static final long MODIFY_DASHBOARD_LIST     = 0x0800000000000000L;
    public static final long MODIFY_RACK_NUMB_SCHEME   = 0x1000000000000000L;
+   public static final long MODIFY_CONTROLLER_ID      = 0x2000000000000000L;
+   public static final long MODIFY_CHASSIS_ID         = 0x4000000000000000L;
        
        private long flags;             // Flags which indicates what object's data should be modified
        private long objectId;
@@ -192,6 +194,8 @@ public class NXCObjectModificationData
        private short rackHeight;
        private Long[] dashboards;
        private boolean rackNumberingTopBottom;
+       private long controllerId;
+       private long chassisId;
        
        /**
         * Constructor for creating modification data for given object
@@ -1580,4 +1584,38 @@ public class NXCObjectModificationData
       this.rackNumberingTopBottom = rackNumberingTopBottom;
       flags |= MODIFY_RACK_NUMB_SCHEME;
    }
+
+   /**
+    * @return the controllerId
+    */
+   public long getControllerId()
+   {
+      return controllerId;
+   }
+
+   /**
+    * @param controllerId the controllerId to set
+    */
+   public void setControllerId(long controllerId)
+   {
+      this.controllerId = controllerId;
+      flags |= MODIFY_CONTROLLER_ID;
+   }
+
+   /**
+    * @return the chassisId
+    */
+   public long getChassisId()
+   {
+      return chassisId;
+   }
+
+   /**
+    * @param chassisId the chassisId to set
+    */
+   public void setChassisId(long chassisId)
+   {
+      this.chassisId = chassisId;
+      flags |= MODIFY_CHASSIS_ID;
+   }
 }
index 21934ae..ce85f9d 100644 (file)
@@ -116,6 +116,7 @@ import org.netxms.client.objects.AgentPolicyConfig;
 import org.netxms.client.objects.AgentPolicyLogParser;
 import org.netxms.client.objects.BusinessService;
 import org.netxms.client.objects.BusinessServiceRoot;
+import org.netxms.client.objects.Chassis;
 import org.netxms.client.objects.Cluster;
 import org.netxms.client.objects.ClusterResource;
 import org.netxms.client.objects.Condition;
@@ -1083,6 +1084,9 @@ public class NXCSession
          case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
             object = new BusinessServiceRoot(msg, this);
             break;
+         case AbstractObject.OBJECT_CHASSIS:
+            object = new Chassis(msg, this);
+            break;
          case AbstractObject.OBJECT_CLUSTER:
             object = new Cluster(msg, this);
             break;
@@ -4043,14 +4047,30 @@ public class NXCSession
       // Class-specific attributes
       switch(data.getObjectClass())
       {
+         case AbstractObject.OBJECT_CHASSIS:
+            msg.setFieldInt32(NXCPCodes.VID_CONTROLLER_ID, (int)data.getControllerId());
+            break;
+         case AbstractObject.OBJECT_INTERFACE:
+            msg.setField(NXCPCodes.VID_MAC_ADDR, data.getMacAddress().getValue());
+            msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getIpAddress());
+            msg.setFieldInt32(NXCPCodes.VID_IF_TYPE, data.getIfType());
+            msg.setFieldInt32(NXCPCodes.VID_IF_INDEX, data.getIfIndex());
+            msg.setFieldInt32(NXCPCodes.VID_IF_SLOT, data.getSlot());
+            msg.setFieldInt32(NXCPCodes.VID_IF_PORT, data.getPort());
+            msg.setFieldInt16(NXCPCodes.VID_IS_PHYS_PORT, data.isPhysicalPort() ? 1 : 0);
+            break;
+         case AbstractObject.OBJECT_MOBILEDEVICE:
+            msg.setField(NXCPCodes.VID_DEVICE_ID, data.getDeviceId());
+            break;
          case AbstractObject.OBJECT_NODE:
             if (data.getPrimaryName() != null) msg.setField(NXCPCodes.VID_PRIMARY_NAME, data.getPrimaryName());
             msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getIpAddress());
             msg.setFieldInt16(NXCPCodes.VID_AGENT_PORT, data.getAgentPort());
             msg.setFieldInt16(NXCPCodes.VID_SNMP_PORT, data.getSnmpPort());
             msg.setFieldInt32(NXCPCodes.VID_CREATION_FLAGS, data.getCreationFlags());
-            msg.setFieldInt32(NXCPCodes.VID_AGENT_PROXY, (int) data.getAgentProxyId());
-            msg.setFieldInt32(NXCPCodes.VID_SNMP_PROXY, (int) data.getSnmpProxyId());
+            msg.setFieldInt32(NXCPCodes.VID_AGENT_PROXY, (int)data.getAgentProxyId());
+            msg.setFieldInt32(NXCPCodes.VID_SNMP_PROXY, (int)data.getSnmpProxyId());
+            msg.setFieldInt32(NXCPCodes.VID_CHASSIS_ID, (int)data.getChassisId());
             break;
          case AbstractObject.OBJECT_NETWORKMAP:
             msg.setFieldInt16(NXCPCodes.VID_MAP_TYPE, data.getMapType());
@@ -4068,24 +4088,12 @@ public class NXCSession
          case AbstractObject.OBJECT_NODELINK:
             msg.setFieldInt32(NXCPCodes.VID_NODE_ID, (int) data.getLinkedNodeId());
             break;
-         case AbstractObject.OBJECT_SLMCHECK:
-            msg.setFieldInt16(NXCPCodes.VID_IS_TEMPLATE, data.isTemplate() ? 1 : 0);
-            break;
-         case AbstractObject.OBJECT_INTERFACE:
-            msg.setField(NXCPCodes.VID_MAC_ADDR, data.getMacAddress().getValue());
-            msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getIpAddress());
-            msg.setFieldInt32(NXCPCodes.VID_IF_TYPE, data.getIfType());
-            msg.setFieldInt32(NXCPCodes.VID_IF_INDEX, data.getIfIndex());
-            msg.setFieldInt32(NXCPCodes.VID_IF_SLOT, data.getSlot());
-            msg.setFieldInt32(NXCPCodes.VID_IF_PORT, data.getPort());
-            msg.setFieldInt16(NXCPCodes.VID_IS_PHYS_PORT, data.isPhysicalPort() ? 1 : 0);
-            break;
-         case AbstractObject.OBJECT_MOBILEDEVICE:
-            msg.setField(NXCPCodes.VID_DEVICE_ID, data.getDeviceId());
-            break;
          case AbstractObject.OBJECT_RACK:
             msg.setFieldInt16(NXCPCodes.VID_HEIGHT, data.getHeight());
             break;
+         case AbstractObject.OBJECT_SLMCHECK:
+            msg.setFieldInt16(NXCPCodes.VID_IS_TEMPLATE, data.isTemplate() ? 1 : 0);
+            break;
       }
 
       if (userData != null) createCustomObject(data, userData, msg);
@@ -4602,6 +4610,16 @@ public class NXCSession
          msg.setField(NXCPCodes.VID_DASHBOARDS, data.getDashboards());
       }
       
+      if ((flags & NXCObjectModificationData.MODIFY_CHASSIS_ID) != 0)
+      {
+         msg.setFieldInt32(NXCPCodes.VID_CHASSIS_ID, (int)data.getChassisId());
+      }
+      
+      if ((flags & NXCObjectModificationData.MODIFY_CONTROLLER_ID) != 0)
+      {
+         msg.setFieldInt32(NXCPCodes.VID_CONTROLLER_ID, (int)data.getControllerId());
+      }
+      
       modifyCustomObject(data, userData, msg);
 
       sendMessage(msg);
index 0bec3f0..847efe3 100644 (file)
@@ -30,7 +30,7 @@ import org.netxms.client.constants.AgentCacheMode;
 /**
  * Abstract base class for node objects.
  */
-public abstract class AbstractNode extends DataCollectionTarget
+public abstract class AbstractNode extends DataCollectionTarget implements RackElement
 {
        // SNMP versions
        public static final int SNMP_VERSION_1 = 0;
@@ -129,6 +129,7 @@ public abstract class AbstractNode extends DataCollectionTarget
        protected UUID rackImage;
        protected short rackPosition;
        protected short rackHeight;
+   protected long chassisId;
        
        /**
         * Create new node object.
@@ -191,6 +192,7 @@ public abstract class AbstractNode extends DataCollectionTarget
                rackImage = msg.getFieldAsUUID(NXCPCodes.VID_RACK_IMAGE);
                rackPosition = msg.getFieldAsInt16(NXCPCodes.VID_RACK_POSITION);
       rackHeight = msg.getFieldAsInt16(NXCPCodes.VID_RACK_HEIGHT);
+      chassisId = msg.getFieldAsInt64(NXCPCodes.VID_CHASSIS_ID);
                
                long bootTimeSeconds = msg.getFieldAsInt64(NXCPCodes.VID_BOOT_TIME);
                bootTime = (bootTimeSeconds > 0) ? new Date(bootTimeSeconds * 1000) : null;
@@ -617,40 +619,55 @@ public abstract class AbstractNode extends DataCollectionTarget
       return primaryIP;
    }
 
-   /**
-    * @return the rackId
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackId()
     */
+   @Override
    public long getRackId()
    {
       return rackId;
    }
 
-   /**
-    * @return the rackImage
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackImage()
     */
+   @Override
    public UUID getRackImage()
    {
       return rackImage;
    }
 
-   /**
-    * @return the rackPosition
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackPosition()
     */
+   @Override
    public short getRackPosition()
    {
       return rackPosition;
    }
 
-   /**
-    * @return the rackHeight
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackHeight()
     */
+   @Override
    public short getRackHeight()
    {
       return rackHeight;
    }
 
+   /**
+    * @return
+    */
    public Date getLastAgentCommTime()
    {
       return lastAgentCommTime;
    }
+
+   /**
+    * @return the chassisId
+    */
+   public long getChassisId()
+   {
+      return chassisId;
+   }
 }
index 6db8600..67aad13 100644 (file)
@@ -96,6 +96,7 @@ public abstract class AbstractObject
        public static final int OBJECT_RACK = 32;
        public static final int OBJECT_ACCESSPOINT = 33;
        public static final int OBJECT_AGENTPOLICY_LOGPARSER = 34;
+   public static final int OBJECT_CHASSIS = 35;
        public static final int OBJECT_CUSTOM = 10000;
        
        // Status calculation methods
diff --git a/src/java/client/netxms-client/src/main/java/org/netxms/client/objects/Chassis.java b/src/java/client/netxms-client/src/main/java/org/netxms/client/objects/Chassis.java
new file mode 100644 (file)
index 0000000..6cfd946
--- /dev/null
@@ -0,0 +1,103 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.client.objects;
+
+import java.util.UUID;
+import org.netxms.base.NXCPCodes;
+import org.netxms.base.NXCPMessage;
+import org.netxms.client.NXCSession;
+
+/**
+ * Chassis object
+ */
+public class Chassis extends DataCollectionTarget implements RackElement
+{
+   protected long controllerId;
+   protected long rackId;
+   protected UUID rackImage;
+   protected short rackPosition;
+   protected short rackHeight;
+
+   /**
+    * @param msg
+    * @param session
+    */
+   public Chassis(NXCPMessage msg, NXCSession session)
+   {
+      super(msg, session);
+      controllerId = msg.getFieldAsInt64(NXCPCodes.VID_CONTROLLER_ID);
+      rackId = msg.getFieldAsInt64(NXCPCodes.VID_RACK_ID);
+      rackImage = msg.getFieldAsUUID(NXCPCodes.VID_RACK_IMAGE);
+      rackPosition = msg.getFieldAsInt16(NXCPCodes.VID_RACK_POSITION);
+      rackHeight = msg.getFieldAsInt16(NXCPCodes.VID_RACK_HEIGHT);
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.AbstractObject#getObjectClassName()
+    */
+   @Override
+   public String getObjectClassName()
+   {
+      return "Chassis";
+   }
+   
+   /**
+    * @return the controllerId
+    */
+   public long getControllerId()
+   {
+      return controllerId;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackId()
+    */
+   @Override
+   public long getRackId()
+   {
+      return rackId;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackImage()
+    */
+   @Override
+   public UUID getRackImage()
+   {
+      return rackImage;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackPosition()
+    */
+   @Override
+   public short getRackPosition()
+   {
+      return rackPosition;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.client.objects.RackElement#getRackHeight()
+    */
+   @Override
+   public short getRackHeight()
+   {
+      return rackHeight;
+   }
+}
index 155b9dd..e37f1b8 100644 (file)
@@ -93,19 +93,19 @@ public class Rack extends GenericObject
         * 
         * @return
         */
-       public List<AbstractNode> getUnits()
+       public List<RackElement> getUnits()
        {
-          List<AbstractNode> units = new ArrayList<AbstractNode>();
+          List<RackElement> units = new ArrayList<RackElement>();
           for(AbstractObject o : getChildsAsArray())
           {
-             if (o instanceof AbstractNode)
-                units.add((AbstractNode)o);
+             if (o instanceof RackElement)
+                units.add((RackElement)o);
           }
-          Collections.sort(units, new Comparator<AbstractNode>() {
+          Collections.sort(units, new Comparator<RackElement>() {
          @Override
-         public int compare(AbstractNode node1, AbstractNode node2)
+         public int compare(RackElement e1, RackElement e2)
          {
-            return node1.getRackPosition() - node2.getRackPosition();
+            return e1.getRackPosition() - e2.getRackPosition();
          }
       });
           return units;
diff --git a/src/java/client/netxms-client/src/main/java/org/netxms/client/objects/RackElement.java b/src/java/client/netxms-client/src/main/java/org/netxms/client/objects/RackElement.java
new file mode 100644 (file)
index 0000000..1a81c0a
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.client.objects;
+
+import java.util.UUID;
+import org.netxms.client.constants.ObjectStatus;
+
+/**
+ * Common interface for rack elements (anything that can be mounted in rack)
+ */
+public interface RackElement
+{
+   /**
+    * Get object ID
+    * 
+    * @return object ID
+    */
+   public long getObjectId();
+
+   /**
+    * Get object name
+    * 
+    * @return object name
+    */
+   public String getObjectName();
+
+   /**
+    * Get object status
+    * 
+    * @return object status
+    */
+   public ObjectStatus getStatus();
+   
+   /**
+    * Get rack object ID
+    * 
+    * @return rack object ID
+    */
+   public long getRackId();
+
+   /**
+    * Get rack image
+    * 
+    * @return rack image
+    */
+   public UUID getRackImage();
+
+   /**
+    * Get position in rack
+    * 
+    * @return position in rack
+    */
+   public short getRackPosition();
+
+   /**
+    * Get device height in rack units
+    * 
+    * @return device height in rack units
+    */
+   public short getRackHeight();
+}
index 92acfb9..e2f03a2 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-SymbolicName: org.netxms.ui.eclipse.console;singleton:=true
-Bundle-Version: 2.0.10
+Bundle-Version: 2.1.0
 Bundle-Activator: org.netxms.ui.eclipse.console.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="[3.8.2,4.0.0)",
@@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.8.2,4.0.0)",
  org.eclipse.ui.forms;bundle-version="3.5.200",
  org.eclipse.ui.console;bundle-version="3.5.100",
  org.eclipse.jface.text;bundle-version="3.8.2",
- org.netxms.ui.eclipse.clientlibrary;bundle-version="2.0.10",
+ org.netxms.ui.eclipse.clientlibrary;bundle-version="2.1.0",
  org.eclipse.ui.workbench.texteditor;bundle-version="3.8.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
index ec7a3ef..0b4ddda 100644 (file)
@@ -62,7 +62,7 @@
          </property>
          <property
                name="aboutText"
-               value="NetXMS Management Console&#x0A;&#x0A;Version 2.0.3&#x0A;Copyright (c) 2003-2016 Raden Solutions">
+               value="NetXMS Management Console&#x0A;&#x0A;Version 2.1-M1&#x0A;Copyright (c) 2003-2016 Raden Solutions">
          </property>
          <property
                name="startupForegroundColor"
diff --git a/src/java/netxms-eclipse/Core/tree b/src/java/netxms-eclipse/Core/tree
deleted file mode 100644 (file)
index ec2fb21..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-[INFO] Scanning for projects...
-[INFO] Computing target platform for MavenProject: com.netxms.nxmc:org.netxms.ui.eclipse.console:2.0.5 @ /home/zev/work/netxms/src/java/netxms-eclipse/Core/pom.xml
-[INFO] Fetching p2.index from http://download.eclipse.org/tools/gef/updates/milestones/ (0B at 0B/s)
-[INFO] Adding repository http://download.eclipse.org/tools/gef/updates/milestones
-[INFO] Adding repository http://archive.eclipse.org/technology/babel/update-site/R0.12.0/juno
-[INFO] Adding repository http://www.netxms.org/eclipse/zest-rcp
-[INFO] Adding repository http://download.eclipse.org/tm/updates/3.5
-[INFO] Adding repository http://download.eclipse.org/birt/update-site/3.7
-[INFO] Fetching p2.index from http://download.eclipse.org/eclipse/updates/3.8/ (0B at 0B/s)
-[INFO] Adding repository http://download.eclipse.org/eclipse/updates/3.8
-[INFO] Adding repository http://download.eclipse.org/modeling/emf/updates/releases
-[INFO] Resolving dependencies of MavenProject: com.netxms.nxmc:org.netxms.ui.eclipse.console:2.0.5 @ /home/zev/work/netxms/src/java/netxms-eclipse/Core/pom.xml
-[INFO] Fetching R-3.8.2-201301310800&format=xml&countryCode=us&timeZone=2&format=xml from http://www.eclipse.org/downloads/download.php?file=/eclipse/updates/3.8/ (0B at 0B/s)
-[INFO] Fetching org.eclipse.core.runtime_3.8.0.v20120521-2346.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 32.04kB at 0B/s)
-[INFO] Fetching org.eclipse.core.runtime_3.8.0.v20120521-2346.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (30.83kB of 32.04kB at 29.41kB/s)
-[INFO] Fetching org.eclipse.core.commands_3.6.1.v20120912-135020.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 35.63kB at 0B/s)
-[INFO] Fetching org.eclipse.core.expressions_3.4.400.v20120523-2004.jar.pack.gz from http://mirror.netcologne.de/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 29.08kB at 0B/s)
-[INFO] Fetching org.eclipse.core.jobs_3.5.200.v20120521-2346.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 37.59kB at 0B/s)
-[INFO] Fetching org.eclipse.swt_3.8.1.v3836b.jar.pack.gz from http://mirror.netcologne.de/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 16.75kB at 0B/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 321.43kB at 0B/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (30.82kB of 321.43kB at 29.41kB/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (59.11kB of 321.43kB at 28.85kB/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (85.97kB of 321.43kB at 24.42kB/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (142.29kB of 321.43kB at 31.04kB/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (163.75kB of 321.43kB at 30.77kB/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (201.68kB of 321.43kB at 29.7kB/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (238.69kB of 321.43kB at 29.98kB/s)
-[INFO] Fetching org.eclipse.jface_3.8.0.v20120912-135020.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (295.01kB of 321.43kB at 35.07kB/s)
-[INFO] Fetching org.eclipse.ui.workbench_3.8.2.v20121128-133708.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 1.14MB at 0B/s)
-[INFO] Fetching org.eclipse.ui.workbench_3.8.2.v20121128-133708.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (617.7kB of 1.14MB at 579.77kB/s)
-[INFO] Fetching org.eclipse.ui.forms_3.5.200.v20120521-2332.jar.pack.gz from http://mirror.netcologne.de/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 97.12kB at 0B/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_3.8.1.v3836b.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 1.03MB at 0B/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_3.8.1.v3836b.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (381.55kB of 1.03MB at 335.13kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_3.8.1.v3836b.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (879.3kB of 1.03MB at 417.86kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 1.21MB at 0B/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (157.85kB of 1.21MB at 97.28kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (261.31kB of 1.21MB at 96.72kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (364.54kB of 1.21MB at 97.47kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (459.28kB of 1.21MB at 96.08kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (539.88kB of 1.21MB at 94.4kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (585.13kB of 1.21MB at 77.77kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (638.63kB of 1.21MB at 68.44kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (705.09kB of 1.21MB at 63.35kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (805.73kB of 1.21MB at 57.69kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (883.5kB of 1.21MB at 59.39kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (938.65kB of 1.21MB at 65.33kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (1,015.01kB of 1.21MB at 67.59kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (1.08MB of 1.21MB at 70.7kB/s)
-[INFO] Fetching org.eclipse.swt.gtk.linux.x86_64_3.8.1.v3836b.jar.pack.gz from http://download.eclipse.org/eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (1.19MB of 1.21MB at 78.34kB/s)
-[INFO] Fetching org.eclipse.swt.win32.win32.x86_3.8.1.v3836b.jar.pack.gz from http://mirror.netcologne.de/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 1.13MB at 0B/s)
-[INFO] Fetching org.eclipse.swt.win32.win32.x86_3.8.1.v3836b.jar.pack.gz from http://mirror.netcologne.de/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (855.25kB of 1.13MB at 852.43kB/s)
-[INFO] Fetching org.eclipse.swt.win32.win32.x86_64_3.8.1.v3836b.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 1.12MB at 0B/s)
-[INFO] Fetching org.eclipse.swt.win32.win32.x86_64_3.8.1.v3836b.jar.pack.gz from http://ftp.heanet.ie/pub/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (638.91kB of 1.12MB at 615.12kB/s)
-[INFO] Fetching org.eclipse.swt.cocoa.macosx.x86_64_3.8.1.v3836b.jar.pack.gz from http://mirror.netcologne.de/eclipse//eclipse/updates/3.8/R-3.8.2-201301310800/plugins/ (0B of 896.28kB at 0B/s)
-[WARNING] The following locally built units have been used to resolve project dependencies:
-[WARNING]   org.netxms.ui.eclipse.clientlibrary/2.0.6
-[INFO] Resolving class path of MavenProject: com.netxms.nxmc:org.netxms.ui.eclipse.console:2.0.5 @ /home/zev/work/netxms/src/java/netxms-eclipse/Core/pom.xml
-[INFO] 
-[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
-[INFO]                                                                         
-[INFO] ------------------------------------------------------------------------
-[INFO] Building org.netxms.ui.eclipse.console 2.0.5
-[INFO] ------------------------------------------------------------------------
-[INFO] 
-[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ org.netxms.ui.eclipse.console ---
-[INFO] com.netxms.nxmc:org.netxms.ui.eclipse.console:eclipse-plugin:2.0.5
-[INFO] +- p2.eclipse-plugin:org.eclipse.osgi:jar:3.8.2.v20130124-134944:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.compare.core:jar:3.5.200.v20120522-1148:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.runtime:jar:3.8.0.v20120521-2346:system
-[INFO] +- p2.eclipse-plugin:com.ibm.icu.base:jar:4.4.2.v20110831:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.equinox.common:jar:3.6.100.v20120522-1841:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.commands:jar:3.6.1.v20120912-135020:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.contenttype:jar:3.4.200.v20120523-2004:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.equinox.preferences:jar:3.5.1.v20121031-182809:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.equinox.registry:jar:3.5.200.v20120522-1841:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.databinding.observable:jar:1.4.1.v20120521-2332:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.databinding.property:jar:1.4.100.v20120523-1956:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.databinding:jar:1.4.1.v20120912-135020:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.expressions:jar:3.4.400.v20120523-2004:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.filesystem:jar:1.3.200.v20130115-145044:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.jobs:jar:3.5.200.v20120521-2346:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.resources:jar:3.8.1.v20121114-124432:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.equinox.app:jar:1.3.100.v20120522-1841:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.core.variables:jar:3.2.600.v20120521-2012:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.help:jar:3.6.0.v20120912-134126:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.swt:jar:3.8.1.v3836b:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.jface:jar:3.8.0.v20120912-135020:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.jface.databinding:jar:1.6.0.v20120912-135020:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.text:jar:3.5.200.v20120523-1310:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.jface.text:jar:3.8.2.v20121126-164145:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.tm.terminal:jar:3.2.100.201305201712:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.ui:jar:3.8.2.v20121018-234953:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.ui.workbench:jar:3.8.2.v20121128-133708:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.ui.console:jar:3.5.100.v20120521-2012:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.ui.workbench.texteditor:jar:3.8.0.v20120523-1310:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.ui.forms:jar:3.5.200.v20120521-2332:system
-[INFO] +- p2.eclipse-plugin:org.netxms.ui.eclipse.clientlibrary:jar:lib/simple-xml-2.6.4.jar:2.0.6:system
-[INFO] +- p2.eclipse-plugin:org.netxms.ui.eclipse.clientlibrary:jar:2.0.6:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.swt.gtk.linux.x86:jar:3.8.1.v3836b:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.swt.gtk.linux.x86_64:jar:3.8.1.v3836b:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.swt.win32.win32.x86:jar:3.8.1.v3836b:system
-[INFO] +- p2.eclipse-plugin:org.eclipse.swt.win32.win32.x86_64:jar:3.8.1.v3836b:system
-[INFO] \- p2.eclipse-plugin:org.eclipse.swt.cocoa.macosx.x86_64:jar:3.8.1.v3836b:system
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESS
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 01:24 min
-[INFO] Finished at: 2015-07-14T16:58:24+02:00
-[INFO] Final Memory: 190M/550M
-[INFO] ------------------------------------------------------------------------
index f22a90b..ae19437 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Adapter Factory for Object Browser Plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.objectbrowser.adapterfactory;singleton:=true
-Bundle-Version: 1.2.14
+Bundle-Version: 2.1.0
 Bundle-Vendor: netxms.org
-Fragment-Host: org.netxms.ui.eclipse.objectbrowser;bundle-version="1.2.14"
+Fragment-Host: org.netxms.ui.eclipse.objectbrowser;bundle-version="2.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
index b5cdc3d..d098734 100644 (file)
@@ -2,14 +2,14 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NXMC Object Browser Plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.objectbrowser;singleton:=true
-Bundle-Version: 2.0.7
+Bundle-Version: 2.1.0
 Bundle-Activator: org.netxms.ui.eclipse.objectbrowser.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="3.8.2",
  org.eclipse.core.runtime;bundle-version="3.8.0",
- org.netxms.ui.eclipse.console;bundle-version="2.0.7",
+ org.netxms.ui.eclipse.console;bundle-version="2.1.0",
  org.eclipse.core.expressions;bundle-version="3.4.300",
- org.netxms.ui.eclipse.clientlibrary;bundle-version="2.0.7"
+ org.netxms.ui.eclipse.clientlibrary;bundle-version="2.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Export-Package: org.netxms.ui.eclipse.objectbrowser.api,
diff --git a/src/java/netxms-eclipse/ObjectBrowser/icons/chassis.png b/src/java/netxms-eclipse/ObjectBrowser/icons/chassis.png
new file mode 100644 (file)
index 0000000..30050eb
Binary files /dev/null and b/src/java/netxms-eclipse/ObjectBrowser/icons/chassis.png differ
index 8ac3911..43aa181 100644 (file)
@@ -54,65 +54,67 @@ public class ObjectAdapter implements IWorkbenchAdapter
                
                switch(((AbstractObject)object).getObjectClass())
                {
+         case AbstractObject.OBJECT_ACCESSPOINT:
+            return Activator.getImageDescriptor("icons/access_point.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_AGENTPOLICY:
+         case AbstractObject.OBJECT_AGENTPOLICY_CONFIG:
+         case AbstractObject.OBJECT_AGENTPOLICY_LOGPARSER:
+            return Activator.getImageDescriptor("icons/policy.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_BUSINESSSERVICE:
+         case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
+            return Activator.getImageDescriptor("icons/business_service.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_CHASSIS:
+            return Activator.getImageDescriptor("icons/chassis.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_CLUSTER:
+            return Activator.getImageDescriptor("icons/cluster.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_CONDITION:
+            return Activator.getImageDescriptor("icons/condition.gif"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_CONTAINER:
+            return Activator.getImageDescriptor("icons/container.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_DASHBOARD:
+            return Activator.getImageDescriptor("icons/dashboard.gif"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_DASHBOARDROOT:
+            return Activator.getImageDescriptor("icons/dashboard_root.gif"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_INTERFACE:
+            return Activator.getImageDescriptor("icons/interface.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_MOBILEDEVICE:
+            return Activator.getImageDescriptor("icons/mobile_device.png"); //$NON-NLS-1$
                        case AbstractObject.OBJECT_NETWORK:
                                return Activator.getImageDescriptor("icons/network.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_NETWORKMAP:
+            return Activator.getImageDescriptor("icons/netmap.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_NETWORKMAPGROUP:
+            return Activator.getImageDescriptor("icons/netmap_group.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_NETWORKMAPROOT:
+            return Activator.getImageDescriptor("icons/netmap_root.gif"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_NETWORKSERVICE:
+            return Activator.getImageDescriptor("icons/network_service.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_NODE:
+            return Activator.getImageDescriptor("icons/node.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_NODELINK:
+            return Activator.getImageDescriptor("icons/node_link.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_POLICYGROUP:
+            return Activator.getImageDescriptor("icons/policy_group.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_POLICYROOT:
+            return Activator.getImageDescriptor("icons/policy_root.gif"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_RACK:
+            return Activator.getImageDescriptor("icons/rack.gif"); //$NON-NLS-1$
                        case AbstractObject.OBJECT_SERVICEROOT:
                                return Activator.getImageDescriptor("icons/service_root.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_CONTAINER:
-                               return Activator.getImageDescriptor("icons/container.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_RACK:
-                               return Activator.getImageDescriptor("icons/rack.gif"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_ZONE:
-                               return Activator.getImageDescriptor("icons/zone.gif"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_SUBNET:
-                               return Activator.getImageDescriptor("icons/subnet.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_CLUSTER:
-                               return Activator.getImageDescriptor("icons/cluster.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_NODE:
-                               return Activator.getImageDescriptor("icons/node.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_ACCESSPOINT:
-                               return Activator.getImageDescriptor("icons/access_point.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_INTERFACE:
-                               return Activator.getImageDescriptor("icons/interface.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_NETWORKSERVICE:
-                               return Activator.getImageDescriptor("icons/network_service.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_MOBILEDEVICE:
-                               return Activator.getImageDescriptor("icons/mobile_device.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_CONDITION:
-                               return Activator.getImageDescriptor("icons/condition.gif"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_SLMCHECK:
+            return Activator.getImageDescriptor(((ServiceCheck)object).isTemplate() ? "icons/service_check_template.gif" : "icons/service_check.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+         case AbstractObject.OBJECT_SUBNET:
+            return Activator.getImageDescriptor("icons/subnet.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_TEMPLATE:
+            return Activator.getImageDescriptor("icons/template.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_TEMPLATEGROUP:
+            return Activator.getImageDescriptor("icons/template_group.png"); //$NON-NLS-1$
                        case AbstractObject.OBJECT_TEMPLATEROOT:
                                return Activator.getImageDescriptor("icons/template_root.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_TEMPLATEGROUP:
-                               return Activator.getImageDescriptor("icons/template_group.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_TEMPLATE:
-                               return Activator.getImageDescriptor("icons/template.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_POLICYROOT:
-                               return Activator.getImageDescriptor("icons/policy_root.gif"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_POLICYGROUP:
-                               return Activator.getImageDescriptor("icons/policy_group.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_AGENTPOLICY:
-                       case AbstractObject.OBJECT_AGENTPOLICY_CONFIG:
-                       case AbstractObject.OBJECT_AGENTPOLICY_LOGPARSER:
-                               return Activator.getImageDescriptor("icons/policy.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_NETWORKMAP:
-                               return Activator.getImageDescriptor("icons/netmap.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_NETWORKMAPGROUP:
-                               return Activator.getImageDescriptor("icons/netmap_group.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_NETWORKMAPROOT:
-                               return Activator.getImageDescriptor("icons/netmap_root.gif"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_DASHBOARD:
-                               return Activator.getImageDescriptor("icons/dashboard.gif"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_DASHBOARDROOT:
-                               return Activator.getImageDescriptor("icons/dashboard_root.gif"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
-                       case AbstractObject.OBJECT_BUSINESSSERVICE:
-                               return Activator.getImageDescriptor("icons/business_service.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_NODELINK:
-                               return Activator.getImageDescriptor("icons/node_link.png"); //$NON-NLS-1$
-                       case AbstractObject.OBJECT_SLMCHECK:
-                               return Activator.getImageDescriptor(((ServiceCheck)object).isTemplate() ? "icons/service_check_template.gif" : "icons/service_check.gif"); //$NON-NLS-1$ //$NON-NLS-2$
          case AbstractObject.OBJECT_VPNCONNECTOR:
             return Activator.getImageDescriptor("icons/vpn.png"); //$NON-NLS-1$
+         case AbstractObject.OBJECT_ZONE:
+            return Activator.getImageDescriptor("icons/zone.gif"); //$NON-NLS-1$
                        default:
                                return SharedIcons.UNKNOWN_OBJECT;
                }
index fc41a67..c29d9f7 100644 (file)
@@ -2,15 +2,15 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NXMC Basic Object Management Plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.objectmanager;singleton:=true
-Bundle-Version: 2.0.7
+Bundle-Version: 2.1.0
 Bundle-Activator: org.netxms.ui.eclipse.objectmanager.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="3.8.2",
  org.eclipse.core.runtime;bundle-version="3.8.0",
- org.netxms.ui.eclipse.clientlibrary;bundle-version="2.0.10",
+ org.netxms.ui.eclipse.clientlibrary;bundle-version="2.1.0",
  org.netxms.ui.eclipse.objectbrowser;bundle-version="2.0.7",
  org.netxms.ui.eclipse.usermanager;bundle-version="2.0.8",
- org.netxms.ui.eclipse.console;bundle-version="2.0.10",
+ org.netxms.ui.eclipse.console;bundle-version="2.1.0",
  org.netxms.ui.eclipse.nxsl;bundle-version="2.0.7",
  org.netxms.ui.eclipse.imagelibrary;bundle-version="2.0.0",
  org.netxms.ui.eclipse.datacollection;bundle-version="2.0.7",
index e57c40c..4a7af79 100644 (file)
@@ -6,6 +6,7 @@ action.label.ChangeExpState = Change interface e&xpected state...
 action.label.ChangeZone = Change zone...
 action.label.ConfPoll = &Configuration
 action.label.ConfPollFull = &Configuration (full)
+action.label.CreateChassis = C&hassis...
 action.label.CreateCluster = Cl&uster...
 action.label.CreateCond = Con&dition...
 action.label.CreateContainer = &Container...
index 4a4a718..273bcdf 100644 (file)
@@ -5,6 +5,7 @@ action.label.ChangeExpState=Zm\u011bnit po&\u017eadovan\u00fd stav rozhran\u00ed
 action.label.ChangeZone=Zm\u011bnit z\u00f3nu...
 action.label.ConfPoll=&Konfigurace
 action.label.ConfPollFull=&Konfigurace (pln\u011b)
+action.label.CreateChassis=C&hassis...
 action.label.CreateCluster=&Cluster...
 action.label.CreateCond=P&odm\u00ednku...
 action.label.CreateContainer=&Kontejner...
index 18fda49..158693e 100644 (file)
@@ -2,11 +2,12 @@ action.label.AddNode= &Add node...
 action.label.Bind= Bind...
 action.label.BindTo=Bind to...
 action.label.ChangeExpState= Change interface e&xpected state...
-action.label.ChangeZone= Change zone...
-action.label.ConfPoll= &Configuration
-action.label.ConfPollFull= &Configuration (full)
-action.label.CreateCluster = Cl&uster...
-action.label.CreateCond = Con&dition...
+action.label.ChangeZone=Change zone...
+action.label.ConfPoll=&Configuration
+action.label.ConfPollFull=&Configuration (full)
+action.label.CreateChassis=C&hassis...
+action.label.CreateCluster=Cl&uster...
+action.label.CreateCond=Con&dition...
 action.label.CreateContainer = &Container...
 action.label.CreateIface = &Interface...
 action.label.CreateMobile = &Mobile device...
index 3d9b55c..cbdf9b4 100644 (file)
@@ -5,8 +5,9 @@ action.label.ChangeExpState=Change interface e&xpected state...
 action.label.ChangeZone=Change zone...
 action.label.ConfPoll=&Configuration
 action.label.ConfPollFull=&Configuration (full)
-action.label.CreateCluster = Cl&uster...
-action.label.CreateCond = Con&dition...
+action.label.CreateChassis=C&hassis...
+action.label.CreateCluster=Cl&uster...
+action.label.CreateCond=Con&dition...
 action.label.CreateContainer = &Container...
 action.label.CreateIface = &Interface...
 action.label.CreateMobile = &Mobile device...
index f53e0a6..ad222e3 100644 (file)
@@ -1,12 +1,13 @@
-action.label.AddNode= &Add node...
-action.label.Bind= Bind...
-action.label.BindTo= Bind to...
-action.label.ChangeExpState= Change interface e&xpected state...
-action.label.ChangeZone= Change zone...
-action.label.ConfPoll= &Configuration
-action.label.ConfPollFull= &Configuration (full)
-action.label.CreateCluster = Cl&uster...
-action.label.CreateCond = Con&dition...
+action.label.AddNode=&Add node...
+action.label.Bind=Bind...
+action.label.BindTo=Bind to...
+action.label.ChangeExpState=Change interface e&xpected state...
+action.label.ChangeZone=Change zone...
+action.label.ConfPoll=&Configuration
+action.label.ConfPollFull=&Configuration (full)
+action.label.CreateChassis=C&hassis...
+action.label.CreateCluster=Cl&uster...
+action.label.CreateCond=Con&dition...
 action.label.CreateContainer = &Container...
 action.label.CreateIface = &Interface...
 action.label.CreateMobile = &Mobile device...
index 8bdf542..a6116e3 100644 (file)
@@ -5,6 +5,7 @@ action.label.ChangeExpState= Change interface e&xpected state...
 action.label.ChangeZone= Change zone...
 action.label.ConfPoll= &Configuration
 action.label.ConfPollFull= &Configuration (full)
+action.label.CreateChassis = C&hassis...
 action.label.CreateCluster = Cl&uster...
 action.label.CreateCond = Con&dition...
 action.label.CreateContainer = &Container...
index e976092..5fea232 100644 (file)
@@ -5,6 +5,7 @@ action.label.ChangeExpState=\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0
 action.label.ChangeZone=\u0421\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u043e\u043d\u0443...
 action.label.ConfPoll=&\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430
 action.label.ConfPollFull=&\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 (\u043f\u043e\u043b\u043d\u044b\u0439)
+action.label.CreateChassis=&\u0428\u0430\u0441\u0441\u0438...
 action.label.CreateCluster=\u041a&\u043b\u0430\u0441\u0442\u0435\u0440...
 action.label.CreateCond=\u0423&\u0441\u043b\u043e\u0432\u0438\u0435...
 action.label.CreateContainer=&\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440...
index 4554d3f..90c5f2b 100644 (file)
@@ -5,6 +5,7 @@ action.label.ChangeExpState=Change interface e&xpected state...
 action.label.ChangeZone=Change zone...
 action.label.ConfPoll=&Configuration
 action.label.ConfPollFull=&Configuration (full)
+action.label.CreateChassis = C&hassis...
 action.label.CreateCluster = Cl&uster...
 action.label.CreateCond = Con&dition...
 action.label.CreateContainer = &Container...
index dcdb9fe..4d50bcf 100644 (file)
               name="%page.name.Rack">
            <enabledWhen>
               <instanceof
-                    value="org.netxms.client.objects.AbstractNode">
+                    value="org.netxms.client.objects.RackElement">
               </instanceof>
            </enabledWhen>
         </page>
                menubarPath="objectbinding">
          </action>
          <action
-               class="org.netxms.ui.eclipse.objectmanager.actions.CreateCluster"
+               class="org.netxms.ui.eclipse.objectmanager.actions.CreateRack"
                enablesFor="1"
-               id="org.netxms.ui.eclipse.objectmanager.popupActions.createCluster_Container"
-               label="%action.label.CreateCluster"
-               menubarPath="CreateObjectSubmenu/additions"
-               state="false">
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.createRack_Container"
+               label="%action.label.CreateRack"
+               menubarPath="CreateObjectSubmenu/additions">
          </action>
          <action
                class="org.netxms.ui.eclipse.objectmanager.actions.CreateNode"
                label="%action.label.CreateContainer"
                menubarPath="CreateObjectSubmenu/additions">
          </action>
-         <action
-               class="org.netxms.ui.eclipse.objectmanager.actions.CreateRack"
-               enablesFor="1"
-               id="org.netxms.ui.eclipse.objectmanager.popupActions.createRack_Container"
-               label="%action.label.CreateRack"
-               menubarPath="CreateObjectSubmenu/additions">
-         </action>
          <action
                class="org.netxms.ui.eclipse.objectmanager.actions.CreateCondition"
                enablesFor="1"
                label="%action.label.CreateCond"
                menubarPath="CreateObjectSubmenu/additions">
          </action>
+         <action
+               class="org.netxms.ui.eclipse.objectmanager.actions.CreateCluster"
+               enablesFor="1"
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.createCluster_Container"
+               label="%action.label.CreateCluster"
+               menubarPath="CreateObjectSubmenu/additions"
+               state="false">
+         </action>
+         <action
+               class="org.netxms.ui.eclipse.objectmanager.actions.CreateChassis"
+               enablesFor="1"
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.createChassis_Container"
+               label="%action.label.CreateChassis"
+               menubarPath="CreateObjectSubmenu/additions"
+               state="false">
+         </action>
       </objectContribution>
 
       <objectContribution
                menubarPath="objectbinding">
          </action>
          <action
-               class="org.netxms.ui.eclipse.objectmanager.actions.CreateCluster"
+               class="org.netxms.ui.eclipse.objectmanager.actions.CreateRack"
                enablesFor="1"
-               id="org.netxms.ui.eclipse.objectmanager.popupActions.createCluster_ServiceRoot"
-               label="%action.label.CreateCluster"
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.createRack_ServiceRoot"
+               label="%action.label.CreateRack"
                menubarPath="CreateObjectSubmenu/additions">
          </action>
          <action
                menubarPath="CreateObjectSubmenu/additions">
          </action>
          <action
-               class="org.netxms.ui.eclipse.objectmanager.actions.CreateRack"
+               class="org.netxms.ui.eclipse.objectmanager.actions.CreateCondition"
                enablesFor="1"
-               id="org.netxms.ui.eclipse.objectmanager.popupActions.createRack_ServiceRoot"
-               label="%action.label.CreateRack"
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.createCondition_ServiceRoot"
+               label="%action.label.CreateCond"
                menubarPath="CreateObjectSubmenu/additions">
          </action>
          <action
-               class="org.netxms.ui.eclipse.objectmanager.actions.CreateCondition"
+               class="org.netxms.ui.eclipse.objectmanager.actions.CreateCluster"
                enablesFor="1"
-               id="org.netxms.ui.eclipse.objectmanager.popupActions.createCondition_ServiceRoot"
-               label="%action.label.CreateCond"
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.createCluster_ServiceRoot"
+               label="%action.label.CreateCluster"
+               menubarPath="CreateObjectSubmenu/additions">
+         </action>
+         <action
+               class="org.netxms.ui.eclipse.objectmanager.actions.CreateChassis"
+               enablesFor="1"
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.createChassis_ServiceRoot"
+               label="%action.label.CreateChassis"
                menubarPath="CreateObjectSubmenu/additions">
          </action>
       </objectContribution>
       <objectContribution
             id="org.netxms.ui.eclipse.objectmanager.actions.popup.object.Node"
             objectClass="org.netxms.client.objects.Node">
+         <action
+               class="org.netxms.ui.eclipse.objectmanager.actions.BindObjectTo"
+               enablesFor="+"
+               id="org.netxms.ui.eclipse.objectmanager.popupActions.BindObjectTo_Node"
+               label="%action.label.BindTo"
+               menubarPath="objectbinding">
+         </action>
          <action
                class="org.netxms.ui.eclipse.objectmanager.actions.ChangeZone"
                enablesFor="1"
                label="%action.label.CreateIface"
                menubarPath="CreateObjectSubmenu/additions">
          </action>
-         <action
-               class="org.netxms.ui.eclipse.objectmanager.actions.BindObjectTo"
-               enablesFor="+"
-               id="org.netxms.ui.eclipse.objectmanager.popupActions.BindObjectTo_Node"
-               label="%action.label.BindTo"
-               menubarPath="objectbinding">
-         </action>
       </objectContribution>
 
 
diff --git a/src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/actions/CreateChassis.java b/src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/actions/CreateChassis.java
new file mode 100644 (file)
index 0000000..151ea2f
--- /dev/null
@@ -0,0 +1,116 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.objectmanager.actions;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.netxms.client.NXCObjectCreationData;
+import org.netxms.client.NXCSession;
+import org.netxms.client.objects.AbstractObject;
+import org.netxms.client.objects.Container;
+import org.netxms.client.objects.ServiceRoot;
+import org.netxms.ui.eclipse.jobs.ConsoleJob;
+import org.netxms.ui.eclipse.objectmanager.Activator;
+import org.netxms.ui.eclipse.objectmanager.dialogs.CreateChassisDialog;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+
+/**
+ * Create chassis object
+ */
+public class CreateChassis implements IObjectActionDelegate
+{
+       private IWorkbenchWindow window;
+       private IWorkbenchPart part;
+       private long parentId = -1;
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+        */
+       @Override
+       public void setActivePart(IAction action, IWorkbenchPart targetPart)
+       {
+               part = targetPart;
+               window = targetPart.getSite().getWorkbenchWindow();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       @Override
+       public void run(IAction action)
+       {
+          CreateChassisDialog dlg = null;
+          do
+          {
+               dlg = new CreateChassisDialog(window.getShell(), dlg);
+               if (dlg.open() != Window.OK)
+                       return;
+               
+         final NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_CHASSIS, dlg.getObjectName(), parentId);
+         cd.setControllerId(dlg.getControllerId());
+               
+               final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
+               new ConsoleJob("Creating chassis", part, Activator.PLUGIN_ID, null) {
+                       @Override
+                       protected void runInternal(IProgressMonitor monitor) throws Exception
+                       {
+                               session.createObject(cd);
+                       }
+   
+                       @Override
+                       protected String getErrorMessage()
+                       {
+                               return String.format("Cannot create chassis object %s", cd.getName());
+                       }
+               }.start();
+          } while(dlg.isShowAgain());
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+        */
+       @Override
+       public void selectionChanged(IAction action, ISelection selection)
+       {
+               if ((selection instanceof IStructuredSelection) && (((IStructuredSelection)selection).size() == 1))
+               {
+                       final Object object = ((IStructuredSelection)selection).getFirstElement();
+                       if ((object instanceof Container) || (object instanceof ServiceRoot))
+                       {
+                               parentId = ((AbstractObject)object).getObjectId();
+                       }
+                       else
+                       {
+                               parentId = -1;
+                       }
+               }
+               else
+               {
+                       parentId = -1;
+               }
+
+               action.setEnabled(parentId != -1);
+       }
+}
diff --git a/src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateChassisDialog.java b/src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateChassisDialog.java
new file mode 100644 (file)
index 0000000..710db28
--- /dev/null
@@ -0,0 +1,167 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.objectmanager.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.netxms.client.objects.Node;
+import org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector;
+import org.netxms.ui.eclipse.tools.MessageDialogHelper;
+import org.netxms.ui.eclipse.tools.WidgetHelper;
+import org.netxms.ui.eclipse.widgets.LabeledText;
+
+/**
+ * Dialog for creating new chassis
+ */
+public class CreateChassisDialog extends Dialog
+{
+       private LabeledText objectNameField;
+       private ObjectSelector controllerSelector;
+       private Button checkCreateAnother;
+       
+       private String objectName;
+       private long controllerId = 0;
+       private boolean showAgain = false;
+       
+       /**
+        * @param parentShell
+        */
+       public CreateChassisDialog(Shell parentShell, CreateChassisDialog prev)
+       {
+               super(parentShell);
+               if (prev != null)
+               {
+                  controllerId = prev.controllerId;
+                  showAgain = prev.showAgain;
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell)
+       {
+               super.configureShell(newShell);
+               newShell.setText("Create Chassis");
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent)
+       {
+               Composite dialogArea = (Composite)super.createDialogArea(parent);
+               
+               GridLayout layout = new GridLayout();
+               layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
+               layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
+               layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
+               layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
+               layout.numColumns = 2;
+               dialogArea.setLayout(layout);
+               
+               objectNameField = new LabeledText(dialogArea, SWT.NONE);
+               objectNameField.setLabel("Name");
+               objectNameField.getTextControl().setTextLimit(255);
+               GridData gd = new GridData();
+               gd.horizontalAlignment = SWT.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.widthHint = 300;
+               gd.horizontalSpan = 2;
+               objectNameField.setLayoutData(gd);
+               
+               final Composite ipAddrGroup = new Composite(dialogArea, SWT.NONE);
+               layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 2;
+               ipAddrGroup.setLayout(layout);
+               gd = new GridData();
+               gd.horizontalAlignment = SWT.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.horizontalSpan = 2;
+               ipAddrGroup.setLayoutData(gd);
+               
+               controllerSelector = new ObjectSelector(dialogArea, SWT.NONE, true);
+               controllerSelector.setLabel("Controller");
+               controllerSelector.setObjectClass(Node.class);
+               controllerSelector.setObjectId(controllerId);
+               gd = new GridData();
+               gd.horizontalAlignment = SWT.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.horizontalSpan = 2;
+               controllerSelector.setLayoutData(gd);
+               
+               checkCreateAnother = new Button(dialogArea, SWT.CHECK);
+               checkCreateAnother.setText("Show this dialog again to &create another chassis");
+               checkCreateAnother.setSelection(showAgain);
+               
+               return dialogArea;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+        */
+       @Override
+       protected void okPressed()
+       {
+               objectName = objectNameField.getText().trim();
+      if (objectName.isEmpty())
+      {
+         MessageDialogHelper.openWarning(getShell(), "Warning", "Please provide non-empty object name");
+         return;
+      }
+      
+               controllerId = controllerSelector.getObjectId();
+               showAgain = checkCreateAnother.getSelection();
+               super.okPressed();
+       }
+
+       /**
+        * @return the name
+        */
+       public String getObjectName()
+       {
+               return objectName;
+       }
+
+   /**
+    * @return the controllerId
+    */
+   public long getControllerId()
+   {
+      return controllerId;
+   }
+
+   /**
+    * @return the showAgain
+    */
+   public boolean isShowAgain()
+   {
+      return showAgain;
+   }
+}
index 1efca0d..ea1d7c2 100644 (file)
@@ -210,6 +210,11 @@ public class CreateInterfaceDialog extends Dialog
                }
        }
        
+       /**
+        * @param mask
+        * @param maxBits
+        * @return
+        */
        private int getMaskBits(String mask, int maxBits)
        {
           if (mask.isEmpty())
index c68fec9..e16aa48 100644 (file)
@@ -28,8 +28,8 @@ import org.eclipse.ui.dialogs.PropertyPage;
 import org.netxms.base.NXCommon;
 import org.netxms.client.NXCObjectModificationData;
 import org.netxms.client.NXCSession;
-import org.netxms.client.objects.AbstractNode;
 import org.netxms.client.objects.Rack;
+import org.netxms.client.objects.RackElement;
 import org.netxms.ui.eclipse.imagelibrary.widgets.ImageSelector;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector;
@@ -44,7 +44,7 @@ import org.netxms.ui.eclipse.widgets.LabeledSpinner;
  */
 public class RackPlacement extends PropertyPage
 {
-       private AbstractNode node;
+       private RackElement object;
        private ObjectSelector rackSelector;
        private ImageSelector rackImageSelector;
        private LabeledSpinner rackHeight;
@@ -58,7 +58,7 @@ public class RackPlacement extends PropertyPage
        {
                Composite dialogArea = new Composite(parent, SWT.NONE);
                
-               node = (AbstractNode)getElement().getAdapter(AbstractNode.class);
+               object = (RackElement)getElement().getAdapter(RackElement.class);
 
                GridLayout layout = new GridLayout();
                layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
@@ -70,7 +70,7 @@ public class RackPlacement extends PropertyPage
       rackSelector = new ObjectSelector(dialogArea, SWT.NONE, true);
       rackSelector.setLabel(Messages.get().RackPlacement_Rack);
       rackSelector.setObjectClass(Rack.class);
-      rackSelector.setObjectId(node.getRackId());
+      rackSelector.setObjectId(object.getRackId());
                GridData gd = new GridData();
                gd.grabExcessHorizontalSpace = true;
                gd.horizontalAlignment = SWT.FILL;
@@ -79,7 +79,7 @@ public class RackPlacement extends PropertyPage
                
                rackImageSelector = new ImageSelector(dialogArea, SWT.NONE);
                rackImageSelector.setLabel(Messages.get().RackPlacement_RackImage);
-               rackImageSelector.setImageGuid(node.getRackImage(), false);
+               rackImageSelector.setImageGuid(object.getRackImage(), false);
       gd = new GridData();
       gd.grabExcessHorizontalSpace = true;
       gd.horizontalAlignment = SWT.FILL;
@@ -89,7 +89,7 @@ public class RackPlacement extends PropertyPage
       rackPosition = new LabeledSpinner(dialogArea, SWT.NONE);
       rackPosition.setLabel(Messages.get().RackPlacement_Position);
       rackPosition.setRange(1, 50);
-      rackPosition.setSelection(node.getRackPosition());
+      rackPosition.setSelection(object.getRackPosition());
       gd = new GridData();
       gd.grabExcessHorizontalSpace = true;
       gd.horizontalAlignment = SWT.FILL;
@@ -98,7 +98,7 @@ public class RackPlacement extends PropertyPage
       rackHeight = new LabeledSpinner(dialogArea, SWT.NONE);
       rackHeight.setLabel(Messages.get().RackPlacement_Height);
       rackHeight.setRange(1, 50);
-      rackHeight.setSelection(node.getRackHeight());
+      rackHeight.setSelection(object.getRackHeight());
       gd = new GridData();
       gd.grabExcessHorizontalSpace = true;
       gd.horizontalAlignment = SWT.FILL;
@@ -117,11 +117,11 @@ public class RackPlacement extends PropertyPage
                if (isApply)
                        setValid(false);
                
-               final NXCObjectModificationData md = new NXCObjectModificationData(node.getObjectId());
+               final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
                md.setRackPlacement(rackSelector.getObjectId(), rackImageSelector.getImageGuid(), (short)rackPosition.getSelection(), (short)rackHeight.getSelection());
                
                final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
-               new ConsoleJob(String.format(Messages.get().RackPlacement_UpdatingRackPlacement, node.getObjectName()), null, Activator.PLUGIN_ID, null) {
+               new ConsoleJob(String.format(Messages.get().RackPlacement_UpdatingRackPlacement, object.getObjectName()), null, Activator.PLUGIN_ID, null) {
                        @Override
                        protected void runInternal(IProgressMonitor monitor) throws Exception
                        {
index dd6205c..516874f 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2015 Victor Kirhenshtein
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@ import org.netxms.client.NXCSession;
 import org.netxms.client.objects.AbstractNode;
 import org.netxms.client.objects.AbstractObject;
 import org.netxms.client.objects.AccessPoint;
+import org.netxms.client.objects.Chassis;
 import org.netxms.client.objects.Interface;
 import org.netxms.client.objects.MobileDevice;
 import org.netxms.client.objects.Node;
@@ -77,6 +78,27 @@ public class GeneralInfo extends TableElement
                   addPair(Messages.get().GeneralInfo_Status, StatusDisplayInfo.getStatusText(object.getStatus()));
                switch(object.getObjectClass())
                {
+         case AbstractObject.OBJECT_CHASSIS:
+            Chassis chassis = (Chassis)object;
+            if (chassis.getControllerId() != 0)
+            {
+               AbstractNode node = session.findObjectById(chassis.getControllerId(), AbstractNode.class);
+               if (node != null)
+               {
+                  addPair("Controller", node.getObjectName());
+               }
+            }
+            if (chassis.getRackId() != 0)
+            {
+               Rack rack = session.findObjectById(chassis.getRackId(), Rack.class);
+               if (rack != null)
+               {
+                  addPair(Messages.get().GeneralInfo_Rack, String.format(Messages.get().GeneralInfo_Units, rack.getObjectName(),
+                          rack.isTopBottomNumbering() ? chassis.getRackPosition() : chassis.getRackPosition() - chassis.getRackHeight() + 1,
+                          rack.isTopBottomNumbering() ? chassis.getRackPosition() + chassis.getRackHeight() - 1 : chassis.getRackPosition()));
+               }
+            }
+            break;
                        case AbstractObject.OBJECT_INTERFACE:
                                Interface iface = (Interface)object;
                                addPair(Messages.get().GeneralInfo_IfIndex, Integer.toString(iface.getIfIndex()));
index 873be2c..cad9a19 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2015 Victor Kirhenshtein
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -44,7 +44,9 @@ import org.netxms.base.NXCommon;
 import org.netxms.client.datacollection.DciValue;
 import org.netxms.client.objects.AbstractNode;
 import org.netxms.client.objects.AbstractObject;
+import org.netxms.client.objects.DataCollectionTarget;
 import org.netxms.client.objects.Rack;
+import org.netxms.client.objects.RackElement;
 import org.netxms.ui.eclipse.console.resources.SharedColors;
 import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
 import org.netxms.ui.eclipse.imagelibrary.shared.ImageProvider;
@@ -200,8 +202,8 @@ public class RackWidget extends Canvas implements PaintListener, DisposeListener
       
       // Draw units
       objects.clear();
-      List<AbstractNode> units = rack.getUnits();
-      for(AbstractNode n : units)
+      List<RackElement> units = rack.getUnits();
+      for(RackElement n : units)
       {
          if ((n.getRackPosition() < 1) || (n.getRackPosition() > rack.getHeight()) || 
              (rack.isTopBottomNumbering() && (n.getRackPosition() + n.getRackHeight() > rack.getHeight() + 1)) ||
@@ -307,14 +309,17 @@ public class RackWidget extends Canvas implements PaintListener, DisposeListener
       int height = OBJECT_TOOLTIP_Y_MARGIN * 2 + titleSize.y + 2 + OBJECT_TOOLTIP_SPACING;
       
       List<String> texts = new ArrayList<String>();
-      texts.add(((AbstractNode)tooltipObject).getPrimaryIP().getHostAddress());
-      texts.add(((AbstractNode)tooltipObject).getPlatformName());
-      String sd = ((AbstractNode)tooltipObject).getSystemDescription();
-      if (sd.length() > 127)
-         sd = sd.substring(0, 127) + "...";
-      texts.add(sd);
-      texts.add(((AbstractNode)tooltipObject).getSnmpSysName());
-      texts.add(((AbstractNode)tooltipObject).getSnmpSysContact());
+      if (tooltipObject instanceof AbstractNode)
+      {
+         texts.add(((AbstractNode)tooltipObject).getPrimaryIP().getHostAddress());
+         texts.add(((AbstractNode)tooltipObject).getPlatformName());
+         String sd = ((AbstractNode)tooltipObject).getSystemDescription();
+         if (sd.length() > 127)
+            sd = sd.substring(0, 127) + "...";
+         texts.add(sd);
+         texts.add(((AbstractNode)tooltipObject).getSnmpSysName());
+         texts.add(((AbstractNode)tooltipObject).getSnmpSysContact());
+      }
       
       for(String s : texts)
       {
@@ -327,7 +332,7 @@ public class RackWidget extends Canvas implements PaintListener, DisposeListener
          height += pt.y;
       }
       
-      List<DciValue> values = ((AbstractNode)tooltipObject).getTooltipDciData();
+      List<DciValue> values = ((DataCollectionTarget)tooltipObject).getTooltipDciData();
       if (!values.isEmpty())
       {
          for(DciValue v : values)
@@ -470,10 +475,10 @@ public class RackWidget extends Canvas implements PaintListener, DisposeListener
    public void imageUpdated(UUID guid)
    {
       boolean found = false;
-      List<AbstractNode> units = rack.getUnits();
-      for(AbstractNode n : units)
+      List<RackElement> units = rack.getUnits();
+      for(RackElement e : units)
       {
-         if (guid.equals(n.getRackImage()))
+         if (guid.equals(e.getRackImage()))
          {
             found = true;
             break;
@@ -502,7 +507,7 @@ public class RackWidget extends Canvas implements PaintListener, DisposeListener
       for(ObjectImage i : objects)
          if (i.contains(p))
          {
-            return i.getObject();
+            return (AbstractObject)i.getObject();
          }
       return null;
    }
@@ -629,10 +634,10 @@ public class RackWidget extends Canvas implements PaintListener, DisposeListener
     */
    private class ObjectImage
    {
-      private AbstractObject object;
+      private RackElement object;
       private Rectangle rect;
 
-      public ObjectImage(AbstractObject object, Rectangle rect)
+      public ObjectImage(RackElement object, Rectangle rect)
       {
          this.object = object;
          this.rect = new Rectangle(rect.x, rect.y, rect.width, rect.height);
@@ -643,7 +648,7 @@ public class RackWidget extends Canvas implements PaintListener, DisposeListener
          return rect.contains(p);
       }
       
-      public AbstractObject getObject()
+      public RackElement getObject()
       {
          return object;
       }
index 22086af..3e433c2 100644 (file)
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?pde version="3.5"?>
 
-<product name="%product.name" uid="org.netxms.ui.eclipse.console.product" id="org.netxms.ui.eclipse.console.product" application="org.netxms.ui.eclipse.console.application" version="2.0.3" useFeatures="false" includeLaunchers="true">
+<product name="%product.name" uid="org.netxms.ui.eclipse.console.product" id="org.netxms.ui.eclipse.console.product" application="org.netxms.ui.eclipse.console.application" version="2.1.0" useFeatures="false" includeLaunchers="true">
 
    <aboutInfo>
       <image path="/Core/icons/about.png"/>
       <text>
          NetXMS Management Console
 
-Version 2.0.3
+Version 2.1-M1
 Copyright (c) 2003-2016 Raden Solutions
       </text>
    </aboutInfo>
@@ -38,6 +38,7 @@ Copyright (c) 2003-2016 Raden Solutions
       </win>
    </launcher>
 
+
    <vm>
    </vm>
 
index 0fabfda..982ed9b 100644 (file)
@@ -5,7 +5,7 @@ libnxcore_la_SOURCES =  accesspoint.cpp acl.cpp actions.cpp addrlist.cpp \
                        admin.cpp agent.cpp agent_policy.cpp alarm.cpp audit.cpp \
                        ap_config.cpp ap_jobs.cpp ap_logparser.cpp beacon.cpp bizservice.cpp \
                        bizsvcroot.cpp bridge.cpp cas_validator.cpp ccy.cpp cdp.cpp \
-                       cert.cpp client.cpp cluster.cpp columnfilter.cpp \
+                       cert.cpp chassis.cpp client.cpp cluster.cpp columnfilter.cpp \
                        components.cpp condition.cpp config.cpp console.cpp \
                        container.cpp correlate.cpp dashboard.cpp datacoll.cpp dbwrite.cpp \
                        dc_nxsl.cpp dcitem.cpp dcithreshold.cpp dcivalue.cpp \
diff --git a/src/server/core/chassis.cpp b/src/server/core/chassis.cpp
new file mode 100644 (file)
index 0000000..bd3e5b6
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+** NetXMS - Network Management System
+** Copyright (C) 2003-2016 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: chassis.cpp
+**
+**/
+
+#include "nxcore.h"
+
+/**
+ * Default constructor
+ */
+Chassis::Chassis() : DataCollectionTarget()
+{
+   m_controllerId = 0;
+   m_rackId = 0;
+   m_rackPosition = 0;
+   m_rackHeight = 1;
+}
+
+/**
+ * Create new chassis object
+ */
+Chassis::Chassis(const TCHAR *name, UINT32 controllerId) : DataCollectionTarget(name)
+{
+   m_controllerId = controllerId;
+   m_rackId = 0;
+   m_rackPosition = 0;
+   m_rackHeight = 1;
+}
+
+/**
+ * Destructor
+ */
+Chassis::~Chassis()
+{
+}
+
+/**
+ * Called by client session handler to check if threshold summary should be shown for this object.
+ */
+bool Chassis::showThresholdSummary()
+{
+   return true;
+}
+
+/**
+ * Update rack binding
+ */
+void Chassis::updateRackBinding()
+{
+   bool rackFound = false;
+   ObjectArray<NetObj> deleteList(16, 16, false);
+
+   lockParentList(true);
+   for(int i = 0; i < m_parentList->size(); i++)
+   {
+      NetObj *object = m_parentList->get(i);
+      if (object->getObjectClass() != OBJECT_RACK)
+         continue;
+      if (object->getId() == m_rackId)
+      {
+         rackFound = true;
+         continue;
+      }
+      object->incRefCount();
+      deleteList.add(object);
+   }
+   unlockParentList();
+
+   for(int n = 0; n < deleteList.size(); n++)
+   {
+      NetObj *rack = deleteList.get(n);
+      DbgPrintf(5, _T("Chassis::updateRackBinding(%s [%d]): delete incorrect rack binding %s [%d]"), m_name, m_id, rack->getName(), rack->getId());
+      rack->deleteChild(this);
+      deleteParent(rack);
+      rack->decRefCount();
+   }
+
+   if (!rackFound && (m_rackId != 0))
+   {
+      Rack *rack = (Rack *)FindObjectById(m_rackId, OBJECT_RACK);
+      if (rack != NULL)
+      {
+         DbgPrintf(5, _T("Chassis::updateRackBinding(%s [%d]): add rack binding %s [%d]"), m_name, m_id, rack->getName(), rack->getId());
+         rack->addChild(this);
+         addParent(rack);
+      }
+      else
+      {
+         DbgPrintf(5, _T("Chassis::updateRackBinding(%s [%d]): rack object [%d] not found"), m_name, m_id, m_rackId);
+      }
+   }
+}
+
+/**
+ * Create NXCP message with object's data
+ */
+void Chassis::fillMessageInternal(NXCPMessage *msg)
+{
+   DataCollectionTarget::fillMessageInternal(msg);
+   msg->setField(VID_CONTROLLER_ID, m_controllerId);
+   msg->setField(VID_RACK_ID, m_rackId);
+   msg->setField(VID_RACK_IMAGE, m_rackImage);
+   msg->setField(VID_RACK_POSITION, m_rackPosition);
+   msg->setField(VID_RACK_HEIGHT, m_rackHeight);
+}
+
+/**
+ * Modify object from NXCP message
+ */
+UINT32 Chassis::modifyFromMessageInternal(NXCPMessage *request)
+{
+   if (request->isFieldExist(VID_CONTROLLER_ID))
+      m_controllerId = request->getFieldAsUInt32(VID_CONTROLLER_ID);
+   if (request->isFieldExist(VID_RACK_ID))
+   {
+      m_rackId = request->getFieldAsUInt32(VID_RACK_ID);
+      updateRackBinding();
+   }
+   if (request->isFieldExist(VID_RACK_IMAGE))
+      m_rackImage = request->getFieldAsGUID(VID_RACK_IMAGE);
+   if (request->isFieldExist(VID_RACK_POSITION))
+      m_rackPosition = request->getFieldAsInt16(VID_RACK_POSITION);
+   if (request->isFieldExist(VID_RACK_HEIGHT))
+      m_rackHeight = request->getFieldAsInt16(VID_RACK_HEIGHT);
+
+   return DataCollectionTarget::modifyFromMessageInternal(request);
+}
+
+/**
+ * Save to database
+ */
+BOOL Chassis::saveToDatabase(DB_HANDLE hdb)
+{
+   lockProperties();
+   bool success = saveCommonProperties(hdb);
+   if (success)
+   {
+      DB_STATEMENT hStmt;
+      if (IsDatabaseRecordExist(hdb, _T("chassis"), _T("id"), m_id))
+         hStmt = DBPrepare(hdb, _T("UPDATE chassis SET controller_id=?,rack_id=?,rack_image=?,rack_position=?,rack_height=? WHERE id=?"));
+      else
+         hStmt = DBPrepare(hdb, _T("INSERT INTO chassis (controller_id,rack_id,rack_image,rack_position,rack_height,id) VALUES (?,?,?,?,?,?)"));
+      if (hStmt != NULL)
+      {
+         DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, m_controllerId);
+         DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, m_rackId);
+         DBBind(hStmt, 3, DB_SQLTYPE_VARCHAR, m_rackImage);
+         DBBind(hStmt, 4, DB_SQLTYPE_INTEGER, m_rackPosition);
+         DBBind(hStmt, 5, DB_SQLTYPE_INTEGER, m_rackHeight);
+         DBBind(hStmt, 6, DB_SQLTYPE_INTEGER, m_id);
+         success = DBExecute(hStmt);
+         DBFreeStatement(hStmt);
+      }
+      else
+      {
+         success = false;
+      }
+   }
+   unlockProperties();
+   return success;
+}
+
+/**
+ * Delete from database
+ */
+bool Chassis::deleteFromDatabase(DB_HANDLE hdb)
+{
+   bool success = DataCollectionTarget::deleteFromDatabase(hdb);
+   if (success)
+   {
+      success = executeQueryOnObject(hdb, _T("DELETE FROM chassis WHERE id=?"));
+   }
+   return success;
+}
+
+/**
+ * Load from database
+ */
+bool Chassis::loadFromDatabase(DB_HANDLE hdb, UINT32 id)
+{
+   m_id = id;
+   if (!loadCommonProperties(hdb))
+   {
+      nxlog_debug(2, _T("Cannot load common properties for chassis object %d"), id);
+      return false;
+   }
+
+   DB_STATEMENT hStmt = DBPrepare(hdb, _T("SELECT controller_id,rack_id,rack_image,rack_position,rack_height FROM chassis WHERE id=?"));
+   if (hStmt == NULL)
+      return false;
+
+   DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, id);
+   DB_RESULT hResult = DBSelectPrepared(hStmt);
+   if (hResult == NULL)
+   {
+      DBFreeStatement(hStmt);
+      return false;
+   }
+
+   m_controllerId = DBGetFieldULong(hResult, 0, 0);
+   m_rackId = DBGetFieldULong(hResult, 0, 1);
+   m_rackImage = DBGetFieldGUID(hResult, 0, 2);
+   m_rackPosition = DBGetFieldULong(hResult, 0, 3);
+   m_rackHeight = DBGetFieldULong(hResult, 0, 4);
+
+   DBFreeResult(hResult);
+   DBFreeStatement(hStmt);
+
+   updateRackBinding();
+   return true;
+}
+
+/**
+ * Unbind cluster from template
+ */
+void Chassis::unbindFromTemplate(UINT32 dwTemplateId, bool removeDCI)
+{
+   DataCollectionTarget::unbindFromTemplate(dwTemplateId, removeDCI);
+   queueUpdate();
+}
+
+/**
+ * Called when data collection configuration changed
+ */
+void Chassis::onDataCollectionChange()
+{
+   queueUpdate();
+}
+
+/**
+ * Create NXSL object for this object
+ */
+NXSL_Value *Chassis::createNXSLObject()
+{
+   return new NXSL_Value(new NXSL_Object(&g_nxslChassisClass, this));
+}
index 0b20841..d0c8ee8 100644 (file)
@@ -72,10 +72,9 @@ bool Cluster::loadFromDatabase(DB_HANDLE hdb, UINT32 dwId)
        int i, nRows;
 
    m_id = dwId;
-
    if (!loadCommonProperties(hdb))
    {
-      DbgPrintf(2, _T("Cannot load common properties for cluster object %d"), dwId);
+      nxlog_debug(2, _T("Cannot load common properties for cluster object %d"), dwId);
       return false;
    }
 
index 6d5f9fd..cc7b9aa 100644 (file)
@@ -36,7 +36,8 @@ static const TCHAR *s_className[]=
       _T("NetworkMapGroup"), _T("NetworkMap"), _T("DashboardRoot"),
       _T("Dashboard"), _T("ReportRoot"), _T("ReportGroup"), _T("Report"),
       _T("BusinessServiceRoot"), _T("BusinessService"), _T("NodeLink"),
-      _T("ServiceCheck"), _T("MobileDevice"), _T("Rack"), _T("AccessPoint")
+      _T("ServiceCheck"), _T("MobileDevice"), _T("Rack"), _T("AccessPoint"),
+      _T("AgentPolicyLogParser"), _T("Chassis")
    };
 
 /**
@@ -115,6 +116,14 @@ const TCHAR *NetObj::getObjectClassName() const
    return ((c >= 0) && (c < sizeof(s_className) / sizeof(const TCHAR *))) ? s_className[c] : _T("Custom");
 }
 
+/**
+ * Get class name for given class ID
+ */
+const TCHAR *NetObj::getObjectClassName(int objectClass)
+{
+   return ((objectClass >= 0) && (objectClass < sizeof(s_className) / sizeof(const TCHAR *))) ? s_className[objectClass] : _T("Custom");
+}
+
 /**
  * Create object from database data
  */
@@ -391,7 +400,7 @@ bool NetObj::saveCommonProperties(DB_HANDLE hdb)
                     _T("VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"));
        }
        if (hStmt == NULL)
-               return FALSE;
+               return false;
 
    TCHAR szTranslation[16], szThresholds[16], lat[32], lon[32];
    for(int i = 0, j = 0; i < 4; i++, j += 2)
@@ -1563,7 +1572,7 @@ void NetObj::prepareForDeletion()
 void NetObj::setComments(TCHAR *text)
 {
    lockProperties();
-   safe_free(m_comments);
+   free(m_comments);
    m_comments = text;
    setModified();
    unlockProperties();
index f91d3d6..1025804 100644 (file)
@@ -68,8 +68,8 @@ NetworkService::NetworkService(int iServiceType, WORD wProto, WORD wPort,
  */
 NetworkService::~NetworkService()
 {
-   safe_free(m_request);
-   safe_free(m_response);
+   free(m_request);
+   free(m_response);
 }
 
 /**
index 2238e73..b0c7d1c 100644 (file)
@@ -112,6 +112,7 @@ Node::Node() : DataCollectionTarget()
        m_rackId = 0;
        m_rackPosition = 0;
        m_rackHeight = 1;
+       m_chassisId = 0;
        m_syslogMessageCount = 0;
        m_snmpTrapCount = 0;
 }
@@ -203,6 +204,7 @@ Node::Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 sn
    m_rackId = 0;
    m_rackPosition = 0;
    m_rackHeight = 1;
+   m_chassisId = 0;
    m_syslogMessageCount = 0;
    m_snmpTrapCount = 0;
 }
@@ -422,7 +424,8 @@ bool Node::loadFromDatabase(DB_HANDLE hdb, UINT32 dwId)
          }
       }
 
-      updateRackBinding();
+      updatePhysicalContainerBinding(OBJECT_RACK, m_rackId);
+      updatePhysicalContainerBinding(OBJECT_CHASSIS, m_chassisId);
    }
    else
    {
@@ -4625,7 +4628,7 @@ UINT32 Node::getTableForClient(const TCHAR *name, Table **table)
 }
 
 /**
- * Create CSCP message with object's data
+ * Create NXCP message with object's data
  */
 void Node::fillMessageInternal(NXCPMessage *pMsg)
 {
@@ -4909,7 +4912,7 @@ UINT32 Node::modifyFromMessageInternal(NXCPMessage *pRequest)
    if (pRequest->isFieldExist(VID_RACK_ID))
    {
       m_rackId = pRequest->getFieldAsUInt32(VID_RACK_ID);
-      updateRackBinding();
+      updatePhysicalContainerBinding(OBJECT_RACK, m_rackId);
    }
    if (pRequest->isFieldExist(VID_RACK_IMAGE))
       m_rackImage = pRequest->getFieldAsGUID(VID_RACK_IMAGE);
@@ -4918,6 +4921,13 @@ UINT32 Node::modifyFromMessageInternal(NXCPMessage *pRequest)
    if (pRequest->isFieldExist(VID_RACK_HEIGHT))
       m_rackHeight = pRequest->getFieldAsInt16(VID_RACK_HEIGHT);
 
+   // Chassis
+   if (pRequest->isFieldExist(VID_CHASSIS_ID))
+   {
+      m_rackId = pRequest->getFieldAsUInt32(VID_CHASSIS_ID);
+      updatePhysicalContainerBinding(OBJECT_CHASSIS, m_chassisId);
+   }
+
    return DataCollectionTarget::modifyFromMessageInternal(pRequest);
 }
 
@@ -7636,22 +7646,22 @@ void Node::forceSyncDataCollectionConfig(Node *node)
 }
 
 /**
- * Update rack binding
+ * Update physical container (rack or chassis) binding
  */
-void Node::updateRackBinding()
+void Node::updatePhysicalContainerBinding(int containerClass, UINT32 containerId)
 {
-   bool rackFound = false;
+   bool containerFound = false;
    ObjectArray<NetObj> deleteList(16, 16, false);
 
    lockParentList(true);
    for(int i = 0; i < m_parentList->size(); i++)
    {
       NetObj *object = m_parentList->get(i);
-      if (object->getObjectClass() != OBJECT_RACK)
+      if (object->getObjectClass() != containerClass)
          continue;
-      if (object->getId() == m_rackId)
+      if (object->getId() == containerId)
       {
-         rackFound = true;
+         containerFound = true;
          continue;
       }
       object->incRefCount();
@@ -7661,25 +7671,26 @@ void Node::updateRackBinding()
 
    for(int n = 0; n < deleteList.size(); n++)
    {
-      NetObj *rack = deleteList.get(n);
-      DbgPrintf(5, _T("Node::updateRackBinding(%s [%d]): delete incorrect rack binding %s [%d]"), m_name, m_id, rack->getName(), rack->getId());
-      rack->deleteChild(this);
-      deleteParent(rack);
-      rack->decRefCount();
+      NetObj *container = deleteList.get(n);
+      nxlog_debug(5, _T("Node::updatePhysicalContainerBinding(%s [%d]): delete incorrect binding %s [%d]"), m_name, m_id, container->getName(), container->getId());
+      container->deleteChild(this);
+      deleteParent(container);
+      container->decRefCount();
    }
 
-   if (!rackFound && (m_rackId != 0))
+   if (!containerFound && (containerId != 0))
    {
-      Rack *rack = (Rack *)FindObjectById(m_rackId, OBJECT_RACK);
-      if (rack != NULL)
+      NetObj *container = FindObjectById(containerId, containerClass);
+      if (container != NULL)
       {
-         DbgPrintf(5, _T("Node::updateRackBinding(%s [%d]): add rack binding %s [%d]"), m_name, m_id, rack->getName(), rack->getId());
-         rack->addChild(this);
-         addParent(rack);
+         nxlog_debug(5, _T("Node::updatePhysicalContainerBinding(%s [%d]): add binding %s [%d]"), m_name, m_id, container->getName(), container->getId());
+         container->addChild(this);
+         addParent(container);
       }
       else
       {
-         DbgPrintf(5, _T("Node::updateRackBinding(%s [%d]): rack object [%d] not found"), m_name, m_id, m_rackId);
+         nxlog_debug(5, _T("Node::updatePhysicalContainerBinding(%s [%d]): object [%d] of class %d (%s) not found"),
+                     m_name, m_id, containerId, containerClass, NetObj::getObjectClassName(containerClass));
       }
    }
 }
index 18c7c8b..bfc50d2 100644 (file)
@@ -424,6 +424,30 @@ NXSL_Value *NXSL_NodeClass::getAttr(NXSL_Object *object, const TCHAR *attr)
    {
       value = new NXSL_Value(node->getPlatformName());
    }
+   else if (!_tcscmp(attr, _T("rack")))
+   {
+      Rack *rack = (Rack *)FindObjectById(node->getRackId(), OBJECT_RACK);
+      if (rack != NULL)
+      {
+         value = rack->createNXSLObject();
+      }
+      else
+      {
+         value = new NXSL_Value;
+      }
+   }
+   else if (!_tcscmp(attr, _T("rackId")))
+   {
+      value = new NXSL_Value(node->getRackId());
+   }
+   else if (!_tcscmp(attr, _T("rackHeight")))
+   {
+      value = new NXSL_Value(node->getRackHeight());
+   }
+   else if (!_tcscmp(attr, _T("rackPosition")))
+   {
+      value = new NXSL_Value(node->getRackPosition());
+   }
    else if (!_tcscmp(attr, _T("runtimeFlags")))
    {
       value = new NXSL_Value(node->getRuntimeFlags());
@@ -789,6 +813,67 @@ NXSL_Value *NXSL_MobileDeviceClass::getAttr(NXSL_Object *object, const TCHAR *at
    return value;
 }
 
+/**
+ * NXSL class "Chassis" constructor
+ */
+NXSL_ChassisClass::NXSL_ChassisClass() : NXSL_NetObjClass()
+{
+   _tcscpy(m_name, _T("Chassis"));
+}
+
+/**
+ * NXSL class "Cluster" attributes
+ */
+NXSL_Value *NXSL_ChassisClass::getAttr(NXSL_Object *object, const TCHAR *attr)
+{
+   NXSL_Value *value = NXSL_NetObjClass::getAttr(object, attr);
+   if (value != NULL)
+      return value;
+
+   Chassis *chassis = (Chassis *)object->getData();
+   if (!_tcscmp(attr, _T("controller")))
+   {
+      Node *node = (Node *)FindObjectById(chassis->getControllerId(), OBJECT_NODE);
+      if (node != NULL)
+      {
+         value = node->createNXSLObject();
+      }
+      else
+      {
+         value = new NXSL_Value;
+      }
+   }
+   else if (!_tcscmp(attr, _T("controllerId")))
+   {
+      value = new NXSL_Value(chassis->getControllerId());
+   }
+   else if (!_tcscmp(attr, _T("rack")))
+   {
+      Rack *rack = (Rack *)FindObjectById(chassis->getRackId(), OBJECT_RACK);
+      if (rack != NULL)
+      {
+         value = rack->createNXSLObject();
+      }
+      else
+      {
+         value = new NXSL_Value;
+      }
+   }
+   else if (!_tcscmp(attr, _T("rackId")))
+   {
+      value = new NXSL_Value(chassis->getRackId());
+   }
+   else if (!_tcscmp(attr, _T("rackHeight")))
+   {
+      value = new NXSL_Value(chassis->getRackHeight());
+   }
+   else if (!_tcscmp(attr, _T("rackPosition")))
+   {
+      value = new NXSL_Value(chassis->getRackPosition());
+   }
+   return value;
+}
+
 /**
  * NXSL class "Cluster" constructor
  */
@@ -814,7 +899,7 @@ NXSL_Value *NXSL_ClusterClass::getAttr(NXSL_Object *object, const TCHAR *attr)
          Zone *zone = FindZoneByGUID(cluster->getZoneId());
          if (zone != NULL)
          {
-            value = new NXSL_Value(new NXSL_Object(&g_nxslZoneClass, zone));
+            value = zone->createNXSLObject();
          }
          else
          {
@@ -1290,10 +1375,11 @@ void NXSL_SNMPVarBindClass::onObjectDelete(NXSL_Object *object)
  * Class objects
  */
 NXSL_AlarmClass g_nxslAlarmClass;
+NXSL_ChassisClass g_nxslChassisClass;
+NXSL_ClusterClass g_nxslClusterClass;
 NXSL_DciClass g_nxslDciClass;
 NXSL_EventClass g_nxslEventClass;
 NXSL_InterfaceClass g_nxslInterfaceClass;
-NXSL_ClusterClass g_nxslClusterClass;
 NXSL_MobileDeviceClass g_nxslMobileDeviceClass;
 NXSL_NetObjClass g_nxslNetObjClass;
 NXSL_NodeClass g_nxslNodeClass;
index acc49b8..6f97ff6 100644 (file)
@@ -323,6 +323,7 @@ void NetObjInsert(NetObj *pObject, bool newObject, bool importedObject)
                        case OBJECT_POLICYROOT:
                        case OBJECT_AGENTPOLICY:
                        case OBJECT_AGENTPOLICY_CONFIG:
+         case OBJECT_AGENTPOLICY_LOGPARSER:
                        case OBJECT_NETWORKMAPROOT:
                        case OBJECT_NETWORKMAPGROUP:
                        case OBJECT_DASHBOARDROOT:
@@ -331,6 +332,7 @@ void NetObjInsert(NetObj *pObject, bool newObject, bool importedObject)
                        case OBJECT_BUSINESSSERVICE:
                        case OBJECT_NODELINK:
                        case OBJECT_RACK:
+                       case OBJECT_CHASSIS:
             break;
          case OBJECT_NODE:
                                g_idxNodeById.put(pObject->getId(), pObject);
@@ -1120,12 +1122,6 @@ static void LinkChildObjectsCallback(NetObj *object, void *data)
  */
 BOOL LoadObjects()
 {
-   DB_RESULT hResult;
-   UINT32 i, dwNumRows;
-   UINT32 dwId;
-   Template *pTemplate;
-   TCHAR szQuery[256];
-
    // Prevent objects to change it's modification flag
    g_bModificationsLocked = TRUE;
 
@@ -1155,15 +1151,15 @@ BOOL LoadObjects()
       NetObjInsert(pZone, false, false);
       g_pEntireNet->AddZone(pZone);
 
-      hResult = DBSelect(hdb, _T("SELECT id FROM zones WHERE id<>4"));
-      if (hResult != 0)
+      DB_RESULT hResult = DBSelect(hdb, _T("SELECT id FROM zones WHERE id<>4"));
+      if (hResult != NULL)
       {
-         dwNumRows = DBGetNumRows(hResult);
-         for(i = 0; i < dwNumRows; i++)
+         int count = DBGetNumRows(hResult);
+         for(int i = 0; i < count; i++)
          {
-            dwId = DBGetFieldULong(hResult, i, 0);
+            UINT32 id = DBGetFieldULong(hResult, i, 0);
             pZone = new Zone;
-            if (pZone->loadFromDatabase(hdb, dwId))
+            if (pZone->loadFromDatabase(hdb, id))
             {
                if (!pZone->isDeleted())
                   g_pEntireNet->AddZone(pZone);
@@ -1172,7 +1168,7 @@ BOOL LoadObjects()
             else     // Object load failed
             {
                delete pZone;
-               nxlog_write(MSG_ZONE_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+               nxlog_write(MSG_ZONE_LOAD_FAILED, NXLOG_ERROR, "d", id);
             }
          }
          DBFreeResult(hResult);
@@ -1183,24 +1179,22 @@ BOOL LoadObjects()
    // We should load conditions before nodes because
    // DCI cache size calculation uses information from condition objects
    DbgPrintf(2, _T("Loading conditions..."));
-   hResult = DBSelect(hdb, _T("SELECT id FROM conditions"));
+   DB_RESULT hResult = DBSelect(hdb, _T("SELECT id FROM conditions"));
    if (hResult != NULL)
    {
-      Condition *pCondition;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pCondition = new Condition;
-         if (pCondition->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Condition *condition = new Condition;
+         if (condition->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pCondition, false, false);  // Insert into indexes
+            NetObjInsert(condition, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pCondition;
-            nxlog_write(MSG_CONDITION_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete condition;
+            nxlog_write(MSG_CONDITION_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1209,38 +1203,36 @@ BOOL LoadObjects()
    // Load subnets
    DbgPrintf(2, _T("Loading subnets..."));
    hResult = DBSelect(hdb, _T("SELECT id FROM subnets"));
-   if (hResult != 0)
+   if (hResult != NULL)
    {
-      Subnet *pSubnet;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pSubnet = new Subnet;
-         if (pSubnet->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Subnet *subnet = new Subnet;
+         if (subnet->loadFromDatabase(hdb, id))
          {
-            if (!pSubnet->isDeleted())
+            if (!subnet->isDeleted())
             {
                if (g_flags & AF_ENABLE_ZONING)
                {
                   Zone *pZone;
 
-                  pZone = FindZoneByGUID(pSubnet->getZoneId());
+                  pZone = FindZoneByGUID(subnet->getZoneId());
                   if (pZone != NULL)
-                     pZone->addSubnet(pSubnet);
+                     pZone->addSubnet(subnet);
                }
                else
                {
-                  g_pEntireNet->AddSubnet(pSubnet);
+                  g_pEntireNet->AddSubnet(subnet);
                }
             }
-            NetObjInsert(pSubnet, false, false);  // Insert into indexes
+            NetObjInsert(subnet, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pSubnet;
-            nxlog_write(MSG_SUBNET_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete subnet;
+            nxlog_write(MSG_SUBNET_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1249,48 +1241,67 @@ BOOL LoadObjects()
    // Load racks
    DbgPrintf(2, _T("Loading racks..."));
    hResult = DBSelect(hdb, _T("SELECT id FROM racks"));
-   if (hResult != 0)
+   if (hResult != NULL)
    {
-      Rack *rack;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         rack = new Rack;
-         if (rack->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Rack *rack = new Rack;
+         if (rack->loadFromDatabase(hdb, id))
          {
             NetObjInsert(rack, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            nxlog_write(MSG_RACK_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            nxlog_write(MSG_RACK_LOAD_FAILED, NXLOG_ERROR, "d", id);
             delete rack;
          }
       }
       DBFreeResult(hResult);
    }
 
+   // Load chassis
+   DbgPrintf(2, _T("Loading chassis..."));
+   hResult = DBSelect(hdb, _T("SELECT id FROM chassis"));
+   if (hResult != NULL)
+   {
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
+      {
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Chassis *chassis = new Chassis;
+         if (chassis->loadFromDatabase(hdb, id))
+         {
+            NetObjInsert(chassis, false, false);  // Insert into indexes
+         }
+         else     // Object load failed
+         {
+            nxlog_write(MSG_CHASSIS_LOAD_FAILED, NXLOG_ERROR, "d", id);
+            delete chassis;
+         }
+      }
+      DBFreeResult(hResult);
+   }
+
    // Load mobile devices
    DbgPrintf(2, _T("Loading mobile devices..."));
    hResult = DBSelect(hdb, _T("SELECT id FROM mobile_devices"));
-   if (hResult != 0)
+   if (hResult != NULL)
    {
-      MobileDevice *md;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         md = new MobileDevice;
-         if (md->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         MobileDevice *md = new MobileDevice;
+         if (md->loadFromDatabase(hdb, id))
          {
             NetObjInsert(md, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
             delete md;
-            nxlog_write(MSG_MOBILEDEVICE_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            nxlog_write(MSG_MOBILEDEVICE_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1301,21 +1312,19 @@ BOOL LoadObjects()
    hResult = DBSelect(hdb, _T("SELECT id FROM nodes"));
    if (hResult != NULL)
    {
-      Node *pNode;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pNode = new Node;
-         if (pNode->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Node *node = new Node;
+         if (node->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pNode, false, false);  // Insert into indexes
+            NetObjInsert(node, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pNode;
-            nxlog_write(MSG_NODE_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete node;
+            nxlog_write(MSG_NODE_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1326,20 +1335,18 @@ BOOL LoadObjects()
    hResult = DBSelect(hdb, _T("SELECT id FROM access_points"));
    if (hResult != NULL)
    {
-               AccessPoint *ap;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         ap = new AccessPoint;
-         if (ap->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         AccessPoint *ap = new AccessPoint;
+         if (ap->loadFromDatabase(hdb, id))
          {
             NetObjInsert(ap, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            nxlog_write(MSG_AP_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            nxlog_write(MSG_AP_LOAD_FAILED, NXLOG_ERROR, "d", id);
             delete ap;
          }
       }
@@ -1349,23 +1356,21 @@ BOOL LoadObjects()
    // Load interfaces
    DbgPrintf(2, _T("Loading interfaces..."));
    hResult = DBSelect(hdb, _T("SELECT id FROM interfaces"));
-   if (hResult != 0)
+   if (hResult != NULL)
    {
-      Interface *pInterface;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pInterface = new Interface;
-         if (pInterface->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Interface *iface = new Interface;
+         if (iface->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pInterface, false, false);  // Insert into indexes
+            NetObjInsert(iface, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            nxlog_write(MSG_INTERFACE_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
-            delete pInterface;
+            nxlog_write(MSG_INTERFACE_LOAD_FAILED, NXLOG_ERROR, "d", id);
+            delete iface;
          }
       }
       DBFreeResult(hResult);
@@ -1374,23 +1379,21 @@ BOOL LoadObjects()
    // Load network services
    DbgPrintf(2, _T("Loading network services..."));
    hResult = DBSelect(hdb, _T("SELECT id FROM network_services"));
-   if (hResult != 0)
+   if (hResult != NULL)
    {
-      NetworkService *pService;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pService = new NetworkService;
-         if (pService->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         NetworkService *service = new NetworkService;
+         if (service->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pService, false, false);  // Insert into indexes
+            NetObjInsert(service, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pService;
-            nxlog_write(MSG_NETSRV_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete service;
+            nxlog_write(MSG_NETSRV_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1401,21 +1404,19 @@ BOOL LoadObjects()
    hResult = DBSelect(hdb, _T("SELECT id FROM vpn_connectors"));
    if (hResult != NULL)
    {
-      VPNConnector *pConnector;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pConnector = new VPNConnector;
-         if (pConnector->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         VPNConnector *connector = new VPNConnector;
+         if (connector->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pConnector, false, false);  // Insert into indexes
+            NetObjInsert(connector, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pConnector;
-            nxlog_write(MSG_VPNC_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete connector;
+            nxlog_write(MSG_VPNC_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1426,21 +1427,19 @@ BOOL LoadObjects()
    hResult = DBSelect(hdb, _T("SELECT id FROM clusters"));
    if (hResult != NULL)
    {
-      Cluster *pCluster;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pCluster = new Cluster;
-         if (pCluster->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Cluster *cluster = new Cluster;
+         if (cluster->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pCluster, false, false);  // Insert into indexes
+            NetObjInsert(cluster, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pCluster;
-            nxlog_write(MSG_CLUSTER_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete cluster;
+            nxlog_write(MSG_CLUSTER_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1455,20 +1454,20 @@ BOOL LoadObjects()
    hResult = DBSelect(hdb, _T("SELECT id FROM templates"));
    if (hResult != NULL)
    {
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pTemplate = new Template;
-         if (pTemplate->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Template *tmpl = new Template;
+         if (tmpl->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pTemplate, false, false);  // Insert into indexes
-                               pTemplate->calculateCompoundStatus();   // Force status change to NORMAL
+            NetObjInsert(tmpl, false, false);  // Insert into indexes
+                               tmpl->calculateCompoundStatus();        // Force status change to NORMAL
          }
          else     // Object load failed
          {
-            delete pTemplate;
-            nxlog_write(MSG_TEMPLATE_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete tmpl;
+            nxlog_write(MSG_TEMPLATE_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1479,12 +1478,12 @@ BOOL LoadObjects()
    hResult = DBSelect(hdb, _T("SELECT id,policy_type FROM ap_common"));
    if (hResult != NULL)
    {
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
          AgentPolicy *policy;
 
-                       dwId = DBGetFieldULong(hResult, i, 0);
+                       UINT32 id = DBGetFieldULong(hResult, i, 0);
                        int type = DBGetFieldLong(hResult, i, 1);
                        switch(type)
                        {
@@ -1498,7 +1497,7 @@ BOOL LoadObjects()
                                        policy = new AgentPolicy(type);
                                        break;
                        }
-         if (policy->loadFromDatabase(hdb, dwId))
+         if (policy->loadFromDatabase(hdb, id))
          {
             NetObjInsert(policy, false, false);  // Insert into indexes
                                policy->calculateCompoundStatus();      // Force status change to NORMAL
@@ -1506,7 +1505,7 @@ BOOL LoadObjects()
          else     // Object load failed
          {
             delete policy;
-            nxlog_write(MSG_AGENTPOLICY_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            nxlog_write(MSG_AGENTPOLICY_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1517,19 +1516,19 @@ BOOL LoadObjects()
    hResult = DBSelect(hdb, _T("SELECT id FROM network_maps"));
    if (hResult != NULL)
    {
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
          NetworkMap *map = new NetworkMap;
-         if (map->loadFromDatabase(hdb, dwId))
+         if (map->loadFromDatabase(hdb, id))
          {
             NetObjInsert(map, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
             delete map;
-            nxlog_write(MSG_NETMAP_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            nxlog_write(MSG_NETMAP_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1537,25 +1536,26 @@ BOOL LoadObjects()
 
    // Load container objects
    DbgPrintf(2, _T("Loading containers..."));
-   _sntprintf(szQuery, sizeof(szQuery) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_CONTAINER);
-   hResult = DBSelect(hdb, szQuery);
-   if (hResult != 0)
+   TCHAR query[256];
+   _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_CONTAINER);
+   hResult = DBSelect(hdb, query);
+   if (hResult != NULL)
    {
       Container *pContainer;
 
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
          pContainer = new Container;
-         if (pContainer->loadFromDatabase(hdb, dwId))
+         if (pContainer->loadFromDatabase(hdb, id))
          {
             NetObjInsert(pContainer, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
             delete pContainer;
-            nxlog_write(MSG_CONTAINER_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            nxlog_write(MSG_CONTAINER_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1563,25 +1563,25 @@ BOOL LoadObjects()
 
    // Load template group objects
    DbgPrintf(2, _T("Loading template groups..."));
-   _sntprintf(szQuery, sizeof(szQuery) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_TEMPLATEGROUP);
-   hResult = DBSelect(hdb, szQuery);
-   if (hResult != 0)
+   _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_TEMPLATEGROUP);
+   hResult = DBSelect(hdb, query);
+   if (hResult != NULL)
    {
       TemplateGroup *pGroup;
 
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
          pGroup = new TemplateGroup;
-         if (pGroup->loadFromDatabase(hdb, dwId))
+         if (pGroup->loadFromDatabase(hdb, id))
          {
             NetObjInsert(pGroup, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
             delete pGroup;
-            nxlog_write(MSG_TG_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            nxlog_write(MSG_TG_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1589,25 +1589,23 @@ BOOL LoadObjects()
 
    // Load policy group objects
    DbgPrintf(2, _T("Loading policy groups..."));
-   _sntprintf(szQuery, sizeof(szQuery) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_POLICYGROUP);
-   hResult = DBSelect(hdb, szQuery);
-   if (hResult != 0)
+   _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_POLICYGROUP);
+   hResult = DBSelect(hdb, query);
+   if (hResult != NULL)
    {
-      PolicyGroup *pGroup;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pGroup = new PolicyGroup;
-         if (pGroup->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         PolicyGroup *group = new PolicyGroup;
+         if (group->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pGroup, false, false);  // Insert into indexes
+            NetObjInsert(group, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pGroup;
-            nxlog_write(MSG_PG_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete group;
+            nxlog_write(MSG_PG_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1615,25 +1613,23 @@ BOOL LoadObjects()
 
    // Load map group objects
    DbgPrintf(2, _T("Loading map groups..."));
-   _sntprintf(szQuery, sizeof(szQuery) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_NETWORKMAPGROUP);
-   hResult = DBSelect(hdb, szQuery);
-   if (hResult != 0)
+   _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_NETWORKMAPGROUP);
+   hResult = DBSelect(hdb, query);
+   if (hResult != NULL)
    {
-      NetworkMapGroup *pGroup;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pGroup = new NetworkMapGroup;
-         if (pGroup->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         NetworkMapGroup *group = new NetworkMapGroup;
+         if (group->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pGroup, false, false);  // Insert into indexes
+            NetObjInsert(group, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pGroup;
-            nxlog_write(MSG_MG_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete group;
+            nxlog_write(MSG_MG_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1642,23 +1638,21 @@ BOOL LoadObjects()
    // Load dashboard objects
    DbgPrintf(2, _T("Loading dashboards..."));
    hResult = DBSelect(hdb, _T("SELECT id FROM dashboards"));
-   if (hResult != 0)
+   if (hResult != NULL)
    {
-      Dashboard *pd;
-
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
-         pd = new Dashboard;
-         if (pd->loadFromDatabase(hdb, dwId))
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
+         Dashboard *dashboard = new Dashboard;
+         if (dashboard->loadFromDatabase(hdb, id))
          {
-            NetObjInsert(pd, false, false);  // Insert into indexes
+            NetObjInsert(dashboard, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
-            delete pd;
-            nxlog_write(MSG_DASHBOARD_LOAD_FAILED, EVENTLOG_ERROR_TYPE, "d", dwId);
+            delete dashboard;
+            nxlog_write(MSG_DASHBOARD_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1666,23 +1660,23 @@ BOOL LoadObjects()
 
    // Loading business service objects
    DbgPrintf(2, _T("Loading business services..."));
-   _sntprintf(szQuery, sizeof(szQuery) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_BUSINESSSERVICE);
-   hResult = DBSelect(hdb, szQuery);
-   if (hResult != 0)
+   _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_BUSINESSSERVICE);
+   hResult = DBSelect(hdb, query);
+   if (hResult != NULL)
    {
-          dwNumRows = DBGetNumRows(hResult);
-          for(i = 0; i < dwNumRows; i++)
+          int count = DBGetNumRows(hResult);
+          for(int i = 0; i < count; i++)
           {
-                  dwId = DBGetFieldULong(hResult, i, 0);
+                  UINT32 id = DBGetFieldULong(hResult, i, 0);
                   BusinessService *service = new BusinessService;
-                  if (service->loadFromDatabase(hdb, dwId))
+                  if (service->loadFromDatabase(hdb, id))
                   {
                           NetObjInsert(service, false, false);  // Insert into indexes
                   }
                   else     // Object load failed
                   {
                           delete service;
-                          nxlog_write(MSG_BUSINESS_SERVICE_LOAD_FAILED, NXLOG_ERROR, "d", dwId);
+                          nxlog_write(MSG_BUSINESS_SERVICE_LOAD_FAILED, NXLOG_ERROR, "d", id);
                   }
           }
           DBFreeResult(hResult);
@@ -1690,23 +1684,23 @@ BOOL LoadObjects()
 
    // Loading business service objects
    DbgPrintf(2, _T("Loading node links..."));
-   _sntprintf(szQuery, sizeof(szQuery) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_NODELINK);
-   hResult = DBSelect(hdb, szQuery);
-   if (hResult != 0)
+   _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("SELECT id FROM object_containers WHERE object_class=%d"), OBJECT_NODELINK);
+   hResult = DBSelect(hdb, query);
+   if (hResult != NULL)
    {
-          dwNumRows = DBGetNumRows(hResult);
-          for(i = 0; i < dwNumRows; i++)
+          int count = DBGetNumRows(hResult);
+          for(int i = 0; i < count; i++)
           {
-                  dwId = DBGetFieldULong(hResult, i, 0);
+                  UINT32 id = DBGetFieldULong(hResult, i, 0);
                   NodeLink *nl = new NodeLink;
-                  if (nl->loadFromDatabase(hdb, dwId))
+                  if (nl->loadFromDatabase(hdb, id))
                   {
                           NetObjInsert(nl, false, false);  // Insert into indexes
                   }
                   else     // Object load failed
                   {
                           delete nl;
-                          nxlog_write(MSG_NODE_LINK_LOAD_FAILED, NXLOG_ERROR, "d", dwId);
+                          nxlog_write(MSG_NODE_LINK_LOAD_FAILED, NXLOG_ERROR, "d", id);
                   }
           }
           DBFreeResult(hResult);
@@ -1715,21 +1709,21 @@ BOOL LoadObjects()
    // Load service check objects
    DbgPrintf(2, _T("Loading service checks..."));
    hResult = DBSelect(hdb, _T("SELECT id FROM slm_checks"));
-   if (hResult != 0)
+   if (hResult != NULL)
    {
-      dwNumRows = DBGetNumRows(hResult);
-      for(i = 0; i < dwNumRows; i++)
+      int count = DBGetNumRows(hResult);
+      for(int i = 0; i < count; i++)
       {
-         dwId = DBGetFieldULong(hResult, i, 0);
+         UINT32 id = DBGetFieldULong(hResult, i, 0);
          SlmCheck *check = new SlmCheck;
-         if (check->loadFromDatabase(hdb, dwId))
+         if (check->loadFromDatabase(hdb, id))
          {
             NetObjInsert(check, false, false);  // Insert into indexes
          }
          else     // Object load failed
          {
             delete check;
-            nxlog_write(MSG_SERVICE_CHECK_LOAD_FAILED, NXLOG_ERROR, "d", dwId);
+            nxlog_write(MSG_SERVICE_CHECK_LOAD_FAILED, NXLOG_ERROR, "d", id);
          }
       }
       DBFreeResult(hResult);
@@ -1882,87 +1876,89 @@ void DumpObjects(CONSOLE_CTX pCtx, const TCHAR *filter)
  * This function is used to check manually created bindings, so it won't
  * return TRUE for node -- subnet for example
  */
-bool IsValidParentClass(int iChildClass, int iParentClass)
+bool IsValidParentClass(int childClass, int parentClass)
 {
-   switch(iParentClass)
+   switch(parentClass)
    {
                case OBJECT_NETWORK:
-                       if ((iChildClass == OBJECT_ZONE) && (g_flags & AF_ENABLE_ZONING))
+                       if ((childClass == OBJECT_ZONE) && (g_flags & AF_ENABLE_ZONING))
                                return true;
                        break;
       case OBJECT_SERVICEROOT:
       case OBJECT_CONTAINER:
-         if ((iChildClass == OBJECT_CONTAINER) ||
-             (iChildClass == OBJECT_RACK) ||
-             (iChildClass == OBJECT_NODE) ||
-             (iChildClass == OBJECT_CLUSTER) ||
-             (iChildClass == OBJECT_MOBILEDEVICE) ||
-             (iChildClass == OBJECT_CONDITION) ||
-             (iChildClass == OBJECT_SUBNET))
+         if ((childClass == OBJECT_CHASSIS) ||
+             (childClass == OBJECT_CLUSTER) ||
+             (childClass == OBJECT_CONDITION) ||
+             (childClass == OBJECT_CONTAINER) ||
+             (childClass == OBJECT_MOBILEDEVICE) ||
+             (childClass == OBJECT_NODE) ||
+             (childClass == OBJECT_RACK) ||
+             (childClass == OBJECT_SUBNET))
             return true;
          break;
+      case OBJECT_CHASSIS:
       case OBJECT_RACK:
-         if (iChildClass == OBJECT_NODE)
+         if (childClass == OBJECT_NODE)
             return true;
          break;
       case OBJECT_TEMPLATEROOT:
       case OBJECT_TEMPLATEGROUP:
-         if ((iChildClass == OBJECT_TEMPLATEGROUP) ||
-             (iChildClass == OBJECT_TEMPLATE))
+         if ((childClass == OBJECT_TEMPLATEGROUP) ||
+             (childClass == OBJECT_TEMPLATE))
             return true;
          break;
       case OBJECT_TEMPLATE:
-         if ((iChildClass == OBJECT_NODE) ||
-             (iChildClass == OBJECT_CLUSTER) ||
-             (iChildClass == OBJECT_MOBILEDEVICE))
+         if ((childClass == OBJECT_NODE) ||
+             (childClass == OBJECT_CLUSTER) ||
+             (childClass == OBJECT_MOBILEDEVICE))
             return true;
          break;
       case OBJECT_NETWORKMAPROOT:
       case OBJECT_NETWORKMAPGROUP:
-         if ((iChildClass == OBJECT_NETWORKMAPGROUP) ||
-             (iChildClass == OBJECT_NETWORKMAP))
+         if ((childClass == OBJECT_NETWORKMAPGROUP) ||
+             (childClass == OBJECT_NETWORKMAP))
             return true;
          break;
       case OBJECT_DASHBOARDROOT:
       case OBJECT_DASHBOARD:
-         if (iChildClass == OBJECT_DASHBOARD)
+         if (childClass == OBJECT_DASHBOARD)
             return true;
          break;
       case OBJECT_POLICYROOT:
       case OBJECT_POLICYGROUP:
-         if ((iChildClass == OBJECT_POLICYGROUP) ||
-             (iChildClass == OBJECT_AGENTPOLICY) ||
-             (iChildClass == OBJECT_AGENTPOLICY_CONFIG) ||
-             (iChildClass == OBJECT_AGENTPOLICY_LOGPARSER))
+         if ((childClass == OBJECT_POLICYGROUP) ||
+             (childClass == OBJECT_AGENTPOLICY) ||
+             (childClass == OBJECT_AGENTPOLICY_CONFIG) ||
+             (childClass == OBJECT_AGENTPOLICY_LOGPARSER))
             return true;
          break;
       case OBJECT_NODE:
-         if ((iChildClass == OBJECT_NETWORKSERVICE) ||
-             (iChildClass == OBJECT_VPNCONNECTOR) ||
-                                (iChildClass == OBJECT_INTERFACE))
+         if ((childClass == OBJECT_NETWORKSERVICE) ||
+             (childClass == OBJECT_VPNCONNECTOR) ||
+                                (childClass == OBJECT_INTERFACE))
             return true;
          break;
       case OBJECT_CLUSTER:
-         if (iChildClass == OBJECT_NODE)
+         if (childClass == OBJECT_NODE)
             return true;
          break;
                case OBJECT_BUSINESSSERVICEROOT:
-                       if ((iChildClass == OBJECT_BUSINESSSERVICE) ||
-                           (iChildClass == OBJECT_NODELINK))
+                       if ((childClass == OBJECT_BUSINESSSERVICE) ||
+                           (childClass == OBJECT_NODELINK))
             return true;
          break;
                case OBJECT_BUSINESSSERVICE:
-                       if ((iChildClass == OBJECT_BUSINESSSERVICE) ||
-                           (iChildClass == OBJECT_NODELINK) ||
-                           (iChildClass == OBJECT_SLMCHECK))
+                       if ((childClass == OBJECT_BUSINESSSERVICE) ||
+                           (childClass == OBJECT_NODELINK) ||
+                           (childClass == OBJECT_SLMCHECK))
             return true;
          break;
                case OBJECT_NODELINK:
-                       if (iChildClass == OBJECT_SLMCHECK)
+                       if (childClass == OBJECT_SLMCHECK)
             return true;
          break;
       case -1:    // Creating object without parent
-         if (iChildClass == OBJECT_NODE)
+         if (childClass == OBJECT_NODE)
             return true;   // OK only for nodes, because parent subnet will be created automatically
          break;
    }
@@ -1972,7 +1968,7 @@ bool IsValidParentClass(int iChildClass, int iParentClass)
        {
                if (g_pModuleList[i].pfIsValidParentClass != NULL)
                {
-                       if (g_pModuleList[i].pfIsValidParentClass(iChildClass, iParentClass))
+                       if (g_pModuleList[i].pfIsValidParentClass(childClass, parentClass))
                                return true;    // accepted by module
                }
        }
index f5a4ea0..a642500 100644 (file)
@@ -4925,58 +4925,54 @@ void ClientSession::sendMIBTimestamp(UINT32 dwRqId)
 /**
  * Create new object
  */
-void ClientSession::createObject(NXCPMessage *pRequest)
+void ClientSession::createObject(NXCPMessage *request)
 {
    NXCPMessage msg;
-   NetObj *object = NULL, *pParent;
-   int iClass, iServiceType;
-   TCHAR szObjectName[MAX_OBJECT_NAME], nodePrimaryName[MAX_DNS_NAME], deviceId[MAX_OBJECT_NAME];
-   TCHAR *pszRequest, *pszResponse, *pszComments;
-   UINT32 zoneId, nodeId;
-   WORD wIpProto, wIpPort;
-   InetAddress ipAddr;
-   BOOL bParentAlwaysValid = FALSE;
-
-   // Prepare response message
    msg.setCode(CMD_REQUEST_COMPLETED);
-   msg.setId(pRequest->getId());
+   msg.setId(request->getId());
 
-   iClass = pRequest->getFieldAsUInt16(VID_OBJECT_CLASS);
-       zoneId = pRequest->getFieldAsUInt32(VID_ZONE_ID);
+   int objectClass = request->getFieldAsUInt16(VID_OBJECT_CLASS);
+       UINT32 zoneId = request->getFieldAsUInt32(VID_ZONE_ID);
 
    // Find parent object
-   pParent = FindObjectById(pRequest->getFieldAsUInt32(VID_PARENT_ID));
-   if (iClass == OBJECT_NODE)
+   NetObj *parent = FindObjectById(request->getFieldAsUInt32(VID_PARENT_ID));
+
+   TCHAR nodePrimaryName[MAX_DNS_NAME];
+   InetAddress ipAddr;
+   bool parentAlwaysValid = false;
+
+   if (objectClass == OBJECT_NODE)
    {
-               if (pRequest->isFieldExist(VID_PRIMARY_NAME))
+               if (request->isFieldExist(VID_PRIMARY_NAME))
                {
-                       pRequest->getFieldAsString(VID_PRIMARY_NAME, nodePrimaryName, MAX_DNS_NAME);
+                       request->getFieldAsString(VID_PRIMARY_NAME, nodePrimaryName, MAX_DNS_NAME);
          ipAddr = InetAddress::resolveHostName(nodePrimaryName);
                }
                else
                {
-         ipAddr = pRequest->getFieldAsInetAddress(VID_IP_ADDRESS);
+         ipAddr = request->getFieldAsInetAddress(VID_IP_ADDRESS);
          ipAddr.toString(nodePrimaryName);
                }
-      if ((pParent == NULL) && ipAddr.isValidUnicast())
+      if ((parent == NULL) && ipAddr.isValidUnicast())
       {
-         pParent = FindSubnetForNode(zoneId, ipAddr);
-         bParentAlwaysValid = TRUE;
+         parent = FindSubnetForNode(zoneId, ipAddr);
+         parentAlwaysValid = true;
       }
    }
-   if ((pParent != NULL) || (iClass == OBJECT_NODE))
+
+   if ((parent != NULL) || (objectClass == OBJECT_NODE))
    {
       // User should have create access to parent object
-      if ((pParent != NULL) ?
-            pParent->checkAccessRights(m_dwUserId, OBJECT_ACCESS_CREATE) :
+      if ((parent != NULL) ?
+            parent->checkAccessRights(m_dwUserId, OBJECT_ACCESS_CREATE) :
             g_pEntireNet->checkAccessRights(m_dwUserId, OBJECT_ACCESS_CREATE))
       {
          // Parent object should be of valid type
-         if (bParentAlwaysValid || IsValidParentClass(iClass, (pParent != NULL) ? pParent->getObjectClass() : -1))
+         if (parentAlwaysValid || IsValidParentClass(objectClass, (parent != NULL) ? parent->getObjectClass() : -1))
          {
                                // Check zone
                                bool zoneIsValid;
-                               if (IsZoningEnabled() && (zoneId != 0) && (iClass != OBJECT_ZONE))
+                               if (IsZoningEnabled() && (zoneId != 0) && (objectClass != OBJECT_ZONE))
                                {
                                        zoneIsValid = (g_idxZoneByGUID.get(zoneId) != NULL);
                                }
@@ -4984,10 +4980,13 @@ void ClientSession::createObject(NXCPMessage *pRequest)
                                {
                                        zoneIsValid = true;
                                }
+
                                if (zoneIsValid)
                                {
-                                       pRequest->getFieldAsString(VID_OBJECT_NAME, szObjectName, MAX_OBJECT_NAME);
-                                       if (IsValidObjectName(szObjectName, TRUE))
+                                  TCHAR objectName[MAX_OBJECT_NAME];
+
+                                       request->getFieldAsString(VID_OBJECT_NAME, objectName, MAX_OBJECT_NAME);
+                                       if (IsValidObjectName(objectName, TRUE))
                                        {
                   // Do additional validation by modules
                   UINT32 moduleRCC = RCC_SUCCESS;
@@ -4995,10 +4994,10 @@ void ClientSession::createObject(NXCPMessage *pRequest)
                       {
                               if (g_pModuleList[i].pfValidateObjectCreation != NULL)
                               {
-                        moduleRCC = g_pModuleList[i].pfValidateObjectCreation(iClass, szObjectName, ipAddr, zoneId, pRequest);
+                        moduleRCC = g_pModuleList[i].pfValidateObjectCreation(objectClass, objectName, ipAddr, zoneId, request);
                                       if (moduleRCC != RCC_SUCCESS)
                         {
-                           DbgPrintf(4, _T("Creation of object \"%s\" of class %d blocked by module %s (RCC=%d)"), szObjectName, iClass, g_pModuleList[i].szName, moduleRCC);
+                           DbgPrintf(4, _T("Creation of object \"%s\" of class %d blocked by module %s (RCC=%d)"), objectName, objectClass, g_pModuleList[i].szName, moduleRCC);
                            break;
                         }
                               }
@@ -5009,106 +5008,147 @@ void ClientSession::createObject(NXCPMessage *pRequest)
                      ObjectTransactionStart();
 
                                                   // Create new object
-                                                  switch(iClass)
+                     NetObj *object = NULL;
+                     UINT32 nodeId;
+                     TCHAR deviceId[MAX_OBJECT_NAME];
+                                                  switch(objectClass)
                                                   {
+                        case OBJECT_AGENTPOLICY_CONFIG:
+                           object = new AgentPolicyConfig(objectName);
+                           NetObjInsert(object, true, false);
+                           object->calculateCompoundStatus();  // Force status change to NORMAL
+                           break;
+                        case OBJECT_AGENTPOLICY_LOGPARSER:
+                           object = new AgentPolicyLogParser(objectName);
+                           NetObjInsert(object, true, false);
+                           object->calculateCompoundStatus();  // Force status change to NORMAL
+                           break;
+                        case OBJECT_BUSINESSSERVICE:
+                           object = new BusinessService(objectName);
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_CHASSIS:
+                           object = new Chassis(objectName, request->getFieldAsUInt32(VID_CONTROLLER_ID));
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_CLUSTER:
+                           object = new Cluster(objectName, zoneId);
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_CONDITION:
+                           object = new Condition(TRUE);
+                           object->setName(objectName);
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_CONTAINER:
+                           object = new Container(objectName, request->getFieldAsUInt32(VID_CATEGORY));
+                           NetObjInsert(object, true, false);
+                           object->calculateCompoundStatus();  // Force status change to NORMAL
+                           break;
+                        case OBJECT_DASHBOARD:
+                           object = new Dashboard(objectName);
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_INTERFACE:
+                           {
+                              InterfaceInfo ifInfo(request->getFieldAsUInt32(VID_IF_INDEX));
+                              nx_strncpy(ifInfo.name, objectName, MAX_DB_STRING);
+                              InetAddress addr = request->getFieldAsInetAddress(VID_IP_ADDRESS);
+                              if (addr.isValidUnicast())
+                                 ifInfo.ipAddrList.add(addr);
+                              ifInfo.type = request->getFieldAsUInt32(VID_IF_TYPE);
+                              request->getFieldAsBinary(VID_MAC_ADDR, ifInfo.macAddr, MAC_ADDR_LENGTH);
+                              ifInfo.slot = request->getFieldAsUInt32(VID_IF_SLOT);
+                              ifInfo.port = request->getFieldAsUInt32(VID_IF_PORT);
+                              ifInfo.isPhysicalPort = request->getFieldAsBoolean(VID_IS_PHYS_PORT);
+                              object = ((Node *)parent)->createNewInterface(&ifInfo, true);
+                           }
+                           break;
+                        case OBJECT_MOBILEDEVICE:
+                           request->getFieldAsString(VID_DEVICE_ID, deviceId, MAX_OBJECT_NAME);
+                           object = new MobileDevice(objectName, deviceId);
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_NETWORKMAP:
+                           object = new NetworkMap((int)request->getFieldAsUInt16(VID_MAP_TYPE), request->getFieldAsUInt32(VID_SEED_OBJECT));
+                           object->setName(objectName);
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_NETWORKMAPGROUP:
+                           object = new NetworkMapGroup(objectName);
+                           NetObjInsert(object, true, false);
+                           object->calculateCompoundStatus();  // Force status change to NORMAL
+                           break;
+                        case OBJECT_NETWORKSERVICE:
+                           object = new NetworkService(request->getFieldAsInt16(VID_SERVICE_TYPE),
+                                                       request->getFieldAsUInt16(VID_IP_PROTO),
+                                                       request->getFieldAsUInt16(VID_IP_PORT),
+                                                       request->getFieldAsString(VID_SERVICE_REQUEST),
+                                                       request->getFieldAsString(VID_SERVICE_RESPONSE),
+                                                       (Node *)parent);
+                           object->setName(objectName);
+                           NetObjInsert(object, true, false);
+                           break;
                                                           case OBJECT_NODE:
-                           ipAddr.setMaskBits(pRequest->getFieldAsInt32(VID_IP_NETMASK));
+                           ipAddr.setMaskBits(request->getFieldAsInt32(VID_IP_NETMASK));
                                                                   object = PollNewNode(ipAddr,
-                                                                                                                          pRequest->getFieldAsUInt32(VID_CREATION_FLAGS),
-                                                                                                                          pRequest->getFieldAsUInt16(VID_AGENT_PORT),
-                                                                                                                          pRequest->getFieldAsUInt16(VID_SNMP_PORT),
-                                                                                                                          szObjectName,
-                                                                                                                          pRequest->getFieldAsUInt32(VID_AGENT_PROXY),
-                                                                                                                          pRequest->getFieldAsUInt32(VID_SNMP_PROXY),
-                                                                                                                          (pParent != NULL) ? ((pParent->getObjectClass() == OBJECT_CLUSTER) ? (Cluster *)pParent : NULL) : NULL,
+                                                                                                                          request->getFieldAsUInt32(VID_CREATION_FLAGS),
+                                                                                                                          request->getFieldAsUInt16(VID_AGENT_PORT),
+                                                                                                                          request->getFieldAsUInt16(VID_SNMP_PORT),
+                                                                                                                          objectName,
+                                                                                                                          request->getFieldAsUInt32(VID_AGENT_PROXY),
+                                                                                                                          request->getFieldAsUInt32(VID_SNMP_PROXY),
+                                                                                                                          (parent != NULL) ? ((parent->getObjectClass() == OBJECT_CLUSTER) ? (Cluster *)parent : NULL) : NULL,
                                                                                                                           zoneId, false, false);
                                                                   if (object != NULL)
                                                                   {
                                                                           ((Node *)object)->setPrimaryName(nodePrimaryName);
                                                                   }
                                                                   break;
-                                                          case OBJECT_MOBILEDEVICE:
-                                                                  pRequest->getFieldAsString(VID_DEVICE_ID, deviceId, MAX_OBJECT_NAME);
-                                                                  object = new MobileDevice(szObjectName, deviceId);
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
-                                                          case OBJECT_CONTAINER:
-                                                                  object = new Container(szObjectName, pRequest->getFieldAsUInt32(VID_CATEGORY));
-                                                                  NetObjInsert(object, true, false);
-                                                                  object->calculateCompoundStatus();   // Force status change to NORMAL
-                                                                  break;
+                        case OBJECT_NODELINK:
+                           nodeId = request->getFieldAsUInt32(VID_NODE_ID);
+                           if (nodeId > 0)
+                           {
+                              object = new NodeLink(objectName, nodeId);
+                              NetObjInsert(object, true, false);
+                           }
+                           else
+                           {
+                              object = NULL;
+                           }
+                           break;
+                        case OBJECT_POLICYGROUP:
+                           object = new PolicyGroup(objectName);
+                           NetObjInsert(object, true, false);
+                           object->calculateCompoundStatus();  // Force status change to NORMAL
+                           break;
                                                           case OBJECT_RACK:
-                                                                  object = new Rack(szObjectName, (int)pRequest->getFieldAsUInt16(VID_HEIGHT));
+                                                                  object = new Rack(objectName, (int)request->getFieldAsUInt16(VID_HEIGHT));
                                                                   NetObjInsert(object, true, false);
                                                                   break;
+                        case OBJECT_SLMCHECK:
+                           object = new SlmCheck(objectName, request->getFieldAsBoolean(VID_IS_TEMPLATE));
+                           NetObjInsert(object, true, false);
+                           break;
+                        case OBJECT_TEMPLATE:
+                           object = new Template(objectName);
+                           NetObjInsert(object, true, false);
+                           object->calculateCompoundStatus();  // Force status change to NORMAL
+                           break;
                                                           case OBJECT_TEMPLATEGROUP:
-                                                                  object = new TemplateGroup(szObjectName);
+                                                                  object = new TemplateGroup(objectName);
                                                                   NetObjInsert(object, true, false);
                                                                   object->calculateCompoundStatus();   // Force status change to NORMAL
                                                                   break;
-                                                          case OBJECT_TEMPLATE:
-                                                                  object = new Template(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  object->calculateCompoundStatus();   // Force status change to NORMAL
-                                                                  break;
-                                                          case OBJECT_POLICYGROUP:
-                                                                  object = new PolicyGroup(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  object->calculateCompoundStatus();   // Force status change to NORMAL
-                                                                  break;
-                                                          case OBJECT_AGENTPOLICY_CONFIG:
-                                                                  object = new AgentPolicyConfig(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  object->calculateCompoundStatus();   // Force status change to NORMAL
-                                                                  break;
-                        case OBJECT_AGENTPOLICY_LOGPARSER:
-                                                                  object = new AgentPolicyLogParser(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  object->calculateCompoundStatus();   // Force status change to NORMAL
-                                                                  break;
-                                                          case OBJECT_CLUSTER:
-                                                                  object = new Cluster(szObjectName, zoneId);
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
-                                                          case OBJECT_NETWORKSERVICE:
-                                                                  iServiceType = (int)pRequest->getFieldAsUInt16(VID_SERVICE_TYPE);
-                                                                  wIpProto = pRequest->getFieldAsUInt16(VID_IP_PROTO);
-                                                                  wIpPort = pRequest->getFieldAsUInt16(VID_IP_PORT);
-                                                                  pszRequest = pRequest->getFieldAsString(VID_SERVICE_REQUEST);
-                                                                  pszResponse = pRequest->getFieldAsString(VID_SERVICE_RESPONSE);
-                                                                  object = new NetworkService(iServiceType, wIpProto, wIpPort,
-                                                                                                                                            pszRequest, pszResponse, (Node *)pParent);
-                                                                  object->setName(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
                                                           case OBJECT_VPNCONNECTOR:
                                                                   object = new VPNConnector(TRUE);
-                                                                  object->setName(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
-                                                          case OBJECT_CONDITION:
-                                                                  object = new Condition(TRUE);
-                                                                  object->setName(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
-                                                          case OBJECT_NETWORKMAPGROUP:
-                                                                  object = new NetworkMapGroup(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  object->calculateCompoundStatus();   // Force status change to NORMAL
-                                                                  break;
-                                                          case OBJECT_NETWORKMAP:
-                                                                  object = new NetworkMap((int)pRequest->getFieldAsUInt16(VID_MAP_TYPE), pRequest->getFieldAsUInt32(VID_SEED_OBJECT));
-                                                                  object->setName(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
-                                                          case OBJECT_DASHBOARD:
-                                                                  object = new Dashboard(szObjectName);
+                                                                  object->setName(objectName);
                                                                   NetObjInsert(object, true, false);
                                                                   break;
                                                           case OBJECT_ZONE:
                                                                   if ((zoneId > 0) && (zoneId != ALL_ZONES) && (g_idxZoneByGUID.get(zoneId) == NULL))
                                                                   {
-                                                                          object = new Zone(zoneId, szObjectName);
+                                                                          object = new Zone(zoneId, objectName);
                                                                           NetObjInsert(object, true, false);
                                                                   }
                                                                   else
@@ -5116,48 +5156,13 @@ void ClientSession::createObject(NXCPMessage *pRequest)
                                                                           object = NULL;
                                                                   }
                                                                   break;
-                                                          case OBJECT_BUSINESSSERVICE:
-                                                                  object = new BusinessService(szObjectName);
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
-                                                          case OBJECT_NODELINK:
-                                                                  nodeId = pRequest->getFieldAsUInt32(VID_NODE_ID);
-                                                                  if (nodeId > 0)
-                                                                  {
-                                                                          object = new NodeLink(szObjectName, nodeId);
-                                                                          NetObjInsert(object, true, false);
-                                                                  }
-                                                                  else
-                                                                  {
-                                                                          object = NULL;
-                                                                  }
-                                                                  break;
-                                                          case OBJECT_SLMCHECK:
-                                                                  object = new SlmCheck(szObjectName, pRequest->getFieldAsBoolean(VID_IS_TEMPLATE));
-                                                                  NetObjInsert(object, true, false);
-                                                                  break;
-                                                          case OBJECT_INTERFACE:
-                           {
-                              InterfaceInfo ifInfo(pRequest->getFieldAsUInt32(VID_IF_INDEX));
-                              nx_strncpy(ifInfo.name, szObjectName, MAX_DB_STRING);
-                              InetAddress addr = pRequest->getFieldAsInetAddress(VID_IP_ADDRESS);
-                              if (addr.isValidUnicast())
-                                 ifInfo.ipAddrList.add(addr);
-                              ifInfo.type = pRequest->getFieldAsUInt32(VID_IF_TYPE);
-                                                                     pRequest->getFieldAsBinary(VID_MAC_ADDR, ifInfo.macAddr, MAC_ADDR_LENGTH);
-                              ifInfo.slot = pRequest->getFieldAsUInt32(VID_IF_SLOT);
-                              ifInfo.port = pRequest->getFieldAsUInt32(VID_IF_PORT);
-                              ifInfo.isPhysicalPort = pRequest->getFieldAsBoolean(VID_IS_PHYS_PORT);
-                                                                     object = ((Node *)pParent)->createNewInterface(&ifInfo, true);
-                           }
-                                                                  break;
                                                           default:
                                                                   // Try to create unknown classes by modules
                                                                   for(UINT32 i = 0; i < g_dwNumModules; i++)
                                                                   {
                                                                           if (g_pModuleList[i].pfCreateObject != NULL)
                                                                           {
-                                                                                  object = g_pModuleList[i].pfCreateObject(iClass, szObjectName, pParent, pRequest);
+                                                                                  object = g_pModuleList[i].pfCreateObject(objectClass, objectName, parent, request);
                                                                                   if (object != NULL)
                                                                                           break;
                                                                           }
@@ -5169,15 +5174,15 @@ void ClientSession::createObject(NXCPMessage *pRequest)
                                                   if (object != NULL)
                                                   {
                                                           WriteAuditLog(AUDIT_OBJECTS, TRUE, m_dwUserId, m_workstation, m_id, object->getId(), _T("Object %s created"), object->getName());
-                                                          if ((pParent != NULL) &&          // parent can be NULL for nodes
-                                                              (iClass != OBJECT_INTERFACE)) // interface already linked by Node::createNewInterface
+                                                          if ((parent != NULL) &&          // parent can be NULL for nodes
+                                                              (objectClass != OBJECT_INTERFACE)) // interface already linked by Node::createNewInterface
                                                           {
-                                                                  pParent->addChild(object);
-                                                                  object->addParent(pParent);
-                                                                  pParent->calculateCompoundStatus();
-                                                                  if (pParent->getObjectClass() == OBJECT_CLUSTER)
+                                                                  parent->addChild(object);
+                                                                  object->addParent(parent);
+                                                                  parent->calculateCompoundStatus();
+                                                                  if (parent->getObjectClass() == OBJECT_CLUSTER)
                                                                   {
-                                                                          ((Cluster *)pParent)->applyToTarget((DataCollectionTarget *)object);
+                                                                          ((Cluster *)parent)->applyToTarget((DataCollectionTarget *)object);
                                                                   }
                                                                   if (object->getObjectClass() == OBJECT_NODELINK)
                                                                   {
@@ -5185,22 +5190,22 @@ void ClientSession::createObject(NXCPMessage *pRequest)
                                                                   }
                                                                   if (object->getObjectClass() == OBJECT_NETWORKSERVICE)
                                                                   {
-                                                                          if (pRequest->getFieldAsUInt16(VID_CREATE_STATUS_DCI))
+                                                                          if (request->getFieldAsUInt16(VID_CREATE_STATUS_DCI))
                                                                           {
                                                                                   TCHAR dciName[MAX_DB_STRING], dciDescription[MAX_DB_STRING];
 
                                                                                   _sntprintf(dciName, MAX_DB_STRING, _T("ChildStatus(%d)"), object->getId());
                                                                                   _sntprintf(dciDescription, MAX_DB_STRING, _T("Status of network service %s"), object->getName());
-                                                                                  ((Node *)pParent)->addDCObject(new DCItem(CreateUniqueId(IDG_ITEM), dciName, DS_INTERNAL, DCI_DT_INT,
+                                                                                  ((Node *)parent)->addDCObject(new DCItem(CreateUniqueId(IDG_ITEM), dciName, DS_INTERNAL, DCI_DT_INT,
                                                                                           ConfigReadInt(_T("DefaultDCIPollingInterval"), 60),
-                                                                                          ConfigReadInt(_T("DefaultDCIRetentionTime"), 30), (Node *)pParent, dciDescription));
+                                                                                          ConfigReadInt(_T("DefaultDCIRetentionTime"), 30), (Node *)parent, dciDescription));
                                                                           }
                                                                   }
                                                           }
 
-                                                          pszComments = pRequest->getFieldAsString(VID_COMMENTS);
-                                                          if (pszComments != NULL)
-                                                                  object->setComments(pszComments);
+                                                          TCHAR *comments = request->getFieldAsString(VID_COMMENTS);
+                                                          if (comments != NULL)
+                                                                  object->setComments(comments);
 
                                                           object->unhide();
                                                           msg.setField(VID_RCC, RCC_SUCCESS);
@@ -5212,13 +5217,13 @@ void ClientSession::createObject(NXCPMessage *pRequest)
                                                           // PollNewNode will return NULL only if IP already
                                                           // in use. some new() can fail there too, but server will
                                                           // crash in that case
-                                                          if (iClass == OBJECT_NODE)
+                                                          if (objectClass == OBJECT_NODE)
                                                           {
                                   msg.setField(VID_RCC, RCC_ALREADY_EXIST);
                                   //Add to description IP of new created node and name of node with the same IP
                            SetNodesConflictString(&msg, zoneId, ipAddr);
                                                           }
-                                                          else if (iClass == OBJECT_ZONE)
+                                                          else if (objectClass == OBJECT_ZONE)
                                                           {
                                   msg.setField(VID_RCC, RCC_ZONE_ID_ALREADY_IN_USE);
                                                           }
index a7b696a..fbd2b8d 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** NetXMS - Network Management System
-** Copyright (C) 2003-2013 Victor Kirhenshtein
+** Copyright (C) 2003-2016 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
index acb1dd0..e3d7fcf 100644 (file)
@@ -639,6 +639,8 @@ public:
    // Debug methods
    const TCHAR *dbgGetParentList(TCHAR *szBuffer);
    const TCHAR *dbgGetChildList(TCHAR *szBuffer);
+
+   static const TCHAR *getObjectClassName(int objectClass);
 };
 
 /**
@@ -1182,6 +1184,46 @@ public:
    UINT32 collectAggregatedData(DCTable *table, Table **result);
 };
 
+/**
+ * Chassis (represents physical chassis)
+ */
+class NXCORE_EXPORTABLE Chassis : public DataCollectionTarget
+{
+protected:
+   UINT32 m_controllerId;
+   INT16 m_rackHeight;
+   INT16 m_rackPosition;
+   UINT32 m_rackId;
+   uuid m_rackImage;
+
+   virtual void fillMessageInternal(NXCPMessage *msg);
+   virtual UINT32 modifyFromMessageInternal(NXCPMessage *request);
+
+   virtual void onDataCollectionChange();
+
+   void updateRackBinding();
+
+public:
+   Chassis();
+   Chassis(const TCHAR *name, UINT32 controllerId);
+   virtual ~Chassis();
+
+   virtual int getObjectClass() const { return OBJECT_CHASSIS; }
+   virtual BOOL saveToDatabase(DB_HANDLE hdb);
+   virtual bool deleteFromDatabase(DB_HANDLE hdb);
+   virtual bool loadFromDatabase(DB_HANDLE hdb, UINT32 id);
+   virtual bool showThresholdSummary();
+
+   virtual void unbindFromTemplate(UINT32 templateId, bool removeDCI);
+
+   virtual NXSL_Value *createNXSLObject();
+
+   UINT32 getControllerId() const { return m_controllerId; }
+   UINT32 getRackId() const { return m_rackId; }
+   INT16 getRackHeight() const { return m_rackHeight; }
+   INT16 getRackPosition() const { return m_rackPosition; }
+};
+
 class Subnet;
 struct ProxyInfo;
 
@@ -1290,6 +1332,7 @@ protected:
        INT16 m_rackPosition;
        UINT32 m_rackId;
        uuid m_rackImage;
+       UINT32 m_chassisId;
        INT64 m_syslogMessageCount;
        INT64 m_snmpTrapCount;
 
@@ -1340,7 +1383,7 @@ protected:
        void updateContainerMembership();
        bool updateInterfaceConfiguration(UINT32 rqid, int maskBits);
    bool deleteDuplicateInterfaces(UINT32 rqid);
-   void updateRackBinding();
+   void updatePhysicalContainerBinding(int containerClass, UINT32 containerId);
 
    bool connectToAgent(UINT32 *error = NULL, UINT32 *socketError = NULL, bool *newConnection = NULL, bool forceConnect = false);
    void setLastAgentCommTime() { time_t now = time(NULL); if (m_lastAgentCommTime < now - 60) { m_lastAgentCommTime = now; setModified(); } }
@@ -1394,23 +1437,26 @@ public:
        bool isPerVlanFdbSupported() { return (m_driver != NULL) ? m_driver->isPerVlanFdbSupported() : false; }
        bool isWirelessController() { return m_dwFlags & NF_IS_WIFI_CONTROLLER ? true : false; }
 
-       LONG getSNMPVersion() { return m_snmpVersion; }
-       const TCHAR *getSNMPObjectId() { return m_szObjectId; }
-       const TCHAR *getAgentVersion() { return m_szAgentVersion; }
-       const TCHAR *getPlatformName() { return m_szPlatformName; }
-   const TCHAR *getObjectId() { return m_szObjectId; }
-       const TCHAR *getSysName() { return CHECK_NULL_EX(m_sysName); }
-       const TCHAR *getSysDescription() { return CHECK_NULL_EX(m_sysDescription); }
-   const TCHAR *getSysContact() { return CHECK_NULL_EX(m_sysContact); }
-   const TCHAR *getSysLocation() { return CHECK_NULL_EX(m_sysLocation); }
-   time_t getBootTime() { return m_bootTime; }
-       const TCHAR *getLLDPNodeId() { return m_lldpNodeId; }
-   const BYTE *getBridgeId() { return m_baseBridgeAddress; }
-       const TCHAR *getDriverName() { return (m_driver != NULL) ? m_driver->getName() : _T("GENERIC"); }
-       UINT16 getAgentPort() { return m_agentPort; }
-       INT16 getAgentAuthMethod() { return m_agentAuthMethod; }
-   INT16 getAgentCacheMode() { return (m_dwDynamicFlags & NDF_CACHE_MODE_NOT_SUPPORTED) ? AGENT_CACHE_OFF : ((m_agentCacheMode == AGENT_CACHE_DEFAULT) ? g_defaultAgentCacheMode : m_agentCacheMode); }
-       const TCHAR *getSharedSecret() { return m_szSharedSecret; }
+       LONG getSNMPVersion() const { return m_snmpVersion; }
+       const TCHAR *getSNMPObjectId() const { return m_szObjectId; }
+       const TCHAR *getAgentVersion() const { return m_szAgentVersion; }
+       const TCHAR *getPlatformName() const { return m_szPlatformName; }
+   const TCHAR *getObjectId() const { return m_szObjectId; }
+       const TCHAR *getSysName() const { return CHECK_NULL_EX(m_sysName); }
+       const TCHAR *getSysDescription() const { return CHECK_NULL_EX(m_sysDescription); }
+   const TCHAR *getSysContact() const { return CHECK_NULL_EX(m_sysContact); }
+   const TCHAR *getSysLocation() const { return CHECK_NULL_EX(m_sysLocation); }
+   time_t getBootTime() const { return m_bootTime; }
+       const TCHAR *getLLDPNodeId() const { return m_lldpNodeId; }
+   const BYTE *getBridgeId() const { return m_baseBridgeAddress; }
+       const TCHAR *getDriverName() const { return (m_driver != NULL) ? m_driver->getName() : _T("GENERIC"); }
+       UINT16 getAgentPort() const { return m_agentPort; }
+       INT16 getAgentAuthMethod() const { return m_agentAuthMethod; }
+   INT16 getAgentCacheMode() const { return (m_dwDynamicFlags & NDF_CACHE_MODE_NOT_SUPPORTED) ? AGENT_CACHE_OFF : ((m_agentCacheMode == AGENT_CACHE_DEFAULT) ? g_defaultAgentCacheMode : m_agentCacheMode); }
+       const TCHAR *getSharedSecret() const { return m_szSharedSecret; }
+       UINT32 getRackId() const { return m_rackId; }
+   INT16 getRackHeight() const { return m_rackHeight; }
+   INT16 getRackPosition() const { return m_rackPosition; }
        bool hasFileUpdateConnection() { lockProperties(); bool result = (m_fileUpdateConn != NULL); unlockProperties(); return result; }
 
    bool isDown() { return (m_dwDynamicFlags & NDF_UNREACHABLE) ? true : false; }
@@ -2494,7 +2540,7 @@ void DumpObjects(CONSOLE_CTX pCtx, const TCHAR *filter);
 
 void DeleteUserFromAllObjects(UINT32 dwUserId);
 
-bool IsValidParentClass(int iChildClass, int iParentClass);
+bool IsValidParentClass(int childClass, int parentClass);
 bool IsAgentPolicyObject(NetObj *object);
 bool IsEventSource(int objectClass);
 
index 4145fe2..54704a0 100644 (file)
@@ -67,6 +67,17 @@ public:
    virtual NXSL_Value *getAttr(NXSL_Object *object, const TCHAR *attr);
 };
 
+/**
+ * NXSL "Chassis" class
+ */
+class NXSL_ChassisClass : public NXSL_NetObjClass
+{
+public:
+   NXSL_ChassisClass();
+
+   virtual NXSL_Value *getAttr(NXSL_Object *object, const TCHAR *attr);
+};
+
 /**
  * NXSL "Cluster" class
  */
@@ -203,10 +214,11 @@ bool ParseValueList(TCHAR **start, ObjectArray<NXSL_Value> &args);
 extern NXSL_Library *g_pScriptLibrary;
 
 extern NXSL_AlarmClass g_nxslAlarmClass;
+extern NXSL_ChassisClass g_nxslChassisClass;
+extern NXSL_ClusterClass g_nxslClusterClass;
 extern NXSL_DciClass g_nxslDciClass;
 extern NXSL_EventClass g_nxslEventClass;
 extern NXSL_InterfaceClass g_nxslInterfaceClass;
-extern NXSL_ClusterClass g_nxslClusterClass;
 extern NXSL_MobileDeviceClass g_nxslMobileDeviceClass;
 extern NXSL_NetObjClass g_nxslNetObjClass;
 extern NXSL_NodeClass g_nxslNodeClass;
index 95f78b8..7762de0 100644 (file)
@@ -1022,4 +1022,10 @@ Language=English
 Failed to execute threshold script for node "%1" DCI %2 threshold %3: %4
 .
 
+MessageId=
+SymbolicName=MSG_CHASSIS_LOAD_FAILED
+Language=English
+Failed to load chassis object with id %1 from database
+.
+
 ;#endif
index 7fc4b38..fd31874 100644 (file)
@@ -673,13 +673,49 @@ static int NextFreeEPPruleID()
        return ruleId;
 }
 
+/**
+ * Set schema version
+ */
+static bool SetSchemaVersion(int version)
+{
+   TCHAR query[256];
+   _sntprintf(query, 256, _T("UPDATE metadata SET var_value='%d' WHERE var_name='SchemaVersion'"), version);
+   return SQLQuery(query);
+}
+
+/**
+ * Upgrade from V407 to V408
+ */
+static BOOL H_UpgradeFromV407(int currVersion, int newVersion)
+{
+   CHK_EXEC(CreateTable(
+         _T("CREATE TABLE chassis (")
+         _T("   id integer not null,")
+         _T("   controller_id integer not null,")
+         _T("   rack_id integer not null,")
+         _T("   rack_image varchar(36) null,")
+         _T("   rack_position integer not null,")
+         _T("   rack_height integer not null,")
+         _T("   PRIMARY KEY(id))")
+       ));
+
+   static const TCHAR *batch =
+      _T("ALTER TABLE nodes ADD chassis_id integer\n")
+      _T("UPDATE nodes SET chassis_id=0\n")
+      _T("<END>");
+   CHK_EXEC(SQLBatch(batch));
+
+   CHK_EXEC(SetSchemaVersion(408));
+   return TRUE;
+}
+
 /**
  * Upgrade from V406 to V407
  */
 static BOOL H_UpgradeFromV406(int currVersion, int newVersion)
 {
    ResizeColumn(_T("user_groups"), _T("ldap_unique_id"), 64, true);
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='407' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(407));
    return TRUE;
 }
 
@@ -694,7 +730,7 @@ static BOOL H_UpgradeFromV405(int currVersion, int newVersion)
       _T("UPDATE nodes SET syslog_msg_count=0,snmp_trap_count=0\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='406' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(406));
    return TRUE;
 }
 
@@ -735,7 +771,7 @@ static BOOL H_UpgradeFromV404(int currVersion, int newVersion)
    _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOCAL_DATABASE_PROBLEM);
    CHK_EXEC(SQLQuery(query));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='405' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(405));
    return TRUE;
 }
 
@@ -747,7 +783,7 @@ static BOOL H_UpgradeFromV403(int currVersion, int newVersion)
    CHK_EXEC(CreateConfigParam(_T("SyslogIgnoreMessageTimestamp"), _T("0"),
             _T("Ignore timestamp received in syslog messages and always use server time"),
             'B', true, false, false, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='404' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(404));
    return TRUE;
 }
 
@@ -758,7 +794,7 @@ static BOOL H_UpgradeFromV402(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("DROP TABLE policy_time_range_list")));
    CHK_EXEC(SQLQuery(_T("DROP TABLE time_ranges")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='403' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(403));
    return TRUE;
 }
 
@@ -768,7 +804,7 @@ static BOOL H_UpgradeFromV402(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV401(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_event_log_source ON event_log(event_source)")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='402' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(402));
    return TRUE;
 }
 
@@ -800,7 +836,7 @@ static BOOL H_UpgradeFromV400(int currVersion, int newVersion)
    CHK_EXEC(CreateConfigParam(_T("LdapUserUniqueId"), _T(""), true, false, false));
    CHK_EXEC(CreateConfigParam(_T("LdapGroupUniqueId"), _T(""), true, false, false));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='401' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(401));
    return TRUE;
 }
 
@@ -810,7 +846,7 @@ static BOOL H_UpgradeFromV400(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV399(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("JobRetryCount"), _T("5"), _T("Maximum mumber of job execution retrys"), 'I', true, false, false, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='400' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(400));
    return TRUE;
 }
 
@@ -828,7 +864,7 @@ static BOOL H_UpgradeFromV398(int currVersion, int newVersion)
          _T("   PRIMARY KEY(id))")
        ));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='399' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(399));
    return TRUE;
 }
 
@@ -1293,7 +1329,7 @@ static BOOL H_UpgradeFromV397(int currVersion, int newVersion)
    CHK_EXEC(SQLBatch(batch1));
    CHK_EXEC(SQLBatch(batch2));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='398' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(398));
    return TRUE;
 }
 
@@ -1389,7 +1425,7 @@ static BOOL H_UpgradeFromV396(int currVersion, int newVersion)
 
    CHK_EXEC(SQLQuery(_T("ALTER TABLE event_cfg ADD guid varchar(36)")));
    CHK_EXEC(GenerateGUID(_T("event_cfg"), _T("event_code"), _T("guid"), eventGuidMapping));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='397' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(397));
    return TRUE;
 }
 
@@ -1404,7 +1440,7 @@ static BOOL H_UpgradeFromV395(int currVersion, int newVersion)
       _T("   file_content $SQL:TEXT null,")
       _T("   PRIMARY KEY(policy_id))")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='396' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(396));
    return TRUE;
 }
 
@@ -1414,7 +1450,7 @@ static BOOL H_UpgradeFromV395(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV394(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("UPDATE config SET need_server_restart='1' WHERE var_name='OfflineDataRelevanceTime'")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='395' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(395));
    return TRUE;
 }
 
@@ -1424,7 +1460,7 @@ static BOOL H_UpgradeFromV394(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV393(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("OfflineDataRelevanceTime"), _T("86400"), _T("Time period in seconds within which received offline data still relevant for threshold validation"), 'I', true, false, false, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='394' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(394));
    return TRUE;
 }
 
@@ -1434,7 +1470,7 @@ static BOOL H_UpgradeFromV393(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV392(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("DefaultInterfaceExpectedState"), _T("0"), _T("Default expected state for new interface objects"), 'C', true, false, false, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='393' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(393));
    return TRUE;
 }
 
@@ -1444,7 +1480,7 @@ static BOOL H_UpgradeFromV392(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV391(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("ImportConfigurationOnStartup"), _T("0"), _T("Import configuration from local files on server startup"), 'B', true, true, false, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='392' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(392));
    return TRUE;
 }
 
@@ -1461,7 +1497,7 @@ static BOOL H_UpgradeFromV390(int currVersion, int newVersion)
       _T("   items $SQL:TEXT,")
       _T("   PRIMARY KEY(object_id, subscription_type))")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='391' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(391));
    return TRUE;
 }
 
@@ -1521,7 +1557,7 @@ static BOOL H_UpgradeFromV389(int currVersion, int newVersion)
 
    CHK_EXEC(SQLQuery(_T("DROP TABLE containers")));
    CHK_EXEC(SQLQuery(_T("DROP TABLE container_categories")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='390' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(390));
    return TRUE;
 }
 
@@ -1535,7 +1571,7 @@ static BOOL H_UpgradeFromV388(int currVersion, int newVersion)
       _T("UPDATE racks SET top_bottom_num='0'\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='389' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(389));
    return TRUE;
 }
 
@@ -1551,7 +1587,7 @@ static BOOL H_UpgradeFromV387(int currVersion, int newVersion)
       _T("UPDATE event_log SET dci_id=0\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='388' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(388));
    return TRUE;
 }
 
@@ -1583,7 +1619,7 @@ static BOOL H_UpgradeFromV386(int currVersion, int newVersion)
       if (!g_bIgnoreErrors)
          return FALSE;
    }
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='387' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(387));
    return TRUE;
 }
 
@@ -1652,7 +1688,7 @@ static BOOL H_UpgradeFromV385(int currVersion, int newVersion)
    }
 
    CHK_EXEC(SQLQuery(_T("UPDATE event_cfg SET severity='3' WHERE event_code=14 OR event_code=15")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='386' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(386));
    return TRUE;
 }
 
@@ -1662,7 +1698,7 @@ static BOOL H_UpgradeFromV385(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV384(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("UPDATE config SET is_visible=1,need_server_restart=0 WHERE var_name='SNMPPorts'")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='385' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(385));
    return TRUE;
 }
 
@@ -1677,7 +1713,7 @@ static BOOL H_UpgradeFromV383(int currVersion, int newVersion)
       _T("ALTER TABLE graphs ADD filters $SQL:TEXT\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='384' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(384));
    return TRUE;
 }
 
@@ -1687,7 +1723,7 @@ static BOOL H_UpgradeFromV383(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV382(int currVersion, int newVersion)
 {
    CHK_EXEC(ResizeColumn(_T("nodes"), _T("primary_ip"), 48, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='383' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(383));
    return TRUE;
 }
 
@@ -1702,7 +1738,7 @@ static BOOL H_UpgradeFromV381(int currVersion, int newVersion)
    CHK_EXEC(CreateLibraryScript(14, _T("Hook::TopologyPoll"), _T("/* Available global variables:\r\n *  $node - current node, object of 'Node' type\r\n *\r\n * Expected return value:\r\n *  none - returned value is ignored\r\n */\r\n")));
    CHK_EXEC(CreateLibraryScript(15, _T("Hook::CreateInterface"), _T("/* Available global variables:\r\n *  $node - current node, object of 'Node' type\r\n *  $1 - current interface, object of 'Interface' type\r\n *\r\n * Expected return value:\r\n *  true/false - boolean - whether interface should be created\r\n */\r\nreturn true;\r\n")));
    CHK_EXEC(CreateLibraryScript(16, _T("Hook::AcceptNewNode"), _T("/* Available global variables:\r\n *  $ipAddr - IP address of the node being processed\r\n *  $ipNetMask - netmask of the node being processed\r\n *  $macAddr - MAC address of the node being processed\r\n *  $zoneId - zone ID of the node being processed\r\n *\r\n * Expected return value:\r\n *  true/false - boolean - whether node should be created\r\n */\r\nreturn true;\r\n")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='382' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(382));
    return TRUE;
 }
 
@@ -1718,7 +1754,7 @@ static BOOL H_UpgradeFromV380(int currVersion, int newVersion)
    CHK_EXEC(SQLBatch(batch));
    CHK_EXEC(GenerateGUID(_T("items"), _T("item_id"), _T("guid"), NULL));
    CHK_EXEC(GenerateGUID(_T("dc_tables"), _T("item_id"), _T("guid"), NULL));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='381' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(381));
    return TRUE;
 }
 
@@ -1732,7 +1768,7 @@ static BOOL H_UpgradeFromV379(int currVersion, int newVersion)
       _T("UPDATE nodes SET last_agent_comm_time=0 WHERE last_agent_comm_time IS NULL\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='380' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(380));
    return TRUE;
 }
 
@@ -1742,7 +1778,7 @@ static BOOL H_UpgradeFromV379(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV378(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='NumberOfDatabaseWriters'")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='379' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(379));
    return TRUE;
 }
 
@@ -1759,7 +1795,7 @@ static BOOL H_UpgradeFromV377(int currVersion, int newVersion)
       _T("UPDATE config SET var_name='DBConnectionPoolMaxLifetime' WHERE var_name='ConnectionPoolMaxLifetime'\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='378' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(378));
    return TRUE;
 }
 
@@ -1770,7 +1806,7 @@ static BOOL H_UpgradeFromV376(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("DefaultSubnetMaskIPv4"), _T("24"), _T("Default mask for synthetic IPv4 subnets"), 'I', true, false, false, false));
    CHK_EXEC(CreateConfigParam(_T("DefaultSubnetMaskIPv6"), _T("64"), _T("Default mask for synthetic IPv6 subnets"), 'I', true, false, false, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='377' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(377));
    return TRUE;
 }
 
@@ -1785,7 +1821,7 @@ static BOOL H_UpgradeFromV375(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='376' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(376));
    return TRUE;
 }
 
@@ -1800,7 +1836,7 @@ static BOOL H_UpgradeFromV374(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='375' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(375));
    return TRUE;
 }
 
@@ -1823,7 +1859,7 @@ static BOOL H_UpgradeFromV373(int currVersion, int newVersion)
          _T("Left maintenance mode"),
          _T("Generated when node, cluster, or mobile device leaves maintenance mode.")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='374' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(374));
    return TRUE;
 }
 
@@ -1833,7 +1869,7 @@ static BOOL H_UpgradeFromV373(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV372(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("ALTER TABLE scheduled_tasks ADD object_id integer")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='373' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(373));
    return TRUE;
 }
 
@@ -1847,7 +1883,7 @@ static BOOL H_UpgradeFromV371(int currVersion, int newVersion)
       _T("UPDATE object_properties SET maint_mode='0'\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='372' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(372));
    return TRUE;
 }
 
@@ -1872,7 +1908,7 @@ static BOOL H_UpgradeFromV370(int currVersion, int newVersion)
    _sntprintf(query, 256, _T("UPDATE dc_tables SET retention_time=0 WHERE retention_time=%d"), defaultRetentionTime);
    CHK_EXEC(SQLQuery(query));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='371' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(371));
    return TRUE;
 }
 
@@ -1886,7 +1922,7 @@ static BOOL H_UpgradeFromV369(int currVersion, int newVersion)
       _T("   object_id integer not null,")
       _T("   dashboard_id integer not null,")
       _T("   PRIMARY KEY(object_id,dashboard_id))")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='370' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(370));
    return TRUE;
 }
 
@@ -1906,7 +1942,7 @@ static BOOL H_UpgradeFromV368(int currVersion, int newVersion)
       _T("   flags integer not null,")
       _T("   owner integer not null,")
       _T("   PRIMARY KEY(id))")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='369' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(369));
    return TRUE;
 }
 
@@ -1920,7 +1956,7 @@ static BOOL H_UpgradeFromV367(int currVersion, int newVersion)
       _T("UPDATE nodes SET rack_height=1\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='368' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(368));
    return TRUE;
 }
 
@@ -1934,7 +1970,7 @@ static BOOL H_UpgradeFromV366(int currVersion, int newVersion)
    CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD snmp_sys_contact varchar(127)")));
    CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD snmp_sys_location varchar(127)")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='367' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(367));
    return TRUE;
 }
 
@@ -1945,7 +1981,7 @@ static BOOL H_UpgradeFromV365(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("ServerCommandOutputTimeout"), _T("60"), true, false));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='366' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(366));
    return TRUE;
 }
 
@@ -1955,7 +1991,7 @@ static BOOL H_UpgradeFromV365(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV364(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("SNMPPorts"), _T("161"), true, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='365' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(365));
    return TRUE;
 }
 
@@ -1971,7 +2007,7 @@ static BOOL H_UpgradeFromV363(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='364' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(364));
    return TRUE;
 }
 
@@ -1981,7 +2017,7 @@ static BOOL H_UpgradeFromV363(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV362(int currVersion, int newVersion)
 {
    ResizeColumn(_T("config"), _T("var_value"), 2000, true);
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='363' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(363));
    return TRUE;
 }
 
@@ -1991,7 +2027,7 @@ static BOOL H_UpgradeFromV362(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV361(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("CaseInsensitiveLoginNames"), _T("0"), _T("Enable/disable case insensitive login names"), 'B', true, true, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='362' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(362));
    return TRUE;
 }
 
@@ -2009,7 +2045,7 @@ static BOOL H_UpgradeFromV360(int currVersion, int newVersion)
       _T("   config $SQL:TEXT null,")
       _T("   PRIMARY KEY(tool_id,name))")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='361' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(361));
    return TRUE;
 }
 
@@ -2051,7 +2087,7 @@ static BOOL H_UpgradeFromV359(int currVersion, int newVersion)
       if (!g_bIgnoreErrors)
          return FALSE;
    }
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='360' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(360));
    return TRUE;
 }
 
@@ -2066,7 +2102,7 @@ static BOOL H_UpgradeFromV358(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='359' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(359));
    return TRUE;
 }
 
@@ -2091,7 +2127,7 @@ static BOOL H_UpgradeFromV357(int currVersion, int newVersion)
 
    CHK_EXEC(CreateConfigParam(_T("DashboardDataExportEnableInterpolation"), _T("1"), _T("Enable/disable data interpolation in dashboard data export"), 'B', true, false, true));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='358' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(358));
    return TRUE;
 }
 
@@ -2134,7 +2170,7 @@ static BOOL H_UpgradeFromV356(int currVersion, int newVersion)
 
    CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='DefaultCommunityString'")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='357' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(357));
    return TRUE;
 }
 
@@ -2158,7 +2194,7 @@ static BOOL H_UpgradeFromV355(int currVersion, int newVersion)
    CHK_EXEC(CreateConfigParam(_T("PollerThreadPoolBaseSize"), _T("10"), true, true));
    CHK_EXEC(CreateConfigParam(_T("PollerThreadPoolMaxSize"), _T("250"), true, true));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='356' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(356));
    return TRUE;
 }
 
@@ -2176,7 +2212,7 @@ static BOOL H_UpgradeFromV354(int currVersion, int newVersion)
 
    CHK_EXEC(CreateConfigParam(_T("DefaultAgentCacheMode"), _T("2"), true, true));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='355' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(355));
    return TRUE;
 }
 
@@ -2186,7 +2222,7 @@ static BOOL H_UpgradeFromV354(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV353(int currVersion, int newVersion)
 {
    CHK_EXEC(ResizeColumn(_T("users"), _T("password"), 127, false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='354' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(354));
    return TRUE;
 }
 
@@ -2197,7 +2233,7 @@ static BOOL H_UpgradeFromV352(int currVersion, int newVersion)
 {
        CHK_EXEC(SQLQuery(_T("ALTER TABLE dci_summary_tables ADD guid varchar(36)")));
    CHK_EXEC(GenerateGUID(_T("dci_summary_tables"), _T("id"), _T("guid"), NULL));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='353' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(353));
    return TRUE;
 }
 
@@ -2208,7 +2244,7 @@ static BOOL H_UpgradeFromV351(int currVersion, int newVersion)
 {
        CHK_EXEC(SQLQuery(_T("ALTER TABLE object_tools ADD guid varchar(36)")));
    CHK_EXEC(GenerateGUID(_T("object_tools"), _T("tool_id"), _T("guid"), NULL));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='352' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(352));
    return TRUE;
 }
 
@@ -2223,7 +2259,7 @@ static BOOL H_UpgradeFromV350(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='351' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(351));
    return TRUE;
 }
 
@@ -2257,7 +2293,7 @@ static BOOL H_UpgradeFromV349(int currVersion, int newVersion)
        }
 
    CHK_EXEC(SQLDropColumn(_T("ap_common"), _T("description")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='350' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(350));
    return TRUE;
 }
 
@@ -2268,7 +2304,7 @@ static BOOL H_UpgradeFromV348(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='HouseKeepingInterval'")));
    CHK_EXEC(CreateConfigParam(_T("HousekeeperStartTime"), _T("02:00"), true, true));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='349' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(349));
    return TRUE;
 }
 
@@ -2297,7 +2333,7 @@ static BOOL H_UpgradeFromV347(int currVersion, int newVersion)
          _T("    4) Network mask\r\n")
          _T("    5) Interface index")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='348' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(348));
    return TRUE;
 }
 
@@ -2338,7 +2374,7 @@ static BOOL H_UpgradeFromV346(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='347' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(347));
    return TRUE;
 }
 
@@ -2402,7 +2438,7 @@ static BOOL H_UpgradeFromV345(int currVersion, int newVersion)
       CHK_EXEC(SQLQuery(_T("ALTER TABLE vpn_connector_networks ADD CONSTRAINT pk_vpn_connector_networks PRIMARY KEY (vpn_id,ip_addr)")));
    }
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='346' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(346));
    return TRUE;
 }
 
@@ -2413,7 +2449,7 @@ static BOOL H_UpgradeFromV344(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("NumberOfInstancePollers"), _T("10"), 1, 1));
    CHK_EXEC(CreateConfigParam(_T("InstancePollingInterval"), _T("600"), 1, 1));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='345' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(345));
    return TRUE;
 }
 
@@ -2428,7 +2464,7 @@ static BOOL H_UpgradeFromV343(int currVersion, int newVersion)
       _T("UPDATE interfaces SET mtu=0\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='344' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(344));
    return TRUE;
 }
 
@@ -2444,7 +2480,7 @@ static BOOL H_UpgradeFromV342(int currVersion, int newVersion)
       ReindexIData();
       CHK_EXEC(DBBegin(g_hCoreDB));
    }
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='343' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(343));
    return TRUE;
 }
 
@@ -2491,7 +2527,7 @@ static BOOL H_UpgradeFromV341(int currVersion, int newVersion)
       }
    }
    CHK_EXEC(SQLDropColumn(_T("object_tools"), _T("matching_oid"))); //delete old column
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='342' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(342));
    return TRUE;
 }
 
@@ -2507,7 +2543,7 @@ static BOOL H_UpgradeFromV340(int currVersion, int newVersion)
       _T("ALTER TABLE object_properties ADD postcode varchar(31)\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='341' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(341));
    return TRUE;
 }
 
@@ -2518,7 +2554,7 @@ static BOOL H_UpgradeFromV339(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("LdapPageSize"), _T("1000"), 1, 0));
    CHK_EXEC(SQLQuery(_T("UPDATE config SET var_value='1' WHERE var_name='LdapUserDeleteAction'")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='340' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(340));
    return TRUE;
 }
 
@@ -2528,7 +2564,7 @@ static BOOL H_UpgradeFromV339(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV338(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("EscapeLocalCommands"), _T("0"), 1, 0));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='339' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(339));
    return TRUE;
 }
 
@@ -2542,7 +2578,7 @@ static BOOL H_UpgradeFromV337(int currVersion, int newVersion)
       _T("UPDATE nodes SET icmp_proxy=0\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='338' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(338));
    return TRUE;
 }
 
@@ -2552,7 +2588,7 @@ static BOOL H_UpgradeFromV337(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV336(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("SyslogNodeMatchingPolicy"), _T("0"), 1, 1));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='337' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(337));
    return TRUE;
 }
 
@@ -2563,7 +2599,7 @@ static BOOL H_UpgradeFromV335(int currVersion, int newVersion)
 {
    CHK_EXEC(ResizeColumn(_T("network_map_links"), _T("connector_name1"), 255, true));
    CHK_EXEC(ResizeColumn(_T("network_map_links"), _T("connector_name2"), 255, true));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='336' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(336));
    return TRUE;
 }
 
@@ -2582,7 +2618,7 @@ static BOOL H_UpgradeFromV334(int currVersion, int newVersion)
          _T("    4) New network mask\r\n")
          _T("    5) Interface index\r\n")
          _T("    6) Old network mask")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='335' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(335));
    return TRUE;
 }
 
@@ -2592,7 +2628,7 @@ static BOOL H_UpgradeFromV334(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV333(int currVersion, int newVersion)
 {
    CHK_EXEC(SetColumnNullable(_T("user_groups"), _T("description")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='334' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(334));
    return TRUE;
 }
 
@@ -2606,7 +2642,7 @@ static BOOL H_UpgradeFromV332(int currVersion, int newVersion)
       _T("   VALUES ('LocationHistory','CREATE TABLE gps_history_%d (latitude varchar(20), longitude varchar(20), accuracy integer not null, start_timestamp integer not null, end_timestamp integer not null, PRIMARY KEY(start_timestamp))')\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='333' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(333));
    return TRUE;
 }
 
@@ -2616,7 +2652,7 @@ static BOOL H_UpgradeFromV332(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV331(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("UPDATE items SET instd_data=instance WHERE node_id=template_id AND instd_method=0")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='332' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(332));
    return TRUE;
 }
 
@@ -2633,7 +2669,7 @@ static BOOL H_UpgradeFromV330(int currVersion, int newVersion)
    {
       CHK_EXEC(SQLQuery(_T("ALTER TABLE audit_log ADD session_id integer NOT NULL DEFAULT 0")));
    }
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='331' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(331));
    return TRUE;
 }
 
@@ -2643,7 +2679,7 @@ static BOOL H_UpgradeFromV330(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV329(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("AlarmListDisplayLimit"), _T("4096"), 1, 0));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='330' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(330));
    return TRUE;
 }
 
@@ -2654,7 +2690,7 @@ static BOOL H_UpgradeFromV328(int currVersion, int newVersion)
 {
        CHK_EXEC(SQLQuery(_T("ALTER TABLE items ADD comments $SQL:TEXT")));
        CHK_EXEC(SQLQuery(_T("ALTER TABLE dc_tables ADD comments $SQL:TEXT")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='329' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(329));
    return TRUE;
 }
 
@@ -2664,7 +2700,7 @@ static BOOL H_UpgradeFromV328(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV327(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("ResolveDNSToIPOnStatusPoll"), _T("0"), 1, 1));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='328' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(328));
    return TRUE;
 }
 
@@ -2675,7 +2711,7 @@ static BOOL H_UpgradeFromV326(int currVersion, int newVersion)
 {
    CHK_EXEC(DropPrimaryKey(_T("network_map_links")));
    CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_network_map_links_map_id ON network_map_links(map_id)")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='327' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(327));
    return TRUE;
 }
 
@@ -2697,7 +2733,7 @@ static BOOL H_UpgradeFromV325(int currVersion, int newVersion)
       CHK_EXEC(SQLQuery(_T("CALL Sysproc.admin_cmd('REORG TABLE network_map_links')")));
    }
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='326' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(326));
    return TRUE;
 }
 
@@ -2781,7 +2817,7 @@ static BOOL H_UpgradeFromV324(int currVersion, int newVersion)
       DBFreeResult(hResult);
    }
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='325' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(325));
    return TRUE;
 }
 
@@ -2804,7 +2840,7 @@ static BOOL H_UpgradeFromV323(int currVersion, int newVersion)
    }
 
    CHK_EXEC(SQLQuery(_T("DELETE FROM metadata WHERE var_name='ValidTDataIndex'")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='324' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(324));
    return TRUE;
 }
 
@@ -2814,7 +2850,7 @@ static BOOL H_UpgradeFromV323(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV322(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("ProcessTrapsFromUnmanagedNodes"), _T("0"), 1, 1));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='323' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(323));
    return TRUE;
 }
 
@@ -2872,7 +2908,7 @@ static BOOL H_UpgradeFromV321(int currVersion, int newVersion)
                        break;
        }
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='322' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(322));
    return TRUE;
 }
 
@@ -2888,7 +2924,7 @@ static BOOL H_UpgradeFromV320(int currVersion, int newVersion)
       _T("UPDATE object_tools SET command_short_name='Wakeup' WHERE tool_id=3\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='321' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(321));
    return TRUE;
 }
 
@@ -2916,7 +2952,7 @@ static BOOL H_UpgradeFromV319(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='320' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(320));
    return TRUE;
 }
 
@@ -2933,7 +2969,7 @@ static BOOL H_UpgradeFromV318(int currVersion, int newVersion)
       _T("UPDATE object_tools SET flags=64,command_name='Wakeup node using Wake-On-LAN',icon='89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff610000000473424954080808087c086488000000097048597300000dd700000dd70142289b780000001974455874536f667477617265007777772e696e6b73636170652e6f72679bee3c1a0000023649444154388d8d924f48545114c67ff7bd37ff7cf9071bc70a4d47271ca15c848d448185b40a89204890362d8568eb2270d7a2762d5cb7711504d1ae10c195218895a488528e4e06a653d338de7bdfbcf75ac84ce38c901f9ccdb9e7fbce39f77c627ce6872df6dd71f01f781e1d9c00866003215efaf99de7d6763afb1078721262053a800908ed5a5aa9b1e3bb0802a600c0717d3cdf3fae6cccd24a25abb302a80b990c265a009859d941299763249296d6b2a6732468d25a1f24156f00e0cbd62e9b5a71a0dd9a490cad14a570b4266c780cf546797cab1b1317139747435ddcec69266c78385a53c9b1b45265b548d022d51563f45a9c778b69ce35850058de928c0cb4933fd04c7ffece812e9639e5158480865098ebc9181fbfeef07a6e9dc68805c0af8243f45480ab174e33bb9426e7484a9b942710020c3b40e24c236f3facb1bd9b634d3a00d8e100ab992cb7af7421bc225aa9b280a195a414524972054d5f679488e5a394442949d8f4b8d4d14caea09115f55a490cad155a2b9452ecfdcef37e619ddef6287706ba89c76ce2319be1fe4e926d51663e6d90cdeda3d42147ebaa4fcc161da6a61739df52cfe88d8b0ca712f8be871d0e31bb94666a7a916c2e8feb7aff3cd33ef2f4c8612dd3a0a5d1a6bfa78d544f1bbeef33bf9a617e65939fb902c50a328068bd3bb10c1c71a3210401cb24143cbc82d2459c62ad8980154b2b3909bca87e91c09fea642d26ad67f7fb32afe6bebd5958dd1c2c48ddf45f8a10d87591bdcb89b3b3f7063a337f01f30f1c1c580292640000000049454e44ae426082' WHERE tool_id=3\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='319' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(319));
    return TRUE;
 }
 
@@ -2954,7 +2990,7 @@ static BOOL H_UpgradeFromV317(int currVersion, int newVersion)
                _T("    6) Access point model\r\n")
                _T("    7) Access point serial number")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='318' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(318));
    return TRUE;
 }
 
@@ -2964,7 +3000,7 @@ static BOOL H_UpgradeFromV317(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV316(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("MinViewRefreshInterval"), _T("1000"), 1, 0));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='317' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(317));
    return TRUE;
 }
 
@@ -3003,7 +3039,7 @@ static BOOL H_UpgradeFromV315(int currVersion, int newVersion)
                _T("    6) Access point model\r\n")
                _T("    7) Access point serial number")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='316' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(316));
    return TRUE;
 }
 
@@ -3018,7 +3054,7 @@ static BOOL H_UpgradeFromV314(int currVersion, int newVersion)
       _T("UPDATE thresholds SET match_count=1 WHERE current_state<>0\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='315' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(315));
    return TRUE;
 }
 
@@ -3049,7 +3085,7 @@ static BOOL H_UpgradeFromV313(int currVersion, int newVersion)
       DBFreeResult(hResult);
    }
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='314' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(314));
    return TRUE;
 }
 
@@ -3070,7 +3106,7 @@ static BOOL H_UpgradeFromV312(int currVersion, int newVersion)
    CHK_EXEC(ConvertStrings(_T("object_tools"), _T("tool_id"), _T("confirmation_text")));
    CHK_EXEC(ConvertStrings(_T("object_tools"), _T("tool_id"), _T("matching_oid")));
    CHK_EXEC(ConvertStrings(_T("object_tools_table_columns"), _T("tool_id"), _T("col_number"), _T("col_name"), false));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='313' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(313));
    return TRUE;
 }
 
@@ -3082,7 +3118,7 @@ static BOOL H_UpgradeFromV311(int currVersion, int newVersion)
    CHK_EXEC(CreateConfigParam(_T("EnableReportingServer"), _T("0"), 1, 1));
    CHK_EXEC(CreateConfigParam(_T("ReportingServerHostname"), _T("localhost"), 1, 1));
    CHK_EXEC(CreateConfigParam(_T("ReportingServerPort"), _T("4710"), 1, 1));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='312' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(312));
    return TRUE;
 }
 
@@ -3137,7 +3173,7 @@ static BOOL H_UpgradeFromV310(int currVersion, int newVersion)
       _T("DELETE FROM object_properties WHERE object_id=8\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='311' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(311));
    return TRUE;
 }
 
@@ -3151,7 +3187,7 @@ static BOOL H_UpgradeFromV309(int currVersion, int newVersion)
       _T("UPDATE interfaces SET peer_proto=0\n")
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='310' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(310));
    return TRUE;
 }
 
@@ -3161,7 +3197,7 @@ static BOOL H_UpgradeFromV309(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV308(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("HelpDeskLink"), _T("none"), 1, 1));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='309' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(309));
    return TRUE;
 }
 
@@ -3200,7 +3236,7 @@ static BOOL H_UpgradeFromV307(int currVersion, int newVersion)
                DBFreeResult(hResult);
        }
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='308' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(308));
    return TRUE;
 }
 
@@ -3211,7 +3247,7 @@ static BOOL H_UpgradeFromV306(int currVersion, int newVersion)
 {
        CHK_EXEC(SetColumnNullable(_T("config_clob"), _T("var_value")));
        CHK_EXEC(ConvertStrings(_T("config_clob"), _T("var_name"), NULL, _T("var_value"), true));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='307' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(307));
    return TRUE;
 }
 
@@ -3223,7 +3259,7 @@ static BOOL H_UpgradeFromV305(int currVersion, int newVersion)
    CHK_EXEC(CreateConfigParam(_T("ExtendedLogQueryAccessControl"), _T("0"), 1, 0));
    CHK_EXEC(CreateConfigParam(_T("EnableTimedAlarmAck"), _T("1"), 1, 1));
    CHK_EXEC(CreateConfigParam(_T("EnableCheckPointSNMP"), _T("0"), 1, 0));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='306' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(306));
    return TRUE;
 }
 
@@ -3248,7 +3284,7 @@ static BOOL H_UpgradeFromV304(int currVersion, int newVersion)
                _T("   10) Peer interface name\r\n")
                _T("   11) Peer interface IP address\r\n")
                _T("   12) Peer interface MAC address")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='305' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(305));
    return TRUE;
 }
 
@@ -3258,7 +3294,7 @@ static BOOL H_UpgradeFromV304(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV303(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("StrictAlarmStatusFlow"), _T("0"), 1, 0));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='304' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(304));
    return TRUE;
 }
 
@@ -3273,7 +3309,7 @@ static BOOL H_UpgradeFromV302(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='303' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(303));
    return TRUE;
 }
 
@@ -3287,7 +3323,7 @@ static BOOL H_UpgradeFromV301(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='302' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(302));
    return TRUE;
 }
 
@@ -3305,7 +3341,7 @@ static BOOL H_UpgradeFromV300(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='301' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(301));
    return TRUE;
 }
 
@@ -3335,7 +3371,7 @@ static BOOL H_UpgradeFromV299(int currVersion, int newVersion)
 
    CHK_EXEC(SQLQuery(_T("ALTER TABLE users ADD xmpp_id varchar(127)")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='300' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(300));
    return TRUE;
 }
 
@@ -3360,7 +3396,7 @@ static BOOL H_UpgradeFromV298(int currVersion, int newVersion)
       _T("   3) IP address\r\n")
       _T("   4) Network mask")
       _T("' WHERE event_code=19")));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='299' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(299));
    return TRUE;
 }
 
@@ -3370,7 +3406,7 @@ static BOOL H_UpgradeFromV298(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV297(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("AgentDefaultSharedSecret"), _T("netxms"), 1, 0));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='298' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(298));
    return TRUE;
 }
 
@@ -3380,7 +3416,7 @@ static BOOL H_UpgradeFromV297(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV296(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("UseSNMPTrapsForDiscovery"), _T("0"), 1, 1));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='297' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(297));
    return TRUE;
 }
 
@@ -3395,7 +3431,7 @@ static BOOL H_UpgradeFromV295(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='296' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(296));
    return TRUE;
 }
 
@@ -3405,7 +3441,7 @@ static BOOL H_UpgradeFromV295(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV294(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("IcmpPingTimeout"), _T("1500"), 1, 1));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='295' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(295));
    return TRUE;
 }
 
@@ -3432,7 +3468,7 @@ static BOOL H_UpgradeFromV293(int currVersion, int newVersion)
    RecreateTData(_T("mobile_devices"), true, false);
 
    CHK_EXEC(SQLQuery(_T("INSERT INTO metadata (var_name,var_value) VALUES ('ValidTDataIndex','1')")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='294' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(294));
    return TRUE;
 }
 
@@ -3442,7 +3478,7 @@ static BOOL H_UpgradeFromV293(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV292(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("DefaultConsoleShortTimeFormat"), _T("HH:mm"), 1, 0));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='293' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(293));
    return TRUE;
 }
 
@@ -3453,7 +3489,7 @@ static BOOL H_UpgradeFromV291(int currVersion, int newVersion)
 {
        CHK_EXEC(SQLQuery(_T("ALTER TABLE event_policy ADD rule_guid varchar(36)")));
    CHK_EXEC(GenerateGUID(_T("event_policy"), _T("rule_id"), _T("rule_guid"), NULL));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='292' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(292));
    return TRUE;
 }
 
@@ -3463,7 +3499,7 @@ static BOOL H_UpgradeFromV291(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV290(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("UPDATE network_services SET service_type=7 WHERE service_type=6")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='291' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(291));
    return TRUE;
 }
 
@@ -3473,7 +3509,7 @@ static BOOL H_UpgradeFromV290(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV289(int currVersion, int newVersion)
 {
    CHK_EXEC(SQLQuery(_T("ALTER TABLE network_maps ADD filter $SQL:TEXT")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='290' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(290));
    return TRUE;
 }
 
@@ -3486,7 +3522,7 @@ static BOOL H_UpgradeFromV288(int currVersion, int newVersion)
        _T("ALTER TABLE dct_thresholds DROP COLUMN current_state\n")
        _T("<END>");
    CHK_EXEC(SQLBatch(batch));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='289' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(289));
    return TRUE;
 }
 
@@ -3515,7 +3551,7 @@ static BOOL H_UpgradeFromV287(int currVersion, int newVersion)
       _T("   4) Table row\r\n")
       _T("   5) Instance")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='288' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(288));
    return TRUE;
 }
 
@@ -3530,7 +3566,7 @@ static BOOL H_UpgradeFromV286(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='287' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(287));
    return TRUE;
 }
 
@@ -3559,7 +3595,7 @@ static BOOL H_UpgradeFromV285(int currVersion, int newVersion)
       _T("check_value varchar(255) null,")
       _T("PRIMARY KEY(threshold_id,group_id,sequence_number))")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='286' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(286));
    return TRUE;
 }
 
@@ -3571,7 +3607,7 @@ static BOOL H_UpgradeFromV284(int currVersion, int newVersion)
    CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_items_node_id ON items(node_id)")));
    CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_dc_tables_node_id ON dc_tables(node_id)")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='285' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(285));
    return TRUE;
 }
 
@@ -3582,7 +3618,7 @@ static BOOL H_UpgradeFromV283(int currVersion, int newVersion)
 {
    CHK_EXEC(CreateConfigParam(_T("SNMPTrapPort"), _T("162"), 1, 1));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='284' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(284));
    return TRUE;
 }
 
@@ -3597,7 +3633,7 @@ static BOOL H_UpgradeFromV282(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='283' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(283));
    return TRUE;
 }
 
@@ -3609,7 +3645,7 @@ static BOOL H_UpgradeFromV281(int currVersion, int newVersion)
    CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='WindowsConsoleUpgradeURL'")));
    CHK_EXEC(CreateConfigParam(_T("EnableObjectTransactions"), _T("0"), 1, 1));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='282' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(282));
    return TRUE;
 }
 
@@ -3635,7 +3671,7 @@ static BOOL H_UpgradeFromV280(int currVersion, int newVersion)
    RecreateTData(_T("clusters"), false, false);
    RecreateTData(_T("mobile_devices"), false, false);
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='281' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(281));
    return TRUE;
 }
 
@@ -3677,7 +3713,7 @@ static BOOL H_UpgradeFromV279(int currVersion, int newVersion)
 
    CHK_EXEC(SQLQuery(_T("ALTER TABLE dc_tables DROP COLUMN instance_column")));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='280' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(280));
    return TRUE;
 }
 
@@ -3689,7 +3725,7 @@ static BOOL H_UpgradeFromV278(int currVersion, int newVersion)
    CHK_EXEC(CreateConfigParam(_T("DeleteEventsOfDeletedObject"), _T("1"), 1, 0));
    CHK_EXEC(CreateConfigParam(_T("DeleteAlarmsOfDeletedObject"), _T("1"), 1, 0));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='279' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(279));
    return TRUE;
 }
 
@@ -3730,7 +3766,7 @@ static BOOL H_UpgradeFromV277(int currVersion, int newVersion)
          return FALSE;
    }
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='278' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(278));
    return TRUE;
 }
 
@@ -3750,7 +3786,7 @@ static BOOL H_UpgradeFromV276(int currVersion, int newVersion)
 
        CHK_EXEC(CreateConfigParam(_T("DefaultMapBackgroundColor"), _T("0xffffff"), 1, 0));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='277' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(277));
    return TRUE;
 }
 
@@ -3765,7 +3801,7 @@ static BOOL H_UpgradeFromV275(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='276' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(276));
    return TRUE;
 }
 
@@ -3796,7 +3832,7 @@ static BOOL H_UpgradeFromV274(int currVersion, int newVersion)
                                                                _T("height integer not null,")
                             _T("PRIMARY KEY(id))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='275' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(275));
    return TRUE;
 }
 
@@ -3811,7 +3847,7 @@ static BOOL H_UpgradeFromV273(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='274' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(274));
    return TRUE;
 }
 
@@ -3822,7 +3858,7 @@ static BOOL H_UpgradeFromV272(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("DefaultDCIRetentionTime"), _T("30"), 1, 0));
        CHK_EXEC(CreateConfigParam(_T("DefaultDCIPollingInterval"), _T("60"), 1, 0));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='273' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(273));
    return TRUE;
 }
 
@@ -3833,7 +3869,7 @@ static BOOL H_UpgradeFromV271(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("SNMPTrapLogRetentionTime"), _T("90"), 1, 0));
    CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD driver_name varchar(32)\n")));
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='272' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(272));
    return TRUE;
 }
 
@@ -3849,7 +3885,7 @@ static BOOL H_UpgradeFromV270(int currVersion, int newVersion)
       _T("<END>");
    CHK_EXEC(SQLBatch(batch));
 
-   CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='271' WHERE var_name='SchemaVersion'")));
+   CHK_EXEC(SetSchemaVersion(271));
    return TRUE;
 }
 
@@ -3866,7 +3902,7 @@ static BOOL H_UpgradeFromV269(int currVersion, int newVersion)
                _T("<END>");
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='270' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(270));
        return TRUE;
 }
 
@@ -3949,7 +3985,7 @@ static BOOL H_UpgradeFromV268(int currVersion, int newVersion)
        CHK_EXEC(ConvertStrings(_T("event_cfg"), _T("event_code"), _T("description")));
        CHK_EXEC(ConvertStrings(_T("event_cfg"), _T("event_code"), _T("message")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='269' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(269));
        return TRUE;
 }
 
@@ -3969,7 +4005,7 @@ static BOOL H_UpgradeFromV267(int currVersion, int newVersion)
        CHK_EXEC(SetColumnNullable(_T("dci_schedules"), _T("schedule")));
        CHK_EXEC(ConvertStrings(_T("dci_schedules"), _T("schedule_id"), _T("item_id"), _T("schedule"), false));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='268' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(268));
        return TRUE;
 }
 
@@ -3981,7 +4017,7 @@ static BOOL H_UpgradeFromV266(int currVersion, int newVersion)
        CHK_EXEC(CreateEventTemplate(EVENT_NODE_UNREACHABLE, _T("SYS_NODE_UNREACHABLE"), EVENT_SEVERITY_CRITICAL,
                                     EF_LOG, NULL, _T("Node unreachable because of network failure"),
                                                                                  _T("Generated when node is unreachable by management server because of network failure.\r\nParameters:\r\n   No event-specific parameters")));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='267' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(267));
        return TRUE;
 }
 
@@ -4033,7 +4069,7 @@ static BOOL H_UpgradeFromV265(int currVersion, int newVersion)
 
        CHK_EXEC(CreateConfigParam(_T("FirstFreeObjectId"), _T("100"), 0, 1, FALSE));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='266' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(266));
        return TRUE;
 }
 
@@ -4053,7 +4089,7 @@ static BOOL H_UpgradeFromV264(int currVersion, int newVersion)
                             _T("message varchar(255) null,")
                             _T("PRIMARY KEY(alarm_id,event_id))")));
        CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_alarm_events_alarm_id ON alarm_events(alarm_id)")));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='265' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(265));
        return TRUE;
 }
 
@@ -4074,7 +4110,7 @@ static BOOL H_UpgradeFromV263(int currVersion, int newVersion)
                                                                _T("battery_level integer not null,")
                             _T("PRIMARY KEY(id))")));
        CHK_EXEC(CreateConfigParam(_T("MobileDeviceListenerPort"), _T("4747"), 1, 1));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='264' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(264));
        return TRUE;
 }
 
@@ -4085,7 +4121,7 @@ static BOOL H_UpgradeFromV262(int currVersion, int newVersion)
 {
        CHK_EXEC(SQLQuery(_T("ALTER TABLE network_maps ADD radius integer")));
        CHK_EXEC(SQLQuery(_T("UPDATE network_maps SET radius=-1")));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='263' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(263));
        return TRUE;
 }
 
@@ -4095,7 +4131,7 @@ static BOOL H_UpgradeFromV262(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV261(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("ApplyDCIFromTemplateToDisabledDCI"), _T("0"), 1, 1));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='262' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(262));
        return TRUE;
 }
 
@@ -4106,7 +4142,7 @@ static BOOL H_UpgradeFromV260(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("NumberOfBusinessServicePollers"), _T("10"), 1, 1));
        CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='NumberOfEventProcessors'")));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='261' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(261));
        return TRUE;
 }
 
@@ -4116,7 +4152,7 @@ static BOOL H_UpgradeFromV260(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV259(int currVersion, int newVersion)
 {
        CHK_EXEC(CreateConfigParam(_T("UseFQDNForNodeNames"), _T("1"), 1, 1));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='260' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(260));
        return TRUE;
 }
 
@@ -4131,7 +4167,7 @@ static BOOL H_UpgradeFromV258(int currVersion, int newVersion)
        CHK_EXEC(SetColumnNullable(_T("templates"), _T("apply_filter")));
        CHK_EXEC(SetColumnNullable(_T("containers"), _T("auto_bind_filter")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='259' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(259));
        return TRUE;
 }
 
@@ -4149,7 +4185,7 @@ static BOOL H_UpgradeFromV257(int currVersion, int newVersion)
 
        CHK_EXEC(CreateConfigParam(_T("DeleteUnreachableNodesPeriod"), _T("0"), 1, 1));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='258' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(258));
        return TRUE;
 }
 
@@ -4169,7 +4205,7 @@ static BOOL H_UpgradeFromV256(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='257' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(257));
    return TRUE;
 }
 
@@ -4181,7 +4217,7 @@ static BOOL H_UpgradeFromV255(int currVersion, int newVersion)
        CHK_EXEC(CreateConfigParam(_T("DefaultConsoleDateFormat"), _T("dd.MM.yyyy"), 1, 0));
        CHK_EXEC(CreateConfigParam(_T("DefaultConsoleTimeFormat"), _T("HH:mm:ss"), 1, 0));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='256' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(256));
    return TRUE;
 }
 
@@ -4198,7 +4234,7 @@ static BOOL H_UpgradeFromV254(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='255' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(255));
    return TRUE;
 }
 
@@ -4218,7 +4254,7 @@ static BOOL H_UpgradeFromV253(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='254' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(254));
    return TRUE;
 }
 
@@ -4289,7 +4325,7 @@ static BOOL H_UpgradeFromV252(int currVersion, int newVersion)
        _sntprintf(buffer, 64, _T("%d"), ConfigReadInt(_T("AllowedCiphers"), 15) + 16);
        CreateConfigParam(_T("AllowedCiphers"), buffer, 1, 1, TRUE);
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='253' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(253));
    return TRUE;
 }
 
@@ -4359,7 +4395,7 @@ static BOOL H_UpgradeFromV251(int currVersion, int newVersion)
        _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_INTERFACE_EXPECTED_DOWN);
        CHK_EXEC(SQLQuery(query));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='252' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(252));
    return TRUE;
 }
 
@@ -4385,7 +4421,7 @@ static BOOL H_UpgradeFromV250(int currVersion, int newVersion)
        CHK_EXEC(CreateConfigParam(_T("UseDNSNameForDiscoveredNodes"), _T("0"), 1, 0));
        CHK_EXEC(CreateConfigParam(_T("AllowTrapVarbindsConversion"), _T("1"), 1, 1));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='251' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(251));
    return TRUE;
 }
 
@@ -4399,7 +4435,7 @@ static BOOL H_UpgradeFromV249(int currVersion, int newVersion)
                                                                _T("content $SQL:TEXT null,")
                             _T("PRIMARY KEY(id))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='250' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(250));
    return TRUE;
 }
 
@@ -4480,7 +4516,7 @@ static BOOL H_UpgradeFromV248(int currVersion, int newVersion)
                        return FALSE;
        }
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='249' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(249));
    return TRUE;
 }
 
@@ -4517,7 +4553,7 @@ static BOOL H_UpgradeFromV247(int currVersion, int newVersion)
                                                                _T("transformation_script $SQL:TEXT null,")
                             _T("PRIMARY KEY(table_id,column_name))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='248' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(248));
    return TRUE;
 }
 
@@ -4598,7 +4634,7 @@ static BOOL H_UpgradeFromV246(int currVersion, int newVersion)
        CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_ocattr_oid ON object_custom_attributes(object_id)")));
        CHK_EXEC(CreateConfigParam(_T("AlarmHistoryRetentionTime"), _T("180"), 1, 0));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='247' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(247));
    return TRUE;
 }
 
@@ -4620,7 +4656,7 @@ static BOOL H_UpgradeFromV245(int currVersion, int newVersion)
        CHK_EXEC(SetColumnNullable(_T("cluster_resources"), _T("resource_name")));
        CHK_EXEC(ConvertStrings(_T("cluster_resources"), _T("cluster_id"), _T("resource_id"), _T("resource_name"), false));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='246' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(246));
    return TRUE;
 }
 
@@ -4644,7 +4680,7 @@ static BOOL H_UpgradeFromV244(int currVersion, int newVersion)
        CHK_EXEC(ConvertStrings(_T("actions"), _T("action_id"), _T("email_subject")));
        CHK_EXEC(ConvertStrings(_T("actions"), _T("action_id"), _T("action_data")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='245' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(245));
    return TRUE;
 }
 
@@ -4701,7 +4737,7 @@ static BOOL H_UpgradeFromV243(int currVersion, int newVersion)
                _T("   1) Interface index\r\n")
                _T("   2) Interface name")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='244' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(244));
    return TRUE;
 }
 
@@ -4722,7 +4758,7 @@ static BOOL H_UpgradeFromV242(int currVersion, int newVersion)
                _T("<END>");
 
        CHK_EXEC(SQLBatch(batch));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='243' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(243));
    return TRUE;
 }
 
@@ -4740,7 +4776,7 @@ static BOOL H_UpgradeFromV241(int currVersion, int newVersion)
                _T("<END>");
 
        CHK_EXEC(SQLBatch(batch));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='242' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(242));
    return TRUE;
 }
 
@@ -4758,7 +4794,7 @@ static BOOL H_UpgradeFromV240(int currVersion, int newVersion)
                _T("<END>");
 
        CHK_EXEC(SQLBatch(batch));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='241' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(241));
    return TRUE;
 }
 
@@ -4770,7 +4806,7 @@ static BOOL H_UpgradeFromV240(int currVersion, int newVersion)
 static BOOL H_UpgradeFromV239(int currVersion, int newVersion)
 {
        CHK_EXEC(SQLQuery(_T("ALTER TABLE raw_dci_values ADD transformed_value varchar(255)")));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='240' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(240));
    return TRUE;
 }
 
@@ -4787,7 +4823,7 @@ static BOOL H_UpgradeFromV238(int currVersion, int newVersion)
                _T("'Generated when primary IP address changed (usually because of primary name change or DNS change).#0D#0A")
                _T("Parameters:#0D#0A   1) New IP address#0D#0A   2) Old IP address#0D#0A   3) Primary host name')")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='239' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(239));
    return TRUE;
 }
 
@@ -4902,7 +4938,7 @@ static BOOL H_UpgradeFromV232toV238(int currVersion, int newVersion)
                          _T("   5) Threshold value#0D#0A")
                          _T("   6) Actual value' WHERE event_code=18")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='238' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(238));
    return TRUE;
 }
 
@@ -4947,7 +4983,7 @@ static BOOL H_UpgradeFromV237(int currVersion, int newVersion)
                             _T("new_status integer not null,")
                             _T("PRIMARY KEY(record_id))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='238' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(238));
    return TRUE;
 }
 
@@ -4967,7 +5003,7 @@ static BOOL H_UpgradeFromV236(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='237' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(237));
    return TRUE;
 }
 
@@ -4984,7 +5020,7 @@ static BOOL H_UpgradeFromV235(int currVersion, int newVersion)
                             _T("job_id integer not null,")
                             _T("PRIMARY KEY(report_id,job_id))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='236' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(236));
    return TRUE;
 }
 
@@ -5000,7 +5036,7 @@ static BOOL H_UpgradeFromV234(int currVersion, int newVersion)
                                                                _T("definition $SQL:TEXT null,")
                             _T("PRIMARY KEY(id))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='235' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(235));
    return TRUE;
 }
 
@@ -5037,7 +5073,7 @@ static BOOL H_UpgradeFromV233(int currVersion, int newVersion)
                          _T("   5) Threshold value#0D#0A")
                          _T("   6) Actual value' WHERE event_code=18")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='234' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(234));
    return TRUE;
 }
 
@@ -5058,7 +5094,7 @@ static BOOL H_UpgradeFromV231(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='232' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(232));
    return TRUE;
 }
 
@@ -5074,7 +5110,7 @@ static BOOL H_UpgradeFromV230(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='231' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(231));
    return TRUE;
 }
 
@@ -5128,7 +5164,7 @@ static BOOL H_UpgradeFromV229(int currVersion, int newVersion)
 
        CreateConfigParam(_T("TileServerURL"), _T("http://tile.openstreetmap.org/"), 1, 0);
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='230' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(230));
    return TRUE;
 }
 
@@ -5155,7 +5191,7 @@ static BOOL H_UpgradeFromV228(int currVersion, int newVersion)
                                _T("   vertical_alignment integer not null,")
                                _T("   PRIMARY KEY(dashboard_id,element_id))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='229' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(229));
    return TRUE;
 }
 
@@ -5166,7 +5202,7 @@ static BOOL H_UpgradeFromV227(int currVersion, int newVersion)
 {
        CHK_EXEC(SQLQuery(_T("DROP TABLE web_maps")));
        CHK_EXEC(MigrateMaps());
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='228' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(228));
    return TRUE;
 }
 
@@ -5182,7 +5218,7 @@ static BOOL H_UpgradeFromV226(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='227' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(227));
    return TRUE;
 }
 
@@ -5202,7 +5238,7 @@ static BOOL H_UpgradeFromV225(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='226' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(226));
    return TRUE;
 }
 
@@ -5220,7 +5256,7 @@ static BOOL H_UpgradeFromV224(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='225' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(225));
    return TRUE;
 }
 
@@ -5241,7 +5277,7 @@ static BOOL H_UpgradeFromV223(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='224' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(224));
    return TRUE;
 }
 
@@ -5259,7 +5295,7 @@ static BOOL H_UpgradeFromV222(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='223' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(223));
    return TRUE;
 }
 
@@ -5277,7 +5313,7 @@ static BOOL H_UpgradeFromV221(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='222' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(222));
    return TRUE;
 }
 
@@ -5295,7 +5331,7 @@ static BOOL H_UpgradeFromV220(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='221' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(221));
    return TRUE;
 }
 
@@ -5319,7 +5355,7 @@ static BOOL H_UpgradeFromV219(int currVersion, int newVersion)
 
        CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='220' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(220));
    return TRUE;
 }
 
@@ -5363,7 +5399,7 @@ static BOOL H_UpgradeFromV218(int currVersion, int newVersion)
 
    CHK_EXEC(SQLBatch(batch));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='219' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(219));
    return TRUE;
 }
 
@@ -5375,7 +5411,7 @@ static BOOL H_UpgradeFromV217(int currVersion, int newVersion)
        CHK_EXEC(SetColumnNullable(_T("snmp_communities"), _T("community")));
        CHK_EXEC(ConvertStrings(_T("snmp_communities"), _T("id"), _T("community")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='218' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(218));
    return TRUE;
 }
 
@@ -5429,7 +5465,7 @@ static BOOL H_UpgradeFromV216(int currVersion, int newVersion)
        CHK_EXEC(SetColumnNullable(_T("items"), _T("instance")));
        CHK_EXEC(ConvertStrings(_T("items"), _T("item_id"), _T("instance")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='217' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(217));
    return TRUE;
 }
 
@@ -5467,7 +5503,7 @@ static BOOL H_UpgradeFromV215(int currVersion, int newVersion)
                DBFreeResult(hResult);
        }
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='216' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(216));
    return TRUE;
 }
 
@@ -5503,7 +5539,7 @@ static BOOL H_UpgradeFromV214(int currVersion, int newVersion)
                                                                _T("connector_name2 varchar(255) null,")
                             _T("PRIMARY KEY(map_id,element1,element2))")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='215' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(215));
    return TRUE;
 }
 
@@ -5573,7 +5609,7 @@ static BOOL H_UpgradeFromV213(int currVersion, int newVersion)
                DBFreeResult(hResult);
        }
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='214' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(214));
    return TRUE;
 }
 
@@ -5588,7 +5624,7 @@ static BOOL H_UpgradeFromV212(int currVersion, int newVersion)
        CHK_EXEC(ConvertStrings(_T("items"), _T("item_id"), _T("custom_units_name")));
        CHK_EXEC(ConvertStrings(_T("items"), _T("item_id"), _T("perftab_settings")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='213' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(213));
 
    return TRUE;
 }
@@ -5605,7 +5641,7 @@ static BOOL H_UpgradeFromV211(int currVersion, int newVersion)
        CHK_EXEC(ConvertStrings(_T("snmp_trap_cfg"), _T("trap_id"), _T("user_tag")));
        CHK_EXEC(ConvertStrings(_T("snmp_trap_cfg"), _T("trap_id"), _T("description")));
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='212' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(212));
 
    return TRUE;
 }
@@ -5631,7 +5667,7 @@ static BOOL H_UpgradeFromV210(int currVersion, int newVersion)
                _T("<END>");
 
        CHK_EXEC(SQLBatch(batch));
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='211' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(211));
 
    return TRUE;
 }
@@ -6079,24 +6115,17 @@ static BOOL H_UpgradeFromV9x(int currVersion, int newVersion)
                if (!g_bIgnoreErrors)
                        return FALSE;
 
-       TCHAR query[256];
-       _sntprintf(query, 256, _T("UPDATE metadata SET var_value='%d' WHERE var_name='SchemaVersion'"), newVersion);
-       if (!SQLQuery(query))
-      if (!g_bIgnoreErrors)
-         return FALSE;
-
+       CHK_EXEC(SetSchemaVersion(newVersion));
    return TRUE;
 }
 
-
-//
-// Upgrade from V100 to V214
-//      or from V101 to V214
-//      or from V102 to V214
-//      or from V103 to V214
-//      or from V104 to V214
-//
-
+/**
+ * Upgrade from V100 to V214
+ *      or from V101 to V214
+ *      or from V102 to V214
+ *      or from V103 to V214
+ *      or from V104 to V214
+ */
 static BOOL H_UpgradeFromV10x(int currVersion, int newVersion)
 {
        if (!H_UpgradeFromV9x(currVersion, 207))
@@ -6131,15 +6160,13 @@ static BOOL H_UpgradeFromV10x(int currVersion, int newVersion)
                if (!H_UpgradeFromV213(213, 214))
                        return FALSE;
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='214' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(214));
    return TRUE;
 }
 
-
-//
-// Upgrade from V105 to V217
-//
-
+/**
+ * Upgrade from V105 to V217
+ */
 static BOOL H_UpgradeFromV105(int currVersion, int newVersion)
 {
        if (!H_UpgradeFromV10x(currVersion, 214))
@@ -6152,15 +6179,13 @@ static BOOL H_UpgradeFromV105(int currVersion, int newVersion)
        if (!H_UpgradeFromV215(215, 216))
                return FALSE;
 
-       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='217' WHERE var_name='SchemaVersion'")));
+       CHK_EXEC(SetSchemaVersion(217));
    return TRUE;
 }
 
-
-//
-// Upgrade from V91 to V92
-//
-
+/**
+ * Upgrade from V91 to V92
+ */
 static BOOL H_UpgradeFromV91(int currVersion, int newVersion)
 {
        static TCHAR batch[] =
@@ -6683,11 +6708,9 @@ static BOOL H_UpgradeFromV78(int currVersion, int newVersion)
    return TRUE;
 }
 
-
-//
-// Upgrade from V77 to V78
-//
-
+/**
+ * Upgrade from V77 to V78
+ */
 static BOOL H_UpgradeFromV77(int currVersion, int newVersion)
 {
        if (!CreateTable(_T("CREATE TABLE trusted_nodes (")
@@ -10261,6 +10284,7 @@ static struct
    { 404, 405, H_UpgradeFromV404 },
    { 405, 406, H_UpgradeFromV405 },
    { 406, 407, H_UpgradeFromV406 },
+   { 407, 408, H_UpgradeFromV407 },
    { 0, 0, NULL }
 };
 
index bbf554b..158f29a 100644 (file)
@@ -2,13 +2,13 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NetXMS WebUI Core
 Bundle-SymbolicName: org.netxms.webui.core; singleton:=true
-Bundle-Version: 2.0.10
+Bundle-Version: 2.1.0
 Bundle-Activator: org.netxms.ui.eclipse.console.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
  org.eclipse.rap.ui;bundle-version="2.3.0",
  org.eclipse.rap.ui.forms;bundle-version="2.3.0",
- org.netxms.ui.eclipse.clientlibrary;bundle-version="2.0.9"
+ org.netxms.ui.eclipse.clientlibrary;bundle-version="2.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Import-Package: javax.servlet;version="2.5.0",
index c2c603e..d8c9f05 100644 (file)
@@ -7,5 +7,5 @@ bin.includes = plugin.xml,\
                theme/,\
                js/,\
                plugin_customization.ini,\
-               META-INF/
+               META-INF/,\
                resource.properties
index f22a90b..ae19437 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Adapter Factory for Object Browser Plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.objectbrowser.adapterfactory;singleton:=true
-Bundle-Version: 1.2.14
+Bundle-Version: 2.1.0
 Bundle-Vendor: netxms.org
-Fragment-Host: org.netxms.ui.eclipse.objectbrowser;bundle-version="1.2.14"
+Fragment-Host: org.netxms.ui.eclipse.objectbrowser;bundle-version="2.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
index 67ebc55..4d0ad83 100644 (file)
@@ -2,12 +2,12 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NXMC Object Browser Plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.objectbrowser;singleton:=true
-Bundle-Version: 2.0.7
+Bundle-Version: 2.1.0
 Bundle-Activator: org.netxms.ui.eclipse.objectbrowser.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.rap.ui;bundle-version="2.3.1",
- org.netxms.ui.eclipse.clientlibrary;bundle-version="2.0.0",
- org.netxms.webui.core;bundle-version="2.0.0",
+ org.netxms.ui.eclipse.clientlibrary;bundle-version="2.1.0",
+ org.netxms.webui.core;bundle-version="2.1.0",
  org.eclipse.core.expressions;bundle-version="3.4.500"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
diff --git a/webui/webapp/ObjectBrowser/icons/chassis.png b/webui/webapp/ObjectBrowser/icons/chassis.png
new file mode 100644 (file)
index 0000000..30050eb
Binary files /dev/null and b/webui/webapp/ObjectBrowser/icons/chassis.png differ
index e57c40c..4a7af79 100644 (file)
@@ -6,6 +6,7 @@ action.label.ChangeExpState = Change interface e&xpected state...
 action.label.ChangeZone = Change zone...
 action.label.ConfPoll = &Configuration
 action.label.ConfPollFull = &Configuration (full)
+action.label.CreateChassis = C&hassis...
 action.label.CreateCluster = Cl&uster...
 action.label.CreateCond = Con&dition...
 action.label.CreateContainer = &Container...
index 4a4a718..273bcdf 100644 (file)
@@ -5,6 +5,7 @@ action.label.ChangeExpState=Zm\u011bnit po&\u017eadovan\u00fd stav rozhran\u00ed
 action.label.ChangeZone=Zm\u011bnit z\u00f3nu...
 action.label.ConfPoll=&Konfigurace
 action.label.ConfPollFull=&Konfigurace (pln\u011b)
+action.label.CreateChassis=C&hassis...
 action.label.CreateCluster=&Cluster...
 action.label.CreateCond=P&odm\u00ednku...
 action.label.CreateContainer=&Kontejner...
index 18fda49..158693e 100644 (file)
@@ -2,11 +2,12 @@ action.label.AddNode= &Add node...
 action.label.Bind= Bind...
 action.label.BindTo=Bind to...
 action.label.ChangeExpState= Change interface e&xpected state...
-action.label.ChangeZone= Change zone...
-action.label.ConfPoll= &Configuration
-action.label.ConfPollFull= &Configuration (full)
-action.label.CreateCluster = Cl&uster...
-action.label.CreateCond = Con&dition...
+action.label.ChangeZone=Change zone...
+action.label.ConfPoll=&Configuration
+action.label.ConfPollFull=&Configuration (full)
+action.label.CreateChassis=C&hassis...
+action.label.CreateCluster=Cl&uster...
+action.label.CreateCond=Con&dition...
 action.label.CreateContainer = &Container...
 action.label.CreateIface = &Interface...
 action.label.CreateMobile = &Mobile device...
index 3d9b55c..cbdf9b4 100644 (file)
@@ -5,8 +5,9 @@ action.label.ChangeExpState=Change interface e&xpected state...
 action.label.ChangeZone=Change zone...
 action.label.ConfPoll=&Configuration
 action.label.ConfPollFull=&Configuration (full)
-action.label.CreateCluster = Cl&uster...
-action.label.CreateCond = Con&dition...
+action.label.CreateChassis=C&hassis...
+action.label.CreateCluster=Cl&uster...
+action.label.CreateCond=Con&dition...
 action.label.CreateContainer = &Container...
 action.label.CreateIface = &Interface...
 action.label.CreateMobile = &Mobile device...