allow search by short name for others vms. if a search for a single VM yields more than one record, fail. (for saftey, this is used for vm deletion)

This commit is contained in:
Lloyd Hilaiel 2013-09-25 11:20:40 +03:00
Родитель 14e05b31a8
Коммит 4e25a8468b
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -89,17 +89,17 @@ function findInstance(r, name) {
var x;
try {
x = jsel.match('object:has(:root > .instanceId:val(?))', [name], r);
if (x.length) return x[0];
if (x.length === 1) return x[0];
} catch(e) {}
// is what the human typed in the vm "short name" ?
var fn = process.env.USER + "'s awsbox deployment (" + name + ")";
x = jsel.match('object:has(:root > .fullName:val(?))', [ fn ], r);
if (x.length) return x[0];
var fn = "awsbox deployment (" + name + ")";
x = jsel.match('object:has(:root > .fullName:contains(?))', [ fn ], r);
if (x.length === 1) return x[0];
// or did the human type in the full name?
x = jsel.match('object:has(:root > .fullName:val(?))', [ name ], r);
if (x.length) return x[0];
if (x.length === 1) return x[0];
return undefined;
}