1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Hector Sanjuan 2011-12-01 19:56:30 +01:00
commit 8748e1a84f
5 changed files with 26 additions and 32 deletions

View File

@ -350,7 +350,6 @@ INSTALL_FILES=(
VMWARE_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/vmware
DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy
LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm
VMWARE_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/vmware
IMAGE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/image/fs
NETWORK_HOOK_SCRIPTS:$VAR_LOCATION/remotes/vnm
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples

View File

@ -136,7 +136,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
Changes the Virtual Network group
EOT
command :chgrp, chgrp_desc,[:range, :vnid_list], :groupid do
command :chgrp, chgrp_desc,[:range, :vnetid_list], :groupid do
helper.perform_actions(args[0],options,"Group changed") do |vn|
vn.chown(-1, args[1].to_i)
end
@ -146,7 +146,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
Changes the Virtual Network owner and group
EOT
command :chown, chown_desc, [:range, :vnid_list], :userid,
command :chown, chown_desc, [:range, :vnetid_list], :userid,
[:groupid,nil] do
gid = args[2].nil? ? -1 : args[2].to_i
helper.perform_actions(args[0],options,"Owner/Group changed") do |vn|

View File

@ -44,8 +44,11 @@ class CloudAuth
def initialize(conf)
@conf = conf
# @token_expiration_delta: Number of seconds that will be used
# the same timestamp for the token generation
# @token_expiration_time: Current timestamp to be used in tokens.
@token_expiration_delta = @conf[:token_expiration_delta] || EXPIRE_DELTA
@token_expiration_time = Time.now.to_i + @token_expiration_delta
@token_expiration_time = Time.now.to_i + @token_expiration_delta
if AUTH_MODULES.include?(@conf[:auth])
require 'CloudAuth/' + AUTH_MODULES[@conf[:auth]]
@ -78,14 +81,23 @@ class CloudAuth
Client.new(token,@conf[:one_xmlrpc])
end
def update_userpool_cache
@user_pool = OpenNebula::UserPool.new(client)
rc = @user_pool.info
if OpenNebula.is_error?(rc)
raise rc.message
end
end
protected
def expiration_time
time_now = Time.now.to_i
if time_now > @token_expiration_time - EXPIRE_MARGIN
update_userpool_cache
@token_expiration_time = time_now + @token_expiration_delta
update_userpool_cache
end
@token_expiration_time
@ -97,15 +109,6 @@ class CloudAuth
@user_pool
end
def update_userpool_cache
@user_pool = OpenNebula::UserPool.new(client)
rc = @user_pool.info
if OpenNebula.is_error?(rc)
raise rc.message
end
end
def get_password(username, non_public_user=false)
if non_public_user == true
xp="USER[NAME=\"#{username}\" and AUTH_DRIVER!=\"public\"]/PASSWORD"

View File

@ -23,17 +23,15 @@ class ImageOCCI < Image
<STORAGE href="<%= base_url %>/storage/<%= self.id.to_s %>">
<ID><%= self.id.to_s %></ID>
<NAME><%= self.name %></NAME>
<% if self['TEMPLATE/TYPE'] != nil %>
<TYPE><%= self['TEMPLATE/TYPE'] %></TYPE>
<% if self['TYPE'] != nil %>
<TYPE><%= self['TYPE'] %></TYPE>
<% end %>
<% if self['TEMPLATE/DESCRIPTION'] != nil %>
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
<% end %>
<% if size != nil %>
<SIZE><%= size.to_i / 1024 %></SIZE>
<% end %>
<% if fstype != nil %>
<FSTYPE><%= fstype %></FSTYPE>
<SIZE><%= self['SIZE'] %></SIZE>
<% if self['FSTYPE'] != nil %>
<FSTYPE><%= self['FSTYPE'] %></FSTYPE>
<% end %>
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
<PERSISTENT><%= self['PERSISTENT'] == "0" ? "NO" : "YES"%></PERSISTENT>
@ -84,25 +82,18 @@ class ImageOCCI < Image
# Creates the OCCI representation of an Image
def to_occi(base_url)
size = nil
begin
if self['SOURCE'] != nil and File.exists?(self['SOURCE'])
size = File.stat(self['SOURCE']).size
size = size / 1024
end
fstype = self['TEMPLATE/FSTYPE'] if self['TEMPLATE/FSTYPE']
occi_im = ERB.new(OCCI_IMAGE)
occi_im_text = occi_im.result(binding)
rescue Exception => e
error = OpenNebula::Error.new(e.message)
return error
end
occi = ERB.new(OCCI_IMAGE)
return occi.result(binding).gsub(/\n\s*/,'')
return occi_im_text.gsub(/\n\s*/,'')
end
def to_one_template()
def to_one_template
if @image_info == nil
error_msg = "Missing STORAGE section in the XML body"
error = OpenNebula::Error.new(error_msg)

View File

@ -89,6 +89,7 @@ helpers do
def build_session
begin
settings.cloud_auth.update_userpool_cache
result = settings.cloud_auth.auth(request.env, params)
rescue Exception => e
error 500, e.message