ICMP and SSH proxy can be set in node creation dialog; SSH credentials can be set...
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 5 Aug 2016 08:10:43 +0000 (11:10 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 5 Aug 2016 08:10:43 +0000 (11:10 +0300)
13 files changed:
src/java/client/netxms-client/src/main/java/org/netxms/client/NXCObjectCreationData.java
src/java/client/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/actions/CreateNode.java
src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateNodeDialog.java
src/server/core/node.cpp
src/server/core/np.cpp
src/server/core/nxslext.cpp
src/server/core/poll.cpp
src/server/core/session.cpp
src/server/include/nms_core.h
src/server/include/nms_objects.h
webui/webapp/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/actions/CreateNode.java
webui/webapp/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/CreateNodeDialog.java

index 153fa91..a202d58 100644 (file)
@@ -46,6 +46,8 @@ public class NXCObjectCreationData
        private InetAddressEx ipAddress;
        private long agentProxyId;
        private long snmpProxyId;
+   private long icmpProxyId;
+   private long sshProxyId;
        private int mapType;
        private long seedObjectId;
        private long zoneId;
@@ -68,6 +70,8 @@ public class NXCObjectCreationData
        private int flags;
        private long controllerId;
        private long chassisId;
+       private String sshLogin;
+       private String sshPassword;
        
        /**
         * Constructor.
@@ -98,6 +102,8 @@ public class NXCObjectCreationData
                creationFlags = 0;
                agentProxyId = 0;
                snmpProxyId = 0;
+               icmpProxyId = 0;
+               sshProxyId = 0;
                mapType = 0;
                seedObjectId = 0;
                zoneId = 0;
@@ -115,6 +121,8 @@ public class NXCObjectCreationData
                port = 0;
                physicalPort = false;
                createStatusDci = false;
+               sshLogin = "";
+               sshPassword = "";
        }
 
        /**
@@ -246,6 +254,38 @@ public class NXCObjectCreationData
        }
 
        /**
+    * @return the icmpProxyId
+    */
+   public long getIcmpProxyId()
+   {
+      return icmpProxyId;
+   }
+
+   /**
+    * @param icmpProxyId the icmpProxyId to set
+    */
+   public void setIcmpProxyId(long icmpProxyId)
+   {
+      this.icmpProxyId = icmpProxyId;
+   }
+
+   /**
+    * @return the sshProxyId
+    */
+   public long getSshProxyId()
+   {
+      return sshProxyId;
+   }
+
+   /**
+    * @param sshProxyId the sshProxyId to set
+    */
+   public void setSshProxyId(long sshProxyId)
+   {
+      this.sshProxyId = sshProxyId;
+   }
+
+   /**
         * @return the mapType
         */
        public int getMapType()
@@ -644,4 +684,36 @@ public class NXCObjectCreationData
    {
       this.chassisId = chassisId;
    }
+
+   /**
+    * @return the sshLogin
+    */
+   public String getSshLogin()
+   {
+      return sshLogin;
+   }
+
+   /**
+    * @param sshLogin the sshLogin to set
+    */
+   public void setSshLogin(String sshLogin)
+   {
+      this.sshLogin = sshLogin;
+   }
+
+   /**
+    * @return the sshPassword
+    */
+   public String getSshPassword()
+   {
+      return sshPassword;
+   }
+
+   /**
+    * @param sshPassword the sshPassword to set
+    */
+   public void setSshPassword(String sshPassword)
+   {
+      this.sshPassword = sshPassword;
+   }
 }
index 5b1d54d..d5fd1a9 100644 (file)
@@ -4063,14 +4063,19 @@ public class NXCSession
             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());
+            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_ICMP_PROXY, (int)data.getIcmpProxyId());
+            msg.setFieldInt32(NXCPCodes.VID_SSH_PROXY, (int)data.getSshProxyId());
             msg.setFieldInt32(NXCPCodes.VID_CHASSIS_ID, (int)data.getChassisId());
