CLOUDSTACK-6647: appending instance name with custom supplied info that contains - character can break vmsync.

This commit is contained in:
Kelven Yang 2014-05-01 15:40:04 -07:00
parent d7291e5200
commit 98307bfcea
1 changed files with 3 additions and 15 deletions

View File

@ -18,8 +18,6 @@ package com.cloud.vm;
import java.util.Formatter;
import com.cloud.dc.Vlan;
/**
* VM Name.
*/
@ -52,8 +50,8 @@ public class VirtualMachineName {
public static boolean isValidVmName(String vmName, String instance) {
String[] tokens = vmName.split(SEPARATOR);
/*Some vms doesn't have vlan/vnet id*/
if (tokens.length != 5 && tokens.length != 4) {
if (tokens.length <= 1) {
return false;
}
@ -61,17 +59,7 @@ public class VirtualMachineName {
return false;
}
try {
Long.parseLong(tokens[1]);
Long.parseLong(tokens[2]);
if (tokens.length == 5 && !Vlan.UNTAGGED.equalsIgnoreCase(tokens[4])) {
Long.parseLong(tokens[4], 16);
}
} catch (NumberFormatException e) {
return false;
}
return instance == null || instance.equals(tokens[3]);
return true;
}
public static String getVmName(long vmId, long userId, String instance) {