123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- App.ReassignMasterController = App.WizardController.extend({
- name: 'reassignMasterController',
- totalSteps: 6,
- /**
- * Used for hiding back button in wizard
- */
- hideBackButton: true,
- /**
- * All wizards data will be stored in this variable
- *
- * cluster - cluster name
- * installOptions - ssh key, repo info, etc.
- * services - services list
- * hosts - list of selected hosts
- * slaveComponentHosts, - info about slave hosts
- * masterComponentHosts - info about master hosts
- * config??? - to be described later
- */
- content: Em.Object.create({
- cluster: null,
- hosts: null,
- installOptions: null,
- services: null,
- slaveComponentHosts: null,
- masterComponentHosts: null,
- serviceConfigProperties: null,
- advancedServiceConfig: null,
- controllerName: 'reassignMasterController',
- serviceName: 'MISC',
- hdfsUser:"hdfs",
- reassign: null,
- hasManualSteps: false
- }),
- componentsWithManualSteps: ['NAMENODE', 'SECONDARY_NAMENODE'],
- addManualSteps: function () {
- this.set('content.hasManualSteps', this.get('componentsWithManualSteps').contains(this.get('content.reassign.component_name')));
- }.observes('content.reassign.component_name'),
- skipStep3: function () {
- return this.get('content.reassign.service_id') == 'GANGLIA';
- }.property('content.reassign.service_id'),
- /**
- * return new object extended from clusterStatusTemplate
- * @return Object
- */
- getCluster: function(){
- return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
- },
- /**
- * Load services data from server.
- */
- loadServicesFromServer: function() {
- var displayOrderConfig = require('data/services');
- var apiUrl = App.get('stack2VersionURL');
- var apiService = this.loadServiceComponents(displayOrderConfig, apiUrl);
- //
- apiService.forEach(function(item, index){
- apiService[index].isSelected = App.Service.find().someProperty('id', item.serviceName);
- apiService[index].isDisabled = apiService[index].isSelected;
- apiService[index].isInstalled = apiService[index].isSelected;
- });
- this.set('content.services', apiService);
- App.db.setService(apiService);
- },
- /**
- * Load confirmed hosts.
- * Will be used at <code>Assign Masters(step5)</code> step
- */
- loadConfirmedHosts: function(){
- var hosts = App.db.getHosts();
- if(!hosts || !hosts.length){
- var hosts = {};
- App.Host.find().forEach(function(item){
- hosts[item.get('id')] = {
- name: item.get('id'),
- cpu: item.get('cpu'),
- memory: item.get('memory'),
- disk_info: item.get('diskInfo'),
- bootStatus: "REGISTERED",
- isInstalled: true
- };
- });
- App.db.setHosts(hosts);
- }
- this.set('content.hosts', hosts);
- console.log('ReassignMasterController.loadConfirmedHosts: loaded hosts', hosts);
- },
- /**
- * Load master component hosts data for using in required step controllers
- */
- loadMasterComponentHosts: function () {
- var masterComponentHosts = App.db.getMasterComponentHosts();
- if(!masterComponentHosts){
- masterComponentHosts = [];
- App.HostComponent.find().filterProperty('isMaster', true).forEach(function(item){
- masterComponentHosts.push({
- component: item.get('componentName'),
- hostName: item.get('host.hostName'),
- isInstalled: true
- })
- });
- }
- this.set("content.masterComponentHosts", masterComponentHosts);
- console.log("ReassignMasterController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
- },
- /**
- * Load tasks statuses for step5 of Reassign Master Wizard to restore installation
- */
- loadTasksStatuses: function(){
- var statuses = App.db.getReassignTasksStatuses();
- this.set('content.tasksStatuses', statuses);
- console.log('ReassignMasterController.loadTasksStatuses: loaded statuses', statuses);
- },
- /**
- * save status of the cluster.
- * @param clusterStatus object with status,requestId fields.
- */
- saveClusterStatus: function (clusterStatus) {
- var oldStatus = this.toObject(this.get('content.cluster'));
- clusterStatus = jQuery.extend(oldStatus, clusterStatus);
- if (clusterStatus.requestId) {
- clusterStatus.requestId.forEach(function (requestId) {
- if (clusterStatus.oldRequestsId.indexOf(requestId) === -1) {
- clusterStatus.oldRequestsId.push(requestId)
- }
- }, this);
- }
- this.set('content.cluster', clusterStatus);
- this.save('cluster');
- },
- /**
- * Save Master Component Hosts data to Main Controller
- * @param stepController App.WizardStep5Controller
- */
- saveMasterComponentHosts: function (stepController) {
- var obj = stepController.get('selectedServicesMasters');
- var masterComponentHosts = [];
- obj.forEach(function (_component) {
- masterComponentHosts.push({
- display_name: _component.get('display_name'),
- component: _component.get('component_name'),
- hostName: _component.get('selectedHost'),
- serviceId: _component.get('serviceId'),
- isInstalled: true
- });
- });
- App.db.setMasterComponentHosts(masterComponentHosts);
- this.set('content.masterComponentHosts', masterComponentHosts);
- },
- loadComponentToReassign: function () {
- var masterComponent = App.db.getMasterToReassign();
- if (masterComponent) {
- this.set('content.reassign', masterComponent);
- }
- },
- saveComponentToReassign: function (masterComponent) {
- var component = {
- component_name: masterComponent.get('componentName'),
- display_name: masterComponent.get('displayName'),
- service_id: masterComponent.get('service.serviceName'),
- host_id: masterComponent.get('host.hostName')
- };
- App.db.setMasterToReassign(component);
- },
- saveTasksStatuses: function(statuses){
- App.db.setReassignTasksStatuses(statuses);
- this.set('content.tasksStatuses', statuses);
- console.log('ReassignMasterController.saveTasksStatuses: saved statuses', statuses);
- },
- loadRequestIds: function(){
- var requestIds = App.db.getReassignMasterWizardRequestIds();
- this.set('content.requestIds', requestIds);
- },
- saveRequestIds: function(requestIds){
- App.db.setReassignMasterWizardRequestIds(requestIds);
- this.set('content.requestIds', requestIds);
- },
- saveLogs: function(logs){
- App.db.setReassignMasterWizardLogs(logs);
- this.set('content.logs', logs);
- },
- loadLogs: function(){
- var logs = App.db.getReassignMasterWizardLogs();
- this.set('content.logs', logs);
- },
- saveComponentDir: function(componentDir){
- App.db.setReassignMasterWizardComponentDir(componentDir);
- this.set('content.componentDir', componentDir);
- },
- loadComponentDir: function(){
- var componentDir = App.db.getReassignMasterWizardComponentDir();
- this.set('content.componentDir', componentDir);
- },
- saveReassignHosts: function(reassignHosts){
- App.db.setReassignMasterWizardReassignHosts(reassignHosts);
- this.set('content.reassignHosts', reassignHosts);
- },
- loadReassignHosts: function(){
- var reassignHosts = App.db.getReassignMasterWizardReassignHosts();
- this.set('content.reassignHosts', reassignHosts);
- },
- /**
- * Load data for all steps until <code>current step</code>
- */
- loadAllPriorSteps: function () {
- var step = this.get('currentStep');
- switch (step) {
- case '6':
- case '5':
- this.loadComponentDir();
- case '4':
- this.loadTasksStatuses();
- this.loadRequestIds();
- this.loadLogs();
- case '3':
- this.loadReassignHosts();
- case '2':
- this.loadServicesFromServer();
- this.loadMasterComponentHosts();
- this.loadConfirmedHosts();
- case '1':
- this.loadComponentToReassign();
- this.load('cluster');
- }
- },
- /**
- * Remove all loaded data.
- * Created as copy for App.router.clearAllSteps
- */
- clearAllSteps: function () {
- this.clearInstallOptions();
- // clear temporary information stored during the install
- this.set('content.cluster', this.getCluster());
- },
- /**
- * Clear all temporary data
- */
- finish: function () {
- this.setCurrentStep('1');
- this.clearAllSteps();
- this.clearStorageData();
- App.router.get('updateController').updateAll();
- }
- });
|