+            msg.setField(NXCPCodes.VID_SSH_LOGIN, data.getSshLogin());
+            msg.setField(NXCPCodes.VID_SSH_PASSWORD, data.getSshPassword());
             break;
          case AbstractObject.OBJECT_NETWORKMAP:
             msg.setFieldInt16(NXCPCodes.VID_MAP_TYPE, data.getMapType());
index 997d758..2364ac9 100644 (file)
@@ -77,7 +77,11 @@ public class CreateNode implements IObjectActionDelegate
          cd.setSnmpPort(dlg.getSnmpPort());
          cd.setAgentProxyId(dlg.getAgentProxy());
          cd.setSnmpProxyId(dlg.getSnmpProxy());
-         cd.setZoneId(dlg.getZoneId());                
+         cd.setIcmpProxyId(dlg.getIcmpProxy());
+         cd.setSshProxyId(dlg.getSshProxy());
+         cd.setZoneId(dlg.getZoneId());
+         cd.setSshLogin(dlg.getSshLogin());
+         cd.setSshPassword(dlg.getSshPassword());
                
                final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
                new ConsoleJob(Messages.get().CreateNode_JobTitle, part, Activator.PLUGIN_ID, null) {
index 0295813..caf2db9 100644 (file)
@@ -52,6 +52,8 @@ public class CreateNodeDialog extends Dialog
        private LabeledText hostNameField;
        private Spinner agentPortField;
        private Spinner snmpPortField;
+       private LabeledText sshLoginField;
+   private LabeledText sshPasswordField;
        private Button checkUnmanaged;
        private Button checkDisableAgent;
        private Button checkDisableSNMP;
@@ -59,6 +61,8 @@ public class CreateNodeDialog extends Dialog
        private Button checkCreateAnother;
        private ObjectSelector agentProxySelector;
        private ObjectSelector snmpProxySelector;
+   private ObjectSelector icmpProxySelector;
+   private ObjectSelector sshProxySelector;
        private ObjectSelector zoneSelector;
        
        private String objectName;
@@ -66,9 +70,13 @@ public class CreateNodeDialog extends Dialog
        private int creationFlags = 0;
        private long agentProxy = 0;
        private long snmpProxy = 0;
+   private long icmpProxy = 0;
+   private long sshProxy = 0;
        private long zoneId = 0;
        private int agentPort = 4700;
        private int snmpPort = 161;
+       private String sshLogin = "";
+       private String sshPassword; 
        private boolean showAgain = false;
        
        /**
@@ -83,10 +91,14 @@ public class CreateNodeDialog extends Dialog
          creationFlags = prev.creationFlags;
          agentProxy = prev.agentProxy;
          snmpProxy = prev.snmpProxy;
+         icmpProxy = prev.snmpProxy;
+         sshProxy = prev.snmpProxy;
                   zoneId = prev.zoneId;
                   agentPort = prev.agentPort;
                   snmpPort = prev.snmpPort;
-                  showAgain = prev.showAgain;
+                  sshLogin = prev.sshLogin;
+                  sshPassword = prev.sshPassword;
+         showAgain = prev.showAgain;
                }
        }
 
@@ -114,6 +126,7 @@ public class CreateNodeDialog extends Dialog
                layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
                layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
                layout.numColumns = 2;
+               layout.makeColumnsEqualWidth = true;
                dialogArea.setLayout(layout);
                
                objectNameField = new LabeledText(dialogArea, SWT.NONE);
@@ -152,6 +165,16 @@ public class CreateNodeDialog extends Dialog
                snmpPortField = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().CreateNodeDialog_SNMPPort, 1, 65535, WidgetHelper.DEFAULT_LAYOUT_DATA);
                snmpPortField.setSelection(snmpPort);
                
+               sshLoginField = new LabeledText(dialogArea, SWT.NONE);
+               sshLoginField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               sshLoginField.setLabel("SSH Login");
+               sshLoginField.setText(sshLogin);
+               
+      sshPasswordField = new LabeledText(dialogArea, SWT.NONE);
+      sshPasswordField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+      sshPasswordField.setLabel("SSH Password");
+      sshPasswordField.setText(sshPassword);
+      
                Group optionsGroup = new Group(dialogArea, SWT.NONE);
                optionsGroup.setText(Messages.get().CreateNodeDialog_Options);
                gd = new GridData();
@@ -184,7 +207,6 @@ public class CreateNodeDialog extends Dialog
                gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
-               gd.horizontalSpan = 2;
                agentProxySelector.setLayoutData(gd);
                
                snmpProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
@@ -194,9 +216,27 @@ public class CreateNodeDialog extends Dialog
                gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
-               gd.horizontalSpan = 2;
                snmpProxySelector.setLayoutData(gd);
                
+      icmpProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
+      icmpProxySelector.setLabel("Proxy for ICMP");
+      icmpProxySelector.setObjectClass(Node.class);
+      icmpProxySelector.setObjectId(icmpProxy);
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      icmpProxySelector.setLayoutData(gd);
+      
+      sshProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
+      sshProxySelector.setLabel("Proxy for SSH");
+      sshProxySelector.setEmptySelectionName("<default>");
+      sshProxySelector.setObjectClass(Node.class);
+      sshProxySelector.setObjectId(sshProxy);
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      sshProxySelector.setLayoutData(gd);
+      
                if (session.isZoningEnabled())
                {
                        zoneSelector = new ObjectSelector(dialogArea, SWT.NONE, false);
@@ -252,6 +292,9 @@ public class CreateNodeDialog extends Dialog
                agentPort = agentPortField.getSelection();
                snmpPort = snmpPortField.getSelection();
                
+               sshLogin = sshLoginField.getText().trim();
+               sshPassword = sshPasswordField.getText();
+               
                agentProxy = agentProxySelector.getObjectId();
                snmpProxy = snmpProxySelector.getObjectId();
                if (session.isZoningEnabled())
@@ -309,6 +352,22 @@ public class CreateNodeDialog extends Dialog
        }
 
        /**
+    * @return the icmpProxy
+    */
+   public long getIcmpProxy()
+   {
+      return icmpProxy;
+   }
+
+   /**
+    * @return the sshProxy
+    */
+   public long getSshProxy()
+   {
+      return sshProxy;
+   }
+
+   /**
         * @return the zoneId
         */
        public long getZoneId()
@@ -332,6 +391,22 @@ public class CreateNodeDialog extends Dialog
                return snmpPort;
        }
 
