node-triton#79 triton instance get NAME
doesn't have dns_names
CNS field
This commit is contained in:
parent
b81b9b0e2d
commit
879e86efa3
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## 4.3.2 (not yet released)
|
## 4.3.2 (not yet released)
|
||||||
|
|
||||||
|
- #79 Fix `triton instance get NAME` to make sure it gets the `dns_names` CNS
|
||||||
|
field.
|
||||||
- PUBAPI-1227: Note that `triton image list` doesn't include Docker images, at
|
- PUBAPI-1227: Note that `triton image list` doesn't include Docker images, at
|
||||||
least currently.
|
least currently.
|
||||||
|
|
||||||
|
@ -547,6 +547,7 @@ TritonApi.prototype.getInstance = function getInstance(name, cb) {
|
|||||||
var res;
|
var res;
|
||||||
var shortId;
|
var shortId;
|
||||||
var inst;
|
var inst;
|
||||||
|
var instFromList;
|
||||||
|
|
||||||
vasync.pipeline({funcs: [
|
vasync.pipeline({funcs: [
|
||||||
function tryUuid(_, next) {
|
function tryUuid(_, next) {
|
||||||
@ -575,7 +576,7 @@ TritonApi.prototype.getInstance = function getInstance(name, cb) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
function tryName(_, next) {
|
function tryName(_, next) {
|
||||||
if (inst) {
|
if (inst || instFromList) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,7 +586,7 @@ TritonApi.prototype.getInstance = function getInstance(name, cb) {
|
|||||||
}
|
}
|
||||||
for (var i = 0; i < insts.length; i++) {
|
for (var i = 0; i < insts.length; i++) {
|
||||||
if (insts[i].name === name) {
|
if (insts[i].name === name) {
|
||||||
inst = insts[i];
|
instFromList = insts[i];
|
||||||
// Relying on rule that instance name is unique
|
// Relying on rule that instance name is unique
|
||||||
// for a user and DC.
|
// for a user and DC.
|
||||||
return next();
|
return next();
|
||||||
@ -596,7 +597,7 @@ TritonApi.prototype.getInstance = function getInstance(name, cb) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
function tryShortId(_, next) {
|
function tryShortId(_, next) {
|
||||||
if (inst || !shortId) {
|
if (inst || instFromList || !shortId) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
var nextOnce = once(next);
|
var nextOnce = once(next);
|
||||||
@ -622,10 +623,34 @@ TritonApi.prototype.getInstance = function getInstance(name, cb) {
|
|||||||
});
|
});
|
||||||
s.on('end', function () {
|
s.on('end', function () {
|
||||||
if (match) {
|
if (match) {
|
||||||
inst = match;
|
instFromList = match;
|
||||||
}
|
}
|
||||||
nextOnce();
|
nextOnce();
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There can be fields that only exist on the machine object from
|
||||||
|
* GetMachine, and not from ListMachine. `dns_names` is one of these.
|
||||||
|
* Therefore, if we got the machine from filtering ListMachine, then
|
||||||
|
* we need to re-GetMachine.
|
||||||
|
*/
|
||||||
|
function reGetIfFromList(_, next) {
|
||||||
|
if (inst || !instFromList) {
|
||||||
|
next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var uuid = instFromList.id;
|
||||||
|
self.cloudapi.getMachine(uuid, function (err, inst_, res_) {
|
||||||
|
res = res_;
|
||||||
|
inst = inst_;
|
||||||
|
if (err && err.restCode === 'ResourceNotFound') {
|
||||||
|
// The CloudApi 404 error message sucks: "VM not found".
|
||||||
|
err = new errors.ResourceNotFoundError(err,
|
||||||
|
format('instance with id %s was not found', name));
|
||||||
|
}
|
||||||
|
next(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
]}, function (err) {
|
]}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Reference in New Issue
Block a user