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);
}
}
}
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);
}
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;
}
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()));
}
}
}
}
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;
}
Aggregations