+   /**
+    * @return the sshLogin
+    */
+   public String getSshLogin()
+   {
+      return sshLogin;
+   }
+
+   /**
+    * @return the sshPassword
+    */
+   public String getSshPassword()
+   {
+      return sshPassword;
+   }
+
    /**
     * @return the showAgain
     */
index 9d297b8..4ace2cc 100644 (file)
@@ -124,7 +124,7 @@ Node::Node() : DataCollectionTarget()
 /**
  * Constructor for new node object
  */
-Node::Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 snmpProxy, UINT32 dwZone) : DataCollectionTarget()
+Node::Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 snmpProxy, UINT32 icmpProxy, UINT32 sshProxy, UINT32 zoneId) : DataCollectionTarget()
 {
    addr.toString(m_primaryName);
    m_status = STATUS_UNKNOWN;
@@ -133,7 +133,7 @@ Node::Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 sn
    m_ipAddress = addr;
    m_flags = dwFlags;
    m_dwDynamicFlags = 0;
-   m_zoneId = dwZone;
+   m_zoneId = zoneId;
    m_agentPort = AGENT_LISTEN_PORT;
    m_agentAuthMethod = AUTH_NONE;
    m_agentCacheMode = AGENT_CACHE_DEFAULT;
@@ -178,7 +178,7 @@ Node::Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 sn
    m_pollerNode = 0;
    m_agentProxy = agentProxy;
        m_snmpProxy = snmpProxy;
-   m_icmpProxy = 0;
+   m_icmpProxy = icmpProxy;
    memset(m_qwLastEvents, 0, sizeof(QWORD) * MAX_LAST_EVENTS);
    m_isHidden = true;
    m_pRoutingTable = NULL;
@@ -215,7 +215,7 @@ Node::Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 sn
    m_snmpTrapCount = 0;
    m_sshLogin[0] = 0;
    m_sshPassword[0] = 0;
-   m_sshProxy = 0;
+   m_sshProxy = sshProxy;
 }
 
 /**
@@ -7787,3 +7787,17 @@ void Node::setChassis(UINT32 chassisId)
 
    updatePhysicalContainerBinding(OBJECT_CHASSIS, chassisId);
 }
+
+/**
+ * Set SSH credentials for node
+ */
+void Node::setSshCredentials(const TCHAR *login, const TCHAR *password)
+{
+   lockProperties();
+   if (login != NULL)
+      nx_strncpy(m_sshLogin, login, MAX_SSH_LOGIN_LEN);
+   if (password != NULL)
+      nx_strncpy(m_sshPassword, password, MAX_SSH_PASSWORD_LEN);
+   setModified();
+   unlockProperties();
+}
index b0949bc..d67ef06 100644 (file)
@@ -126,20 +126,25 @@ static NXSL_DiscoveryClass m_nxslDiscoveryClass;
  * Returns pointer to new node object on success or NULL on failure
  *
  * @param ipAddr IP address of new node
