Alona Kaplan has uploaded a new change for review. Change subject: webadmin: edit vfsConfig- persist vfs config changes ......................................................................
webadmin: edit vfsConfig- persist vfs config changes Change-Id: Ifa221586d123a3bc4925b077921391508a4680ec Signed-off-by: Alona Kaplan <alkap...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostNicModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/host/HostNicPopupPresenterWidget.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostNicPopupView.java 5 files changed, 53 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/36421/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostNicModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostNicModel.java index d09be71..152fbc8 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostNicModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostNicModel.java @@ -14,8 +14,9 @@ public class HostNicModel extends Model { public static final VfsConfigModel EMPTY_VFS_CONFIG_MODEL = new VfsConfigModel(); + public static final NicLabelModel EMPTY_LABELS_MODEL = new NicLabelModel(); - private final NicLabelModel labelsModel; + private NicLabelModel labelsModel = EMPTY_LABELS_MODEL; private VfsConfigModel vfsConfigModel = EMPTY_VFS_CONFIG_MODEL; private VdsNetworkInterface iface; @@ -30,7 +31,10 @@ List<Network> allClusterNetworks) { setTitle(ConstantsManager.getInstance().getMessages().editInterfaceTitle(iface.getName())); this.iface = iface; - labelsModel = new NicLabelModel(Collections.singletonList(iface), suggestedLabels, labelToIface); + + if (labelToIface != null) { + labelsModel = new NicLabelModel(Collections.singletonList(iface), suggestedLabels, labelToIface); + } if (vfsConfig != null) { vfsConfigModel = new VfsConfigModel(vfsConfig, allClusterNetworks); @@ -38,7 +42,7 @@ } public boolean validate() { - return labelsModel.validate(); + return labelsModel == EMPTY_LABELS_MODEL ? true : labelsModel.validate(); } public VfsConfigModel getVfsConfigModel() { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java index 49e8ad0..10509c4 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java @@ -39,6 +39,7 @@ import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; +import org.ovirt.engine.ui.uicommonweb.models.hosts.VfsConfigModel.AllNetworksSelector; import org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel; import org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel; import org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkCommand; @@ -303,6 +304,25 @@ NetworkOperation.attachNetworks(ifaceModel, new ArrayList<LogicalNetworkModel>(potentialNetworks), allNics); } + private void commitVfsConfigChanges(final HostNicVfsConfig hostNicVfsConfig, + final VfsConfigModel vfsConfigModel) { + if (hostNicVfsConfig != null) { + hostNicVfsConfig.setNumOfVfs(vfsConfigModel.getNumOfVfs().getEntity()); + + hostNicVfsConfig.setAllNetworksAllowed(vfsConfigModel + .getAllNetworksAllowed().getSelectedItem() == AllNetworksSelector.allNetworkAllowed); + Set<Guid> networks = new HashSet<>(); + for (VfsConfigNetwork vfsConfigNetwork : vfsConfigModel.getNetworks().getItems()) { + if (vfsConfigNetwork.isAttached() && vfsConfigNetwork.getLabelViaAttached() == null) { + networks.add(vfsConfigNetwork.getEntity().getId()); + } + } + hostNicVfsConfig.setNetworks(networks); + + hostNicVfsConfig.setLabels(new HashSet<>(vfsConfigModel.getLabels().getItems())); + } + } + public void onEdit(NetworkItemModel<?> item) { Model editPopup = null; BaseCommandTarget okTarget = null; @@ -337,10 +357,12 @@ * Interface Dialog *******************/ final VdsNetworkInterface entity = ((NetworkInterfaceModel) item).getEntity(); + final boolean isBondSalve = entity.isBondSlave(); + final HostNicVfsConfig hostNicVfsConfig = nicToVfsConfig.get(entity.getId()); final HostNicModel interfacePopupModel = new HostNicModel(entity, - getFreeLabels(), - labelToIface, + isBondSalve ? null : getFreeLabels(), + isBondSalve ? null : labelToIface, nicToVfsConfig.get(entity.getId()), allNetworks); editPopup = interfacePopupModel; @@ -353,15 +375,20 @@ return; } sourceListModel.setConfirmWindow(null); - Collection<LogicalNetworkModel> potentialNetworks = - computeLabelChanges(interfacePopupModel.getLabelsModel(), nicMap.get(entity.getName()) - .getItems()); - if (validateLabelChanges(potentialNetworks)) { - commitLabelChanges(interfacePopupModel.getLabelsModel(), entity, potentialNetworks); - redraw(); + + if (!isBondSalve) { + Collection<LogicalNetworkModel> potentialNetworks = + computeLabelChanges(interfacePopupModel.getLabelsModel(), nicMap.get(entity.getName()) + .getItems()); + if (validateLabelChanges(potentialNetworks)) { + commitLabelChanges(interfacePopupModel.getLabelsModel(), entity, potentialNetworks); + redraw(); + } } + + commitVfsConfigChanges(hostNicVfsConfig, interfacePopupModel.getVfsConfigModel()); } - }; + }; } else if (item instanceof LogicalNetworkModel) { /***************** * Network Dialog diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java index b0f70ae..a254c3f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java @@ -29,6 +29,12 @@ return suggestedLabels; } + public NicLabelModel() { + this(Collections.<VdsNetworkInterface> emptyList(), + Collections.<String> emptyList(), + Collections.<String, String> emptyMap()); + } + public NicLabelModel(Collection<VdsNetworkInterface> srcIfaces, Collection<String> suggestedLabels, Map<String, String> labelToIface) { diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/host/HostNicPopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/host/HostNicPopupPresenterWidget.java index c1ad6a4..2738380 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/host/HostNicPopupPresenterWidget.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/host/HostNicPopupPresenterWidget.java @@ -24,9 +24,10 @@ @Override public void init(HostNicModel model) { if (model.getVfsConfigModel() != HostNicModel.EMPTY_VFS_CONFIG_MODEL) { - if (model.getInterface().getBondName() == null) { + if (model.getLabelsModel() != HostNicModel.EMPTY_LABELS_MODEL) { // sriov nic getView().showTabs(); + } else { // sriov bond slave getView().showOnlyVfsConfig(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostNicPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostNicPopupView.java index 8871261..d35714f 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostNicPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostNicPopupView.java @@ -77,9 +77,10 @@ @Override public HostNicModel flush() { + HostNicModel hostNicModel = driver.flush(); labelsWidget.flush(); vfsConfigWidget.flush(); - return driver.flush(); + return hostNicModel; } @Override -- To view, visit http://gerrit.ovirt.org/36421 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa221586d123a3bc4925b077921391508a4680ec Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches