Skip to content

Commit 98307bf

Browse files
committed
CLOUDSTACK-6647: appending instance name with custom supplied info that contains - character can break vmsync.
1 parent d7291e5 commit 98307bf

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

api/src/com/cloud/vm/VirtualMachineName.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import java.util.Formatter;
2020

21-
import com.cloud.dc.Vlan;
22-
2321
/**
2422
* VM Name.
2523
*/
@@ -52,26 +50,16 @@ public static boolean isValidVmName(String vmName) {
5250

5351
public static boolean isValidVmName(String vmName, String instance) {
5452
String[] tokens = vmName.split(SEPARATOR);
55-
/*Some vms doesn't have vlan/vnet id*/
56-
if (tokens.length != 5 && tokens.length != 4) {
57-
return false;
58-
}
5953

60-
if (!tokens[0].equals("i")) {
54+
if (tokens.length <= 1) {
6155
return false;
6256
}
6357

64-
try {
65-
Long.parseLong(tokens[1]);
66-
Long.parseLong(tokens[2]);
67-
if (tokens.length == 5 && !Vlan.UNTAGGED.equalsIgnoreCase(tokens[4])) {
68-
Long.parseLong(tokens[4], 16);
69-
}
70-
} catch (NumberFormatException e) {
58+
if (!tokens[0].equals("i")) {
7159
return false;
7260
}
7361

74-
return instance == null || instance.equals(tokens[3]);
62+
return true;
7563
}
7664

7765
public static String getVmName(long vmId, long userId, String instance) {

0 commit comments

Comments
 (0)