bug 11978: don't allow passing -, + and spaces for instance.name config param

status 11978: resolved fixed
This commit is contained in:
Alena Prokharchyk 2011-11-28 11:52:04 -08:00
parent 102f460458
commit ecd7004f15
3 changed files with 16 additions and 2 deletions

View File

@ -144,7 +144,7 @@ public enum Config {
AccountCleanupInterval("Advanced", ManagementServer.class, Integer.class, "account.cleanup.interval", "86400", "The interval (in seconds) between cleanup for removed accounts", null),
AllowPublicUserTemplates("Advanced", ManagementServer.class, Integer.class, "allow.public.user.templates", "true", "If false, users will not be able to create public templates.", null),
InstanceName("Advanced", AgentManager.class, String.class, "instance.name", "VM", "Name of the deployment instance.", null),
InstanceName("Advanced", AgentManager.class, String.class, "instance.name", "VM", "Name of the deployment instance.", "instanceName"),
ExpungeDelay("Advanced", UserVmManager.class, Integer.class, "expunge.delay", "86400", "Determines how long (in seconds) to wait before actually expunging destroyed vm. The default value = the default value of expunge.interval", null),
ExpungeInterval("Advanced", UserVmManager.class, Integer.class, "expunge.interval", "86400", "The interval (in seconds) to wait before running the expunge thread.", null),
ExpungeWorkers("Advanced", UserVmManager.class, Integer.class, "expunge.workers", "1", "Number of workers performing expunge ", null),

View File

@ -520,7 +520,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
return "Please enter valid hypervisor type";
}
}
} else {
} else if (range.equalsIgnoreCase("instanceName")) {
if (!NetUtils.verifyInstanceName(value)) {
return "Instance name can not contain hyphen, spaces and \"+\" char";
}
}else {
String[] options = range.split(",");
for (String option : options) {
if (option.trim().equalsIgnoreCase(value)) {

View File

@ -1060,5 +1060,15 @@ public class NetUtils {
return false;
}
}
public static boolean verifyInstanceName(String instanceName) {
//instance name for cloudstack vms shouldn't contain - and spaces
if (instanceName.contains("-") || instanceName.contains(" ") || instanceName.contains("+")) {
s_logger.warn("Instance name can not contain hyphen, spaces and \"+\" char");
return false;
}
return true;
}
}