Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/jobs/ucs-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ function UcsCatalogJobFactory(
options,
context,
taskId);
this.node = this.context.target;
this.nodes = _.union( this.context.physicalNodeList, this.context.logicalNodeList);
if(_.isEmpty(this.nodes)) {
this.nodes = [ this.context.target ];
}
this.ucs = new UcsTool();
}

Expand All @@ -55,13 +58,15 @@ function UcsCatalogJobFactory(
*/
UcsCatalogJob.prototype._run = function() {
var self = this;
return self.catalogRackmounts(this.node)
.then(function() {
self._done();
})
.catch(function(err) {
self._done(err);
});
return Promise.map(this.nodes, function(node) {
return self.catalogRackmounts(node);
})
.then(function() {
self._done();
})
.catch(function(err) {
self._done(err);
});
};


Expand Down
32 changes: 25 additions & 7 deletions lib/jobs/ucs-discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,21 @@ function UcsDiscoveryJobFactory(

return self.getRoot()
.then(function(root) {
return [ root, self.createRackmounts(root), self.createServers(root) ];
return [ self.createRackmounts(root), self.createServers(root) ];
})
.spread(function() {
.spread(function(rackmounts, servers) {
self.context.physicalNodeList = (self.context.physicalNodeList || []).concat(
_.map(rackmounts, function(it) {
return _.get(it, 'id');
})
);
self.context.physicalNodeList = _.flattenDeep(self.context.physicalNodeList.concat(
_.map(servers, function(it) {
return [_.get(it, 'id'),
_.get(_.find(it.relations, {"relationType": "encloses"}),
'targets')];
})
));
self._done();
})
.catch(function(err) {
Expand Down Expand Up @@ -129,7 +141,7 @@ function UcsDiscoveryJobFactory(
return res.body;
})
.map(function(data) {
self.createNode(data, Constants.NodeTypes.Compute);
return self.createNode(data, Constants.NodeTypes.Compute);
});
}else{
logger.warning('No rackmount servers found');
Expand Down Expand Up @@ -157,12 +169,12 @@ function UcsDiscoveryJobFactory(
})
.map(function(chassisData) {
return self.createNode(chassisData, Constants.NodeTypes.Enclosure)
.spread(function (chassisNode) {
.then(function (chassisNode) {
var chassisId = chassisNode.id;
var nodeList = [];
return Promise.map(chassisData.members, function (data) {
return self.createNode(data, Constants.NodeTypes.Compute)
.spread(function(newNode) {
.then(function(newNode) {
var relations = [{
relationType: 'enclosedBy',
targets: [chassisId]
Expand Down Expand Up @@ -228,12 +240,18 @@ function UcsDiscoveryJobFactory(
})
.catch(function(error) {
if (error.name === 'NotFoundError') {
return waterline.nodes.create(node);
return waterline.nodes.create(node)
.then(function(node) {
return node;
});
}
throw error;
})
.then(function(data){
return [data, waterline.obms.upsertByNode(data.id,obm)];
return waterline.obms.upsertByNode(data.id,obm)
.then(function() {
return data;
});
});
};

Expand Down
6 changes: 4 additions & 2 deletions lib/jobs/ucs-service-profile-discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ function UcsServiceProfileDiscoveryJobFactory(

return self.getRoot()
.then(function(root) {
return [ self.createServiceProfile(root) ];
return self.createServiceProfile(root);
})
.spread(function() {
.then(function(logicalServers) {
self.context.logicalNodeList = (self.context.logicalNodeList || []).concat(
_.map(logicalServers, _.property('id')));
self._done();
})
.catch(function(err) {
Expand Down
5 changes: 2 additions & 3 deletions lib/task-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ function taskGraphFactory(
_.forEach(task.waitingOn, function(value, dep) {
var nonTerminalOnStates = [];
if (dep === "anyOf") {

_.forEach(task.waitingOn.dep, function(orValue, orDep) {
_.forEach(task.waitingOn.anyOf, function(orValue, orDep) {
nonTerminalOnStates = self._checkGraphNode(
self.tasks.anyOf, orValue, orDep);
return self._visitGraphNode(
orDep, task.dep.injectableName, markers, nonTerminalOnStates);
orDep, task.injectableName, markers, nonTerminalOnStates);
});
}
else {
Expand Down