Search in sources :

Example 1 with HostDevChangeNumVfsVDSParameters

use of org.ovirt.engine.core.common.vdscommands.HostDevChangeNumVfsVDSParameters in project ovirt-engine by oVirt.

the class UpdateHostNicVfsConfigCommand method executeCommand.

@Override
protected void executeCommand() {
    boolean result = true;
    HostNicVfsConfig oldVfsConfig = getVfsConfig();
    boolean allNetworksAllowedChanged = isAllNetworksAllowed() != oldVfsConfig.isAllNetworksAllowed();
    super.executeCommand();
    // Check if 'allNetworksAllowed' has changed
    if (allNetworksAllowedChanged) {
        oldVfsConfig.setAllNetworksAllowed(isAllNetworksAllowed());
        if (isAllNetworksAllowed()) {
            oldVfsConfig.setNetworks(Collections.emptySet());
            oldVfsConfig.setNetworkLabels(Collections.emptySet());
        }
    }
    boolean shouldRefreshHost = false;
    if (wasNumOfVfsChanged()) {
        shouldRefreshHost = true;
        String deviceName = networkDeviceHelper.getPciDeviceNameByNic(getNic());
        try {
            VDSReturnValue returnValue = runVdsCommand(VDSCommandType.HostDevChangeNumVfs, new HostDevChangeNumVfsVDSParameters(getVdsId(), deviceName, getNumOfVfs()));
            result = returnValue.getSucceeded();
        } catch (EngineException e) {
            throw new EngineException(EngineError.UPDATE_NUM_VFS_FAILURE);
        }
    }
    if (result) {
        setSucceeded(saveChangesToDb(shouldRefreshHost, oldVfsConfig, allNetworksAllowedChanged));
    }
}
Also used : HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) HostDevChangeNumVfsVDSParameters(org.ovirt.engine.core.common.vdscommands.HostDevChangeNumVfsVDSParameters)

Aggregations

HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 HostDevChangeNumVfsVDSParameters (org.ovirt.engine.core.common.vdscommands.HostDevChangeNumVfsVDSParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1