- * @param dwCreationFlags
+ * @param creationFlags node creation flags
  * @param agentPort port number of NetXMS agent
  * @param snmpPort port number of SNMP agent
- * @param pszName name for new node, can be NULL
- * @param dwProxyNode agent proxy node ID or 0 to use direct communications
- * @param dwSNMPProxy SNMP proxy node ID or 0 to use direct communications
- * @param pCluster pointer to parent cluster object or NULL
+ * @param name name for new node, can be NULL
+ * @param agentProxyId agent proxy node ID or 0 to use direct communications
+ * @param snmpProxyId SNMP proxy node ID or 0 to use direct communications
+ * @param icmpProxyId ICMP proxy node ID or 0 to use direct communications
+ * @param sshProxyId SSH proxy node ID or 0 to use default proxy
+ * @param sshLogin SSH login name
+ * @param sshPassword SSH password
+ * @param cluster pointer to parent cluster object or NULL
  * @param zoneId zone ID
  * @param doConfPoll if set to true, Node::configurationPoll will be called before exit
  * @param discoveredNode must be set to true if node being added automatically by discovery thread
  */
-Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 dwCreationFlags,
-                                    WORD agentPort, WORD snmpPort, const TCHAR *pszName, UINT32 dwProxyNode, UINT32 dwSNMPProxy,
-                                    Cluster *pCluster, UINT32 zoneId, bool doConfPoll, bool discoveredNode)
+Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 creationFlags, UINT16 agentPort,
+                                    UINT16 snmpPort, const TCHAR *name, UINT32 agentProxyId, UINT32 snmpProxyId,
+                                    UINT32 icmpProxyId, UINT32 sshProxyId, const TCHAR *sshLogin, const TCHAR *sshPassword,
+                                    Cluster *cluster, UINT32 zoneId, bool doConfPoll, bool discoveredNode)
 {
    Node *pNode;
    TCHAR szIpAddr[64];
@@ -154,20 +159,21 @@ Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 dwCreation
       return NULL;
    }
 
-   if (dwCreationFlags & NXC_NCF_DISABLE_ICMP)
+   if (creationFlags & NXC_NCF_DISABLE_ICMP)
       dwFlags |= NF_DISABLE_ICMP;
