Search in sources :

Example 6 with ConnectionPoint

use of org.netxms.client.topology.ConnectionPoint in project netxms by netxms.

the class NXCSession method findConnectionPoint.

/**
 * Find connection point (either directly connected or most close known
 * interface on a switch) for given IP address. Will return null if
 * connection point information cannot be found.
 *
 * @param zoneId zone ID
 * @param ipAddr IP address to find
 * @return connection point information or null
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public ConnectionPoint findConnectionPoint(int zoneId, InetAddress ipAddr) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_FIND_IP_LOCATION);
    msg.setFieldInt32(NXCPCodes.VID_ZONE_UIN, zoneId);
    msg.setField(NXCPCodes.VID_IP_ADDRESS, ipAddr);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.isFieldPresent(NXCPCodes.VID_CONNECTION_TYPE) ? new ConnectionPoint(response) : null;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

Example 7 with ConnectionPoint

use of org.netxms.client.topology.ConnectionPoint in project netxms by netxms.

the class HostSearchResults method showConnection.

/**
 * Show connection point information
 *
 * @param cp[] connection point information
 */
public static void showConnection(ConnectionPoint[] cps) {
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    int counter = 0;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    try {
        Node host;
        AbstractObject iface;
        for (ConnectionPoint p : cps) {
            host = (Node) session.findObjectById(p.getLocalNodeId());
            iface = session.findObjectById(p.getLocalInterfaceId());
            if (!p.hasConnection())
                counter++;
            if ((host != null) && (iface != null)) {
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IViewPart part = page.showView(ID);
                ((HostSearchResults) part).addResult(p);
            }
        }
        if (counter > 0) {
            MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, Messages.get().HostSearchResults_NotFound + " for " + counter + " interfaces!");
        }
    } catch (Exception e) {
        MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, String.format(Messages.get().HostSearchResults_ShowError, e.getLocalizedMessage()));
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IViewPart(org.eclipse.ui.IViewPart) NXCSession(org.netxms.client.NXCSession) Node(org.netxms.client.objects.Node) AbstractObject(org.netxms.client.objects.AbstractObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

Example 8 with ConnectionPoint

use of org.netxms.client.topology.ConnectionPoint in project netxms by netxms.

the class ConnectionPointComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    int result;
    // $NON-NLS-1$
    int column = (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID");
    switch(column) {
        case HostSearchResults.COLUMN_SEQUENCE:
            result = (Integer) ((ConnectionPoint) e1).getData() - (Integer) ((ConnectionPoint) e2).getData();
            break;
        case HostSearchResults.COLUMN_NODE:
        case HostSearchResults.COLUMN_INTERFACE:
        case HostSearchResults.COLUMN_MAC_ADDRESS:
        case HostSearchResults.COLUMN_SWITCH:
        case HostSearchResults.COLUMN_PORT:
            result = labelProvider.getColumnText(e1, column).compareToIgnoreCase(labelProvider.getColumnText(e2, column));
            break;
        case HostSearchResults.COLUMN_IP_ADDRESS:
            Interface iface1 = (Interface) session.findObjectById(((ConnectionPoint) e1).getLocalInterfaceId(), Interface.class);
            Interface iface2 = (Interface) session.findObjectById(((ConnectionPoint) e2).getLocalInterfaceId(), Interface.class);
            InetAddress a1 = ((ConnectionPoint) e1).getLocalIpAddress();
            InetAddress a2 = ((ConnectionPoint) e2).getLocalIpAddress();
            if ((a1 == null) && (iface1 != null))
                a1 = iface1.getFirstUnicastAddress();
            if ((a2 == null) && (iface2 != null))
                a2 = iface2.getFirstUnicastAddress();
            result = ComparatorHelper.compareInetAddresses(a1, a2);
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) InetAddress(java.net.InetAddress) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) Interface(org.netxms.client.objects.Interface) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

Example 9 with ConnectionPoint

use of org.netxms.client.topology.ConnectionPoint in project netxms by netxms.

the class FindIpAddress method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final EnterIpAddressDlg dlg = new EnterIpAddressDlg(window.getShell());
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(String.format(Messages.get().FindIpAddress_JobTitle, dlg.getIpAddress().getHostAddress()), null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final ConnectionPoint cp = session.findConnectionPoint((int) dlg.getZoneId(), dlg.getIpAddress());
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    HostSearchResults.showConnection(cp);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().FindIpAddress_JobError, dlg.getIpAddress().getHostAddress());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) EnterIpAddressDlg(org.netxms.ui.eclipse.topology.dialogs.EnterIpAddressDlg) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

Aggregations

ConnectionPoint (org.netxms.client.topology.ConnectionPoint)9 NXCSession (org.netxms.client.NXCSession)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NXCPMessage (org.netxms.base.NXCPMessage)3 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)3 InetAddress (java.net.InetAddress)2 AbstractObject (org.netxms.client.objects.AbstractObject)2 Interface (org.netxms.client.objects.Interface)2 Node (org.netxms.client.objects.Node)2 Shell (org.eclipse.swt.widgets.Shell)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 MacAddress (org.netxms.base.MacAddress)1 EnterIpAddressDlg (org.netxms.ui.eclipse.topology.dialogs.EnterIpAddressDlg)1 EnterMacAddressDlg (org.netxms.ui.eclipse.topology.dialogs.EnterMacAddressDlg)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1