@Override public String getValue(VmNetworkInterface object) { return object.getVnicProfileName(); } };
@Override public String getValue(VmNetworkInterface object) { return object.getVnicProfileName(); } };
/** * create a {@link VnicProfileMappingEntity} with no target profile for each pre-loaded interface of the registered entity * if a previous mapping for the same source profile is not found. * * @param interfaces the interfaces of the registered entity initially loaded by the frontend when the register action started * @param previousClusterVnicProfileMappings the mappings passed to {@link VnicProfileMappingModel}, with user selections of target profiles * @return a set of mappings for all interfaces of registered entity */ private Set<VnicProfileMappingEntity> getNewVnicProfileMappings(List<VmNetworkInterface> interfaces, Set<VnicProfileMappingEntity> previousClusterVnicProfileMappings) { Set<VnicProfileMappingEntity> result = new HashSet<>(); for (VmNetworkInterface vnic : interfaces) { VnicProfileMappingEntity newMapping = new VnicProfileMappingEntity(vnic.getNetworkName(), vnic.getVnicProfileName(), null); VnicProfileMappingEntity mapping = previousClusterVnicProfileMappings.stream().filter(x -> x.isSameSourceProfile(newMapping)).findFirst().orElse(newMapping); // warning: the Set.add() uses the equals of {@link VnicProfileMappingEntity} which only compares the source profile result.add(mapping); } return result; }
/** * Comparison used by the backend to compare mappings. * External mapping supplied by the user may include empty string to denote 'no profile', * whereas in {@link VmNetworkInterface} 'no profile' is denoted with {@code null}s. * So apart from a standard equals(), compare the empty string mapping to null on the vnic. */ public boolean isSameSourceProfile(VmNetworkInterface vnic) { return (Objects.equals(getSourceNetworkName(), vnic.getNetworkName()) || ("".equals(getSourceNetworkName()) && vnic.getNetworkName() == null)) && (Objects.equals(getSourceProfileName(), vnic.getVnicProfileName()) || ("".equals(getSourceProfileName()) && vnic.getVnicProfileName() == null)); }
@Override public void update(int index, VmNetworkInterface networkInterface, String value) { Map<String, String> parameters = new HashMap<>(); parameters.put(FragmentParams.NAME.getName(), networkInterface.getVnicProfileName()); parameters.put(FragmentParams.NETWORK.getName(), networkInterface.getNetworkName()); parameters.put(FragmentParams.DATACENTER.getName(), templateListModel.getSelectedItem().getStoragePoolName()); getPlaceTransitionHandler().handlePlaceTransition( WebAdminApplicationPlaces.vnicProfileVmSubTabPlace, parameters); } }) {
if (StringUtils.isNotEmpty(iface.getVnicProfileName())) { _writer.writeRaw(iface.getVnicProfileName());
nic.getNetworkName()), dl); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.profileNameInterface()), SafeHtmlUtils.fromString(nic.getVnicProfileName() == null ? messages.emptyProfile().asString() : nic.getVnicProfileName()), dl); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.typeInterface()), SafeHtmlUtils.fromString(VmInterfaceType.forValue(nic.getType()).getDescription()), dl);
constants.unAvailablePropertyLabel()), dl); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.profileNameInterface()), SafeHtmlUtils.fromString(networkInterface.getVnicProfileName() != null ? networkInterface.getVnicProfileName() : messages.emptyProfile().asString()), dl); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.vmNetworkQosName()),
@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(); }