Search in sources :

Example 1 with NetworkLabelModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel in project ovirt-engine by oVirt.

the class HostSetupNetworksModel method onOperation.

public void onOperation(NetworkOperation operation, final NetworkCommand networkCommand) {
    Model popupWindow;
    UICommand cancelCommand = new UICommand("Cancel", new // $NON-NLS-1$
    BaseCommandTarget() {

        @Override
        public void executeCommand(UICommand command) {
            sourceListModel.setConfirmWindow(null);
        }
    });
    cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel());
    cancelCommand.setIsCancel(true);
    if (operation.isNullOperation()) {
        return;
    } else if (operation == NetworkOperation.BOND_WITH || operation == NetworkOperation.JOIN_BONDS) {
        final SetupNetworksBondModel bondPopup;
        boolean doesBondHaveVmNetworkAttached = doesBondHaveVmNetworkAttached((NetworkInterfaceModel) networkCommand.getOp1(), (NetworkInterfaceModel) networkCommand.getOp2());
        if (operation == NetworkOperation.BOND_WITH) {
            bondPopup = new SetupNetworksAddBondModel(getFreeBonds(), nextBondName, doesBondHaveVmNetworkAttached);
        } else {
            bondPopup = new SetupNetworksJoinBondsModel(getFreeBonds(), (BondNetworkInterfaceModel) networkCommand.getOp1(), (BondNetworkInterfaceModel) networkCommand.getOp2(), doesBondHaveVmNetworkAttached);
        }
        bondPopup.getCommands().add(new UICommand("OK", new // $NON-NLS-1$
        BaseCommandTarget() {

            @Override
            public void executeCommand(UICommand command) {
                if (!bondPopup.validate()) {
                    return;
                }
                sourceListModel.setConfirmWindow(null);
                CreateOrUpdateBond bond = new CreateOrUpdateBond();
                bond.setName(bondPopup.getBond().getSelectedItem());
                setBondOptions(bond, bondPopup);
                NetworkInterfaceModel nic1 = (NetworkInterfaceModel) networkCommand.getOp1();
                NetworkInterfaceModel nic2 = (NetworkInterfaceModel) networkCommand.getOp2();
                // Store networks
                List<LogicalNetworkModel> networks = new ArrayList<>();
                networks.addAll(nic1.getItems());
                networks.addAll(nic2.getItems());
                // Store labels
                List<NetworkLabelModel> labels = new ArrayList<>();
                labels.addAll(nic1.getLabels());
                labels.addAll(nic2.getLabels());
                networkCommand.execute(bond);
                /*
                     * We are calling the <code>redraw()</code> to create the BondModel which is needed by the following
                     * operations (attaching the networks and the labels to the bond).
                     *
                     * For more details @see #redraw. After executing the <code>networkCommand</code> which creates the
                     * bond, the bondModel still not exist (only the <code>hostSetupNetworksParametersData.bonds</code>
                     * are updated). <code>redraw()</code> has to be called to create it.
                     */
                redraw();
                // Attach the previous networks
                attachNetworks(bond.getName(), networks);
                // Attach previous labels
                attachLabels(bond.getName(), labels);
                redraw();
            }
        }));
        popupWindow = bondPopup;
    } else if (networkCommand.getOp1() == getNewNetworkLabelModel()) {
        final SetupNetworksLabelModel labelPopup = new SetupNetworksLabelModel(dcLabels);
        labelPopup.getCommands().add(new UICommand("OK", new // $NON-NLS-1$
        BaseCommandTarget() {

            @Override
            public void executeCommand(UICommand uiCommand) {
                if (!labelPopup.validate()) {
                    return;
                }
                sourceListModel.setConfirmWindow(null);
                String label = labelPopup.getLabel().getEntity();
                dcLabels.add(label);
                NetworkOperation.LABEL.getCommand(new NetworkLabelModel(label, HostSetupNetworksModel.this), networkCommand.getOp2(), hostSetupNetworksParametersData).execute();
                redraw();
            }
        }));
        popupWindow = labelPopup;
    } else {
        // just execute the command
        networkCommand.execute();
        redraw();
        return;
    }
    // add cancel
    popupWindow.getCommands().add(cancelCommand);
    // set window
    sourceListModel.setConfirmWindow(popupWindow);
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NewNetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel) NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) DataFromHostSetupNetworksModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) NewNetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkItemModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkItemModel) NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with NetworkLabelModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel in project ovirt-engine by oVirt.

