Search in sources :

Example 1 with LogicalNetworkModel

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

the class HostSetupNetworksModel method createModelsForUnamangedNetworks.

public void createModelsForUnamangedNetworks(Map<String, Set<LogicalNetworkModel>> nicToNetworks) {
    for (VdsNetworkInterface nic : allExistingNics) {
        if (shouldCreateUnmanagedNetworkModel(nic)) {
            LogicalNetworkModel networkModel = createUnmanagedNetworkModel(nic.getNetworkName(), nic);
            networkModelByName.put(networkModel.getName(), networkModel);
            String baseNicName = NetworkCommonUtils.stripVlan(nic);
            if (!nicToNetworks.containsKey(baseNicName)) {
                nicToNetworks.put(baseNicName, new HashSet<LogicalNetworkModel>());
            }
            nicToNetworks.get(baseNicName).add(networkModel);
        }
    }
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Example 2 with LogicalNetworkModel

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

the class HostSetupNetworksModel method createUnmanagedNetworkModel.

private LogicalNetworkModel createUnmanagedNetworkModel(String networkName, VdsNetworkInterface nic) {
    Network unmanagedNetwork = new Network();
    unmanagedNetwork.setName(networkName);
    unmanagedNetwork.setVlanId(nic.getVlanId());
    unmanagedNetwork.setMtu(nic.getMtu());
    unmanagedNetwork.setVmNetwork(nic.isBridged());
    LogicalNetworkModel networkModel = new LogicalNetworkModel(unmanagedNetwork, null, this);
    return networkModel;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Example 3 with LogicalNetworkModel

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

the class HostSetupNetworksModel method createRegularNicModels.

private Map<String, NetworkInterfaceModel> createRegularNicModels(Map<String, Set<LogicalNetworkModel>> nicNameToNetworkModels, Map<String, List<VdsNetworkInterface>> bondNameToSlaves, Map<String, List<NetworkLabelModel>> nicNameToLabelModels, final Map<Guid, VdsNetworkInterface> nicsById) {
    Map<String, NetworkInterfaceModel> regularNicModels = new HashMap<>();
    for (VdsNetworkInterface nic : allExistingNics) {
        if (!isPhysicalNic(nic, bondNameToSlaves.keySet(), getAllSlaveNames())) {
            continue;
        }
        final VdsNetworkInterface physicalFunction = findPhysicalFunction(nicsById, nic.getId());
        if (physicalFunction != null && !getShowVf().getEntity()) {
            continue;
        }
        String nicName = nic.getName();
        Collection<LogicalNetworkModel> nicNetworks = nicNameToNetworkModels.get(nicName);
        NetworkInterfaceModel nicModel = new NetworkInterfaceModel(nic, nicNetworks, nicNameToLabelModels.get(nicName), nicToVfsConfig.containsKey(nic.getId()), physicalFunction == null ? null : physicalFunction.getName(), this);
        regularNicModels.put(nicName, nicModel);
    }
    return regularNicModels;
}
Also used : NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) HashMap(java.util.HashMap) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Example 4 with LogicalNetworkModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel 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 5 with LogicalNetworkModel

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

the class NetworkLabelPanel method getContents.

@Override
protected Widget getContents() {
    VerticalPanel vPanel = new VerticalPanel();
    // $NON-NLS-1$
    vPanel.addStyleName("ts5");
    // $NON-NLS-1$
    vPanel.setWidth("100%");
    Grid titleRow = new Grid(1, 2);
    // $NON-NLS-1$
    titleRow.addStyleName("ts3");
    ColumnFormatter columnFormatter = titleRow.getColumnFormatter();
    // $NON-NLS-1$
    columnFormatter.setWidth(0, "30px");
    // $NON-NLS-1$
    columnFormatter.setWidth(1, "100%");
    // $NON-NLS-1$
    titleRow.setWidth("100%");
    // $NON-NLS-1$
    titleRow.setHeight("27px");
    LabelWithTextTruncation titleLabel = new LabelWithTextTruncation(item.getName());
    // $NON-NLS-1$
    titleLabel.setWidth("185px");
    // $NON-NLS-1$
    titleLabel.setHeight("100%");
    Image labelImage = new Image(resources.tagImage());
    titleRow.setWidget(0, 0, labelImage);
    titleRow.setWidget(0, 1, titleLabel);
    // $NON-NLS-1$
    titleRow.addStyleName("ts3");
    // $NON-NLS-1$
    titleRow.addStyleName("tp3");
    vPanel.add(titleRow);
    addClassName();
    List<LogicalNetworkModel> networks = item.getNetworks();
    Collections.sort(networks);
    for (LogicalNetworkModel network : networks) {
        InternalNetworkPanel networkPanel = new InternalNetworkPanel(network, style, false);
        networkPanel.parentPanel = this;
        vPanel.add(networkPanel);
    }
    return vPanel;
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) Grid(com.google.gwt.user.client.ui.Grid) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) Image(com.google.gwt.user.client.ui.Image) ColumnFormatter(com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter) LabelWithTextTruncation(org.ovirt.engine.ui.common.widget.label.LabelWithTextTruncation)

Aggregations

LogicalNetworkModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)15 HashMap (java.util.HashMap)6 BondNetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel)5 NetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel)5 NetworkLabelModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel)4 ArrayList (java.util.ArrayList)3 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)3 Network (org.ovirt.engine.core.common.businessentities.network.Network)3 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)3 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)3 NewNetworkLabelModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel)3 List (java.util.List)2 BaseCommandTarget (org.ovirt.engine.ui.uicommonweb.BaseCommandTarget)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)2 Model (org.ovirt.engine.ui.uicommonweb.models.Model)2 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)2 FromNetworkAttachmentModel (org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel)2 DataFromHostSetupNetworksModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel)2 NetworkItemModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkItemModel)2