- Implemented recalculation of object status after binding change
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 26 Jan 2005 20:43:04 +0000 (20:43 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 26 Jan 2005 20:43:04 +0000 (20:43 +0000)
- Implemented creation of NetworkService objects

ChangeLog
TODO
include/nxclapi.h
include/nximage.h
sql/images.in
src/libnxcl/objects.cpp
src/server/core/netobj.cpp
src/server/core/netsrv.cpp
src/server/core/objects.cpp
src/server/core/session.cpp
src/server/include/nms_objects.h

index 2ae7061..db88bc5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@
 - Fixed deadlock sometimes caused by retrieving DCI collected data
 - Added parameters System.Hostname, System.Uname and System.Uptime to
   Solaris subagent
+- Object status now recalculated after binding change
 
 
 *
diff --git a/TODO b/TODO
index af10bd4..41ec6fc 100644 (file)
--- a/TODO
+++ b/TODO
@@ -28,7 +28,6 @@ GENERAL:
 
 SERVER:
 
-- Recalculate object status after binding change
 - Implement sending of all alarms from database
 - Implement normal mailer shutdown
 - Check if object indexes always locked when used
index ec75ed9..f5b5363 100644 (file)
@@ -868,6 +868,14 @@ typedef struct
       {
          TCHAR *pszDescription;
       } templateGroup;
+      struct
+      {
+         int iServiceType;
+         WORD wProto;
+         WORD wPort;
+         TCHAR *pszRequest;
+         TCHAR *pszResponce;
+      } netsrv;
    } cs;
 } NXC_OBJECT_CREATE_INFO;
 
index 78f0a95..9e1cdd9 100644 (file)
@@ -40,5 +40,6 @@
 #define IMG_TEMPLATE                9
 #define IMG_TEMPLATE_GROUP          10
 #define IMG_TEMPLATE_ROOT           11
+#define IMG_NETWORK_SERVICE         12
 
 #endif
