@Override public Boolean getValue(VmNetworkInterface object) { return object.isPlugged(); }
private boolean isCardPlugged(VmNetworkInterface networkInterface) { return networkInterface != null ? networkInterface.isPlugged() : false; }
private boolean isPluggedBeforeAndAfterEdit() { return getNic().isPlugged() && getPlugged().getEntity(); }
private boolean canRemoveNics() { VM vm = getEntity(); if (VMStatus.Down.equals(vm.getStatus())) { return true; } List<VmNetworkInterface> nics = getSelectedItems() != null ? getSelectedItems() : new ArrayList<VmNetworkInterface>(); for (VmNetworkInterface nic : nics) { if (nic.isPlugged()) { return false; } } return true; }
private boolean canRemoveVnics() { Iterable<PairQueryable<VmNetworkInterface, VM>> selectedItems = getSelectedItems() != null ? getSelectedItems() : new ArrayList(); for (PairQueryable<VmNetworkInterface, VM> pair : selectedItems) { if (pair.getFirst().isPlugged() && !VMStatus.Down.equals(pair.getSecond().getStatus())) { return false; } } return true; }
private ImageResource getImage(T object) { VmNetworkInterface vnic = null; if (object instanceof VmNetworkInterface) { vnic = (VmNetworkInterface) object; } else if (object instanceof PairQueryable && ((PairQueryable) object).getFirst() instanceof VmNetworkInterface) { vnic = ((PairQueryable<VmNetworkInterface, VM>) object).getFirst(); } if (vnic != null) { return vnic.isPlugged() && vnic.isLinked() ? resources.upImage() : resources.downImage(); } return null; }
@Override public SafeHtml getTooltip(T object) { VmNetworkInterface vnic = null; if (object instanceof VmNetworkInterface) { vnic = (VmNetworkInterface) object; } else if (object instanceof PairQueryable && ((PairQueryable) object).getFirst() instanceof VmNetworkInterface) { vnic = ((PairQueryable<VmNetworkInterface, VM>) object).getFirst(); } StringBuilder tooltip = new StringBuilder(""); //$NON-NLS-1$ boolean vnicExist = vnic != null; if (vnicExist && vnic.isPlugged()) { tooltip = tooltip.append(templates.cardStatus(constants.pluggedNetworkInterface()).asString()); } else { tooltip = tooltip.append(templates.cardStatus(constants.unpluggedNetworkInterface()).asString()); } tooltip = tooltip.append("<BR>"); //$NON-NLS-1$ if (vnicExist && vnic.isLinked()) { tooltip = tooltip.append(templates.linkState(constants.linkedNetworkInterface()) .asString()); } else { tooltip = tooltip.append(templates.linkState(constants.unlinkedNetworkInterface()) .asString()); } return SafeHtmlUtils.fromTrustedString(tooltip.toString()); }
private void confirmSave() { // Check if the nic was unplugged if (getNic().isPlugged() && !getPlugged().getEntity()) { ConfirmationModel model = new ConfirmationModel(); model.setTitle(ConstantsManager.getInstance().getConstants().unplugVnicTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantUnplugVnicMsg()); model.setHashName("unplug_vnic"); //$NON-NLS-1$ getSourceModel().setConfirmWindow(model); UICommand approveCommand = UICommand.createDefaultOkUiCommand(ON_APPROVE_COMMAND, this); model.getCommands().add(approveCommand); UICommand cancel = UICommand.createCancelUiCommand(ABORT_COMMAMD, this); //$NON-NLS-1$ model.getCommands().add(cancel); } else { onSave(); } }
private void postNicInit() { getName().setEntity(getNic().getName()); initMAC(); initLinked(); initNetworkFilterParameters(new AsyncQuery<>(returnValue -> { getNetworkFilterParameterListModel().setItems(returnValue); })); initProfiles(); // Plug should be the last one updated, cause it controls the changeability of the other editor getPlugged().setEntity(getNic().isPlugged()); getPlugged().setIsChangeable(allowPlug()); if (!allowPlug()) { getPlugged().setChangeProhibitionReason(ConstantsManager.getInstance() .getMessages() .nicHotPlugNotSupported(getClusterCompatibilityVersion().toString())); } initCommands(); }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", getId()) .append("name", getName()) .append("networkName", getNetworkName()) .append("vnicProfileName", getVnicProfileName()) .append("vnicProfileId", getVnicProfileId()) .append("speed", getSpeed()) .append("type", getType()) .append("macAddress", getMacAddress()) .append("active", isPlugged()) .append("linked", isLinked()) .append("portMirroring", isPortMirroring()) .append("vmId", getVmId()) .append("vmName", getVmName()) .append("vmTemplateId", getVmTemplateId()) .append("QoSName", getQosName()) .append("remoteNetworkName", getRemoteNetworkName()) .build(); }
@Mapping(from = VmNetworkInterface.class, to = Nic.class) public static Nic map(VmNetworkInterface entity, Nic template) { Nic model = template != null ? template : new Nic(); if (entity.getVmId() != null) { model.setVm(new Vm()); model.getVm().setId(entity.getVmId().toString()); } if (entity.getId() != null) { model.setId(entity.getId().toString()); } if (entity.getName() != null) { model.setName(entity.getName()); } if (entity.getMacAddress() != null) { model.setMac(new Mac()); model.getMac().setAddress(entity.getMacAddress()); } model.setLinked(entity.isLinked()); model.setInterface(map(entity.getType())); model.setPlugged(entity.isPlugged()); if (entity.getVnicProfileId() != null) { model.setVnicProfile(new VnicProfile()); model.getVnicProfile().setId(entity.getVnicProfileId().toString()); } return model; }
dl.addClassName(DL_HORIZONTAL); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.plugged()), renderPlugged(networkInterface.isPlugged()), dl); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.networkNameInterface()), SafeHtmlUtils.fromString(networkInterface.getNetworkName() != null ?