mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
422a3cc6d1
@ -81,6 +81,9 @@ digraph OpenNebula {
|
||||
unknown -> boot [label="restart"];
|
||||
boot -> boot [label="restart"];
|
||||
|
||||
# reboot
|
||||
running -> running [label="reboot"];
|
||||
|
||||
# resubmit
|
||||
"ANY \\ {suspended,done}" -> pending [label="resubmit"];
|
||||
|
||||
|
@ -75,6 +75,9 @@ digraph OpenNebula {
|
||||
unknown -> boot [label="restart"];
|
||||
boot -> boot [label="restart"];
|
||||
|
||||
# reboot
|
||||
running -> running [label="reboot"];
|
||||
|
||||
# resubmit
|
||||
"ANY \\ {suspended,done}" -> pending [label="resubmit"];
|
||||
|
||||
|
@ -50,7 +50,13 @@ quota = Quota.new
|
||||
#OpenNebula.log_debug("quotas: #{quota.get(1)}")
|
||||
|
||||
ARGV.each {|request|
|
||||
rc = quota.authorize(user_id, request)
|
||||
obj, template_or_id, op, owner, acl_eval = request.split(':')
|
||||
|
||||
if ( obj == "TEMPLATE" && op == "USE" && ARGV.size == 1 )
|
||||
rc = false
|
||||
else
|
||||
rc = quota.authorize(user_id, request)
|
||||
end
|
||||
|
||||
if rc
|
||||
OpenNebula.error_message rc
|
||||
|
@ -219,10 +219,20 @@ class Quota
|
||||
# Check if this op needs to check the quota
|
||||
return false unless with_quota?(obj, op)
|
||||
|
||||
# If the object is a template the info should be retrived from the
|
||||
# VM pool.
|
||||
obj = "VM" if obj == "TEMPLATE"
|
||||
template = Base64::decode64(template_or_id)
|
||||
template = ""
|
||||
|
||||
if ( obj == "TEMPLATE" )
|
||||
obj = "VM"
|
||||
|
||||
vm_template = OpenNebula::Template.new_with_id(template_or_id, @client)
|
||||
vm_template.info
|
||||
|
||||
vm_template.each("TEMPLATE") { |xml_elem|
|
||||
template = xml_elem.to_xml
|
||||
}
|
||||
else
|
||||
template = Base64::decode64(template_or_id)
|
||||
end
|
||||
|
||||
check_quotas(user_id.to_i, obj, template)
|
||||
end
|
||||
@ -267,7 +277,7 @@ class Quota
|
||||
def with_quota?(obj, op)
|
||||
return (obj == "VM" && op == "CREATE") ||
|
||||
(obj == "IMAGE" && op == "CREATE") ||
|
||||
(obj == "TEMPLATE" && op == "INSTANTIATE")
|
||||
(obj == "TEMPLATE" && op == "USE")
|
||||
end
|
||||
|
||||
###########################################################################
|
||||
|
@ -385,6 +385,13 @@ EOT
|
||||
tmp = Tempfile.new(id.to_s)
|
||||
path = tmp.path
|
||||
|
||||
rc = resource.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
puts rc.message
|
||||
exit -1
|
||||
end
|
||||
|
||||
tmp << resource.template_str
|
||||
tmp.flush
|
||||
|
||||
|
@ -24,7 +24,7 @@ class ImageOCCI < Image
|
||||
<ID><%= self.id.to_s %></ID>
|
||||
<NAME><%= self.name %></NAME>
|
||||
<% if self['TYPE'] != nil %>
|
||||
<TYPE><%= self['TYPE'] %></TYPE>
|
||||
<TYPE><%= self.type_str %></TYPE>
|
||||
<% end %>
|
||||
<% if self['TEMPLATE/DESCRIPTION'] != nil %>
|
||||
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
|
||||
@ -33,7 +33,7 @@ class ImageOCCI < Image
|
||||
<% if self['FSTYPE'] != nil and !self['FSTYPE'].empty? %>
|
||||
<FSTYPE><%= self['FSTYPE'] %></FSTYPE>
|
||||
<% end %>
|
||||
<PUBLIC><%= pub %></PUBLIC>
|
||||
<PUBLIC><%= self.public? ? "YES" : "NO" %></PUBLIC>
|
||||
<PERSISTENT><%= self['PERSISTENT'] == "0" ? "NO" : "YES"%></PERSISTENT>
|
||||
</STORAGE>
|
||||
}
|
||||
@ -82,12 +82,6 @@ class ImageOCCI < Image
|
||||
|
||||
# Creates the OCCI representation of an Image
|
||||
def to_occi(base_url)
|
||||
if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
|
||||
pub = "YES"
|
||||
else
|
||||
pub = "NO"
|
||||
end
|
||||
|
||||
begin
|
||||
occi_im = ERB.new(OCCI_IMAGE)
|
||||
occi_im_text = occi_im.result(binding)
|
||||
|
@ -34,7 +34,7 @@ class VirtualNetworkOCCI < VirtualNetwork
|
||||
<SIZE><%= network_size %></SIZE>
|
||||
<% end %>
|
||||
<USED_LEASES><%= self['TOTAL_LEASES'] %></USED_LEASES>
|
||||
<PUBLIC><%= pub %></PUBLIC>
|
||||
<PUBLIC><%= self.public? ? "YES" : "NO" %></PUBLIC>
|
||||
</NETWORK>
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ require 'sinatra'
|
||||
require 'yaml'
|
||||
require 'erb'
|
||||
require 'tempfile'
|
||||
require 'fileutils'
|
||||
require 'json'
|
||||
|
||||
require 'OCCIServer'
|
||||
@ -255,11 +256,7 @@ end
|
||||
###################################################
|
||||
|
||||
get '/compute/:id' do
|
||||
if params[:id] == "types"
|
||||
result,rc = @occi_server.get_computes_types
|
||||
else
|
||||
result,rc = @occi_server.get_compute(request, params)
|
||||
end
|
||||
result,rc = @occi_server.get_compute(request, params)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
||||
@ -353,9 +350,8 @@ end
|
||||
|
||||
post '/ui/upload' do
|
||||
file = Tempfile.new('uploaded_image')
|
||||
FileUtils.cp(request.env['rack.input'].path,file.path)
|
||||
request.params['file'] = file.path #so we can re-use occi post_storage()
|
||||
file.write(request.env['rack.input'].read)
|
||||
#file.close # this would allow that file is garbage-collected
|
||||
result,rc = @occi_server.post_storage(request)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
@ -427,9 +427,12 @@ function vMachineInfoListener(){
|
||||
|
||||
$('#tbodyvmachines tr',dataTable_vMachines).live("click", function(e){
|
||||
if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
|
||||
popDialogLoading();
|
||||
|
||||
var aData = dataTable_vMachines.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("VM.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -237,10 +237,13 @@ function vNetworkElementArray(vn_json){
|
||||
function vNetworkInfoListener(){
|
||||
|
||||
$('#tbodyvnetworks tr',dataTable_vNetworks).live("click", function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
if ($(e.target).is('input')) {return true;};
|
||||
|
||||
var aData = dataTable_vNetworks.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Network.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -308,9 +308,11 @@ function imageInfoListener(){
|
||||
if (target.is('input') || target.is('select') || target.is('option'))
|
||||
return true;
|
||||
|
||||
popDialogLoading();
|
||||
var aData = dataTable_images.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Image.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -219,6 +219,14 @@ module OpenNebula
|
||||
self['GID'].to_i
|
||||
end
|
||||
|
||||
def public?
|
||||
if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_enabled(enabled)
|
||||
|
@ -154,6 +154,14 @@ module OpenNebula
|
||||
self['UID'].to_i
|
||||
end
|
||||
|
||||
def public?
|
||||
if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_publish(published)
|
||||
|
@ -210,6 +210,14 @@ module OpenNebula
|
||||
SHORT_VN_TYPES[type_str]
|
||||
end
|
||||
|
||||
def public?
|
||||
if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def set_publish(published)
|
||||
group_u = published ? 1 : 0
|
||||
|
@ -233,7 +233,8 @@ module OZones
|
||||
|
||||
# Grant permissions to the vdc admin
|
||||
rule_str << "##{@vdc.VDCADMIN_ID} USER/* CREATE"
|
||||
rule_str << "##{@vdc.VDCADMIN_ID} USER/@#{@vdc.GROUP_ID} USE+MANAGE"
|
||||
rule_str << "##{@vdc.VDCADMIN_ID} USER/@#{@vdc.GROUP_ID} " \
|
||||
"USE+MANAGE+ADMIN"
|
||||
|
||||
###############################################################
|
||||
#When more rules are added the class constant HOST_ACL_FIRST_ID
|
||||
|
@ -234,11 +234,14 @@ function vdcElementArray(vdc_json){
|
||||
}
|
||||
|
||||
function vdcInfoListener() {
|
||||
$("#tbodyvdcs tr").live("click", function(e){
|
||||
$("#tbodyvdcs tr").live("click", function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
|
||||
var aData = dataTable_vdcs.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("VDC.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -244,9 +244,12 @@ function zoneElementArray(zone_json){
|
||||
function zoneInfoListener(){
|
||||
$("#tbodyzones tr").live("click", function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
|
||||
var aData = dataTable_zones.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Zone.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -146,7 +146,7 @@ var acl_buttons = {
|
||||
text: tr("+ New")
|
||||
},
|
||||
"Acl.delete" : {
|
||||
type: "action",
|
||||
type: "confirm",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ var group_buttons = {
|
||||
// },
|
||||
|
||||
"Group.delete" : {
|
||||
type: "action",
|
||||
type: "confirm",
|
||||
text: tr("Delete")
|
||||
}
|
||||
};
|
||||
|
@ -273,7 +273,7 @@ var host_buttons = {
|
||||
text: tr("Disable")
|
||||
},
|
||||
"Host.delete" : {
|
||||
type: "action",
|
||||
type: "confirm",
|
||||
text: tr("Delete host")
|
||||
}
|
||||
};
|
||||
@ -369,9 +369,12 @@ function hostInfoListener(){
|
||||
$('#tbodyhosts tr',dataTable_hosts).live("click",function(e){
|
||||
//do nothing if we are clicking a checkbox!
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
|
||||
var aData = dataTable_hosts.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Host.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -456,7 +456,7 @@ var image_buttons = {
|
||||
}
|
||||
},
|
||||
"Image.delete" : {
|
||||
type: "action",
|
||||
type: "confirm",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
@ -528,9 +528,11 @@ function imageInfoListener(){
|
||||
if (target.is('input') || target.is('select') || target.is('option'))
|
||||
return true;
|
||||
|
||||
popDialogLoading();
|
||||
var aData = dataTable_images.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Image.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -815,7 +815,7 @@ var template_buttons = {
|
||||
}
|
||||
},
|
||||
"Template.delete" : {
|
||||
type: "action",
|
||||
type: "confirm",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
@ -865,9 +865,12 @@ function templateElementArray(template_json){
|
||||
function templateInfoListener(){
|
||||
$('#tbodytemplates tr',dataTable_templates).live("click",function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
|
||||
var aData = dataTable_templates.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Template.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -282,7 +282,7 @@ var user_buttons = {
|
||||
// condition: True
|
||||
// },
|
||||
"User.delete" : {
|
||||
type: "action",
|
||||
type: "confirm",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
|
@ -651,9 +651,12 @@ function vMachineInfoListener(){
|
||||
|
||||
$('#tbodyvmachines tr',dataTable_vMachines).live("click", function(e){
|
||||
if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
|
||||
popDialogLoading();
|
||||
|
||||
var aData = dataTable_vMachines.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("VM.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -401,7 +401,7 @@ var vnet_buttons = {
|
||||
},
|
||||
|
||||
"Network.delete" : {
|
||||
type: "action",
|
||||
type: "confirm",
|
||||
text: tr("Delete")
|
||||
}
|
||||
}
|
||||
@ -457,9 +457,12 @@ function vNetworkInfoListener(){
|
||||
|
||||
$('#tbodyvnetworks tr',dataTable_vNetworks).live("click", function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
popDialogLoading();
|
||||
|
||||
var aData = dataTable_vNetworks.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Network.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
/* Some useful functions for Sunstone default plugins */
|
||||
var INTERVAL=300000; //milisecs
|
||||
var INTERVAL=60000; //milisecs
|
||||
|
||||
function someTime(){
|
||||
return Math.floor(Math.random()*30000);
|
||||
|
@ -252,14 +252,14 @@ class VMwareDriver
|
||||
end
|
||||
|
||||
#Performs a action usgin libvirt
|
||||
def do_action(cmd)
|
||||
def do_action(cmd, log=true)
|
||||
rc = LocalCommand.run(esx_cmd(cmd))
|
||||
|
||||
if rc.code == 0
|
||||
return [true, rc.stdout]
|
||||
else
|
||||
err = "Error executing: #{cmd} err: #{rc.stderr} out: #{rc.stdout}"
|
||||
OpenNebula.log_error(err)
|
||||
OpenNebula.log_error(err) if log
|
||||
return [false, rc.code]
|
||||
end
|
||||
end
|
||||
@ -299,7 +299,7 @@ class VMwareDriver
|
||||
end
|
||||
|
||||
def domain_defined?(one_id)
|
||||
rc, info = do_action("virsh -c #{@uri} dominfo one-#{one_id}")
|
||||
rc, info = do_action("virsh -c #{@uri} dominfo one-#{one_id}", false)
|
||||
|
||||
return rc
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user