1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-03-09 23:38:54 +00:00

Update server side test cases and disable client side tests for now. Integrate later.

This commit is contained in:
Mumshad Mannambeth 2017-07-07 12:23:45 -04:00
parent ab295a073a
commit 9c880c0bba
13 changed files with 588 additions and 318 deletions

View file

@ -93,43 +93,38 @@ export function index(req, res) {
.catch(handleError(res));*/
}
// Gets a single CustomModule from the DB
// Gets a single CustomModule or a module_template from DB
export function show(req, res) {
console.log("Show " + req.params.custom_module);
var ansibleEngine = req.body.ansibleEngine;
if(!ansibleEngine.customModules){
res.status(500).send("Custom Modules Folder not defined in Ansible Engine")
return res.status(500).send("Custom Modules Folder not defined in Ansible Engine")
}
var command = 'cat "' + ansibleEngine.customModules + '"/' + req.params.custom_module;
// If request is for module template, return module_template from default path
if(req.params.custom_module === 'template.py'){
//command = 'cat ' + '/opt/ehc-builder-scripts/ansible_modules/template.py';
return require('fs').readFile('./helpers/module_template.py', (err, data) => {
if (err) res.status(500).send(data);
if (err) return res.status(500).send(data);
res.send(data);
});
}else{
ssh2_exec.executeCommand(command,
null,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
}
ssh2_exec.executeCommand(command,
null,
function(data){
res.send(data);
},
function(data){
res.status(500).send(data)
},
ansibleEngine
);
/*return CustomModule.findById(req.params.custom_module).exec()
.then(handleEntityNotFound(res))
.then(respondWithResult(res))
.catch(handleError(res));*/
}
// Test Module
@ -145,7 +140,7 @@ export function testModule(req, res) {
var test_module = '/tmp/test-module';
var command = 'chmod 755 ' + test_module + '; ' + test_module + ' -m "' + ansibleEngine.customModules + '/' + req.params.custom_module + "\" -a '" + JSON.stringify(moduleArgs) + "'";
var command = 'chmod 755 ' + test_module + '; python ' + test_module + ' -m "' + ansibleEngine.customModules + '/' + req.params.custom_module + "\" -a '" + JSON.stringify(moduleArgs) + "'";
scp2_exec.copyFileToScriptEngine('./helpers/test-module',test_module,ansibleEngine,function(){
console.log("Command=" + command);
@ -174,8 +169,6 @@ export function testModule(req, res) {
// Creates a new CustomModule in the DB
export function create(req, res) {
console.log("Create");
var custom_module_name = req.params.custom_module;
var custom_module_code = req.body.custom_module_code;