the class HostSetupNetworksPopupView method updateLabels.

private void updateLabels(NetworkLabelModel newLabelModel, List<NetworkLabelModel> labels) {
    labelsList.clear();
    List<NetworkLabelPanel> labelPanels = new ArrayList<>();
    labelPanels.add(new NewNetworkLabelPanel(newLabelModel, style));
    Collections.sort(labels);
    for (NetworkLabelModel label : labels) {
        if (!label.isAttached()) {
            labelPanels.add(new NetworkLabelPanel(label, style));
        }
    }
    labelsList.addAll(labelPanels, !rendered);
}
Also used : NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) NetworkLabelPanel(org.ovirt.engine.ui.webadmin.section.main.view.popup.host.panels.NetworkLabelPanel) NewNetworkLabelPanel(org.ovirt.engine.ui.webadmin.section.main.view.popup.host.panels.NetworkLabelPanel.NewNetworkLabelPanel) ArrayList(java.util.ArrayList) NewNetworkLabelPanel(org.ovirt.engine.ui.webadmin.section.main.view.popup.host.panels.NetworkLabelPanel.NewNetworkLabelPanel)

Example 3 with NetworkLabelModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel in project ovirt-engine by oVirt.

the class HostSetupNetworksModel method createNicToLabelModels.

private Map<String, List<NetworkLabelModel>> createNicToLabelModels(Map<String, Set<LogicalNetworkModel>> nicNameToNetworkModels, List<LogicalNetworkModel> errorLabelNetworks, Map<String, String> labelToDesiredNicName) {
    Map<String, List<NetworkLabelModel>> nicToLabelModels = new HashMap<>();
    for (NicLabel nicLabel : hostSetupNetworksParametersData.getLabels()) {
        String label = nicLabel.getLabel();
        String nicName = nicLabel.getNicName();
        labelToDesiredNicName.put(label, nicName);
        Collection<LogicalNetworkModel> nicNetworks = nicNameToNetworkModels.get(nicName);
        NetworkLabelModel labelModel = networkLabelModelByLabel.get(label);
        // $NON-NLS-1$
        assert labelModel != null : "NicLabel should have a NetworkLabelModel";
        markNetworkModelsAsAttachedViaLabel(errorLabelNetworks, nicNetworks, labelModel);
        if (nicToLabelModels.get(nicName) == null) {
            nicToLabelModels.put(nicName, new ArrayList<NetworkLabelModel>());
        }
        nicToLabelModels.get(nicName).add(labelModel);
    }
    return nicToLabelModels;
}
Also used : HashMap(java.util.HashMap) NewNetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel) NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) List(java.util.List) ArrayList(java.util.ArrayList) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Example 4 with NetworkLabelModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel in project ovirt-engine by oVirt.

the class NetworkGroup method createNetworkTable.

private FlexTable createNetworkTable(Iterable<NetworkLabelModel> labels, Iterable<LogicalNetworkModel> networks) {
    FlexTable networkTable = new FlexTable();
    int i = 0;
    Iterator<NetworkLabelModel> labelIterator = labels.iterator();
    Iterator<LogicalNetworkModel> networkIterator = networks.iterator();
    while (labelIterator.hasNext()) {
        networkTable.setWidget(i++, 0, new NetworkLabelPanel(labelIterator.next(), style));
    }
    while (networkIterator.hasNext()) {
        networkTable.setWidget(i++, 0, new InternalNetworkPanel(networkIterator.next(), style));
    }
    // $NON-NLS-1$
    networkTable.setWidth("100%");
    return networkTable;
}
Also used : NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) FlexTable(com.google.gwt.user.client.ui.FlexTable) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Aggregations

NetworkLabelModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel)4 ArrayList (java.util.ArrayList)3 LogicalNetworkModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)3 List (java.util.List)2 NewNetworkLabelModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel)2 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 HashMap (java.util.HashMap)1 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)1 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)1 BaseCommandTarget (org.ovirt.engine.ui.uicommonweb.BaseCommandTarget)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1 Model (org.ovirt.engine.ui.uicommonweb.models.Model)1 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)1 FromNetworkAttachmentModel (org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel)1 BondNetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel)1 DataFromHostSetupNetworksModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel)1 NetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel)1 NetworkItemModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkItemModel)1 KeyValueModel (org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel)1