index 0fc844c..8fdd533 100644 (file)
@@ -34,6 +34,9 @@ INSERT INTO images (image_id,name,file_name_png,file_hash_png,file_name_ico,file
 INSERT INTO images (image_id,name,file_name_png,file_hash_png,file_name_ico,file_hash_ico)
        VALUES (IMG_TEMPLATE_ROOT,'Obj.TemplateRoot','template_root.png','<invalid_hash>',
                 'template_root.ico','<invalid_hash>');
+INSERT INTO images (image_id,name,file_name_png,file_hash_png,file_name_ico,file_hash_ico)
+       VALUES (IMG_NETWORK_SERVICE,'Obj.NetworkService','network_service.png','<invalid_hash>',
+                'network_service.ico','<invalid_hash>');
 
 
 /*
@@ -58,3 +61,5 @@ INSERT INTO default_images (object_class,image_id)
        VALUES (9, IMG_TEMPLATE_GROUP);
 INSERT INTO default_images (object_class,image_id)
        VALUES (10, IMG_TEMPLATE_ROOT);
+INSERT INTO default_images (object_class,image_id)
+       VALUES (11, IMG_NETWORK_SERVICE);
index a422244..e6a518c 100644 (file)
@@ -605,6 +605,13 @@ DWORD LIBNXCL_EXPORTABLE NXCCreateObject(NXC_SESSION hSession,
       case OBJECT_TEMPLATEGROUP:
          msg.SetVariable(VID_DESCRIPTION, pCreateInfo->cs.templateGroup.pszDescription);
          break;
+      case OBJECT_NETWORKSERVICE:
+         msg.SetVariable(VID_SERVICE_TYPE, (WORD)pCreateInfo->cs.netsrv.iServiceType);
+         msg.SetVariable(VID_IP_PROTO, pCreateInfo->cs.netsrv.wProto);
+         msg.SetVariable(VID_IP_PORT, pCreateInfo->cs.netsrv.wPort);
+         msg.SetVariable(VID_SERVICE_REQUEST, pCreateInfo->cs.netsrv.pszRequest);
+         msg.SetVariable(VID_SERVICE_RESPONCE, pCreateInfo->cs.netsrv.pszResponce);
+         break;
       default:
          break;
    }
index fe255e5..dbbdbbc 100644 (file)
@@ -222,7 +222,10 @@ void NetObj::Delete(void)
 
    // Remove references to this object from parent objects
    for(i = 0; i < m_dwParentCount; i++)
+   {
       m_pParentList[i]->DeleteChild(this);
+      m_pParentList[i]->CalculateCompoundStatus();
+   }
    free(m_pParentList);
    m_pParentList = NULL;
    m_dwParentCount = 0;
index b5e55a4..47a439e 100644 (file)
@@ -24,7 +24,7 @@
 
 
 //
-// Constructor
+// Default constructor
 //
 
 NetworkService::NetworkService()
@@ -40,6 +40,26 @@ NetworkService::NetworkService()
 }
 
 
+//
+// Extended constructor
+// Note that pszRequest and pszResponce should be dynamically allocated
+// and they will be freed by object's destructor!!!
+//
+
+NetworkService::NetworkService(int iServiceType, WORD wProto, WORD wPort,
+                               TCHAR *pszRequest, TCHAR *pszResponce,
+                               Node *pHostNode, Node *pPollNode)
+{
+   m_iServiceType = iServiceType;
+   m_pHostNode = pHostNode;
+   m_pPollNode = pPollNode;
+   m_wProto = wProto;
+   m_wPort = wPort;
+   m_pszRequest = pszRequest;
+   m_pszResponce = pszResponce;
+}
+
+
 //
 // Destructor
 //
index 321346d..d26ead7 100644 (file)
@@ -677,6 +677,10 @@ BOOL IsValidParentClass(int iChildClass, int iParentClass)
              (iChildClass == OBJECT_TEMPLATE))
             return TRUE;
          break;
+      case OBJECT_NODE:
+         if (iChildClass == OBJECT_NETWORKSERVICE)
+            return TRUE;
+         break;
       case -1:    // Creating object without parent
          if (iChildClass == OBJECT_NODE)
             return TRUE;   // OK only for nodes, because parent subnet will be created automatically
index 211cb67..b5fff11 100644 (file)
@@ -2579,9 +2579,11 @@ void ClientSession::CreateObject(CSCPMessage *pRequest)
 {
    CSCPMessage msg;
    NetObj *pObject, *pParent;
-   int iClass;
-   char *pDescription, szObjectName[MAX_OBJECT_NAME];
+   int iClass, iServiceType;
+   TCHAR *pDescription, szObjectName[MAX_OBJECT_NAME];
+   TCHAR *pszRequest, *pszResponce;
    DWORD dwIpAddr;
+   WORD wIpProto, wIpPort;
    BOOL bParentAlwaysValid = FALSE;
 
    // Prepare responce message
@@ -2640,6 +2642,17 @@ void ClientSession::CreateObject(CSCPMessage *pRequest)
                      pObject->SetName(szObjectName);
                      NetObjInsert(pObject, TRUE);
                      break;
+                  case OBJECT_NETWORKSERVICE:
+                     iServiceType = (int)pRequest->GetVariableShort(VID_SERVICE_TYPE);
+                     wIpProto = pRequest->GetVariableShort(VID_IP_PROTO);
+                     wIpPort = pRequest->GetVariableShort(VID_IP_PORT);
+                     pszRequest = pRequest->GetVariableStr(VID_SERVICE_REQUEST);
+                     pszResponce = pRequest->GetVariableStr(VID_SERVICE_RESPONCE);
+                     pObject = new NetworkService(iServiceType, wIpProto, wIpPort, 
+                                                  pszRequest, pszResponce, (Node *)pParent);
+                     pObject->SetName(szObjectName);
+                     NetObjInsert(pObject, TRUE);
+                     break;
                }
 
                // If creation was successful do binding
@@ -2649,6 +2662,7 @@ void ClientSession::CreateObject(CSCPMessage *pRequest)
                   {
                      pParent->AddChild(pObject);
                      pObject->AddParent(pParent);
+                     pParent->CalculateCompoundStatus();
                   }
                   msg.SetVariable(VID_RCC, RCC_SUCCESS);
                   msg.SetVariable(VID_OBJECT_ID, pObject->Id());
@@ -2718,6 +2732,7 @@ void ClientSession::ChangeObjectBinding(CSCPMessage *pRequest, BOOL bBind)
                {
                   pParent->AddChild(pChild);
                   pChild->AddParent(pParent);
+                  pParent->CalculateCompoundStatus();
                   msg.SetVariable(VID_RCC, RCC_SUCCESS);
                }
                else
index 7dcab06..edd1c91 100644 (file)
@@ -280,6 +280,9 @@ protected:
 
 public:
    NetworkService();
+   NetworkService(int iServiceType, WORD wProto, WORD wPort,
+                  TCHAR *pszRequest, TCHAR *pszResponce,
+                  Node *pHostNode = NULL, Node *pPollNode = NULL);
    virtual ~NetworkService();
 
    virtual int Type(void) { return OBJECT_NETWORKSERVICE; }