|
6524 | 6524 | } |
6525 | 6525 | } |
6526 | 6526 | } |
6527 | | - } |
| 6527 | + }, |
| 6528 | + Opendaylight: { |
| 6529 | + type: 'detailView', |
| 6530 | + id: 'openDaylightProvider', |
| 6531 | + label: 'label.openDaylight', |
| 6532 | + tabs: { |
| 6533 | + details: { |
| 6534 | + title: 'label.details', |
| 6535 | + fields:[ { |
| 6536 | + name: { |
| 6537 | + label: 'label.name' |
| 6538 | + } |
| 6539 | + }, |
| 6540 | + { |
| 6541 | + state: { |
| 6542 | + label: 'label.state' |
| 6543 | + } |
| 6544 | + }], |
| 6545 | + dataProvider: function (args) { |
| 6546 | + refreshNspData("Opendaylight"); |
| 6547 | + var providerObj; |
| 6548 | + $(nspHardcodingArray).each(function () { |
| 6549 | + if (this.id == "Opendaylight") { |
| 6550 | + providerObj = this; |
| 6551 | + return false; //break each loop |
| 6552 | + } |
| 6553 | + }); |
| 6554 | + args.response.success({ |
| 6555 | + data: providerObj, |
| 6556 | + actionFilter: networkProviderActionFilter('Opendaylight') |
| 6557 | + }); |
| 6558 | + } |
| 6559 | + }, |
| 6560 | + controllers: { |
| 6561 | + title: 'label.opendaylight.controllers', |
| 6562 | + listView: { |
| 6563 | + id: 'openDaylightControllerList', |
| 6564 | + fields: { |
| 6565 | + name: { |
| 6566 | + label: 'label.name' |
| 6567 | + }, |
| 6568 | + url: { |
| 6569 | + label: 'label.url' |
| 6570 | + }, |
| 6571 | + username: { |
| 6572 | + label: 'label.username' |
| 6573 | + } |
| 6574 | + }, |
| 6575 | + dataProvider: function (args) { |
| 6576 | + var providerObj |
| 6577 | + $.ajax({ |
| 6578 | + url: createURL("listOpenDaylightControllers"), |
| 6579 | + async: false, |
| 6580 | + success: function (json) { |
| 6581 | + providerObj = json.listOpenDaylightControllers.opendaylightcontroller |
| 6582 | + } |
| 6583 | + }); |
| 6584 | + args.response.success({ |
| 6585 | + data: providerObj |
| 6586 | + }); |
| 6587 | + }, |
| 6588 | + detailView: { |
| 6589 | + name: "OpenDaylight Controller", |
| 6590 | + tabs: { |
| 6591 | + details: { |
| 6592 | + title: 'label.opendaylight.controllerdetail', |
| 6593 | + fields:[ { |
| 6594 | + name: { |
| 6595 | + label: 'label.name' |
| 6596 | + }, |
| 6597 | + url: { |
| 6598 | + label: 'label.url', header: true |
| 6599 | + }, |
| 6600 | + username: { |
| 6601 | + label: 'label.username' |
| 6602 | + } |
| 6603 | + }], |
| 6604 | + dataProvider: function (args) { |
| 6605 | + var providerObj |
| 6606 | + $.ajax({ |
| 6607 | + url: createURL("listOpenDaylightControllers&id=" + args.id), |
| 6608 | + async: false, |
| 6609 | + success: function (json) { |
| 6610 | + providerObj = json.listOpenDaylightControllers.opendaylightcontroller |
| 6611 | + } |
| 6612 | + }); |
| 6613 | + args.response.success({ |
| 6614 | + data: providerObj[0], |
| 6615 | + actionFilter: function(args) { return [ 'destroy' ] } |
| 6616 | + }); |
| 6617 | + } |
| 6618 | + } |
| 6619 | + }, |
| 6620 | + actions: { |
| 6621 | + destroy: { |
| 6622 | + label: 'label.destroy.controller', |
| 6623 | + action: function (args) { |
| 6624 | + $.ajax({ |
| 6625 | + url: createURL("deleteOpenDaylightController&id=" + args.data.id), |
| 6626 | + dataType: "json", |
| 6627 | + success: function (json) { |
| 6628 | + var jid = json.deleteOpenDaylightController.jobid; |
| 6629 | + args.response.success({ |
| 6630 | + _custom: { |
| 6631 | + jobId: jid, |
| 6632 | + getUpdatedItem: function (json) { |
| 6633 | + $(window).trigger('cloudStack.fullRefresh'); |
| 6634 | + } |
| 6635 | + } |
| 6636 | + }); |
| 6637 | + } |
| 6638 | + }); |
| 6639 | + }, |
| 6640 | + messages: { |
| 6641 | + notification: function(args) { |
| 6642 | + return 'label.openaylight.destroycontroller' |
| 6643 | + } |
| 6644 | + }, |
| 6645 | + notification: { |
| 6646 | + poll: pollAsyncJobResult |
| 6647 | + } |
| 6648 | + } |
| 6649 | + } |
| 6650 | + } |
| 6651 | + } |
| 6652 | + } |
| 6653 | + }, |
| 6654 | + actions: { |
| 6655 | + add: { |
| 6656 | + label: 'label.add.OpenDaylight.device', |
| 6657 | + createForm: { |
| 6658 | + title: 'label.add.OpenDaylight.device', |
| 6659 | + preFilter: function (args) { |
| 6660 | + }, |
| 6661 | + // TODO What is this? |
| 6662 | + fields: { |
| 6663 | + url: { |
| 6664 | + label: 'label.url' |
| 6665 | + }, |
| 6666 | + username: { |
| 6667 | + label: 'label.username' |
| 6668 | + }, |
| 6669 | + password: { |
| 6670 | + label: 'label.password', |
| 6671 | + isPassword: true |
| 6672 | + }, |
| 6673 | + numretries: { |
| 6674 | + label: 'label.numretries', |
| 6675 | + defaultValue: '2' |
| 6676 | + } |
| 6677 | + } |
| 6678 | + }, |
| 6679 | + action: function (args) { |
| 6680 | + if (nspMap[ "Opendaylight"] == null) { |
| 6681 | + $.ajax({ |
| 6682 | + url: createURL("addNetworkServiceProvider&name=Opendaylight&physicalnetworkid=" + selectedPhysicalNetworkObj.id), |
| 6683 | + dataType: "json", |
| 6684 | + async: true, |
| 6685 | + success: function (json) { |
| 6686 | + var jobId = json.addnetworkserviceproviderresponse.jobid; |
| 6687 | + var addOpenDaylightProviderIntervalID = setInterval(function () { |
| 6688 | + $.ajax({ |
| 6689 | + url: createURL("queryAsyncJobResult&jobId=" + jobId), |
| 6690 | + dataType: "json", |
| 6691 | + success: function (json) { |
| 6692 | + var result = json.queryasyncjobresultresponse; |
| 6693 | + if (result.jobstatus == 0) { |
| 6694 | + return; //Job has not completed |
| 6695 | + } else { |
| 6696 | + clearInterval(addOpenDaylightProviderIntervalID); |
| 6697 | + if (result.jobstatus == 1) { |
| 6698 | + nspMap[ "Opendaylight"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider; |
| 6699 | + addOpenDaylightController(args, selectedPhysicalNetworkObj, "addOpenDaylightController", "addopendaylightcontrollerresponse", "opendaylightcontroller") |
| 6700 | + } else if (result.jobstatus == 2) { |
| 6701 | + alert("addNetworkServiceProvider&name=OpenDaylight failed. Error: " + _s(result.jobresult.errortext)); |
| 6702 | + } |
| 6703 | + } |
| 6704 | + }, |
| 6705 | + error: function (XMLHttpResponse) { |
| 6706 | + var errorMsg = parseXMLHttpResponse(XMLHttpResponse); |
| 6707 | + alert("addNetworkServiceProvider&name=OpenDaylight failed. Error: " + errorMsg); |
| 6708 | + } |
| 6709 | + }); |
| 6710 | + }, |
| 6711 | + g_queryAsyncJobResultInterval); |
| 6712 | + } |
| 6713 | + }); |
| 6714 | + } else { |
| 6715 | + addOpenDaylightController(args, selectedPhysicalNetworkObj, "addOpenDaylightController", "addOpenDaylightController", "opendaylightcontroller") |
| 6716 | + } |
| 6717 | + }, |
| 6718 | + messages: { |
| 6719 | + notification: function (args) { |
| 6720 | + return 'label.add.OpenDaylight.device'; |
| 6721 | + } |
| 6722 | + }, |
| 6723 | + notification: { |
| 6724 | + poll: pollAsyncJobResult |
| 6725 | + } |
| 6726 | + }, |
| 6727 | + enable: { |
| 6728 | + label: 'label.enable.provider', |
| 6729 | + action: function (args) { |
| 6730 | + $.ajax({ |
| 6731 | + url: createURL("updateNetworkServiceProvider&id=" + nspMap[ "Opendaylight"].id + "&state=Enabled"), |
| 6732 | + dataType: "json", |
| 6733 | + success: function (json) { |
| 6734 | + var jid = json.updatenetworkserviceproviderresponse.jobid; |
| 6735 | + args.response.success({ |
| 6736 | + _custom: { |
| 6737 | + jobId: jid, |
| 6738 | + getUpdatedItem: function (json) { |
| 6739 | + $(window).trigger('cloudStack.fullRefresh'); |
| 6740 | + } |
| 6741 | + } |
| 6742 | + }); |
| 6743 | + } |
| 6744 | + }); |
| 6745 | + }, |
| 6746 | + messages: { |
| 6747 | + confirm: function (args) { |
| 6748 | + return 'message.confirm.enable.provider'; |
| 6749 | + }, |
| 6750 | + notification: function () { |
| 6751 | + return 'label.enable.provider'; |
| 6752 | + } |
| 6753 | + }, |
| 6754 | + notification: { |
| 6755 | + poll: pollAsyncJobResult |
| 6756 | + } |
| 6757 | + }, |
| 6758 | + disable: { |
| 6759 | + label: 'label.disable.provider', |
| 6760 | + action: function (args) { |
| 6761 | + $.ajax({ |
| 6762 | + url: createURL("updateNetworkServiceProvider&id=" + nspMap[ "Opendaylight"].id + "&state=Disabled"), |
| 6763 | + dataType: "json", |
| 6764 | + success: function (json) { |
| 6765 | + var jid = json.updatenetworkserviceproviderresponse.jobid; |
| 6766 | + args.response.success({ |
| 6767 | + _custom: { |
| 6768 | + jobId: jid, |
| 6769 | + getUpdatedItem: function (json) { |
| 6770 | + $(window).trigger('cloudStack.fullRefresh'); |
| 6771 | + } |
| 6772 | + } |
| 6773 | + }); |
| 6774 | + } |
| 6775 | + }); |
| 6776 | + }, |
| 6777 | + messages: { |
| 6778 | + confirm: function (args) { |
| 6779 | + return 'message.confirm.disable.provider'; |
| 6780 | + }, |
| 6781 | + notification: function () { |
| 6782 | + return 'label.disable.provider'; |
| 6783 | + } |
| 6784 | + }, |
| 6785 | + notification: { |
| 6786 | + poll: pollAsyncJobResult |
| 6787 | + } |
| 6788 | + }, |
| 6789 | + destroy: { |
| 6790 | + label: 'label.shutdown.provider', |
| 6791 | + action: function (args) { |
| 6792 | + $.ajax({ |
| 6793 | + url: createURL("deleteNetworkServiceProvider&id=" + nspMap[ "Opendaylight"].id), |
| 6794 | + dataType: "json", |
| 6795 | + success: function (json) { |
| 6796 | + var jid = json.deletenetworkserviceproviderresponse.jobid; |
| 6797 | + args.response.success({ |
| 6798 | + _custom: { |
| 6799 | + jobId: jid |
| 6800 | + } |
| 6801 | + }); |
| 6802 | + |
| 6803 | + $(window).trigger('cloudStack.fullRefresh'); |
| 6804 | + } |
| 6805 | + }); |
| 6806 | + }, |
| 6807 | + messages: { |
| 6808 | + confirm: function (args) { |
| 6809 | + return 'message.confirm.shutdown.provider'; |
| 6810 | + }, |
| 6811 | + notification: function (args) { |
| 6812 | + return 'label.shutdown.provider'; |
| 6813 | + } |
| 6814 | + }, |
| 6815 | + notification: { |
| 6816 | + poll: pollAsyncJobResult |
| 6817 | + } |
| 6818 | + } |
| 6819 | + } |
| 6820 | + } |
6528 | 6821 | } |
6529 | 6822 | } |
6530 | 6823 | }, |
|
0 commit comments