Repository: hadoop
Updated Branches:
  refs/heads/trunk 26f1e22fc -> 7802af6e9


YARN-8293.  Removed "User Name for service" for deploying secure YARN service.
            Contributed by Sunil G


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7802af6e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7802af6e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7802af6e

Branch: refs/heads/trunk
Commit: 7802af6e9a85f033e9515cc7b23c125a0e06c325
Parents: 26f1e22
Author: Eric Yang <ey...@apache.org>
Authored: Thu May 17 17:06:58 2018 -0400
Committer: Eric Yang <ey...@apache.org>
Committed: Thu May 17 17:06:58 2018 -0400

----------------------------------------------------------------------
 .../main/webapp/app/adapters/yarn-servicedef.js |  4 ++-
 .../webapp/app/components/deploy-service.js     |  5 +++
 .../src/main/webapp/app/initializers/loader.js  | 32 ++++++++++++++++++++
 .../src/main/webapp/app/services/hosts.js       |  5 +++
 .../app/templates/components/deploy-service.hbs | 18 ++++++-----
 .../src/main/webapp/config/default-config.js    |  3 +-
 6 files changed, 57 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7802af6e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js
index 03685fb..9000d74 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js
@@ -26,7 +26,9 @@ export default RESTAbstractAdapter.extend({
 
   deployService(request, user) {
     var url = this.buildURL();
-    url += "/?user.name=" + user;
+    if(user) {
+      url += "/?user.name=" + user;
+    }
     return this.ajax(url, "POST", {data: request});
   },
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7802af6e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js
index 36895d7..18e4d36 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js
@@ -28,6 +28,7 @@ export default Ember.Component.extend({
   serviceResp: null,
   isLoading: false,
   userName: '',
+  hosts: Ember.inject.service('hosts'),
 
   actions: {
     showSaveTemplateModal() {
@@ -157,6 +158,10 @@ export default Ember.Component.extend({
 
   isValidCustomServiceDef: Ember.computed.notEmpty('customServiceDef'),
 
+  isSecurityNotEnabled: Ember.computed('isSecurityEnabled', function () {
+    return this.get(`hosts.isSecurityEnabled`) === 'simple';
+  }),
+
   enableSaveOrDeployBtn: Ember.computed('isValidServiceDef', 
'isValidCustomServiceDef', 'viewType', 'isLoading', 'isUserNameGiven', 
function() {
     if (this.get('isLoading')) {
       return false;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7802af6e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js
index 43b5065..53f9c44 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js
@@ -75,6 +75,15 @@ function getTimeLineV1URL(rmhost, isHttpsSchemeEnabled) {
   return url;
 }
 
+function getSecurityURL(rmhost) {
+  var url = window.location.protocol + '//' +
+    (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + 
rmhost;
+
+  url += '/conf?name=hadoop.security.authentication';
+  Ember.Logger.log("Server security mode url is: " + url);
+  return url;
+}
+
 function updateConfigs(application) {
   var hostname = window.location.hostname;
   var rmhost = hostname + (window.location.port ? ':' + window.location.port: 
'') + skipTrailingSlash(window.location.pathname);
@@ -156,6 +165,29 @@ function updateConfigs(application) {
     Ember.Logger.log("Timeline V1 Address: " + ENV.hosts.timelineV1WebAddress);
     application.advanceReadiness();
   }
+
+  if(!ENV.hosts.isSecurityEnabled) {
+    var isSecurityEnabled = "";
+    $.ajax({
+      type: 'GET',
+      dataType: 'json',
+      async: true,
+      context: this,
+      url: getSecurityURL(rmhost),
+      success: function(data) {
+        isSecurityEnabled = data.property.value;
+        ENV.hosts.isSecurityEnabled = isSecurityEnabled;
+        Ember.Logger.log("Security mode is : " + isSecurityEnabled);
+        application.advanceReadiness();
+      },
+      error: function() {
+        application.advanceReadiness();
+      }
+    });
+  } else {
+    Ember.Logger.log("Security mode is: " + ENV.hosts.isSecurityEnabled);
+    application.advanceReadiness();
+  }
 }
 
 export function initialize( application ) {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7802af6e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js
index 738f5f1..a53451b 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js
@@ -82,5 +82,10 @@ export default Ember.Service.extend({
 
   dashWebAddress: Ember.computed(function () {
     return this.normalizeURL(this.get("env.app.hosts.dashWebAddress"));
+  }),
+
+  isSecurityEnabled: Ember.computed(function () {
+    console.log(this.get("env.app.hosts.isSecurityEnabled"));
+    return this.get("env.app.hosts.isSecurityEnabled");
   })
 });

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7802af6e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs
index 720074e..2d18610 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs
@@ -29,16 +29,18 @@
       </div>
     </div>
   {{/if}}
-  <div class="row">
-    <div class="col-md-4">
-      <div class="form-group shrink-height">
-        <label class="required">User Name for service</label>
-        <span class="glyphicon glyphicon-info-sign info-icon" 
data-info="userName"></span>
-        {{input type="text" class="form-control" placeholder="User Name" 
value=userName}}
+  {{#if isSecurityNotEnabled}}
+    <div class="row">
+      <div class="col-md-4">
+        <div class="form-group shrink-height">
+          <label class="required">User Name for service</label>
+          <span class="glyphicon glyphicon-info-sign info-icon" 
data-info="userName"></span>
+          {{input type="text" class="form-control" placeholder="User Name" 
value=userName}}
+        </div>
+        <br>
       </div>
-      <br>
     </div>
-  </div>
+  {{/if}}
   <div class="panel panel-default {{if isLoading 'loading-state'}}">
     {{#if isLoading}}
       <img src="assets/images/spinner.gif" alt="Loading...">

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7802af6e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js
index ff95115..3d37796 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js
@@ -22,7 +22,8 @@ module.exports = { // YARN UI App configurations
       timelineWebAddress: "localhost:8188",
       timelineV1WebAddress: "localhost:8188",
       rmWebAddress: "localhost:8088",
-      protocolScheme: "http:"
+      protocolScheme: "http:",
+      isSecurityEnabled: ""
     },
     namespaces: {
       timeline: 'ws/v1/applicationhistory',


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to