stack_and_upgrade_controller.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.MainAdminStackAndUpgradeController = Em.Controller.extend({
  20. name: 'mainAdminStackAndUpgradeController',
  21. serviceToInstall: null,
  22. /**
  23. * version that currently applied to server
  24. */
  25. currentVersion: null,
  26. /**
  27. * versions to which cluster could be upgraded
  28. */
  29. targetVersions: [],
  30. services: function() {
  31. return App.StackService.find().map(function(s) {
  32. s.set('isInstalled', App.Service.find().someProperty('serviceName', s.get('serviceName')));
  33. return s;
  34. });
  35. }.property('App.router.clusterController.isLoaded'),
  36. /**
  37. * launch Add Service wizard
  38. * @param event
  39. */
  40. goToAddService: function (event) {
  41. this.set('serviceToInstall', event.context);
  42. App.get('router').transitionTo('main.serviceAdd');
  43. },
  44. /**
  45. * call to fetch cluster stack versions
  46. * @return {$.ajax}
  47. */
  48. loadVersionsInfo: function () {
  49. return App.ajax.send({
  50. name: 'admin.stack_versions.all',
  51. sender: this,
  52. data: {},
  53. success: 'loadVersionsInfoSuccessCallback'
  54. });
  55. },
  56. /**
  57. * parse stack versions and
  58. * set <code>currentVersion</code>
  59. * set <code>targetVersions</code>
  60. * @param data
  61. */
  62. loadVersionsInfoSuccessCallback: function (data) {
  63. var current = data.items.findProperty('ClusterStackVersions.state', 'CURRENT');
  64. var target = data.items.without(current);
  65. this.set('currentVersion', current.ClusterStackVersions);
  66. this.set('targetVersions', target.map(function (ver) {
  67. return ver.ClusterStackVersions;
  68. }));
  69. },
  70. /**
  71. * start cluster downgrade
  72. */
  73. downgrade: function () {
  74. //TODO start actual downgrade
  75. },
  76. /**
  77. * start cluster upgrade
  78. */
  79. upgrade: function () {
  80. //TODO start actual upgrade
  81. },
  82. /**
  83. * resume upgrade process
  84. */
  85. resumeUpgrade: function () {
  86. //TODO resume upgrade
  87. },
  88. /**
  89. * finish upgrade process
  90. */
  91. finalize: function () {
  92. //TODO start actual finalize
  93. }
  94. });