'tic_image.image_name job_image_name, ',
'tic_image.image_size job_image_size, ',
'tic_job.job_hasksfile job_hasksfile, ',
+ 'tic_job.job_ks job_ks, ',
+ 'tic_job.job_arch job_arch, ',
'tic_job.job_uptime job_uptime ',
'from tic_job ',
'left join tic_image on tic_job.job_image_id = tic_image.image_id ',
],
'getImagesAllList': [
'select tic_job.job_image_id image_id, ',
- 'tic_job.job_id image_job_id, ',
- 'tic_image.image_name image_name, ',
- 'tic_image.image_size image_size, ',
- 'tic_job.job_hasksfile image_hasksfile, ',
- 'tic_job.job_status image_status, ',
- 'tic_job.job_uptime image_uptime ',
+ 'tic_job.job_id image_job_id, ',
+ 'tic_image.image_name image_name, ',
+ 'tic_image.image_size image_size, ',
+ 'tic_job.job_hasksfile image_hasksfile, ',
+ 'tic_job.job_ks image_ks, ',
+ 'tic_job.job_arch image_arch, ',
+ 'tic_job.job_status image_status, ',
+ 'tic_job.job_uptime image_uptime ',
'from tic_job inner join tic_image ',
'where tic_job.job_image_id = tic_image.image_id ',
'and tic_job.job_deleted = false ',
/**
* Edit the Job By Id
*/
-mariadb.editJob = function addJob(req, res) {
+mariadb.editJob = function editJob(req, res) {
var queryString, strJobId, reqParam,
- job_status, job_deleted, job_hasksfile, job_image_id;
+ job_status, job_deleted, job_hasksfile, job_image_id, job_ks, job_arch;
function onSuccess(err, rows) {
if (err) {
job_deleted = reqParam.job_deleted;
job_hasksfile = reqParam.job_hasksfile;
job_image_id = reqParam.job_image_id;
+ job_ks = reqParam.job_ks;
+ job_arch = reqParam.job_arch;
queryString = 'update tic_job set';
if (job_image_id) {
if (job_hasksfile) {
queryString += ' job_hasksfile = ' + job_hasksfile + ',';
}
+ if (job_ks) {
+ queryString += ' job_ks = "' + job_ks + '",';
+ }
+ if (job_arch) {
+ queryString += ' job_arch = "' + job_arch + '",';
+ }
queryString += ' job_updater = "tic",';
queryString += ' job_uptime = now()';
queryString += ' where job_id = ' + strJobId + ';';
ps.on('exit', callback.exit);
};
+/**
+ * paramObj = {
+ * jobId: '',
+ * pathKsFile: '',
+ * pathOutput: '',
+ * imageName: ''
+ * imageArch: ''
+ * };
+ */
Mic.create = function create(paramObj, io) {
+ var micCommand, strLogfile, strOutdir, strArch, strRecordPkgs, strPackto;
+
logger.info('MIC Create: paramObj = ' + JSON.stringify(paramObj));
- var micCommand = 'sudo mic create loop ' + paramObj.pathKsFile +
- util.format(' --arch %s', 'armv7l') +
- util.format(' --outdir %s', paramObj.pathOutput) +
- util.format(' --logfile %s', paramObj.pathOutput + AppConfig.TIC_WEB.LOG_FILE_NAME) +
- util.format(' --pack-to %s', AppConfig.TIC_WEB.IMAGE_FILE_NAME);
+ strLogfile = paramObj.pathOutput + AppConfig.TIC_WEB.LOG_FILE_NAME;
+ strOutdir = paramObj.pathOutput;
+ strArch = paramObj.imageArch;
+ strRecordPkgs = 'name';
+ strPackto = paramObj.imageName;
+
+ micCommand = 'sudo mic create loop '
+ + paramObj.pathKsFile
+ + util.format(' --logfile %s', strLogfile)
+ + util.format(' --outdir %s', strOutdir)
+ + util.format(' --arch %s', strArch)
+ + util.format(' --record-pkgs %s', strRecordPkgs)
+ + util.format(' --pack-to %s', strPackto);
function sendMsg(path, msgObj) {
io.sockets.emit(path, msgObj);
sendMsg(AppConfig.EVENT.SOCKET.FS_IMAGE_ADD_FINISH, {
msg: 'Terminated (' + code + ')',
jobId: paramObj.jobId,
+ imageName: strPackto
});
} else {
sendMsg(AppConfig.EVENT.SOCKET.FS_IMAGE_ADD_FAIL, {
color: #31708f;
float: left;
margin-bottom: 8px;
+ width: 75%;
}
.image-list-name-btndownload {
float: left;
font-size: smaller;
text-overflow: ellipsis;
white-space:nowrap;
- display:inline-block;
overflow: hidden;
+ display: table-cell;
}
.image-list-btndownload {
min-width: 10px;
}
.image-item {
overflow: hidden;
- height: 7vh;
}
.image-item-title {
width: 100%;
.image-item-info {
width: 100%;
float: left;
+ display: table;
+ margin-top: 12px;
+ height: 3vh;
}
#tic-image-list-content {
height: calc(100vh - 320px);
this.imageStatus = null;
this.imageJobId = null;
- this.imageJobPath = null;
+ this.imageKs = null;
this.imageHasKsFile = null;
this.imageIsDownload = false;
+ this.imageArch = null;
// for the href on a tag
this.jobAbsPath = null;
ImageModel.prototype.init = function init(obj) {
logger.info('init: ' + JSON.stringify(obj));
+ this.setImageJobId(obj.image_job_id);
+ this.setJobAbsPath();
this.setImageId(obj.image_id);
+
this.setImageName(obj.image_name);
this.setImageSize(obj.image_size);
this.setImageUptime(obj.image_uptime);
this.setImageStatus(obj.image_status);
- this.setImageJobId(obj.image_job_id);
-
+ this.setImageKs(obj.image_ks);
this.setImageHasKsFile(obj.image_hasksfile);
this.setImageIsDownload(obj.image_status);
+ this.setImageArch(obj.image_arch);
- this.setJobAbsPath();
- this.setJobAbsImagePath();
- this.setJobAbsKsPath();
this.setJobAbsLogPath();
};
this.jobAbsLogPath = this.getJobAbsPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
};
- ImageModel.prototype.getJobAbsKsPath = function getJobAbsKsPath(value) {
- return this.jobAbsKsPath = value;
+ ImageModel.prototype.getJobAbsKsPath = function getJobAbsKsPath() {
+ return this.jobAbsKsPath;
};
ImageModel.prototype.setJobAbsKsPath = function setJobAbsKsPath(value) {
- this.jobAbsKsPath = value || this.getJobAbsPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
+ this.jobAbsKsPath = value || this.getJobAbsPath() + this.getImageKs();
};
ImageModel.prototype.getJobAbsImagePath = function getJobAbsImagePath() {
this.imageIsDownload = isDownloadable;
};
+ ImageModel.prototype.getImageArch = function getImageArch() {
+ return this.imageArch;
+ };
+
+ ImageModel.prototype.setImageArch = function setImageArch(value) {
+ /**
+ * FIXME
+ *
+ * Confirm default value . armv7l right?
+ */
+ this.imageArch = value || 'armv7l';
+ };
+
ImageModel.prototype.getImageHasKsFile = function getImageHasKsFile() {
return this.imageHasKsFile;
};
this.imageHasKsFile = value || false;
};
+ ImageModel.prototype.getImageKs = function getImageKs() {
+ return this.imageKs;
+ };
+
+ ImageModel.prototype.setImageKs = function setImageKs(value) {
+ this.imageKs = value || '';
+
+ this.setJobAbsKsPath();
+ };
+
ImageModel.prototype.getImageJobId = function getImageJobId() {
return this.imageJobId;
};
ImageModel.prototype.setImageName = function setImageName(value) {
this.imageName = value || '-';
+
+ this.setJobAbsImagePath();
};
ImageModel.prototype.getImageId = function getImageId() {
this.jobPath = null;
this.jobImagePath = null;
this.jobHasKsFile = false;
+ this.jobKs = null;
this.jobKsPath = null;
this.jobLogPath = null;
+ this.jobArch = null;
this.isDownload = false;
// for the href on a tag
logger.info('init: ' + JSON.stringify(obj));
this.setJobId(obj.job_id);
+ this.setJobAbsPath();
+ this.setJobPath();
+
this.setJobStatus(obj.job_status);
this.setJobImageName(obj.job_image_name);
this.setJobImageSize(obj.job_image_size);
- this.setJobPath();
- this.setJobImagePath();
this.setJobHasKsFile(obj.job_hasksfile);
- this.setJobKsPath();
+ this.setJobKs(obj.job_ks);
+
this.setJobLogPath();
+ this.setJobArch(obj.job_arch);
- this.setJobAbsPath();
- this.setJobAbsImagePath();
- this.setJobAbsKsPath();
this.setJobAbsLogPath();
this.setJobUptime(obj.job_uptime);
this.jobLogPath = this.getJobPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
};
+ JobModel.prototype.getJobArch = function () {
+ return this.jobArch;
+ };
+
+ JobModel.prototype.setJobArch = function (value) {
+ /**
+ * FIXME
+ *
+ * Confirm default value . armv7l right?
+ */
+ this.jobArch = value || 'armv7l';
+ };
+
JobModel.prototype.getJobAbsLogPath = function () {
return this.jobAbsLogPath;
};
};
JobModel.prototype.setJobKsPath = function () {
- this.jobKsPath = this.getJobPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
+ this.jobKsPath = this.getJobPath() + this.getJobKs();
};
JobModel.prototype.getJobAbsKsPath = function () {
};
JobModel.prototype.setJobAbsKsPath = function () {
- this.jobAbsKsPath = this.getJobAbsPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
+ this.jobAbsKsPath = this.getJobAbsPath() + this.getJobKs();
};
JobModel.prototype.getJobHasKsFile = function () {
this.jobHasKsFile = value || false;
};
+ JobModel.prototype.getJobKs = function () {
+ return this.jobKs;
+ };
+
+ JobModel.prototype.setJobKs = function (value) {
+ this.jobKs = value || '';
+
+ this.setJobKsPath();
+ this.setJobAbsKsPath();
+ };
+
JobModel.prototype.getJobImagePath = function () {
return this.jobImagePath;
};
};
JobModel.prototype.setJobImageName = function (value) {
- this.jobImageName = value ? value : '-';
+ this.jobImageName = value || '-';
+
+ this.setJobImagePath();
+ this.setJobAbsImagePath();
};
JobModel.prototype.getJobStatusText = function () {
* @param paramObj {
* jobId: '1',
* pathKsFile: '/var/tmp/tic-web/1/default.ks',
- * pathOutput: '/var/tmp/tic-web/1/'
+ * pathOutput: '/var/tmp/tic-web/1/',
+ * imageName: 'default',
+ * imageArch: 'armv7l'
* }
*/
function doCreateAnImage(paramObj) {
msgData = {
jobId: paramObj.jobId,
pathKsFile: paramObj.pathKsFile,
- pathOutput: paramObj.pathOutput
+ pathOutput: paramObj.pathOutput,
+ imageName: paramObj.pathOutput + paramObj.imageName,
+ imageArch: paramObj.imageArch
};
client.emit(AppConfig.EVENT.SOCKET.FS_IMAGE_ADD_FROM, msgData);
* AppConfig.EVENT.SOCKET.FS_IMAGE_ADD_FINISH = 'ws/fs/image/add/finish'
*/
client.on(AppConfig.EVENT.SOCKET.FS_IMAGE_ADD_FINISH, function (dataObj) {
- var jobId, logItem1, logItem2, msgObj;
+ var jobId, imageName, logItem1, logItem2, msgObj;
// jobId
jobId = dataObj.jobId;
+ // imageName
+ imageName = dataObj.imageName;
+ imageName = imageName.substring(imageName.lastIndexOf('/')+1);
+
// log
logItem1 = new JobLog(dataObj);
*/
function addAnImage(arrFileInfo) {
return new Promise(function (resolve, reject) {
+ var imageInfo, msgObj;
/**
- * imageInfo
- * @type {Object}
+ * imageInfo @type {Object}
+ * imageInfo = {
+ * mtime: "Thu, 09 Mar 2017 13:06:01 GMT",
+ * name: "default.tar.gz",
+ * size: 127013,
+ * type: "file"
+ * }
*/
- var imageInfo = _.find(arrFileInfo, {name: AppConfig.TIC_WEB.IMAGE_FILE_NAME});
+ imageInfo = _.find(arrFileInfo, {name: imageName});
logger.info('IMAGE_ADD_FINISH.addAnImage: ' + JSON.stringify(imageInfo));
- if (imageInfo.type !== 'file') {
+ if (imageInfo && imageInfo.type === 'file') {
+ msgObj = {
+ image_name: imageInfo.name,
+ image_type: 'external',
+ image_size: imageInfo.size
+ };
+
+ Util.POST(AppConfig.EVENT.IMAGE.IMAGE_ADD_ONE, msgObj)
+ .then(resolve, reject);
+ } else {
reject('This is not a valid image file');
}
- var msgObj = {
- image_name: imageInfo.name,
- image_type: 'external',
- image_size: imageInfo.size
- };
-
- Util.POST(AppConfig.EVENT.IMAGE.IMAGE_ADD_ONE, msgObj)
- .then(resolve, reject);
});
}
}
function doCreateAnImage() {
+ var pathKsFile, imageName;
logger.info('onClickHandlerForImgCreationBtn.doCreateAnImage');
// scroll
scrollTop: $('#tic-job-section').offset().top
}, 500);
+ // get the name of image
+ pathKsFile = newJobModel.getJobKsPath();
+ imageName = pathKsFile.substring(pathKsFile.lastIndexOf('/')+1, pathKsFile.lastIndexOf('.'));
+
+ /**
+ * FIXME
+ *
+ * imageArch
+ */
+
// options for the creation
var msgData = {
jobId: newJobModel.getJobId(),
- pathKsFile: newJobModel.getJobKsPath(),
- pathOutput: newJobModel.getJobPath()
+ pathKsFile: pathKsFile,
+ pathOutput: newJobModel.getJobPath(),
+ imageName: imageName + '.tar.gz',
+ imageArch: newJobModel.getJobArch()
};
// create
logger.info('onClickHandlerForImgCreationBtn.getRecipeFile: job_path = ' + newJobModel.getJobPath());
+ /**
+ * FIXME
+ *
+ * filename will be removed.
+ * filenmae generated by ticcore
+ */
msgData = {
recipe: {
name: 'default'
},
packages: _.map(checkedPackagesList, 'name'),
- outdir: newJobModel.getJobPath(),
- filename: AppConfig.TIC_WEB.KS_FILE_NAME
+ outdir: newJobModel.getJobPath()
};
function onErrorGetRecipeFile(err) {
throw err;
}
- function onSuccessGetRecipeFile(result) {
- var msgObj;
- logger.info('onClickHandlerForImgCreationBtn.onSuccessGetRecipeFile: ' + result.data);
+ function onSuccessGetRecipeFile(responseObj) {
+ var msgObj, strKsName, strKsPath, strArch;
+
+ if (responseObj && responseObj.result === "false") {
+ logger.error(responseObj.message);
+ throw responseObj;
+ }
+ strKsPath = responseObj.data.kspath;
+ strKsName = strKsPath.substring(strKsPath.lastIndexOf('/') + 1);
+ strArch = responseObj.data.arch;
+
+ // update
+ newJobModel.setJobKs(strKsName);
+ newJobModel.setJobArch(strArch);
+
+ logger.info('onClickHandlerForImgCreationBtn.onSuccessGetRecipeFile: ' + responseObj.data.kspath);
msgObj = {
job_status: JOB_STATUS_INPROGRESS,
- job_hasksfile: true
+ job_hasksfile: true,
+ job_ks: strKsName,
+ job_arch: strArch
};
return Util.POST(AppConfig.EVENT.JOB.JOB_EDIT_ONE + newJobModel.getJobId(), msgObj);
}
var strItem = [
'<li class="list-group-item image-item">',
'<div class="image-item-title">',
- '<div class="image-list-name" title="<%= jobId %>_<%= imageFileName %>">( <%= jobId %> ) <%= imageFileName %></div>',
- '<div class="image-list-name-btndownload"><a class="image-list-btndownload" href="<%= imagePath %>" date-name="<%= imageFileName %>">Download</a></div>',
- '<div class="image-list-name-btndownload"><a class="image-list-btndownload <%= classJobKsPath %>" href="<%= ksPath %>" date-name="<%= ksFileName %>">KS</a></div>',
- '<div class="image-list-name-btndownload"><a class="image-list-btndownload" href="<%= logPath %>" date-name="<%= logFileName %>">Log</a></div>',
+ '<div class="image-list-name" title="<%= jobId %>_<%= imageFileName %>">#<%= jobId %>. <%= imageFileName %></div>',
+ '<div class="image-list-name-btndownload"><a class="image-list-btndownload" href="<%= imagePath %>" title="<%= imageFileName %>" date-name="<%= imageFileName %>">Download</a></div>',
+ '<div class="image-list-name-btndownload"><a class="image-list-btndownload <%= classJobKsPath %>" href="<%= ksPath %>" title="<%= ksFileName %>" date-name="<%= ksFileName %>">KS</a></div>',
+ '<div class="image-list-name-btndownload"><a class="image-list-btndownload" href="<%= logPath %>" title="Log" date-name="<%= logFileName %>">Log</a></div>',
'</div>',
'<div class="image-item-info">',
- '<p class="image-list-detail">Job ID: <%= jobId %></p>',
- '<p class="image-list-detail">Size: <%= fileSize %></p>',
- '<p class="image-list-detail">Updated: <%= fileTime %></p>',
+ '<p class="image-list-detail"><b>Job ID:</b> <%= jobId %></p>',
+ '<p class="image-list-detail"><b>Name:</b> <%= imageFileName %></p>',
+ '<p class="image-list-detail"><b>Size:</b> <%= fileSize %></p>',
+ '<p class="image-list-detail"><b>Arch:</b> <%= fileArch %></p>',
+ '<p class="image-list-detail"><b>KS:</b> <%= ksFileName %></p>',
+ '<p class="image-list-detail"><b>Updated:</b> <%= fileTime %></p>',
'</div>',
'</li>'
];
fileSize: item.getImageSize(),
fileTime: item.getImageUptime(),
imageFileName: item.getImageName(),
- ksFileName: AppConfig.TIC_WEB.KS_FILE_NAME,
+ ksFileName: item.getImageKs(),
logFileName: AppConfig.TIC_WEB.LOG_FILE_NAME,
imagePath: item.getJobAbsImagePath(),
classJobKsPath: item.getImageHasKsFile() === '0' ? 'btnnotactive' : '',
ksPath: item.getJobAbsKsPath(),
- logPath: item.getJobAbsLogPath()
+ logPath: item.getJobAbsLogPath(),
+ fileArch: item.getImageArch()
});
};
'<tr id="job_table_row_<%= jobNum %>">',
'<td><%= jobNum %></td>',
'<td class="<%= classJobStatus %>" title="<%= jobStatus %>"></td>',
- '<td><a class="tic-job-list-btn btndownload <%= classJobImageDownload %>" href="<%= jobImagePath %>" title="<%= jobImageName %> Download">Download</a></td>',
+ '<td><a class="tic-job-list-btn btndownload <%= classJobImageDownload %>" href="<%= jobImagePath %>" title="<%= jobImageName %>">Download</a></td>',
'<td><%= jobImageSize %></td>',
'<td><%= jobUptime %></td>',
'<td><a class="tic-job-list-btn btncancel <%= classJobCancel %>" title="Cancel">Cancel</a></td>',
'jobImageSize': data.getJobImageSize(),
'jobImagePath': data.getJobAbsImagePath(),
'classJobImageDownload': data.getJobStatus() === JOB_STATUS_DONE ? '' : 'btnnotactive',
- 'classJobCancel': statusValue === JOB_STATUS_DONE ? 'btnnotactive' : '',
+ 'classJobCancel': statusValue === JOB_STATUS_INPROGRESS ? '' : 'btnnotactive' ,
'classJobKsPath': data.getJobHasKsFile() === '0' ? 'btnnotactive' : '',
'jobKsPath': data.getJobAbsKsPath(),
'jobLogPath': data.getJobAbsLogPath(),
'jobImageName': data.getJobImageName(),
'jobImageSize': data.getJobImageSize(),
'jobImagePath': data.getJobAbsImagePath(),
- 'classJobCancel': statusValue === JOB_STATUS_DONE ? 'btnnotactive' : '',
+ 'classJobCancel': statusValue === JOB_STATUS_INPROGRESS ? '' : 'btnnotactive' ,
'classJobKsPath': data.getJobHasKsFile() === '0' ? 'btnnotactive' : '',
'jobKsPath': data.getJobAbsKsPath(),
'jobLogPath': data.getJobAbsLogPath(),