use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel 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.BondNetworkInterfaceModel in project ovirt-engine by oVirt.
the class BondPanel 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, 3);
// $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");
Label titleLabel = new Label(item.getName());
// $NON-NLS-1$
titleLabel.setHeight("100%");
Image bondImage = new Image(resources.bond());
titleRow.setWidget(0, 0, bondImage);
titleRow.setWidget(0, 1, titleLabel);
titleRow.setWidget(0, 2, actionButton);
// $NON-NLS-1$
titleRow.addStyleName("ts3");
titleRow.setCellPadding(3);
vPanel.add(titleRow);
getElement().addClassName(style.bondPanel());
List<NetworkInterfaceModel> bonded = ((BondNetworkInterfaceModel) item).getSlaves();
Collections.sort(bonded);
for (NetworkInterfaceModel networkInterfaceModel : bonded) {
NicPanel nicPanel = new NicPanel(networkInterfaceModel, style);
nicPanel.parentPanel = this;
if (!networkInterfaceModel.isSriovEnabled()) {
nicPanel.actionButton.setVisible(false);
}
vPanel.add(nicPanel);
}
return vPanel;
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel 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.BondNetworkInterfaceModel in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method onEdit.
public void onEdit(NetworkItemModel<?> item) {
Model editPopup = null;
BaseCommandTarget okTarget = null;
if (item instanceof BondNetworkInterfaceModel) {
/**
***************
* Bond Dialog
****************
*/
boolean doesBondHaveVmNetworkAttached = doesBondHaveVmNetworkAttached((NetworkInterfaceModel) item);
BondNetworkInterfaceModel bondModel = (BondNetworkInterfaceModel) item;
final CreateOrUpdateBond createOrUpdateBondParameter = bondModel.getCreateOrUpdateBond();
editPopup = new SetupNetworksEditBondModel(createOrUpdateBondParameter, doesBondHaveVmNetworkAttached);
final SetupNetworksBondModel bondDialogModel = (SetupNetworksBondModel) editPopup;
// OK Target
okTarget = new BaseCommandTarget() {
@Override
public void executeCommand(UICommand command) {
if (!bondDialogModel.validate()) {
return;
}
sourceListModel.setConfirmWindow(null);
setBondOptions(createOrUpdateBondParameter, bondDialogModel);
redraw();
}
};
} else if (item instanceof NetworkInterfaceModel) {
/**
*****************
* VFs Config Dialog
******************
*/
final VdsNetworkInterface entity = ((NetworkInterfaceModel) item).getOriginalIface();
final HostNicVfsConfig hostNicVfsConfig = nicToVfsConfig.get(entity.getId());
if (hostNicVfsConfig != null) {
final VfsConfigModel vfsConfigPopupModel = new VfsConfigModel(hostNicVfsConfig, allNetworks, dcLabels);
vfsConfigPopupModel.setTitle(ConstantsManager.getInstance().getMessages().editHostNicVfsConfigTitle(entity.getName()));
editPopup = vfsConfigPopupModel;
// OK Target
okTarget = new BaseCommandTarget() {
@Override
public void executeCommand(UICommand uiCommand) {
if (!vfsConfigPopupModel.validate()) {
return;
}
sourceListModel.setConfirmWindow(null);
commitVfsConfigChanges(hostNicVfsConfig, vfsConfigPopupModel);
redraw();
}
};
}
} else if (item instanceof LogicalNetworkModel) {
/**
***************
* Network Dialog
****************
*/
final LogicalNetworkModel logicalNetworkModel = (LogicalNetworkModel) item;
final VdsNetworkInterface nic;
if (logicalNetworkModel.isInSync()) {
nic = logicalNetworkModel.hasVlan() ? logicalNetworkModel.getVlanDevice() : logicalNetworkModel.getAttachedToNic().getOriginalIface();
} else {
nic = logicalNetworkModel.getVlanDevice() != null ? logicalNetworkModel.getVlanDevice() : logicalNetworkModel.getAttachedToNic().getOriginalIface();
}
final NetworkAttachmentModel networkAttachmentModel;
String version = getEntity().getClusterCompatibilityVersion().getValue();
final Network network = logicalNetworkModel.getNetwork();
final String logicalNetworkModelName = network.getName();
final NetworkAttachment networkAttachment = logicalNetworkModel.getNetworkAttachment();
HostNetworkQos networkQos = qosById.get(network.getQosId());
DnsResolverConfiguration reportedDnsResolverConfiguration = getEntity().getReportedDnsResolverConfiguration();
if (logicalNetworkModel.isManagement()) {
networkAttachmentModel = new ManagementNetworkAttachmentModel(network, nic, networkAttachment, networkQos, reportedDnsResolverConfiguration);
} else {
networkAttachmentModel = new NetworkAttachmentModel(network, nic, networkAttachment, networkQos, reportedDnsResolverConfiguration);
networkAttachmentModel.getIpv4Gateway().setIsAvailable(true);
networkAttachmentModel.getIpv6Gateway().setIsAvailable(false);
}
networkAttachmentModel.getQosOverridden().setIsAvailable(true);
networkAttachmentModel.getQosModel().setIsAvailable(true);
KeyValueModel customPropertiesModel = networkAttachmentModel.getCustomPropertiesModel();
customPropertiesModel.setIsAvailable(true);
Map<String, String> validProperties = KeyValueModel.convertProperties((String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.PreDefinedNetworkCustomProperties, version));
// to backend and frontend (lvernia)
if (!network.isVmNetwork()) {
// $NON-NLS-1$
validProperties.remove("bridge_opts");
}
validProperties.putAll(KeyValueModel.convertProperties((String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.UserDefinedNetworkCustomProperties, version)));
customPropertiesModel.setKeyValueMap(validProperties);
customPropertiesModel.deserialize(KeyValueModel.convertProperties(networkAttachment.getProperties()));
networkAttachmentModel.getIsToSync().setIsChangeable(!logicalNetworkModel.isInSync());
networkAttachmentModel.getIsToSync().setEntity(shouldSyncNetwork(logicalNetworkModelName));
networkAttachmentModel.getQosOverridden().setEntity(networkAttachment.isQosOverridden());
editPopup = networkAttachmentModel;
// OK Target
okTarget = new BaseCommandTarget() {
@Override
public void executeCommand(UICommand command) {
if (!networkAttachmentModel.validate()) {
return;
}
final FromNetworkAttachmentModel interfacePropertiesAccessor = new FromNetworkAttachmentModel(networkAttachmentModel);
LogicalNetworkModelParametersHelper.populateIpv4Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv4PrimaryAddress());
LogicalNetworkModelParametersHelper.populateIpv6Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv6PrimaryAddress());
if (networkAttachmentModel.getQosModel().getIsAvailable()) {
if (networkAttachmentModel.getQosOverridden().getEntity()) {
HostNetworkQos overriddenQos = new HostNetworkQos();
networkAttachmentModel.getQosModel().flush(overriddenQos);
AnonymousHostNetworkQos hostNetworkQos = fromHostNetworkQos(overriddenQos);
networkAttachment.setHostNetworkQos(hostNetworkQos);
} else {
networkAttachment.setHostNetworkQos(null);
}
}
if (networkAttachmentModel.getIsToSync().getEntity()) {
hostSetupNetworksParametersData.getNetworksToSync().add(logicalNetworkModelName);
} else {
hostSetupNetworksParametersData.getNetworksToSync().remove(logicalNetworkModelName);
}
boolean customPropertiesAvailable = networkAttachmentModel.getCustomPropertiesModel().getIsAvailable();
Map<String, String> customProperties = customPropertiesAvailable ? KeyValueModel.convertProperties(networkAttachmentModel.getCustomPropertiesModel().serialize()) : null;
networkAttachment.setProperties(customProperties);
networkAttachment.setDnsResolverConfiguration(networkAttachmentModel.getDnsConfigurationModel().flush());
sourceListModel.setConfirmWindow(null);
redraw();
}
};
}
// ok command
// $NON-NLS-1$
UICommand okCommand = UICommand.createDefaultOkUiCommand("OK", okTarget);
// cancel command
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 (editPopup != null) {
editPopup.getCommands().add(okCommand);
editPopup.getCommands().add(cancelCommand);
}
sourceListModel.setConfirmWindow(editPopup);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel in project ovirt-engine by oVirt.
the class ItemInfoPopup method showNic.
private void showNic(NetworkInterfaceModel nic) {
contents.removeAllRows();
VdsNetworkInterface entity = nic.getOriginalIface();
addRow(templates.titleSetupNetworkTooltip(nic.getName(), SafeStylesUtils.forTrustedBackgroundColor(BACKGROUND_COLOR)));
if (nic.getItems().isEmpty() && !nic.isBonded()) {
insertHorizontalLine();
addMtuInfo(entity.getMtu());
addBootProtoAndIpInfo(new InterfacePropertiesAccessor.FromNic(entity, null));
}
if (nic instanceof BondNetworkInterfaceModel) {
CreateOrUpdateBond createOrUpdateBond = ((BondNetworkInterfaceModel) nic).getCreateOrUpdateBond();
String bondOptions = entity.getBondOptions();
if (createOrUpdateBond != null) {
bondOptions = createOrUpdateBond.getBondOptions();
}
addRow(constants.bondOptionsItemInfo(), // $NON-NLS-1$
bondOptions.replace(BOND_OPTIONS_IP_SEPARATOR, BOND_OPTIONS_IP_SEPARATOR + " "));
} else {
addLldpInfo(nic);
}
if (nic.isVf()) {
addRow(constants.physicalFunction(), nic.getPhysicalFunction());
}
}
Aggregations