Skip to content

Commit

Permalink
Merge pull request #402 from pkgcloud/gh-398
Browse files Browse the repository at this point in the history
Adding a refresh method on the stack model
  • Loading branch information
kenperkins committed Feb 24, 2015
2 parents 7369700 + 10cf832 commit c478c72
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/pkgcloud/openstack/orchestration/stack.js
Expand Up @@ -17,6 +17,17 @@ var Stack = exports.Stack = function Stack(client, details) {

util.inherits(Stack, base.Model);

Stack.prototype.refresh = function (callback) {
var self = this;
return self.client.getStack(this, function (err, stack) {
if (!err) {
self._setProperties(stack.original);
}

return callback.apply(this, arguments);
});
};

Stack.prototype._setProperties = function (details) {
this.id = details.id;
this.name = details.name || details['stack_name'];
Expand All @@ -33,6 +44,8 @@ Stack.prototype._setProperties = function (details) {

this.createdAt = details['creation_time'];
this.updatedAt = details['updated_time'];

this.original = this.openstack = details;
};

Stack.prototype.toJSON = function () {
Expand Down

0 comments on commit c478c72

Please sign in to comment.