diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb
index 2ed9e8f20f..74f3bc9370 100644
--- a/src/cloud/common/CloudAuth.rb
+++ b/src/cloud/common/CloudAuth.rb
@@ -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
diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js
index 40ea18e2db..9e92cc31f9 100644
--- a/src/sunstone/public/js/sunstone.js
+++ b/src/sunstone/public/js/sunstone.js
@@ -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('
'+this.ZONE.NAME+'');
+ });
+ },
+ 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(){
Settings\
Sign Out\
\
+ \
+ ';
diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb
index 6e456f6e16..e9fae24e6b 100755
--- a/src/sunstone/sunstone-server.rb
+++ b/src/sunstone/sunstone-server.rb
@@ -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
diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb
index 256e47bfb4..df723f8854 100644
--- a/src/sunstone/views/index.erb
+++ b/src/sunstone/views/index.erb
@@ -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" %>'
};