use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel 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.LogicalNetworkModel in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method createNicNameToNetworkModels.
private Map<String, Set<LogicalNetworkModel>> createNicNameToNetworkModels() {
Map<String, Set<LogicalNetworkModel>> nicToNetworks = new HashMap<>();
for (NetworkAttachment networkAttachment : hostSetupNetworksParametersData.getNetworkAttachments()) {
String nicName = networkAttachment.getNicName();
if (!nicToNetworks.containsKey(nicName)) {
nicToNetworks.put(nicName, new HashSet<LogicalNetworkModel>());
}
LogicalNetworkModel networkModel = networkModelByName.get(networkAttachment.getNetworkName());
// $NON-NLS-1$
assert networkModel != null : "network on an attachment should have a logical model";
setVlanDeviceOnNetworkModelIfNeeded(nicName, networkModel);
nicToNetworks.get(nicName).add(networkModel);
}
createModelsForUnamangedNetworks(nicToNetworks);
return nicToNetworks;
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel in project ovirt-engine by oVirt.
the class HostSetupNetworksPopupView method updateNetworks.
private void updateNetworks(List<LogicalNetworkModel> allNetworks) {
internalNetworkList.clear();
externalNetworkList.clear();
Collections.sort(allNetworks);
List<NetworkPanel> staticNetworkPanels = new ArrayList<>();
List<NetworkPanel> dynamicNetworkPanels = new ArrayList<>();
for (LogicalNetworkModel network : allNetworks) {
if (network.getNetwork().isExternal()) {
dynamicNetworkPanels.add(new ExternalNetworkPanel(network, style));
} else if (!network.isAttached()) {
staticNetworkPanels.add(new InternalNetworkPanel(network, style));
}
}
internalNetworkList.addAll(staticNetworkPanels, !rendered);
externalNetworkList.addAll(dynamicNetworkPanels, !rendered);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel in project ovirt-engine by oVirt.
the class InternalNetworksPanel method addAll.
@Override
public void addAll(List<NetworkPanel> list, boolean fadeIn) {
requiredPanel.add(requiredTitlePanel);
nonRequiredPanel.add(nonRequiredTitlePanel);
for (NetworkPanel networkPanel : list) {
LogicalNetworkModel networkModel = networkPanel.getItem();
boolean isRequired = networkModel.getNetwork().getCluster() != null && networkModel.getNetwork().getCluster().isRequired();
if (isRequired) {
requiredPanel.add(networkPanel);
} else {
nonRequiredPanel.add(networkPanel);
}
}
animatedPanel.addAll(unassignNetworksList, fadeIn);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel in project ovirt-engine by oVirt.
the class NetworkGroup method createNetworkTable.
private FlexTable createNetworkTable(Iterable<NetworkLabelModel> labels, Iterable<LogicalNetworkModel> networks) {
FlexTable networkTable = new FlexTable();
int i = 0;
Iterator<NetworkLabelModel> labelIterator = labels.iterator();
Iterator<LogicalNetworkModel> networkIterator = networks.iterator();
while (labelIterator.hasNext()) {
networkTable.setWidget(i++, 0, new NetworkLabelPanel(labelIterator.next(), style));
}
while (networkIterator.hasNext()) {
networkTable.setWidget(i++, 0, new InternalNetworkPanel(networkIterator.next(), style));
}
// $NON-NLS-1$
networkTable.setWidth("100%");
return networkTable;
}
Aggregations