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));
}
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));
}
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();
}
Aggregations