ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [1/2] ambari git commit: AMBARI-18662. Check that Stack Version and repo URLs match up when registering repo (alexantonenko)
Date Fri, 21 Oct 2016 18:53:16 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 5114bc9f7 -> 00f1e71b6


AMBARI-18662. Check that Stack Version and repo URLs match up when registering repo (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/00f1e71b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/00f1e71b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/00f1e71b

Branch: refs/heads/trunk
Commit: 00f1e71b62f4133e70d7d8f9f2cd6fa0624ec40d
Parents: db8f3e3
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Fri Oct 21 17:13:40 2016 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Fri Oct 21 21:53:10 2016 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/installer.js         |  3 ++-
 .../app/controllers/wizard/step1_controller.js  | 21 +++++++++++++++++++-
 ambari-web/app/messages.js                      |  2 ++
 ambari-web/test/controllers/installer_test.js   | 13 +++++++-----
 4 files changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/00f1e71b/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index e2c60c4..f736ba3 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -841,6 +841,7 @@ App.InstallerController = App.WizardController.extend({
       selectedStack.get('operatingSystems').forEach(function (os) {
         if (os.get('isSelected') && !os.get('isEmpty')) {
           os.get('repositories').forEach(function (repo) {
+            if (!repo.get('isUtils') && wizardStep1Controller.inappropriateUrlForStackVersion(repo,
stackVersion)) return;
             repo.setProperties({
               errorTitle: '',
               errorContent: '',
@@ -888,8 +889,8 @@ App.InstallerController = App.WizardController.extend({
       }
     }
     this.set('validationCnt', this.get('validationCnt') - 1);
+    this.set('content.isCheckInProgress', false);
     if (!this.get('validationCnt')) {
-      this.set('content.isCheckInProgress', false);
       data.dfd.resolve();
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f1e71b/ambari-web/app/controllers/wizard/step1_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step1_controller.js b/ambari-web/app/controllers/wizard/step1_controller.js
index e1cb4ff..6c105c2 100644
--- a/ambari-web/app/controllers/wizard/step1_controller.js
+++ b/ambari-web/app/controllers/wizard/step1_controller.js
@@ -272,6 +272,25 @@ App.WizardStep1Controller = Em.Controller.extend({
     this.selectStackBy('id', event.context.get('id'));
   },
 
+  inappropriateUrlForStackVersion: function (repo, stackVersion) {
+    var baseUrl = repo.get('baseUrl'),
+      splittedBaseUrlArray = baseUrl.split('/'),
+      versionInUrl =  baseUrl[baseUrl.length - 1] === '/' ? splittedBaseUrlArray[splittedBaseUrlArray.length
- 2] :
+                      splittedBaseUrlArray[splittedBaseUrlArray.length - 1],
+      versionInUrlString = String(parseFloat(versionInUrl)),
+      UrlIsInvalidForStackVersion = versionInUrlString !== stackVersion;
+
+    if (UrlIsInvalidForStackVersion) {
+      repo.setProperties({
+        validation: App.Repository.validation.INVALID,
+        errorTitle: Em.I18n.t("installer.step1.error.inappropriateUrlForStackVersion.title"),
+        errorContent: Em.I18n.t("installer.step1.error.inappropriateUrlForStackVersion.content").format(stackVersion,
versionInUrlString)
+      });
+    }
+
+    return UrlIsInvalidForStackVersion;
+  },
+
   /**
    * Show popup with options to upload new version
    *
@@ -444,7 +463,7 @@ App.WizardStep1Controller = Em.Controller.extend({
           enterUrlRadioButton: Em.Checkbox.extend({
             attributeBindings: [ 'type', 'checked' ],
             checked: Em.computed.alias('controller.optionsToSelect.useLocalRepo.enterUrl.isSelected'),
-            type: 'radio',
+            type: 'radio'
           }),
 
           click: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f1e71b/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index a3c5e58..b27e8f5 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -627,6 +627,8 @@ Em.I18n.translations = {
   'installer.step1.invalidURLAttention': '<b>Attention:</b> Please make sure
all repository URLs are valid before proceeding.',
   'installer.step1.checkAtLeastOneAttention': '<b>Attention:</b> Please check
at least one repository.',
   'installer.step1.retryRepoUrls': 'Click <b>here</b> to retry.',
+  'installer.step1.error.inappropriateUrlForStackVersion.title':'Inappropriate Url for selected
Stack Version',
+  'installer.step1.error.inappropriateUrlForStackVersion.content': 'Your stack version is
{0} when version in Url is {1}',
 
   'installer.step2.header':'Install Options',
   'installer.step2.body':'Enter the list of hosts to be included in the cluster and provide
your SSH key.',

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f1e71b/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index 441af87..63578bc 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -75,8 +75,8 @@ describe('App.InstallerController', function () {
       Em.Object.create({
         isSelected: true,
         reload: false,
-        id: 'nn-cc',
-        stackNameVersion: 'nn-cc',
+        id: 'nn-2.5',
+        stackNameVersion: 'nn-2.5',
         repositories: Em.A([
           Em.Object.create({
             isSelected: true,
@@ -89,6 +89,7 @@ describe('App.InstallerController', function () {
             isEmpty: false,
             repositories: Em.A([
               Em.Object.create({
+                baseUrl: 'url/2.5',
                 isEmpty: false,
                 errorTitle: '1',
                 errorContent: '1',
@@ -100,7 +101,8 @@ describe('App.InstallerController', function () {
       })
     ]);
     var wizard = Em.Object.create({
-      skipValidationChecked: true
+      skipValidationChecked: true,
+      inappropriateUrlForStackVersion: App.WizardStep1Controller.create().inappropriateUrlForStackVersion
     });
     it ('Should reload installed stacks', function() {
 
@@ -114,8 +116,8 @@ describe('App.InstallerController', function () {
         {
           "isSelected": true,
           "reload": true,
-          "id": "nn-cc",
-          "stackNameVersion": 'nn-cc',
+          "id": "nn-2.5",
+          "stackNameVersion": 'nn-2.5',
           "repositories": [
             {
               "isSelected": true,
@@ -128,6 +130,7 @@ describe('App.InstallerController', function () {
               "isEmpty": false,
               "repositories": [
                 {
+                  "baseUrl": "url/2.5",
                   "isEmpty": false,
                   "errorTitle": "",
                   "errorContent": "",


Mime
View raw message