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
189
api/swagger.json
189
api/swagger.json
@ -12,7 +12,7 @@
|
||||
"/info": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "Shovel Config" ],
|
||||
"operationId": "infoGet",
|
||||
"summary": "Get nodes info",
|
||||
"responses": {
|
||||
@ -30,7 +30,7 @@
|
||||
"/shovel/config": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "Shovel Config" ],
|
||||
"operationId": "configget",
|
||||
"summary": "Get shovel config file",
|
||||
"responses": {
|
||||
@ -48,7 +48,7 @@
|
||||
"/shovel/set-config": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "POST" ],
|
||||
"tags": [ "Shovel Config" ],
|
||||
"operationId": "configset",
|
||||
"summary": "set shovel config file",
|
||||
"parameters": [
|
||||
@ -77,7 +77,7 @@
|
||||
"/shovel/monorail/set-config": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "POST" ],
|
||||
"tags": [ "Shovel Config" ],
|
||||
"operationId": "configsetmono",
|
||||
"summary": "set shovel- monorail info",
|
||||
"parameters": [
|
||||
@ -106,7 +106,7 @@
|
||||
"/shovel/ironic/set-config": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "POST" ],
|
||||
"tags": [ "Shovel Config" ],
|
||||
"operationId": "configsetironic",
|
||||
"summary": "set shovel ironic info",
|
||||
"parameters": [
|
||||
@ -135,7 +135,7 @@
|
||||
"/shovel/glance/set-config": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "POST" ],
|
||||
"tags": [ "Shovel Config" ],
|
||||
"operationId": "configsetglance",
|
||||
"summary": "set shovel glance info",
|
||||
"parameters": [
|
||||
@ -164,7 +164,7 @@
|
||||
"/shovel/keystone/set-config": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "POST" ],
|
||||
"tags": [ "Shovel Config" ],
|
||||
"operationId": "configsetkeystone",
|
||||
"summary": "set shovel Keystone info",
|
||||
"parameters": [
|
||||
@ -193,13 +193,13 @@
|
||||
"/catalogs/{identifier}": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "RackHD API Wrappers" ],
|
||||
"operationId": "catalogsGet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "identifier",
|
||||
"in": "path",
|
||||
"description": "Onrack node ID",
|
||||
"description": "rackhd node ID",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
@ -220,13 +220,13 @@
|
||||
"/catalogs/{identifier}/{source}": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "RackHD API Wrappers" ],
|
||||
"operationId": "catalogsbysourceGet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "identifier",
|
||||
"in": "path",
|
||||
"description": "Onrack node ID",
|
||||
"description": "rackhd node ID",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
@ -254,13 +254,13 @@
|
||||
"/nodes/{identifier}": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "RackHD API Wrappers" ],
|
||||
"operationId": "nodeGet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "identifier",
|
||||
"in": "path",
|
||||
"description": "Onrack node ID",
|
||||
"description": "rackhd node ID",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
@ -281,9 +281,9 @@
|
||||
"/nodes": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "RackHD API Wrappers" ],
|
||||
"operationId": "nodesGet",
|
||||
"summary": "get All OnRack Nodes",
|
||||
"summary": "get All rackhd Nodes that been discovered with BMC,DMI information",
|
||||
"responses": {
|
||||
|
||||
"200": {
|
||||
@ -299,7 +299,7 @@
|
||||
"/nodes/{identifier}/sel": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "RackHD API Wrappers" ],
|
||||
"operationId": "getSeldata",
|
||||
"parameters": [
|
||||
{
|
||||
@ -325,7 +325,7 @@
|
||||
"/ironic/nodes": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "Ironic API Wrappers" ],
|
||||
"operationId": "ironicnodesGet",
|
||||
"summary": "get All ironic Nodes",
|
||||
"responses": {
|
||||
@ -343,7 +343,7 @@
|
||||
"/ironic/node/{identifier}": {
|
||||
"patch": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "PATCH" ],
|
||||
"tags": [ "Ironic API Wrappers" ],
|
||||
"operationId": "ironicnodePatch",
|
||||
"summary": "patch specified ironic node",
|
||||
"parameters": [
|
||||
@ -378,7 +378,7 @@
|
||||
"/ironic/chassis/{identifier}": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "Ironic API Wrappers" ],
|
||||
"operationId": "ironicchassisGet",
|
||||
"summary": "get Ironic chassis by id",
|
||||
"parameters": [
|
||||
@ -405,7 +405,7 @@
|
||||
"/ironic/nodes/{identifier}": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "Ironic API Wrappers" ],
|
||||
"operationId": "ironicnodeGet",
|
||||
"summary": "get Ironic node by name",
|
||||
"parameters": [
|
||||
@ -432,9 +432,9 @@
|
||||
"/register": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "POST" ],
|
||||
"tags": [ "Shoveling" ],
|
||||
"operationId": "registerpost",
|
||||
"summary": "Register an OnRack node in Ironic",
|
||||
"summary": "Register an rackhd node in Ironic",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Node Info",
|
||||
@ -461,7 +461,7 @@
|
||||
"/unregister/{identifier}": {
|
||||
"delete": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "DEL" ],
|
||||
"tags": [ "Shoveling" ],
|
||||
"operationId": "unregisterdel",
|
||||
"summary": "UnRegister a node from Ironic",
|
||||
"parameters": [
|
||||
@ -488,7 +488,7 @@
|
||||
"/ironic/drivers": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "Ironic API Wrappers" ],
|
||||
"operationId": "driversGet",
|
||||
"summary": "Get all the drivers used in Ironic",
|
||||
"responses": {
|
||||
@ -511,7 +511,7 @@
|
||||
"/glance/images": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "GET" ],
|
||||
"tags": [ "Glance API Wrappers" ],
|
||||
"operationId": "imagesGet",
|
||||
"summary": "Get all the images in Glance",
|
||||
"responses": {
|
||||
@ -530,6 +530,65 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deployos/{identifier}/": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "Nodes Provisionning" ],
|
||||
"operationId": "deployOS",
|
||||
"summary": "Deploy OS to a specific node",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "identifier",
|
||||
"in": "path",
|
||||
"description": "rackHD node ID",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "Config",
|
||||
"in": "body",
|
||||
"description": "OS Configuration",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/deployos"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Not Implemented"
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/worflow-status/{identifier}": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Shovel",
|
||||
"tags": [ "Nodes Provisionning" ],
|
||||
"operationId": "workflowStatus",
|
||||
"summary": "Get status of an active worflow running on a certain node in rackHD",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "identifier",
|
||||
"in": "path",
|
||||
"description": "rackHD node ID",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Not Implemented"
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
@ -684,6 +743,86 @@
|
||||
"items": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"deployos": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"options"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example":"Graph.InstallCentOS"
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"defaults"
|
||||
],
|
||||
"properties": {
|
||||
"defaults": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"obmServiceName": {
|
||||
"type": "string",
|
||||
"example": "ipmi-obm-service"
|
||||
}
|
||||
}
|
||||
},
|
||||
"install-os": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"repo": {
|
||||
"type": "string"
|
||||
},
|
||||
"rootPassword": {
|
||||
"type": "string"
|
||||
},
|
||||
"users": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"uid": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"networkDevices": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"device",
|
||||
"ipv4"
|
||||
],
|
||||
"properties": {
|
||||
"device": {
|
||||
"type": "string"
|
||||
},
|
||||
"ipv4": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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