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
4 changes: 3 additions & 1 deletion server/app/model/classes/instance/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ var InstanceSchema = new Schema({
required: false,
trim: true
},
interval:[Schema.Types.Mixed],
cronJobId: {
type: String,
required: false,
Expand Down Expand Up @@ -2329,7 +2330,8 @@ var InstancesDao = function () {
instanceStopScheduler: instanceScheduler.instanceStopScheduler,
schedulerStartOn: instanceScheduler.schedulerStartOn,
schedulerEndOn: instanceScheduler.schedulerEndOn,
isScheduled: instanceScheduler.isScheduled
isScheduled: instanceScheduler.isScheduled,
interval:instanceScheduler.interval
},
}, {multi: true}, function (err, data) {
if (err) {
Expand Down
1 change: 1 addition & 0 deletions server/app/services/instanceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@ function updateScheduler(instanceScheduler, callback) {
generateCronPattern(instanceScheduler.interval,instanceScheduler.schedulerStartOn,instanceScheduler.schedulerEndOn,next);
},
function(schedulerDetails,next){
schedulerDetails.interval = instanceScheduler.interval;
instancesDao.updateScheduler(instanceScheduler.instanceIds, schedulerDetails,next);
},
function(updateSchedulerDetails,next){
Expand Down
24 changes: 12 additions & 12 deletions server/app/services/schedulerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,32 @@ schedulerService.startStopInstance= function startStopInstance(instanceId,catUse
}

function startStopManagedInstance(instance,catUser,action,callback){
var actionStartLog = '',actionCompleteLog='',actionFailedLog='',vmWareAction='',instanceState='';
if(action === 'Start'){
var actionStartLog = '',actionCompleteLog='',actionFailedLog='',vmWareAction='',instanceState='',actionLog = null;
var timestampStarted = new Date().getTime();
if(instanceState !== '' && instanceState === instance.instanceState){
callback({
errCode:201,
errMsg:"Instance is already in "+instanceState+" state. So no need to do same action again"
})
return;
}else if(action === 'Start'){
actionStartLog = 'Instance Starting';
actionCompleteLog = 'Instance Started';
actionFailedLog='Unable to start instance';
vmWareAction='poweron';
instanceState='running';
actionLog = instancesDao.insertStartActionLog(instance._id, catUser, timestampStarted);
}else if(action === 'Stop'){
actionStartLog = 'Instance Stopping';
actionCompleteLog = 'Instance Stopped';
actionFailedLog='Unable to stop instance';
vmWareAction='poweroff';
instanceState='stopped';
actionLog = instancesDao.insertStopActionLog(instance._id, catUser, timestampStarted);
}else{
logger.debug("Action is not matched for corresponding operation. "+action);
callback(null,null);
}
if(instanceState !== '' && instanceState === instance.instanceState){
callback({
errCode:201,
errMsg:"Instance is already in "+instanceState+" state. So no need to do same action again"
})
return;
}
var instanceLog = {
actionId: "",
instanceId: instance._id,
Expand All @@ -189,10 +191,8 @@ function startStopManagedInstance(instance,catUser,action,callback){
action: action,
logs: []
};
var timestampStarted = new Date().getTime();
var actionLog = instancesDao.insertStopActionLog(instance._id, catUser, timestampStarted);
var logReferenceIds = [instance._id];
if (actionLog) {
if (actionLog !== null) {
logReferenceIds.push(actionLog._id);
}
logsDao.insertLog({
Expand Down