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;
}
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()));
}
}
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;
}
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();
}
Aggregations