Search in sources :

Example 21 with HostNicVfsConfig

use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.

the class HostSetupNetworksModel method queryVfsConfig.

private void queryVfsConfig() {
    // query for vfsConfigs
    VDS vds = getEntity();
    IdQueryParameters params = new IdQueryParameters(vds.getId());
    Frontend.getInstance().runQuery(QueryType.GetAllVfsConfigByHostId, params, new AsyncQuery<QueryReturnValue>(returnValueObj -> {
        Object returnValue = returnValueObj.getReturnValue();
        List<HostNicVfsConfig> allHostVfs = (List<HostNicVfsConfig>) returnValue;
        for (HostNicVfsConfig vfsConfig : allHostVfs) {
            originalVfsConfigs.add(vfsConfig);
            nicToVfsConfig.put(vfsConfig.getNicId(), new HostNicVfsConfig(vfsConfig));
        }
        queryVfMap();
    }));
}
Also used : SortedSet(java.util.SortedSet) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) DataFromHostSetupNetworksModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) OperationCandidateEventArgs(org.ovirt.engine.ui.uicommonweb.models.hosts.network.OperationCandidateEventArgs) SimpleAction(org.ovirt.engine.ui.uicommonweb.action.SimpleAction) Event(org.ovirt.engine.ui.uicompat.Event) AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) UiVdcAction(org.ovirt.engine.ui.uicommonweb.action.UiVdcAction) AllNetworksSelector(org.ovirt.engine.ui.uicommonweb.models.hosts.VfsConfigModel.AllNetworksSelector) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) AnonymousHostNetworkQos.fromHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos.fromHostNetworkQos) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Set(java.util.Set) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) Objects(java.util.Objects) LldpInfo(org.ovirt.engine.core.common.businessentities.network.LldpInfo) List(java.util.List) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) NetworkCommand(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkCommand) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) NetworkCommonUtils(org.ovirt.engine.core.common.utils.NetworkCommonUtils) EventDefinition(org.ovirt.engine.ui.uicompat.EventDefinition) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) QueryType(org.ovirt.engine.core.common.queries.QueryType) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) UiAction(org.ovirt.engine.ui.uicommonweb.action.UiAction) NewNetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Entities(org.ovirt.engine.core.common.businessentities.Entities) HashMap(java.util.HashMap) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) NetworkOperation(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperation) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) Network(org.ovirt.engine.core.common.businessentities.network.Network) MapNetworkAttachments(org.ovirt.engine.core.common.utils.MapNetworkAttachments) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) Model(org.ovirt.engine.ui.uicommonweb.models.Model) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkItemModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkItemModel) Iterator(java.util.Iterator) NetworkOperationFactory(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperationFactory) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) LogicalNetworkModelParametersHelper(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModelParametersHelper) NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) List(java.util.List) ArrayList(java.util.ArrayList)

Example 22 with HostNicVfsConfig

use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig 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);
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) AnonymousHostNetworkQos.fromHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos.fromHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) DataFromHostSetupNetworksModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) NewNetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkItemModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkItemModel) NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 23 with HostNicVfsConfig

use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.

the class VfSchedulerImplTest method multipleVnicCommonTest.

private void multipleVnicCommonTest(boolean allNicsValid) {
    VmNetworkInterface vnic1 = mockVnic(true, "net1");
    VmNetworkInterface vnic2 = mockVnic(true, "net2");
    VmNetworkInterface vnic3 = mockVnic(false);
    VmNetworkInterface vnic4 = mockVnic(false);
    HostNicVfsConfig hostNicVfsConfig1 = new HostNicVfsConfig();
    updateVfsConfig(hostNicVfsConfig1, vnic1, true, false, true);
    HostNicVfsConfig hostNicVfsConfig2 = new HostNicVfsConfig();
    updateVfsConfig(hostNicVfsConfig2, vnic2, false, allNicsValid, allNicsValid);
    mockVfsConfigsOnHost(Arrays.asList(hostNicVfsConfig1, hostNicVfsConfig2));
    List<VmNetworkInterface> allVnics = Arrays.asList(vnic1, vnic2, vnic3, vnic4);
    if (allNicsValid) {
        assertHostValid(allVnics);
    } else {
        assertHostNotValid(allVnics, Collections.singletonList(vnic2.getName()));
    }
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)

Example 24 with HostNicVfsConfig

use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.

the class VfSchedulerImplTest method findFreeVfForVnicCommon.

private void findFreeVfForVnicCommon(boolean existFreeVf) {
    VmNetworkInterface vnic = mockVnic(true, "net1");
    HostNicVfsConfig hostNicVfsConfig = new HostNicVfsConfig();
    updateVfsConfig(hostNicVfsConfig, vnic, true, false, existFreeVf);
    mockVfsConfigsOnHost(Collections.singletonList(hostNicVfsConfig));
    String freeVf = vfScheduler.findFreeVfForVnic(hostId, createNetwork(vnic.getNetworkName()), vmId);
    if (existFreeVf) {
        assertNotNull(freeVf);
    } else {
        assertNull(freeVf);
    }
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)

Example 25 with HostNicVfsConfig

use of org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig in project ovirt-engine by oVirt.

the class NetworkDeviceHelperImpl method getHostNicVfsConfigsWithNumVfsDataByHostId.

@Override
public List<HostNicVfsConfig> getHostNicVfsConfigsWithNumVfsDataByHostId(Guid hostId) {
    List<HostNicVfsConfig> hostNicVfsConfigList = hostNicVfsConfigDao.getAllVfsConfigByHostId(hostId);
    List<HostDevice> deviceList = getDevicesByHostId(hostId);
    for (HostNicVfsConfig hostNicVfsConfig : hostNicVfsConfigList) {
        updateVfsConfigWithNumOfVfsData(hostNicVfsConfig, null, deviceList);
    }
    return hostNicVfsConfigList;
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice)

Aggregations

HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)34 Test (org.junit.Test)13 Guid (org.ovirt.engine.core.compat.Guid)8 ArrayList (java.util.ArrayList)7 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)7 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)5 List (java.util.List)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 Arrays (java.util.Arrays)2 Collectors (java.util.stream.Collectors)2 RandomStringUtils (org.apache.commons.lang.RandomStringUtils)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 Assert.assertNull (org.junit.Assert.assertNull)2 Before (org.junit.Before)2