|
520 | 520 | poll: pollAsyncJobResult |
521 | 521 | } |
522 | 522 | }, |
| 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 | + }, |
523 | 624 | stop: { |
524 | 625 | label: 'label.action.stop.instance', |
525 | 626 | compactLabel: 'label.stop', |
|
2464 | 2565 | allowedActions.push("viewConsole"); |
2465 | 2566 | } else if (jsonObj.state == 'Stopped') { |
2466 | 2567 | allowedActions.push("edit"); |
2467 | | - allowedActions.push("start"); |
| 2568 | + if (isAdmin()) |
| 2569 | + allowedActions.push("startByAdmin"); |
| 2570 | + else |
| 2571 | + allowedActions.push("start"); |
2468 | 2572 | allowedActions.push("destroy"); |
2469 | 2573 | allowedActions.push("reinstall"); |
2470 | 2574 |
|
|
0 commit comments