-   if (dwCreationFlags & NXC_NCF_DISABLE_SNMP)
+   if (creationFlags & NXC_NCF_DISABLE_SNMP)
       dwFlags |= NF_DISABLE_SNMP;
-   if (dwCreationFlags & NXC_NCF_DISABLE_NXCP)
+   if (creationFlags & NXC_NCF_DISABLE_NXCP)
       dwFlags |= NF_DISABLE_NXCP;
-   pNode = new Node(ipAddr, dwFlags, dwProxyNode, dwSNMPProxy, zoneId);
+   pNode = new Node(ipAddr, dwFlags, agentProxyId, snmpProxyId, icmpProxyId, sshProxyId, zoneId);
        if (agentPort != 0)
                pNode->setAgentPort(agentPort);
        if (snmpPort != 0)
                pNode->setSnmpPort(snmpPort);
+       pNode->setSshCredentials(sshLogin, sshPassword);
+   if (name != NULL)
+      pNode->setName(name);
    NetObjInsert(pNode, true, false);
-   if (pszName != NULL)
-      pNode->setName(pszName);
 
        // Use DNS name as primary name if required
        if (discoveredNode && ConfigReadInt(_T("UseDNSNameForDiscoveredNodes"), 0))
@@ -185,12 +191,12 @@ Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 dwCreation
        }
 
        // Bind node to cluster before first configuration poll
-       if (pCluster != NULL)
+       if (cluster != NULL)
        {
-               pCluster->applyToTarget(pNode);
+               cluster->applyToTarget(pNode);
        }
 
