use of org.netxms.client.objects.Zone in project netxms by netxms.
the class ObjectSearchResultLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
if (!(element instanceof AbstractObject))
return null;
AbstractObject object = (AbstractObject) element;
switch(columnIndex) {
case ObjectFinder.COL_CLASS:
return object.getObjectClassName();
case ObjectFinder.COL_ID:
return Long.toString(object.getObjectId());
case ObjectFinder.COL_IP_ADDRESS:
if (object instanceof AbstractNode) {
InetAddressEx addr = ((AbstractNode) object).getPrimaryIP();
return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
}
if (object instanceof AccessPoint) {
InetAddressEx addr = ((AccessPoint) object).getIpAddress();
return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
}
if (object instanceof Interface) {
return ((Interface) object).getIpAddressListAsString();
}
return null;
case ObjectFinder.COL_NAME:
return wbLabelProvider.getText(element);
case ObjectFinder.COL_PARENT:
return getParentNames((AbstractObject) element);
case ObjectFinder.COL_ZONE:
if (object instanceof AbstractNode) {
long zoneId = ((AbstractNode) object).getZoneId();
Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
} else if (object instanceof Interface) {
long zoneId = ((Interface) object).getZoneId();
Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
}
return null;
}
return null;
}
use of org.netxms.client.objects.Zone in project netxms by netxms.
the class CreateNodeDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
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);
objectNameField.setLabel(Messages.get().CreateNodeDialog_Name);
objectNameField.getTextControl().setTextLimit(255);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 600;
gd.horizontalSpan = 2;
objectNameField.setLayoutData(gd);
objectNameField.setText(objectName);
final Composite ipAddrGroup = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
ipAddrGroup.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
ipAddrGroup.setLayoutData(gd);
hostNameField = new LabeledText(ipAddrGroup, SWT.NONE);
hostNameField.setLabel(Messages.get().CreateNodeDialog_PrimaryHostName);
hostNameField.getTextControl().setTextLimit(255);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
hostNameField.setLayoutData(gd);
hostNameField.setText(hostName);
agentPortField = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().CreateNodeDialog_AgentPort, 1, 65535, WidgetHelper.DEFAULT_LAYOUT_DATA);
agentPortField.setSelection(agentPort);
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();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
optionsGroup.setLayoutData(gd);
optionsGroup.setLayout(new RowLayout(SWT.VERTICAL));
checkUnmanaged = new Button(optionsGroup, SWT.CHECK);
checkUnmanaged.setText(Messages.get().CreateNodeDialog_CreateUnmanaged);
checkUnmanaged.setSelection((creationFlags & NXCObjectCreationData.CF_CREATE_UNMANAGED) != 0);
checkDisableAgent = new Button(optionsGroup, SWT.CHECK);
checkDisableAgent.setText(Messages.get().CreateNodeDialog_DisableAgent);
checkDisableAgent.setSelection((creationFlags & NXCObjectCreationData.CF_DISABLE_NXCP) != 0);
checkDisableSNMP = new Button(optionsGroup, SWT.CHECK);
checkDisableSNMP.setText(Messages.get().CreateNodeDialog_DisableSNMP);
checkDisableSNMP.setSelection((creationFlags & NXCObjectCreationData.CF_DISABLE_SNMP) != 0);
checkDisablePing = new Button(optionsGroup, SWT.CHECK);
checkDisablePing.setText(Messages.get().CreateNodeDialog_DisableICMP);
checkDisablePing.setSelection((creationFlags & NXCObjectCreationData.CF_DISABLE_ICMP) != 0);
agentProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
agentProxySelector.setLabel(Messages.get().CreateNodeDialog_AgentProxy);
agentProxySelector.setObjectClass(Node.class);
agentProxySelector.setObjectId(agentProxy);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
agentProxySelector.setLayoutData(gd);
snmpProxySelector = new ObjectSelector(dialogArea, SWT.NONE, true);
snmpProxySelector.setLabel(Messages.get().CreateNodeDialog_SNMPProxy);
snmpProxySelector.setObjectClass(Node.class);
snmpProxySelector.setObjectId(snmpProxy);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
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 ZoneSelector(dialogArea, SWT.NONE, false);
zoneSelector.setLabel(Messages.get().CreateNodeDialog_Zone);
Zone zone = ConsoleSharedData.getSession().findZone(zoneUIN);
zoneSelector.setZoneUIN((zone != null) ? zone.getUIN() : -1);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
zoneSelector.setLayoutData(gd);
}
if (enableShowAgainFlag) {
checkCreateAnother = new Button(dialogArea, SWT.CHECK);
checkCreateAnother.setText(Messages.get().CreateNodeDialog_ShowAgain);
checkCreateAnother.setSelection(showAgain);
}
return dialogArea;
}
use of org.netxms.client.objects.Zone in project netxms by netxms.
the class GeneralInfo method fillTable.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.elements.TableElement#fillTable()
*/
@Override
protected void fillTable() {
final AbstractObject object = getObject();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
addPair(Messages.get().GeneralInfo_ID, Long.toString(object.getObjectId()));
if (object.getGuid() != null)
addPair(Messages.get().GeneralInfo_GUID, object.getGuid().toString());
addPair(Messages.get().GeneralInfo_Class, object.getObjectClassName());
if (object.isInMaintenanceMode())
addPair(Messages.get().GeneralInfo_Status, StatusDisplayInfo.getStatusText(object.getStatus()) + Messages.get().GeneralInfo_Maintenance);
else
addPair(Messages.get().GeneralInfo_Status, StatusDisplayInfo.getStatusText(object.getStatus()));
switch(object.getObjectClass()) {
case AbstractObject.OBJECT_CHASSIS:
Chassis chassis = (Chassis) object;
if (chassis.getControllerId() != 0) {
AbstractNode node = session.findObjectById(chassis.getControllerId(), AbstractNode.class);
if (node != null) {
addPair(Messages.get().GeneralInfo_Controller, node.getObjectName());
}
}
if (chassis.getRackId() != 0) {
Rack rack = session.findObjectById(chassis.getRackId(), Rack.class);
if (rack != null) {
addPair(Messages.get().GeneralInfo_Rack, String.format(Messages.get().GeneralInfo_Units, rack.getObjectName(), rack.isTopBottomNumbering() ? chassis.getRackPosition() : chassis.getRackPosition() - chassis.getRackHeight() + 1, rack.isTopBottomNumbering() ? chassis.getRackPosition() + chassis.getRackHeight() - 1 : chassis.getRackPosition()));
}
}
break;
case AbstractObject.OBJECT_INTERFACE:
Interface iface = (Interface) object;
Interface parentIface = iface.getParentInterface();
if (parentIface != null)
addPair("Parent interface", parentIface.getObjectName());
addPair(Messages.get().GeneralInfo_IfIndex, Integer.toString(iface.getIfIndex()));
String typeName = iface.getIfTypeName();
// $NON-NLS-1$
addPair(Messages.get().GeneralInfo_IfType, (typeName != null) ? String.format("%d (%s)", iface.getIfType(), typeName) : Integer.toString(iface.getIfType()));
addPair(Messages.get().GeneralInfo_Description, iface.getDescription(), false);
addPair(Messages.get().GeneralInfo_Alias, iface.getAlias(), false);
if (iface.getMtu() > 0)
addPair(Messages.get().GeneralInfo_MTU, Integer.toString(iface.getMtu()));
if (iface.getSpeed() > 0)
addPair(Messages.get().GeneralInfo_Speed, InterfaceListLabelProvider.ifSpeedTotext(iface.getSpeed()));
addPair(Messages.get().GeneralInfo_MACAddr, iface.getMacAddress().toString());
if ((iface.getFlags() & Interface.IF_PHYSICAL_PORT) != 0) {
// $NON-NLS-1$
addPair(Messages.get().GeneralInfo_SlotPort, Integer.toString(iface.getSlot()) + "/" + Integer.toString(iface.getPort()));
AbstractNode node = iface.getParentNode();
if ((node != null) && node.is8021xSupported()) {
addPair(Messages.get().GeneralInfo_8021xPAE, iface.getDot1xPaeStateAsText());
addPair(Messages.get().GeneralInfo_8021xBackend, iface.getDot1xBackendStateAsText());
}
}
if (iface.getIpAddressList().size() > 0) {
if (session.isZoningEnabled())
addPair(Messages.get().GeneralInfo_ZoneId, getZoneName(iface.getZoneId()));
addPair(Messages.get().GeneralInfo_IPAddr, iface.getIpAddressList().get(0).toString());
for (int i = 1; i < iface.getIpAddressList().size(); i++) // $NON-NLS-1$
addPair("", iface.getIpAddressList().get(i).toString());
}
addPair(Messages.get().GeneralInfo_AdmState, iface.getAdminStateAsText());
addPair(Messages.get().GeneralInfo_OperState, iface.getOperStateAsText());
addPair(Messages.get().GeneralInfo_ExpectedState, ifaceExpectedState[iface.getExpectedState()]);
break;
case AbstractObject.OBJECT_NODE:
AbstractNode node = (AbstractNode) object;
if (session.isZoningEnabled())
addPair(Messages.get().GeneralInfo_ZoneId, getZoneName(node.getZoneId()));
addPair(Messages.get().GeneralInfo_PrimaryHostName, node.getPrimaryName());
addPair(Messages.get().GeneralInfo_PrimaryIP, node.getPrimaryIP().getHostAddress());
if (node.hasAgent())
addPair(Messages.get().GeneralInfo_AgentVersion, node.getAgentVersion());
addPair(Messages.get().GeneralInfo_SysDescr, node.getSystemDescription(), false);
addPair(Messages.get().GeneralInfo_PlatformName, node.getPlatformName(), false);
addPair(Messages.get().GeneralInfo_SysName, node.getSnmpSysName(), false);
addPair(Messages.get().GeneralInfo_SysOID, node.getSnmpOID(), false);
addPair(Messages.get().GeneralInfo_SNMPsysLocation, node.getSnmpSysLocation(), false);
addPair(Messages.get().GeneralInfo_SNMPsysContact, node.getSnmpSysContact(), false);
if ((node.getCapabilities() & AbstractNode.NC_IS_BRIDGE) != 0)
addPair(Messages.get().GeneralInfo_BridgeBaseAddress, node.getBridgeBaseAddress().toString());
addPair(Messages.get().GeneralInfo_Driver, node.getDriverName(), false);
addPair(Messages.get().GeneralInfo_NodeType, node.getNodeType().toString(), false);
if (node.getBootTime() != null)
addPair(Messages.get().GeneralInfo_BootTime, RegionalSettings.getDateTimeFormat().format(node.getBootTime()), false);
if (node.hasAgent())
addPair(Messages.get().GeneralInfo_AgentStatus, (node.getStateFlags() & Node.NSF_AGENT_UNREACHABLE) != 0 ? Messages.get().GeneralInfo_Unreachable : Messages.get().GeneralInfo_Connected);
if (node.getLastAgentCommTime() != null)
addPair(Messages.get().GeneralInfo_LastAgentContact, RegionalSettings.getDateTimeFormat().format(node.getLastAgentCommTime()), false);
if (node.getRackId() != 0) {
Rack rack = session.findObjectById(node.getRackId(), Rack.class);
if (rack != null) {
addPair(Messages.get().GeneralInfo_Rack, String.format(Messages.get().GeneralInfo_Units, rack.getObjectName(), rack.isTopBottomNumbering() ? node.getRackPosition() : node.getRackPosition() - node.getRackHeight() + 1, rack.isTopBottomNumbering() ? node.getRackPosition() + node.getRackHeight() - 1 : node.getRackPosition()));
}
}
break;
case AbstractObject.OBJECT_MOBILEDEVICE:
MobileDevice md = (MobileDevice) object;
if (md.getLastReportTime().getTime() == 0)
addPair(Messages.get().GeneralInfo_LastReport, Messages.get().GeneralInfo_Never);
else
addPair(Messages.get().GeneralInfo_LastReport, RegionalSettings.getDateTimeFormat().format(md.getLastReportTime()));
addPair(Messages.get().GeneralInfo_DeviceId, md.getDeviceId());
addPair(Messages.get().GeneralInfo_Vendor, md.getVendor());
addPair(Messages.get().GeneralInfo_Model, md.getModel());
addPair(Messages.get().GeneralInfo_Serial, md.getSerialNumber());
addPair(Messages.get().GeneralInfo_OS, md.getOsName());
addPair(Messages.get().GeneralInfo_OSVersion, md.getOsVersion());
addPair(Messages.get().GeneralInfo_User, md.getUserId(), false);
if (md.getBatteryLevel() >= 0)
// $NON-NLS-1$
addPair(Messages.get().GeneralInfo_BatteryLevel, Integer.toString(md.getBatteryLevel()) + "%");
break;
case AbstractObject.OBJECT_SENSOR:
Sensor sensor = (Sensor) object;
addPair(Messages.get().SensorStatus_DeviceAddress, sensor.getDeviceAddress(), false);
if (sensor.getMacAddress() != null && !sensor.getMacAddress().isNull())
addPair(Messages.get().SensorStatus_MacAddress, sensor.getMacAddress().toString(), true);
addPair(Messages.get().SensorStatus_Vendor, sensor.getVendor(), true);
addPair(Messages.get().SensorStatus_DeviceClass, Sensor.DEV_CLASS_NAMES[sensor.getDeviceClass()]);
addPair(Messages.get().SensorStatus_CommProtocol, Sensor.COMM_METHOD[sensor.getCommProtocol()]);
addPair(Messages.get().SensorStatus_SerialNumber, sensor.getSerialNumber(), true);
addPair(Messages.get().SensorStatus_MetaType, sensor.getMetaType(), true);
addPair(Messages.get().SensorStatus_Description, sensor.getDescription(), true);
if (sensor.getFrameCount() != 0)
addPair(Messages.get().SensorStatus_FrameCount, Integer.toString(sensor.getFrameCount()));
if (sensor.getSignalStrenght() != 1)
addPair(Messages.get().SensorStatus_RSSI, Integer.toString(sensor.getSignalStrenght()));
if (sensor.getSignalNoise() != Integer.MAX_VALUE)
addPair(Messages.get().SensorStatus_SNR, Double.toString((double) sensor.getSignalNoise() / 10));
if (sensor.getFrequency() != 0)
addPair(Messages.get().SensorStatus_Frequency, Double.toString((double) sensor.getFrequency() / 10));
break;
case AbstractObject.OBJECT_ACCESSPOINT:
AccessPoint ap = (AccessPoint) object;
addPair(Messages.get().GeneralInfo_State, ap.getState().toString());
addPair(Messages.get().GeneralInfo_Vendor, ap.getVendor());
addPair(Messages.get().GeneralInfo_Model, ap.getModel());
addPair(Messages.get().GeneralInfo_Serial, ap.getSerialNumber());
addPair(Messages.get().GeneralInfo_MACAddr, ap.getMacAddress().toString());
if (ap.getIpAddress().isValidAddress())
addPair(Messages.get().GeneralInfo_IPAddr, ap.getIpAddress().getHostAddress());
break;
case AbstractObject.OBJECT_SUBNET:
Subnet subnet = (Subnet) object;
if (session.isZoningEnabled())
addPair(Messages.get().GeneralInfo_ZoneId, getZoneName(subnet.getZoneId()));
addPair(Messages.get().GeneralInfo_IPAddress, subnet.getNetworkAddress().toString());
break;
case AbstractObject.OBJECT_ZONE:
Zone zone = (Zone) object;
addPair(Messages.get().GeneralInfo_ZoneId, Long.toString(zone.getUIN()));
break;
case AbstractObject.OBJECT_NODELINK:
AbstractNode linkedNode = (AbstractNode) session.findObjectById(((NodeLink) object).getNodeId(), AbstractNode.class);
if (linkedNode != null)
addPair(Messages.get().GeneralInfo_LinkedNode, linkedNode.getObjectName());
case AbstractObject.OBJECT_BUSINESSSERVICE:
case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
ServiceContainer service = (ServiceContainer) object;
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMinimumFractionDigits(3);
nf.setMaximumFractionDigits(3);
// $NON-NLS-1$
addPair(Messages.get().GeneralInfo_UptimeDay, nf.format(service.getUptimeForDay()) + "%");
// $NON-NLS-1$
addPair(Messages.get().GeneralInfo_UptimeWeek, nf.format(service.getUptimeForWeek()) + "%");
// $NON-NLS-1$
addPair(Messages.get().GeneralInfo_UptimeMonth, nf.format(service.getUptimeForMonth()) + "%");
break;
case AbstractObject.OBJECT_SLMCHECK:
ServiceCheck check = (ServiceCheck) object;
addPair(Messages.get().GeneralInfo_IsTemplate, check.isTemplate() ? Messages.get().GeneralInfo_Yes : Messages.get().GeneralInfo_No);
if (check.getTemplateId() != 0) {
ServiceCheck tmpl = (ServiceCheck) session.findObjectById(check.getTemplateId(), ServiceCheck.class);
if (tmpl != null)
addPair(Messages.get().GeneralInfo_Template, tmpl.getObjectName());
}
break;
default:
break;
}
if (object.getGeolocation().getType() != GeoLocation.UNSET)
addPair(Messages.get().GeneralInfo_Location, object.getGeolocation().toString());
if (!object.getPostalAddress().isEmpty())
addPair(Messages.get().GeneralInfo_PostalAddress, object.getPostalAddress().getAddressLine());
}
use of org.netxms.client.objects.Zone in project netxms by netxms.
the class SnmpConfig method loadPortConfig.
private static Map<Integer, List<String>> loadPortConfig(NXCSession session) throws IOException, NXCException {
List<Zone> zones = session.getAllZones();
Map<Integer, List<String>> ports = new HashMap<Integer, List<String>>();
for (Zone z : zones) {
if (!z.getSnmpPorts().isEmpty())
ports.put((int) z.getUIN(), z.getSnmpPorts());
}
Map<String, ServerVariable> variables = session.getServerVariables();
// $NON-NLS-1$
ServerVariable v = variables.get("SNMPPorts");
// $NON-NLS-1$
parsePorts(v != null ? v.getValue() : "", ports);
return ports;
}
use of org.netxms.client.objects.Zone in project netxms by netxms.
the class NXCSession method deleteObject.
/**
* Delete object
*
* @param objectId ID of an object which should be deleted
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void deleteObject(final long objectId) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_DELETE_OBJECT);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
sendMessage(msg);
waitForRCC(msg.getMessageId());
// appropriate notification without waiting for actual server update
synchronized (objectList) {
AbstractObject object = objectList.get(objectId);
if (object != null) {
objectList.remove(objectId);
objectListGUID.remove(object.getGuid());
if (object instanceof Zone)
zoneList.remove(((Zone) object).getUIN());
removeOrphanedObjects(object);
}
}
sendNotification(new SessionNotification(SessionNotification.OBJECT_DELETED, objectId));
}
Aggregations