Search in sources :

Example 6 with LogicalNetworkModel

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

the class HostSetupNetworksModel method markNetworkModelsAsAttachedViaLabel.

private void markNetworkModelsAsAttachedViaLabel(List<LogicalNetworkModel> errorLabelNetworks, Collection<LogicalNetworkModel> nicNetworks, NetworkLabelModel labelModel) {
    for (Iterator<LogicalNetworkModel> iter = labelModel.getNetworks().iterator(); iter.hasNext(); ) {
        LogicalNetworkModel networkModel = iter.next();
        if (nicNetworks != null && nicNetworks.contains(networkModel)) {
            networkModel.attachViaLabel();
        } else {
            // The network has the same label as the nic but not attached to the nic.
            iter.remove();
            errorLabelNetworks.add(networkModel);
        }
    }
}
Also used : LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Example 7 with LogicalNetworkModel

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

the class HostSetupNetworksModel method initNetworkModels.

private void initNetworkModels() {
    Map<String, LogicalNetworkModel> networkModels = new HashMap<>();
    Map<Guid, NetworkAttachment> networkAttachmentByNetworkId = mapNetworkAttachmentsByNetworkId();
    for (Network network : allNetworks) {
        NetworkAttachment attachment = networkAttachmentByNetworkId.get(network.getId());
        LogicalNetworkModel networkModel = new LogicalNetworkModel(network, attachment, this);
        networkModels.put(network.getName(), networkModel);
        if (networkModel.isManagement()) {
            managementNetworkModel = networkModel;
        }
        if (!network.isExternal()) {
            String label = network.getLabel();
            if (label != null) {
                // The network model is candidate to be drawn as part of the label.
                // This doesn't yet consider whether it actually exists on the interface.
                networkLabelModelByLabel.get(label).getNetworks().add(networkModel);
            }
        }
    }
    setNetworks(networkModels);
}
Also used : HashMap(java.util.HashMap) Network(org.ovirt.engine.core.common.businessentities.network.Network) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 8 with LogicalNetworkModel

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

the class HostSetupNetworksModel method createBondModels.

private Map<String, NetworkInterfaceModel> createBondModels(Map<String, Set<LogicalNetworkModel>> nicNameToNetworkModels, Map<String, List<VdsNetworkInterface>> bondNameToSlaves, Map<String, List<NetworkLabelModel>> nicNameToLabelModels, final Map<Guid, VdsNetworkInterface> nicsById) {
    Map<String, NetworkInterfaceModel> bondModels = new HashMap<>();
    for (CreateOrUpdateBond createOrUpdateBond : hostSetupNetworksParametersData.getBonds()) {
        String bondName = createOrUpdateBond.getName();
        List<NetworkInterfaceModel> slavesModels = createSlaveModels(bondNameToSlaves, nicsById, bondName);
        Collection<LogicalNetworkModel> nicNetworks = nicNameToNetworkModels.get(bondName);
        Bond originalBond = getOriginalBond(nicsById, createOrUpdateBond);
        BondNetworkInterfaceModel bondNetworkInterfaceModel = new BondNetworkInterfaceModel(originalBond, createOrUpdateBond, nicNetworks, nicNameToLabelModels.get(createOrUpdateBond.getName()), slavesModels, this);
        bondModels.put(bondName, bondNetworkInterfaceModel);
    }
    return bondModels;
}
Also used : BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) HashMap(java.util.HashMap) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 9 with LogicalNetworkModel

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

the class HostSetupNetworksModel method setLabelErrorsOnNicModels.

private void setLabelErrorsOnNicModels(Map<String, NetworkInterfaceModel> nicModels, List<LogicalNetworkModel> networkModelsWithLabelError, Map<String, String> labelToDesiredNicName) {
    for (LogicalNetworkModel networkModel : networkModelsWithLabelError) {
        NetworkInterfaceModel desiredNicModel = nicModels.get(labelToDesiredNicName.get(networkModel.getNetwork().getLabel()));
        NetworkOperation operation = NetworkOperationFactory.operationFor(networkModel, desiredNicModel);
        UIMessages messages = ConstantsManager.getInstance().getMessages();
        // Should be attached but can't due to conflict
        if (desiredNicModel != null) {
            if (operation.isNullOperation()) {
                networkModel.setErrorMessage(messages.networkLabelConflict(desiredNicModel.getName(), networkModel.getNetwork().getLabel()) + " " + // $NON-NLS-1$
                operation.getMessage(networkModel, desiredNicModel));
            } else {
                networkModel.setErrorMessage(messages.labeledNetworkNotAttached(desiredNicModel.getName(), networkModel.getNetwork().getLabel()));
            }
        }
    }
}
Also used : NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) NetworkOperation(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperation)

Example 10 with LogicalNetworkModel

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

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