use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class SubTabClusterNetworkView method initTable.
private void initTable() {
getTable().enableColumnResizing();
NetworkStatusColumn statusIconColumn = new NetworkStatusColumn();
statusIconColumn.setContextMenuTitle(constants.statusIconNetwork());
// $NON-NLS-1$ //$NON-NLS-2$
getTable().addColumn(statusIconColumn, "", "20px");
AbstractTextColumn<Network> nameColumn = new AbstractLinkColumn<Network>(new FieldUpdater<Network, String>() {
@Override
public void update(int index, Network network, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), network.getName());
parameters.put(FragmentParams.DATACENTER.getName(), getModelProvider().getMainModel().getSelectedItem().getStoragePoolName());
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.networkGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(Network object) {
return object.getName();
}
};
nameColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameNetwork(), "400px");
AbstractTextColumn<Network> statusColumn = new AbstractEnumColumn<Network, NetworkStatus>() {
@Override
public NetworkStatus getRawValue(Network object) {
return object.getCluster().getStatus();
}
};
statusColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(statusColumn, constants.statusNetwork(), "100px");
// $NON-NLS-1$
getTable().addColumn(createNetRoleColumn(), constants.roleNetwork(), "90px");
AbstractTextColumn<Network> descColumn = new AbstractTextColumn<Network>() {
@Override
public String getValue(Network object) {
return object.getDescription();
}
};
descColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(descColumn, constants.descriptionNetwork(), "400px");
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class SubTabClusterNetworkView method createNetRoleColumn.
private AbstractSafeHtmlColumn<Network> createNetRoleColumn() {
return new AbstractSafeHtmlColumn<Network>() {
@Override
public SafeHtml getValue(Network network) {
List<SafeHtml> images = new LinkedList<>();
final NetworkCluster networkCluster = network.getCluster();
if (networkCluster != null) {
images.add(thisOrEmptyImage(networkCluster.isManagement(), managementImage));
images.add(thisOrEmptyImage(networkCluster.isDisplay(), displayImage));
images.add(thisOrEmptyImage(networkCluster.isMigration(), migrationImage));
images.add(thisOrEmptyImage(network.getCluster().isGluster(), glusterNwImage));
images.add(thisOrEmptyImage(networkCluster.isDefaultRoute(), defaultRouteImage));
}
return MultiImageColumnHelper.getValue(images);
}
@Override
public SafeHtml getTooltip(Network network) {
Map<SafeHtml, String> imagesToText = new LinkedHashMap<>();
final NetworkCluster networkCluster = network.getCluster();
if (networkCluster != null) {
if (networkCluster.isManagement()) {
imagesToText.put(managementImage, constants.managementItemInfo());
}
if (networkCluster.isDisplay()) {
imagesToText.put(displayImage, constants.displayItemInfo());
}
if (networkCluster.isMigration()) {
imagesToText.put(migrationImage, constants.migrationItemInfo());
}
if (network.getCluster().isGluster()) {
imagesToText.put(glusterNwImage, constants.glusterNwItemInfo());
}
if (networkCluster.isDefaultRoute()) {
imagesToText.put(defaultRouteImage, constants.defaultRouteItemInfo());
}
}
return MultiImageColumnHelper.getTooltip(imagesToText);
}
};
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class ChangeVDSClusterCommand method isSameManagementNetwork.
private boolean isSameManagementNetwork() {
final Network sourceManagementNetwork = networkDao.getManagementNetwork(getSourceCluster().getId());
final Network targetManagementNetwork = networkDao.getManagementNetwork(getTargetCluster().getId());
return targetManagementNetwork != null && sourceManagementNetwork.getName().equals(targetManagementNetwork.getName());
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class RunVmCommandBase method initParametersForExternalNetworks.
protected void initParametersForExternalNetworks(VDS vds, boolean isMigration) {
for (VmNetworkInterface iface : getVm().getInterfaces()) {
VnicProfile vnicProfile = vnicProfileDao.get(iface.getVnicProfileId());
Network network = networkHelper.getNetworkByVnicProfile(vnicProfile);
if (network != null && network.isExternal() && iface.isPlugged()) {
Provider<?> provider = providerDao.get(network.getProvidedBy().getProviderId());
NetworkProviderProxy providerProxy = providerProxyFactory.create(provider);
Map<String, String> deviceProperties = providerProxy.allocate(network, vnicProfile, iface, vds, isMigration);
getVm().getRuntimeDeviceCustomProperties().put(new VmDeviceId(iface.getId(), getVmId()), deviceProperties);
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class UpdateVmCommand method updateVmNetworks.
private void updateVmNetworks() {
// check if the cluster has changed
if (!Objects.equals(getVm().getClusterId(), getParameters().getVmStaticData().getClusterId())) {
List<Network> networks = networkDao.getAllForCluster(getParameters().getVmStaticData().getClusterId());
List<VmNic> interfaces = vmNicDao.getAllForVm(getParameters().getVmStaticData().getId());
for (final VmNic iface : interfaces) {
final Network network = networkHelper.getNetworkByVnicProfileId(iface.getVnicProfileId());
boolean networkFound = networks.stream().anyMatch(n -> Objects.equals(n.getId(), network.getId()));
// if network not exists in cluster we remove the network from the interface
if (!networkFound) {
iface.setVnicProfileId(null);
vmNicDao.update(iface);
}
}
}
}
Aggregations