Enable OS Deployement using rackHD
- Allow user to deploy OS using rackHD graphs - OS supproted are ESXI, CentOS, Ubuntu, RedHat - Allow user to monitor the active workflow on certain node - Add hooks in shovel to post/get/and delete node workflow in rackhd Implements: blueprint shovel-deployment-capability Change-Id: I9411be06de64f76496412e77ecfa6ebfdd9ce3cd
This commit is contained in:
parent
af687f8c0d
commit
9449f7a443
1499
api/swagger.json
1499
api/swagger.json
File diff suppressed because it is too large
Load Diff
@ -628,3 +628,38 @@ module.exports.imagesGet = function imagesGet(req, res) {
|
||||
res.end(JSON.stringify(err));
|
||||
});
|
||||
};
|
||||
/*
|
||||
* @api {post} /api/1.1/deployOS/identifier / POST /
|
||||
* @apiDescription deploy OS to specific node
|
||||
*/
|
||||
module.exports.deployOS = function deployOS(req, res) {
|
||||
'use strict';
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
return monorail.runWorkFlow(req.swagger.params.identifier.value,
|
||||
req.body.name,req.body)
|
||||
.then(function(data) {
|
||||
res.end(data);
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.end(JSON.stringify(err));
|
||||
});
|
||||
};
|
||||
/*
|
||||
* @api {get} /api/1.1/workflow-status/identifier / GET /
|
||||
* @apiDescription Get status of an active worflow running on a node in rackHD
|
||||
*/
|
||||
module.exports.workflowStatus = function workflowStatus(req,res) {
|
||||
'use strict';
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
return monorail.getWorkFlowActive(req.swagger.params.identifier.value)
|
||||
.then(function(data) {
|
||||
if (data) {
|
||||
res.end(JSON.stringify({'jobStatus':'Running'}));
|
||||
} else {
|
||||
res.end(JSON.stringify({'jobStatus':'Currently there is no job running on this node'}));
|
||||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
res.end(JSON.stringify(err));
|
||||
});
|
||||
};
|
||||
|
@ -145,7 +145,22 @@ var MonorailWrapper = {
|
||||
.catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
},
|
||||
runWorkFlow: function runWorkFlow(hwaddr,graphName,content) {
|
||||
'use strict';
|
||||
request.path = pfx + '/nodes/' + hwaddr + '/workflows/?name=' + graphName;
|
||||
request.data = JSON.stringify(content);
|
||||
return client.PostAsync(request);
|
||||
},
|
||||
getWorkFlowActive: function getWorkFlowActive(hwaddr) {
|
||||
'use strict';
|
||||
request.path = pfx + '/nodes/' + hwaddr + '/workflows/active';
|
||||
return client.GetAsync(request);
|
||||
},
|
||||
deleteWorkFlowActive: function deleteWorkFlowActive(hwaddr) {
|
||||
'use strict';
|
||||
request.path = pfx + '/nodes/' + hwaddr + '/workflows/active';
|
||||
return client.DeleteAsync(request);
|
||||
}
|
||||
|
||||
};
|
||||
module.exports = Object.create(MonorailWrapper);
|
||||
|
@ -164,5 +164,26 @@ describe('****Monorail Lib****',function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('monorail.runWorkFlow return data from monorail', function (done) {
|
||||
return monorail.runWorkFlow('123','Graph.Name',{})
|
||||
.then(function (result) {
|
||||
result.should.have.property('data');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('monorail.getWorkFlowActive return data from monorail', function (done) {
|
||||
return monorail.getWorkFlowActive('123')
|
||||
.then(function (result) {
|
||||
result.should.have.property('data');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('monorail.deleteWorkFlowActive return data from monorail', function (done) {
|
||||
return monorail.deleteWorkFlowActive('123')
|
||||
.then(function (result) {
|
||||
result.should.have.property('data');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -41,7 +41,7 @@ describe('****SHOVEL API Interface****', function () {
|
||||
});
|
||||
describe('Shovel api unit testing', function () {
|
||||
var dmiData = { cpus: 1, memory: 1 };
|
||||
|
||||
var getWorkflow;
|
||||
beforeEach('set up mocks', function () {
|
||||
//monorail
|
||||
sinon.stub(monorail, 'request_node_get').returns(Promise.resolve(JSON.stringify(rackhdNode[0])));
|
||||
@ -54,6 +54,8 @@ describe('****SHOVEL API Interface****', function () {
|
||||
sinon.stub(monorail, 'nodeDiskSize').returns(Promise.resolve(0));
|
||||
sinon.stub(monorail, 'getNodeMemoryCpu').returns(Promise.resolve(dmiData));
|
||||
sinon.stub(monorail, 'get_catalog_data_by_source').returns(Promise.resolve(JSON.stringify(catalogSource[0])));
|
||||
sinon.stub(monorail, 'runWorkFlow').returns(Promise.resolve('{"definition":{}}'));
|
||||
getWorkflow = sinon.stub(monorail,'getWorkFlowActive');
|
||||
//glance
|
||||
sinon.stub(glance, 'get_images').returns(Promise.resolve(JSON.stringify(glanceImages)));
|
||||
//keystone
|
||||
@ -79,6 +81,8 @@ describe('****SHOVEL API Interface****', function () {
|
||||
monorail['nodeDiskSize'].restore();
|
||||
monorail['getNodeMemoryCpu'].restore();
|
||||
monorail['get_catalog_data_by_source'].restore();
|
||||
monorail['runWorkFlow'].restore();
|
||||
monorail['getWorkFlowActive'].restore();
|
||||
//ironic
|
||||
ironic['patch_node'].restore();
|
||||
ironic['get_node_list'].restore();
|
||||
@ -324,6 +328,45 @@ describe('****SHOVEL API Interface****', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('/api/1.1/deployos/ should return property definition', function (done) {
|
||||
request(url)
|
||||
.post('/api/1.1/deployos/123')
|
||||
.send({"name": "Graph.InstallCentOS","options": { "defaults": {"obmServiceName": "ipmi-obm-service"}}})
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
console.log('hey yo');
|
||||
throw err;
|
||||
}
|
||||
console.log('hello' + res.text)
|
||||
JSON.parse(res.text).should.have.property('definition');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('/api/1.1/worflow-status/{identifier} should return property jobStatus', function (done) {
|
||||
getWorkflow.returns(Promise.resolve('{"node":"123", "_status": "valid"}'))
|
||||
request(url)
|
||||
.get('/api/1.1/worflow-status/123')
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
console.log(res.text);
|
||||
JSON.parse(res.text).should.have.property('jobStatus');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('/api/1.1/worflow-status/{identifier} should return property jobStatus even if no job is running', function (done) {
|
||||
getWorkflow.returns(Promise.resolve());
|
||||
request(url)
|
||||
.get('/api/1.1/worflow-status/123')
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
JSON.parse(res.text).should.have.property('jobStatus');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -490,6 +533,31 @@ describe('****SHOVEL API Interface****', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('/deployos/{identifier} should return error message', function (done) {
|
||||
request(url)
|
||||
.post('/api/1.1/deployos/123')
|
||||
.send([{}])
|
||||
.expect(200)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
JSON.parse(res.text).should.have.property('error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('/worflow-status/{identifier} should return error message', function (done) {
|
||||
request(url)
|
||||
.get('/api/1.1/worflow-status/123')
|
||||
.expect(200)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
JSON.parse(res.text).should.have.property('error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Shovel api unit test for register', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user