-   if (dwCreationFlags & NXC_NCF_CREATE_UNMANAGED)
+   if (creationFlags & NXC_NCF_CREATE_UNMANAGED)
    {
       pNode->setMgmtStatus(FALSE);
       pNode->checkSubnetBinding();
@@ -674,7 +680,7 @@ THREAD_RESULT THREAD_CALL NodePoller(void *arg)
       if (pInfo->ignoreFilter || AcceptNewNode(pInfo->ipAddr, pInfo->zoneId, pInfo->bMacAddr))
                {
          ObjectTransactionStart();
-         PollNewNode(pInfo->ipAddr, 0, 0, 0, NULL, 0, 0, NULL, pInfo->zoneId, true, true);
+         PollNewNode(pInfo->ipAddr, 0, 0, 0, NULL, 0, 0, 0, 0, NULL, NULL, NULL, pInfo->zoneId, true, true);
          ObjectTransactionEnd();
                }
       free(pInfo);
index dfc3f77..4a08edf 100644 (file)
@@ -594,7 +594,7 @@ static int F_CreateNode(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL
        const TCHAR *pname = argv[2]->getValueAsCString();
        if (*pname == 0)
                pname = argv[1]->getValueAsCString();
-   Node *node = PollNewNode(InetAddress::resolveHostName(pname), 0, 0, 0, argv[1]->getValueAsCString(), 0, 0, NULL, 0, true, false);
+   Node *node = PollNewNode(InetAddress::resolveHostName(pname), 0, 0, 0, argv[1]->getValueAsCString(), 0, 0, 0, 0, NULL, NULL, NULL, 0, true, false);
        if (node != NULL)
        {
                node->setPrimaryName(pname);
index 1bed636..55e1c50 100644 (file)
@@ -107,7 +107,7 @@ static void CreateManagementNode(const InetAddress& addr)
 {
        TCHAR buffer[256];
 
-       Node *node = new Node(addr, NF_IS_LOCAL_MGMT, 0, 0, 0);
+       Node *node = new Node(addr, NF_IS_LOCAL_MGMT, 0, 0, 0, 0, 0);
    NetObjInsert(node, true, false);
        node->setName(GetLocalHostName(buffer, 256));
 
index 6ef1fb9..60e91b7 100644 (file)
@@ -4997,7 +4997,7 @@ void ClientSession::createObject(NXCPMessage *request)
                                                   // Create new object
                      NetObj *object = NULL;
                      UINT32 nodeId;
-                     TCHAR deviceId[MAX_OBJECT_NAME];
+                     TCHAR deviceId[MAX_OBJECT_NAME], sshLogin[MAX_SSH_LOGIN_LEN], sshPassword[MAX_SSH_PASSWORD_LEN];
                                                   switch(objectClass)
                                                   {
                         case OBJECT_AGENTPOLICY_CONFIG:
@@ -5085,6 +5085,10 @@ void ClientSession::createObject(NXCPMessage *request)
                                                                                                                           objectName,
                                                                                                                           request->getFieldAsUInt32(VID_AGENT_PROXY),
                                                                                                                           request->getFieldAsUInt32(VID_SNMP_PROXY),
+                                                request->getFieldAsUInt32(VID_ICMP_PROXY),
+                                                request->getFieldAsUInt32(VID_SSH_PROXY),
+                                                request->getFieldAsString(VID_SSH_LOGIN, sshLogin, MAX_SSH_LOGIN_LEN),
+                                                request->getFieldAsString(VID_SSH_PASSWORD, sshPassword, MAX_SSH_PASSWORD_LEN),
                                                                                                                           (parent != NULL) ? ((parent->getObjectClass() == OBJECT_CLUSTER) ? (Cluster *)parent : NULL) : NULL,
                                                                                                                           zoneId, false, false);
                                                                   if (object != NULL)
index 637c752..3b11f4d 100644 (file)
@@ -974,9 +974,10 @@ void WatchdogNotify(UINT32 dwId);
 void WatchdogPrintStatus(CONSOLE_CTX pCtx);
 
 void CheckForMgmtNode();
-Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 dwCreationFlags, WORD agentPort,
-                                    WORD snmpPort, const TCHAR *pszName, UINT32 dwProxyNode, UINT32 dwSNMPProxy, Cluster *pCluster,
-                                                                 UINT32 zoneId, bool doConfPoll, bool discoveredNode);
+Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 creationFlags, UINT16 agentPort,
+                                    UINT16 snmpPort, const TCHAR *name, UINT32 agentProxyId, UINT32 snmpProxyId,
+                                    UINT32 icmpProxyId, UINT32 sshProxyId, const TCHAR *sshLogin, const TCHAR *sshPassword,
+                                    Cluster *cluster, UINT32 zoneId, bool doConfPoll, bool discoveredNode);
 
 void NXCORE_EXPORTABLE EnumerateClientSessions(void (*pHandler)(ClientSession *, void *), void *pArg);
 void NXCORE_EXPORTABLE NotifyClientSessions(UINT32 dwCode, UINT32 dwData);
index 9536142..072e3ac 100644 (file)
@@ -1444,7 +1444,7 @@ protected:
 
 public:
    Node();
-   Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 snmpProxy, UINT32 dwZone);
+   Node(const InetAddress& addr, UINT32 dwFlags, UINT32 agentProxy, UINT32 snmpProxy, UINT32 icmpProxy, UINT32 sshProxy, UINT32 zoneId);
    virtual ~Node();
 
    virtual int getObjectClass() const { return OBJECT_NODE; }
@@ -1516,8 +1516,9 @@ public:
    void deleteInterface(Interface *iface);
 
        void setPrimaryName(const TCHAR *name) { nx_strncpy(m_primaryName, name, MAX_DNS_NAME); }
-       void setAgentPort(WORD port) { m_agentPort = port; }
-       void setSnmpPort(WORD port) { m_snmpPort = port; }
+       void setAgentPort(UINT16 port) { m_agentPort = port; }
+       void setSnmpPort(UINT16 port) { m_snmpPort = port; }
+   void setSshCredentials(const TCHAR *login, const TCHAR *password);
    void changeIPAddress(const InetAddress& ipAddr);
        void changeZone(UINT32 newZone);
        void setFileUpdateConnection(AgentConnection *conn);
index 891bf71..2364ac9 100644 (file)
@@ -71,13 +71,17 @@ public class CreateNode implements IObjectActionDelegate
                        return;
                
          final NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NODE, dlg.getObjectName(), parentId);
