use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method attachLabels.
private void attachLabels(String bondName, List<NetworkLabelModel> labels) {
NetworkInterfaceModel bondModel = nicModelByName.get(bondName);
NetworkOperation.attachLabels(bondModel, new ArrayList<>(labels), hostSetupNetworksParametersData);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method createSlaveModels.
private List<NetworkInterfaceModel> createSlaveModels(Map<String, List<VdsNetworkInterface>> bondNameToSlaves, final Map<Guid, VdsNetworkInterface> nicsById, String bondName) {
List<NetworkInterfaceModel> slavesModels = new ArrayList<>();
for (VdsNetworkInterface slave : bondNameToSlaves.get(bondName)) {
NetworkInterfaceModel slaveModel = createSlaveModel(nicsById, slave);
slavesModels.add(slaveModel);
}
return slavesModels;
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel 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;
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel 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);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel in project ovirt-engine by oVirt.
the class HostSetupNetworksPopupView method updateNics.
private void updateNics(List<NetworkInterfaceModel> nics) {
nicList.clear();
Collections.sort(nics);
List<NetworkGroup> groups = new ArrayList<>();
for (NetworkInterfaceModel nic : nics) {
groups.add(new NetworkGroup(nic, eventBus, style));
}
nicList.addAll(groups, !rendered);
}
Aggregations