diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 3124ed8a2d0..37b07e978ca 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -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), diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 51c192af086..c15dfa3dcaf 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -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)) { diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index 6e5cbeda4cf..8c350fe5ca1 100755 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -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; + } }