-                               cd.setCreationFlags(dlg.getCreationFlags());
-                               cd.setPrimaryName(dlg.getHostName());
-                               cd.setAgentPort(dlg.getAgentPort());
-                               cd.setSnmpPort(dlg.getSnmpPort());
-                               cd.setAgentProxyId(dlg.getAgentProxy());
-                               cd.setSnmpProxyId(dlg.getSnmpProxy());
-                               cd.setZoneId(dlg.getZoneId());
+         cd.setCreationFlags(dlg.getCreationFlags());
+         cd.setPrimaryName(dlg.getHostName());
+         cd.setAgentPort(dlg.getAgentPort());
+         cd.setSnmpPort(dlg.getSnmpPort());
+         cd.setAgentProxyId(dlg.getAgentProxy());
+         cd.setSnmpProxyId(dlg.getSnmpProxy());
+         cd.setIcmpProxyId(dlg.getIcmpProxy());
+         cd.setSshProxyId(dlg.getSshProxy());
+         cd.setZoneId(dlg.getZoneId());
+         cd.setSshLogin(dlg.getSshLogin());
+         cd.setSshPassword(dlg.getSshPassword());
                
                final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
                new ConsoleJob(Messages.get().CreateNode_JobTitle, part, Activator.PLUGIN_ID, null) {
@@ -86,13 +90,13 @@ public class CreateNode implements IObjectActionDelegate
                        {
                                session.createObject(cd);
                        }
-
+   
                        @Override
                        protected String getErrorMessage()
                        {
-                               return String.format(Messages.get().CreateNode_JobError, cd.getName());
+                               return String.format(Messages.get().CreateNode_JobError, cd.getName());
                        }
-         }.start();
+               }.start();
           } while(dlg.isShowAgain());
        }
 
index 0295813..caf2db9 100644 (file)
@@ -52,6 +52,8 @@ public class CreateNodeDialog extends Dialog
        private LabeledText hostNameField;
        private Spinner agentPortField;
        private Spinner snmpPortField;
+       private LabeledText sshLoginField;
+   private LabeledText sshPasswordField;
        private Button checkUnmanaged;
        private Button checkDisableAgent;
        private Button checkDisableSNMP;
@@ -59,6 +61,8 @@ public class CreateNodeDialog extends Dialog
        private Button checkCreateAnother;
        private ObjectSelector agentProxySelector;
        private ObjectSelector snmpProxySelector;
+   private ObjectSelector icmpProxySelector;
+   private ObjectSelector sshProxySelector;
        private ObjectSelector zoneSelector;
        
        private String objectName;
@@ -66,9 +70,13 @@ public class CreateNodeDialog extends Dialog
        private int creationFlags = 0;
        private long agentProxy = 0;
        private long snmpProxy = 0;
+   private long icmpProxy = 0;
+   private long sshProxy = 0;
        private long zoneId = 0;
        private int agentPort = 4700;
        private int snmpPort = 161;
