Skip to content

Commit 6cced18

Browse files
committed
CLOUDSTACK-8990: start a stopped machine on a specific determinable host on UI
1 parent f241455 commit 6cced18

2 files changed

Lines changed: 109 additions & 3 deletions

File tree

ui/css/cloudstack3.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12363,11 +12363,13 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it
1236312363
background-position: 1px -583px;
1236412364
}
1236512365

12366-
.start .icon {
12366+
.start .icon,
12367+
.startByAdmin .icon {
1236712368
background-position: -169px -1px;
1236812369
}
1236912370

12370-
.start:hover .icon {
12371+
.start:hover .icon,
12372+
.startByAdmin:hover .icon {
1237112373
background-position: -169px -583px;
1237212374
}
1237312375

ui/scripts/instances.js

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,107 @@
520520
poll: pollAsyncJobResult
521521
}
522522
},
523+
startByAdmin: {
524+
label: 'label.action.start.instance',
525+
createForm: {
526+
title: 'label.action.start.instance',
527+
desc: 'message.action.start.instance',
528+
fields: {
529+
hostId: {
530+
label: 'label.host',
531+
isHidden: function(args) {
532+
if (isAdmin())
533+
return false;
534+
else
535+
return true;
536+
},
537+
select: function(args) {
538+
if (isAdmin()) {
539+
$.ajax({
540+
url: createURL("listHosts&state=Up&type=Routing&zoneid=" + args.context.instances[0].zoneid),
541+
dataType: "json",
542+
async: true,
543+
success: function(json) {
544+
if (json.listhostsresponse.host != undefined) {
545+
hostObjs = json.listhostsresponse.host;
546+
var items = [{
547+
id: -1,
548+
description: 'Default'
549+
}];
550+
$(hostObjs).each(function() {
551+
items.push({
552+
id: this.id,
553+
description: this.name
554+
});
555+
});
556+
args.response.success({
557+
data: items
558+
});
559+
} else {
560+
cloudStack.dialog.notice({
561+
message: _l('No Hosts are avaialble')
562+
});
563+
}
564+
}
565+
});
566+
} else {
567+
args.response.success({
568+
data: null
569+
});
570+
}
571+
}
572+
},
573+
}
574+
},
575+
action: function(args) {
576+
var data = {
577+
id: args.context.instances[0].id
578+
}
579+
if (args.$form.find('.form-item[rel=hostId]').css("display") != "none" && args.data.hostId != -1) {
580+
$.extend(data, {
581+
hostid: args.data.hostId
582+
});
583+
}
584+
$.ajax({
585+
url: createURL("startVirtualMachine"),
586+
data: data,
587+
dataType: "json",
588+
async: true,
589+
success: function(json) {
590+
var jid = json.startvirtualmachineresponse.jobid;
591+
args.response.success({
592+
_custom: {
593+
jobId: jid,
594+
getUpdatedItem: function(json) {
595+
return json.queryasyncjobresultresponse.jobresult.virtualmachine;
596+
},
597+
getActionFilter: function() {
598+
return vmActionfilter;
599+
}
600+
}
601+
});
602+
}
603+
});
604+
},
605+
messages: {
606+
confirm: function(args) {
607+
return 'message.action.start.instance';
608+
},
609+
notification: function(args) {
610+
return 'label.action.start.instance';
611+
},
612+
complete: function(args) {
613+
if (args.password != null) {
614+
return 'label.vm.password' + ' ' + args.password;
615+
}
616+
617+
return false;
618+
}
619+
},
620+
notification: {
621+
poll: pollAsyncJobResult
622+
}
623+
},
523624
stop: {
524625
label: 'label.action.stop.instance',
525626
compactLabel: 'label.stop',
@@ -2464,7 +2565,10 @@
24642565
allowedActions.push("viewConsole");
24652566
} else if (jsonObj.state == 'Stopped') {
24662567
allowedActions.push("edit");
2467-
allowedActions.push("start");
2568+
if (isAdmin())
2569+
allowedActions.push("startByAdmin");
2570+
else
2571+
allowedActions.push("start");
24682572
allowedActions.push("destroy");
24692573
allowedActions.push("reinstall");
24702574

0 commit comments

Comments
 (0)