mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
Feature #2614: Multi zone support for Sunstone
Redirects requests to appropriate Zone OpenNebula instance
This commit is contained in:
parent
09f204e242
commit
0b8b4625a4
@ -91,7 +91,7 @@ class CloudAuth
|
||||
# is nil the Client is generated for the server_admin
|
||||
# username:: _String_ Name of the User
|
||||
# [return] _Client_
|
||||
def client(username=nil)
|
||||
def client(username=nil, endpoint=nil)
|
||||
expiration_time = @lock.synchronize {
|
||||
time_now = Time.now.to_i
|
||||
|
||||
@ -104,7 +104,11 @@ class CloudAuth
|
||||
|
||||
token = @server_auth.login_token(expiration_time,username)
|
||||
|
||||
OpenNebula::Client.new(token,@conf[:one_xmlrpc])
|
||||
if endpoint
|
||||
return OpenNebula::Client.new(token,endpoint)
|
||||
else
|
||||
return OpenNebula::Client.new(token,@conf[:one_xmlrpc])
|
||||
end
|
||||
end
|
||||
|
||||
# Authenticate the request. This is a wrapper method that executes the
|
||||
|
@ -438,7 +438,33 @@ $(document).ready(function(){
|
||||
return false;
|
||||
});
|
||||
|
||||
// Populate Zones dropdown
|
||||
OpenNebula.Zone.list({
|
||||
timeout: true,
|
||||
success: function (request, obj_list){
|
||||
$.each(obj_list,function(){
|
||||
$('#zone-ul').append('<li><a id="'+this.ZONE.TEMPLATE.ENDPOINT+'" class="zone-choice '+this.ZONE.NAME+'"><i class="icon-home"></i> '+this.ZONE.NAME+'</a></li>');
|
||||
});
|
||||
},
|
||||
error: onError
|
||||
});
|
||||
|
||||
$('a.zone-choice').live("click", function(){
|
||||
$.ajax({
|
||||
url: 'config',
|
||||
type: "POST",
|
||||
headers: {
|
||||
"ZONE_ENDPOINT": this.id,
|
||||
"ZONE_NAME" : this.className.split(" ")[1]
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(){
|
||||
window.location.href = ".";
|
||||
},
|
||||
error: function(response){
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//Start with the dashboard (supposing we have one).
|
||||
showTab('dashboard-tab');
|
||||
@ -483,6 +509,10 @@ function setLogin(){
|
||||
<li><a href="#" class="configuration"><i class="icon-cog"></i> Settings</a></li>\
|
||||
<li><a href="#" class="logout"><i class="icon-off"></i> Sign Out</a></li>\
|
||||
</ul>\
|
||||
</div>\
|
||||
<div href="#" class="button tiny secondary dropdown" id="zonelector">\
|
||||
<i class="icon-home header-icon"></i> '+ config['zone_name'] + '\
|
||||
<ul id="zone-ul"></ul>\
|
||||
</div>';
|
||||
|
||||
|
||||
|
@ -224,11 +224,26 @@ before do
|
||||
unless request.path=='/login' || request.path=='/' || request.path=='/vnc'
|
||||
halt 401 unless authorized?
|
||||
|
||||
@SunstoneServer = SunstoneServer.new(
|
||||
$cloud_auth.client(session[:user]),
|
||||
$conf,
|
||||
logger)
|
||||
if env['HTTP_ZONE_ENDPOINT']
|
||||
session[:active_zone_endpoint] = env['HTTP_ZONE_ENDPOINT']
|
||||
end
|
||||
|
||||
if env['HTTP_ZONE_ENDPOINT'] and env['HTTP_ZONE_ENDPOINT'].to_i == -1
|
||||
session.delete(:active_zone_endpoint)
|
||||
end
|
||||
|
||||
if env['HTTP_ZONE_NAME']
|
||||
session[:zone_name] = env['HTTP_ZONE_NAME']
|
||||
end
|
||||
|
||||
client=$cloud_auth.client(session[:user],
|
||||
session[:active_zone_endpoint])
|
||||
end
|
||||
|
||||
@SunstoneServer = SunstoneServer.new(
|
||||
client,
|
||||
$conf,
|
||||
logger)
|
||||
end
|
||||
|
||||
after do
|
||||
|
@ -57,7 +57,8 @@
|
||||
},
|
||||
'view' : view,
|
||||
'available_views' : available_views,
|
||||
'display_name' : '<%= session[:display_name] %>'
|
||||
'display_name' : '<%= session[:display_name] %>',
|
||||
'zone_name' : '<%= session[:zone_name] ? session[:zone_name] : "Local Zone" %>'
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user