Search in sources :

Example 36 with VmBase

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

the class CpuProfileHelperTest method testNullClusterId.

@Test
public void testNullClusterId() {
    VmBase vmBase = createVmBase(cpuProfile1.getId());
    vmBase.setClusterId(null);
    ValidationResult res = cpuProfileHelper.setAndValidateCpuProfile(vmBase, USER_1_ID);
    assertThat(res, failsWith(EngineMessage.ACTION_TYPE_CPU_PROFILE_CLUSTER_NOT_PROVIDED));
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 37 with VmBase

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

the class CpuProfileHelperTest method testNonExistingCpuProfile.

@Test
public void testNonExistingCpuProfile() {
    VmBase vmBase = createVmBase(Guid.newGuid());
    ValidationResult res = cpuProfileHelper.setAndValidateCpuProfile(vmBase, USER_1_ID);
    assertThat(res, failsWith(EngineMessage.ACTION_TYPE_FAILED_CPU_PROFILE_NOT_FOUND));
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 38 with VmBase

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

the class VmInitModel method init.

public void init(final VmBase vm) {
    getWindowsSysprepTimeZoneEnabled().setEntity(false);
    getRegenerateKeysEnabled().setEntity(false);
    getTimeZoneEnabled().setEntity(false);
    getNetworkEnabled().setEntity(false);
    getAttachmentEnabled().setEntity(false);
    getCloudInitPasswordSet().setEntity(false);
    getCloudInitPasswordSet().setIsChangeable(false);
    getSysprepPasswordSet().setEntity(false);
    getSysprepPasswordSet().setIsChangeable(false);
    getWindowsHostname().setEntity("");
    getSysprepOrgName().setEntity("");
    getInputLocale().setEntity("");
    getUiLanguage().setEntity("");
    getSystemLocale().setEntity("");
    getUserLocale().setEntity("");
    getSysprepScript().setEntity("");
    getHostname().setEntity("");
    getUserName().setEntity("");
    getCloudInitRootPassword().setEntity("");
    getCloudInitRootPasswordVerification().setEntity("");
    getSysprepAdminPassword().setEntity("");
    getSysprepAdminPasswordVerification().setEntity("");
    getAuthorizedKeys().setEntity("");
    getRegenerateKeysEnabled().setEntity(false);
    getCustomScript().setEntity("");
    getActiveDirectoryOU().setEntity("");
    Map<String, String> timezones = TimeZoneType.GENERAL_TIMEZONE.getTimeZoneList();
    getTimeZoneList().setItems(timezones.entrySet());
    getTimeZoneList().setSelectedItem(Linq.firstOrNull(timezones.entrySet(), // $NON-NLS-1$
    item -> item.getValue().startsWith("(GMT) Greenwich")));
    Map<String, String> windowsTimezones = TimeZoneType.WINDOWS_TIMEZONE.getTimeZoneList();
    getWindowsSysprepTimeZone().setItems(windowsTimezones.entrySet());
    getWindowsSysprepTimeZone().setSelectedItem(Linq.firstOrNull(windowsTimezones.entrySet(), // $NON-NLS-1$
    item -> item.getValue().startsWith("(GMT) Greenwich")));
    isWindowsOS = vm != null ? AsyncDataProvider.getInstance().isWindowsOsType(vm.getOsId()) : true;
    getIpv4BootProtocolList().setItems(Arrays.asList(Ipv4BootProtocol.values()));
    getIpv4BootProtocolList().setSelectedItem(Ipv4BootProtocol.NONE);
    // only add values which are supported by cloud-init. autoconf ('stateless address autconfiguration') is not supported by cloud-init 0.7.9
    getIpv6BootProtocolList().setItems(Arrays.asList(Ipv6BootProtocol.NONE, Ipv6BootProtocol.DHCP, Ipv6BootProtocol.STATIC_IP));
    getIpv6BootProtocolList().setSelectedItem(Ipv6BootProtocol.NONE);
    VmInit vmInit = (vm != null) ? vm.getVmInit() : null;
    if (vmInit != null) {
        if (!StringHelper.isNullOrEmpty(vmInit.getHostname())) {
            getHostname().setEntity(vmInit.getHostname());
            getWindowsHostname().setEntity(vmInit.getHostname());
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getOrgName())) {
            getSysprepOrgName().setEntity(vmInit.getOrgName());
        }
        updateSysprepDomain(vmInit.getDomain());
        if (!StringHelper.isNullOrEmpty(vmInit.getInputLocale())) {
            getInputLocale().setEntity(vmInit.getInputLocale());
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getUiLanguage())) {
            getUiLanguage().setEntity(vmInit.getUiLanguage());
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getSystemLocale())) {
            getSystemLocale().setEntity(vmInit.getSystemLocale());
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getUserLocale())) {
            getUserLocale().setEntity(vmInit.getUserLocale());
        }
        final String tz = vmInit.getTimeZone();
        if (!StringHelper.isNullOrEmpty(tz)) {
            if (AsyncDataProvider.getInstance().isWindowsOsType(vm.getOsId())) {
                getWindowsSysprepTimeZoneEnabled().setEntity(true);
                selectTimeZone(getWindowsSysprepTimeZone(), windowsTimezones, tz);
            } else {
                getTimeZoneEnabled().setEntity(true);
                selectTimeZone(getTimeZoneList(), timezones, tz);
            }
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getUserName())) {
            getUserName().setEntity(vmInit.getUserName());
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getRootPassword())) {
            getCloudInitRootPassword().setEntity(vmInit.getRootPassword());
            getCloudInitRootPasswordVerification().setEntity(vmInit.getRootPassword());
            getSysprepAdminPassword().setEntity(vmInit.getRootPassword());
            getSysprepAdminPasswordVerification().setEntity(vmInit.getRootPassword());
        }
        getCloudInitPasswordSet().setEntity(vmInit.isPasswordAlreadyStored());
        getCloudInitPasswordSet().setIsChangeable(vmInit.isPasswordAlreadyStored());
        getSysprepPasswordSet().setEntity(vmInit.isPasswordAlreadyStored());
        getSysprepPasswordSet().setIsChangeable(vmInit.isPasswordAlreadyStored());
        if (!StringHelper.isNullOrEmpty(vmInit.getAuthorizedKeys())) {
            getAuthorizedKeys().setEntity(vmInit.getAuthorizedKeys());
        }
        if (vmInit.getRegenerateKeys() != null) {
            getRegenerateKeysEnabled().setEntity(vmInit.getRegenerateKeys());
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getCustomScript())) {
            if (isWindowsOS) {
                getSysprepScript().setEntity(vmInit.getCustomScript());
            } else {
                getCustomScript().setEntity(vmInit.getCustomScript());
            }
        }
        if (!StringHelper.isNullOrEmpty(vmInit.getActiveDirectoryOU())) {
            getActiveDirectoryOU().setEntity(vmInit.getActiveDirectoryOU());
        }
        initNetworks(vmInit);
    }
    addHostnameListeners();
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) SubnetMaskValidation(org.ovirt.engine.ui.uicommonweb.validation.SubnetMaskValidation) Arrays(java.util.Arrays) TimeZoneType(org.ovirt.engine.core.common.TimeZoneType) Event(org.ovirt.engine.ui.uicompat.Event) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) HostnameValidation(org.ovirt.engine.ui.uicommonweb.validation.HostnameValidation) Map(java.util.Map) Ipv4AddressValidation(org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) IpAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.IpAddressValidation) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) VmInitNetworkNameValidation(org.ovirt.engine.ui.uicommonweb.validation.VmInitNetworkNameValidation) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) StringHelper(org.ovirt.engine.core.compat.StringHelper) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) MatchFieldsValidator(org.ovirt.engine.ui.uicommonweb.validation.MatchFieldsValidator) VmInitNetwork(org.ovirt.engine.core.common.businessentities.VmInitNetwork) Ipv6AddressValidation(org.ovirt.engine.ui.uicommonweb.validation.Ipv6AddressValidation) List(java.util.List) TreeMap(java.util.TreeMap) VmInit(org.ovirt.engine.core.common.businessentities.VmInit) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) SortedMap(java.util.SortedMap) VmInit(org.ovirt.engine.core.common.businessentities.VmInit)

Aggregations

VmBase (org.ovirt.engine.core.common.businessentities.VmBase)38 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)15 Guid (org.ovirt.engine.core.compat.Guid)11 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)9 VM (org.ovirt.engine.core.common.businessentities.VM)8 HashSet (java.util.HashSet)7 List (java.util.List)7 Set (java.util.Set)7 HashMap (java.util.HashMap)6 Collection (java.util.Collection)5 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)5 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)5 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)5 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)5 Collections (java.util.Collections)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4