Permalink
Browse files

AMBARI-1059. Refactor cluster management. (yusaku)

  • Loading branch information...
1 parent 856f382 commit 0ea9f9b7780a6896530235343c6894c14424944e Yusaku Sako committed Dec 9, 2012

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,11 @@
+{
+ "href" : "http://dev.hortonworks.com:8080/api/v1/users/admin",
+ "Users" : {
+ "user_name" : "admin",
+ "ldap_user" : false,
+ "roles" : [
+ "admin",
+ "user"
+ ]
+ }
+}
@@ -0,0 +1,10 @@
+{
+ "href" : "http://dev.hortonworks.com:8080/api/v1/users/user",
+ "Users" : {
+ "user_name" : "user",
+ "ldap_user" : false,
+ "roles" : [
+ "user"
+ ]
+ }
+}
@@ -1,25 +1,47 @@
{
- "href": "http://ambari:8080/api/clusters/mycluster/users",
- "items": [
+ "href" : "http://dev.hortonworks.com:8080/api/v1/users/?fields=*",
+ "items" : [
{
- "href" : "http://ambari:8080/api/users/admin",
- "Users" :
- { "user_name" : "admin", "roles" : "admin,user", "type" : "local" }
+ "href" : "http://dev.hortonworks.com:8080/api/v1/users/user",
+ "Users" : {
+ "user_name" : "user",
+ "ldap_user" : false,
+ "roles" : [
+ "user"
+ ]
+ }
},
{
- "href" : "http://ambari:8080/api/users/user",
- "Users" :
- { "user_name" : "user", "roles" : "user", "type" : "local" }
+ "href" : "http://dev.hortonworks.com:8080/api/v1/users/admin",
+ "Users" : {
+ "user_name" : "admin",
+ "ldap_user" : false,
+ "roles" : [
+ "admin",
+ "user"
+ ]
+ }
},
{
- "href" : "http://ambari:8080/api/users/john",
- "Users" :
- { "user_name" : "john", "roles" : "admin,user", "type" : "LDAP" }
+ "href" : "http://dev.hortonworks.com:8080/api/v1/users/jone",
+ "Users" : {
+ "user_name" : "jone",
+ "ldap_user" : true,
+ "roles" : [
+ "user"
+ ]
+ }
},
{
- "href" : "http://ambari:8080/api/users/mike",
- "Users" :
- { "user_name" : "mike", "roles" : "user", "type" : "LDAP" }
+ "href" : "http://dev.hortonworks.com:8080/api/v1/users/alex",
+ "Users" : {
+ "user_name" : "alex",
+ "ldap_user" : false,
+ "roles" : [
+ "admin",
+ "user"
+ ]
+ }
}
]
-}
+}
@@ -32,7 +32,7 @@ App.LoginController = Em.Object.extend({
this.set('errorMessage', '');
var self = this;
- var loginFunc = (App.testMode) ? App.get('router').mockLogin : App.get('router').login;
+ var loginFunc = App.get('router').login;
var user = loginFunc.call(App.get('router'), function (isAuthenticated) {
if (!isAuthenticated) {
@@ -21,6 +21,13 @@ require('models/background_operation');
App.MainController = Em.Controller.extend({
name: 'mainController',
+ clusterName: function () {
+ var name = App.db.getClusterName();
+ if (name) {
+ return name.capitalize();
+ }
+ return 'My Cluster';
+ }.property(),
isClusterDataLoaded: function(){
return App.router.get('clusterController.isLoaded');
}.property('App.router.clusterController.isLoaded'),
@@ -277,9 +277,13 @@ App.WizardStep3Controller = Em.Controller.extend({
_host.set('bootStatus', 'REGISTERED');
_host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + '\nRegistration with the server succeeded.');
}
+ } else if (_host.get('bootStatus') == 'FAILED') {
+ // ignore FAILED hosts
} else {
+ // there are some hosts that are not REGISTERED or FAILED
+ // we need to keep polling
allRegistered = false;
- if (_host.get('bootStatus') != 'FAILED' && _host.get('bootStatus') != 'REGISTERING') {
+ if (_host.get('bootStatus') != 'REGISTERING') {
_host.set('bootStatus', 'REGISTERING');
currentBootLog = _host.get('bootLog') != null ? _host.get('bootLog') : '';
_host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + '\nRegistering with the server...');
@@ -391,7 +395,44 @@ App.WizardStep3Controller = Em.Controller.extend({
bodyClass: Ember.View.extend({
templateName: require('templates/wizard/step3_host_log_popup'),
- host: host
+ host: host,
+ didInsertElement: function () {
+ var self = this;
+ var button = $(this.get('element')).find('#textTrigger');
+ button.click(function () {
+ if(self.get('isTextArea')){
+ $(this).text('click to highlight');
+ } else {
+ $(this).text('press CTRL+C');
+ }
+ self.set('isTextArea', !self.get('isTextArea'));
+ });
+ $(this.get('element')).find('.content-area').mouseenter(
+ function () {
+ var element = $(this);
+ element.css('border', '1px solid #dcdcdc');
+ button.css('visibility', 'visible');
+ }).mouseleave(
+ function () {
+ var element = $(this);
+ element.css('border', 'none');
+ button.css('visibility', 'hidden');
+ })
+ },
+ isTextArea: false,
+ textArea: Em.TextArea.extend({
+ didInsertElement: function(){
+ var element = $(this.get('element'));
+ element.width($(this.get('parentView').get('element')).width() - 10);
+ element.height($(this.get('parentView').get('element')).height());
+ element.select();
+ element.css('resize', 'none');
+ },
+ disabled: true,
+ value: function(){
+ return this.get('content');
+ }.property('content')
+ })
})
});
},
@@ -774,7 +774,7 @@ App.WizardStep8Controller = Em.Controller.extend({
var allHosts = this.get('content.hostsInfo');
var data = [];
for (var hostName in allHosts) {
- if (!allHosts[hostName].isInstalled) {
+ if (!allHosts[hostName].isInstalled && allHosts[hostName].bootStatus == 'REGISTERED') {
data.pushObject({"Hosts": { "host_name": hostName}});
}
}
@@ -520,7 +520,6 @@ App.WizardStep9Controller = Em.Controller.extend({
} else {
url = 'data/wizard/deploy/poll_' + this.numPolls + '.json';
}
- debugger;
}
$.ajax({
@@ -39,9 +39,9 @@ App.hostsMapper = App.QuickDataMapper.create({
disk_info: 'Hosts.disk_info',
disk_usage: 'disk_usage',
health_status: 'Hosts.host_status',
- load_one: 'Hosts.load.load_one',
- load_five: 'Hosts.load.load_five',
- load_fifteen: 'Hosts.load.load_fifteen',
+ load_one: 'metrics.load.load_one',
+ load_five: 'metrics.load.load_five',
+ load_fifteen: 'metrics.load.load_fifteen',
cpu_usage: 'cpu_usage',
memory_usage: 'memory_usage',
$network_usage: 36,
@@ -110,7 +110,7 @@ App.hostsMapper = App.QuickDataMapper.create({
}
}, this);
- // console.log(this.get('model'), result);
+ //console.log(this.get('model'), result);
}
},
@@ -20,8 +20,26 @@
App.usersMapper = App.QuickDataMapper.create({
model : App.User,
config : {
+ id : 'Users.user_name',
user_name : 'Users.user_name',
roles : 'Users.roles',
- is_ldap: 'Users.ldap_user'
+ is_ldap: 'Users.ldap_user',
+ admin: 'Users.admin'
+ },
+ map: function (json) {
+ self = this;
+ json.items.forEach(function (item) {
+ var result= [] ;
+ if(App.User.find(item.Users.user_name).get("userName") != item.Users.user_name)
+ {
+ if(item.Users.roles.indexOf("admin") >= 0){
+ item.Users.admin = true;
+ }else{
+ item.Users.admin = false;
+ }
+ result.push(self.parseIt(item, self.config));
+ App.store.loadMany(self.get('model'), result);
+ }
+ });
}
});
View
@@ -135,9 +135,18 @@ App.Router = Em.Router.extend({
controller.set('loginName', loginName);
var hash = window.btoa(loginName + ":" + controller.get('password'));
var router = this;
+ var url = '';
+
+ if(loginName === "admin" && controller.get('password') === 'admin')
+ {
+ url = '/data/users/user_admin.json';
+ }else if(loginName === 'user' && controller.get('password') === 'user'){
+ url = '/data/users/user_user.json';
+ }
+
$.ajax({
- url : App.apiPrefix + '/users/' + loginName,
- dataType : 'text',
+ url : (App.testMode) ? url : App.apiPrefix + '/users/' + loginName ,
+ dataType : 'json',
type: 'GET',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + hash);
@@ -156,27 +165,27 @@ App.Router = Em.Router.extend({
success: function (data) {
console.log('login success');
- var resp = $.parseJSON(data);
+ var resp = data;
var isAdmin = resp.Users.roles.indexOf('admin') >= 0;
if(isAdmin){
router.setAuthenticated(true);
router.setLoginName(loginName);
-
- router.setUser(App.store.createRecord(App.User, { userName: loginName, admin: isAdmin }));
+ App.usersMapper.map({"items":[data]});
+ router.setUser(App.User.find(loginName));
router.transitionTo(router.getSection());
postLogin(true);
} else {
$.ajax({
- url: App.apiPrefix + '/clusters',
+ url: (App.testMode) ? '/data/clusters/info.json' : App.apiPrefix + '/clusters',
dataType: 'text',
type: 'GET',
success: function (data) {
var clusterResp = $.parseJSON(data);
if (clusterResp.items.length) {
router.setAuthenticated(true);
router.setLoginName(loginName);
-
- router.setUser(App.store.createRecord(App.User, { userName: loginName, admin: isAdmin }));
+ App.usersMapper.map({"items":[resp]});
+ router.setUser(App.User.find(loginName));
router.transitionTo(router.getSection());
postLogin(true);
} else {
@@ -234,54 +243,6 @@ App.Router = Em.Router.extend({
});
},
- mockLogin: function (postLogin) {
- var controller = this.get('loginController');
- var loginName = controller.get('loginName');
- var router = this;
- if ((loginName === 'admin' && controller.get('password') === 'admin') ||
- (loginName === 'user' && controller.get('password') === 'user')) {
- if(loginName === 'admin'){
- router.setAuthenticated(true);
- router.setLoginName(loginName);
-
- router.setUser(App.store.createRecord(App.User, { userName: loginName, admin: loginName === 'admin' }));
- router.setAmbariStacks();
-
- router.transitionTo(router.getSection());
- postLogin(true);
- } else {
- $.ajax({
- url: '/data/clusters/info.json',
- dataType: 'text',
- type: 'GET',
- success: function (data) {
- var clusterResp = $.parseJSON(data);
- if (clusterResp.items.length) {
- router.setAuthenticated(true);
- router.setLoginName(loginName);
-
- router.setUser(App.store.createRecord(App.User, { userName: loginName, admin: loginName === 'admin' }));
- router.setAmbariStacks();
-
- router.transitionTo(router.getSection());
- postLogin(true);
- } else {
- controller.set('errorMessage', "Your administrator has not set up a Hadoop cluster yet.");
- }
- },
- error: function (req) {
- console.log("Server not responding: " + req.statusCode);
- }
- });
- }
- } else {
- router.setAuthenticated(false);
- postLogin(false);
- }
-
-
- },
-
getSection: function () {
if (App.alwaysGoToInstaller) {
return 'installer';
@@ -131,6 +131,7 @@ footer {
.brand {
font-size: 17px;
border-right: 1px solid rgba(0, 0, 0, 0.08);
+ color: #555555;
}
.operations-count {
background-color: #006DCC;
@@ -1881,6 +1882,18 @@ ul.inline li {
#step10-content {
max-height: 440px;
}
+.content-area {
+ position: relative;
+ #textTrigger {
+ cursor: pointer;
+ position: absolute;
+ right: 0;
+ top: 0;
+ visibility: hidden;
+ background-color: #dcdcdc;
+ }
+}
+
//bootstrap
//.dropdown-menu .active > a, .dropdown-menu .active > a:hover {
@@ -1894,3 +1907,10 @@ ul.inline li {
background-position: 0;
}
// COMBOBOX FIXES END
+@media all and (max-width: 1024px) {
+ #main-nav {
+ li.span2 {
+ width: 125px;
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 0ea9f9b

Please sign in to comment.