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 MAC address. Will return null if
* connection point information cannot be found.
*
* @param macAddr MAC address
* @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(MacAddress macAddr) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_FIND_MAC_LOCATION);
msg.setField(NXCPCodes.VID_MAC_ADDR, macAddr.getValue());
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 NXCSession method findConnectionPoint.
/**
* Find connection point (either directly connected or most close known
* interface on a switch) for given node or interface object. Will return
* null if connection point information cannot be found.
*
* @param objectId Node or interface object ID
* @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(long objectId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_FIND_NODE_CONNECTION);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
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 ConnectionPointLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
ConnectionPoint cp = (ConnectionPoint) element;
switch(columnIndex) {
case HostSearchResults.COLUMN_SEQUENCE:
return Integer.toString((Integer) cp.getData() + 1);
case HostSearchResults.COLUMN_NODE:
return getObjectName(cp.getLocalNodeId());
case HostSearchResults.COLUMN_INTERFACE:
return getObjectName(cp.getLocalInterfaceId());
case HostSearchResults.COLUMN_MAC_ADDRESS:
if (cp.getLocalMacAddress() == null)
return "n/a";
else
return cp.getLocalMacAddress().toString();
case HostSearchResults.COLUMN_IP_ADDRESS:
InetAddress addr = cp.getLocalIpAddress();
if (addr != null)
return addr.getHostAddress();
Interface iface = (Interface) session.findObjectById(cp.getLocalInterfaceId(), Interface.class);
if (iface == null)
// $NON-NLS-1$
return "";
InetAddress a = iface.getFirstUnicastAddress();
// $NON-NLS-1$
return (a != null) ? a.getHostAddress() : "";
case HostSearchResults.COLUMN_SWITCH:
if ((cp.getNodeId() == 0))
return "n/a";
else
return getObjectName(cp.getNodeId());
case HostSearchResults.COLUMN_PORT:
if (cp.getInterfaceId() == 0)
return "n/a";
else
return getObjectName(cp.getInterfaceId());
case HostSearchResults.COLUMN_TYPE:
if (cp.getType() == null)
return "n/a";
switch(cp.getType()) {
case DIRECT:
return Messages.get().ConnectionPointLabelProvider_Direct;
case INDIRECT:
return Messages.get().ConnectionPointLabelProvider_Indirect;
case WIRELESS:
return Messages.get().ConnectionPointLabelProvider_Wireless;
default:
return Messages.get().ConnectionPointLabelProvider_Unknown;
}
}
return null;
}
use of org.netxms.client.topology.ConnectionPoint in project netxms by netxms.
the class FindConnectionPoint method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
if ((objects == null) || (objects.isEmpty()))
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().FindConnectionPoint_JobTitle, wbPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final ConnectionPoint[] cps = new ConnectionPoint[objects.size()];
for (int i = 0; i < objects.size(); i++) {
AbstractObject object = objects.get(i);
cps[i] = session.findConnectionPoint(object.getObjectId());
if (cps[i] == null) {
if (object instanceof Node)
cps[i] = new ConnectionPoint(object.getObjectId(), 0, false);
else
cps[i] = new ConnectionPoint(object.getParentIdList()[0], object.getObjectId(), false);
}
}
runInUIThread(new Runnable() {
@Override
public void run() {
if (cps.length == 1)
HostSearchResults.showConnection(cps[0]);
else
HostSearchResults.showConnection(cps);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().FindConnectionPoint_JobError;
}
}.start();
}
use of org.netxms.client.topology.ConnectionPoint in project netxms by netxms.
the class FindMacAddress method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
EnterMacAddressDlg dlg = new EnterMacAddressDlg(window.getShell());
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final MacAddress macAddr = dlg.getMacAddress();
new ConsoleJob(String.format(Messages.get().FindMacAddress_JobTitle, macAddr), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final ConnectionPoint cp = session.findConnectionPoint(macAddr);
runInUIThread(new Runnable() {
@Override
public void run() {
HostSearchResults.showConnection(cp);
}
});
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().FindMacAddress_JobError, macAddr);
}
}.start();
}
Aggregations