+       private String sshLogin = "";
+       private String sshPassword; 
        private boolean showAgain = false;
        
        /**
@@ -83,10 +91,14 @@ public class CreateNodeDialog extends Dialog
          creationFlags = prev.creationFlags;
          agentProxy = prev.agentProxy;
          snmpProxy = prev.snmpProxy;
+         icmpProxy = prev.snmpProxy;
+         sshProxy = prev.snmpProxy;
                   zoneId = prev.zoneId;
                   agentPort = prev.agentPort;
                   snmpPort = prev.snmpPort;
-                  showAgain = prev.showAgain;
+                  sshLogin = prev.sshLogin;
+                  sshPassword = prev.sshPassword;
+         showAgain = prev.showAgain;
                }
        }
 
@@ -114,6 +126,7 @@ public class CreateNodeDialog extends Dialog
                layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
                layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
                layout.numColumns = 2;
+               layout.makeColumnsEqualWidth = true;
                dialogArea.setLayout(layout);
                
                objectNameField = new LabeledText(dialogArea, SWT.NONE);
@@ -152,6 +165,16 @@ public class CreateNodeDialog extends Dialog
                snmpPortField = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().CreateNodeDialog_SNMPPort, 1, 65535, WidgetHelper.DEFAULT_LAYOUT_DATA);
                snmpPortField.setSelection(snmpPort);
                
+               sshLoginField = new LabeledText(dialogArea, SWT.NONE);
+               sshLoginField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               sshLoginField.setLabel("SSH Login");
+               sshLoginField.setText(sshLogin);
+               
+      sshPasswordField = new LabeledText(dialogArea, SWT.NONE);
+      sshPasswordField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+      sshPasswordField.setLabel("SSH Password");
+      sshPasswordField.setText(sshPassword);
+      
                Group optionsGroup = new Group(dialogArea, SWT.NONE);
                optionsGroup.setText(Messages.get().CreateNodeDialog_Options);
                gd = new GridData();
@@ -184,7 +207,6 @@ public class CreateNodeDialog extends Dialog
                gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
-               gd.horizontalSpan = 2;
                agentProxySelector.setLayoutData(gd);
                
                snmpProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
@@ -194,9 +216,27 @@ public class CreateNodeDialog extends Dialog
                gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
-               gd.horizontalSpan = 2;
                snmpProxySelector.setLayoutData(gd);
                
+      icmpProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
+      icmpProxySelector.setLabel("Proxy for ICMP");
+      icmpProxySelector.setObjectClass(Node.class);
+      icmpProxySelector.setObjectId(icmpProxy);
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      icmpProxySelector.setLayoutData(gd);
+      
+      sshProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
+      sshProxySelector.setLabel("Proxy for SSH");
+      sshProxySelector.setEmptySelectionName("<default>");
+      sshProxySelector.setObjectClass(Node.class);
+      sshProxySelector.setObjectId(sshProxy);
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      sshProxySelector.setLayoutData(gd);
+      
                if (session.isZoningEnabled())
                {
                        zoneSelector = new ObjectSelector(dialogArea, SWT.NONE, false);
@@ -252,6 +292,9 @@ public class CreateNodeDialog extends Dialog
                agentPort = agentPortField.getSelection();
                snmpPort = snmpPortField.getSelection();
                
+               sshLogin = sshLoginField.getText().trim();
+               sshPassword = sshPasswordField.getText();
+               
                agentProxy = agentProxySelector.getObjectId();
                snmpProxy = snmpProxySelector.getObjectId();
                if (session.isZoningEnabled())
@@ -309,6 +352,22 @@ public class CreateNodeDialog extends Dialog
        }
 
        /**
+    * @return the icmpProxy
+    */
+   public long getIcmpProxy()
+   {
+      return icmpProxy;
+   }
+
+   /**
+    * @return the sshProxy
+    */
+   public long getSshProxy()
+   {
+      return sshProxy;
+   }
+
+   /**
         * @return the zoneId
         */
        public long getZoneId()
@@ -332,6 +391,22 @@ public class CreateNodeDialog extends Dialog
                return snmpPort;
        }
 
+   /**
+    * @return the sshLogin
+    */
+   public String getSshLogin()
+   {
+      return sshLogin;
+   }
+
+   /**
+    * @return the sshPassword
+    */
+   public String getSshPassword()
+   {
+      return sshPassword;
+   }
+
    /**
     * @return the showAgain
     */