Merge branch 'feature-1004' into feature-992

Conflicts:
	src/cloud/occi/etc/occi-server.conf
	src/cloud/occi/lib/OCCIServer.rb
This commit is contained in:
Hector Sanjuan committed 2011-12-13 14:52:16 +01:00
commit ef13f05ca7
252 files changed
+10829 -5209

No files matched your search

+183
View File
@@ -0,0 +1,183 @@
# --------------------------------------------------------------------------
# Copyright 2010-2011, C12G Labs S.L.
#
# This file is part of OpenNebula addons.
#
# OpenNebula addons are free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or the hope That it will be useful, but (at your
# option) any later version.
#
# OpenNebula addons are distributed in WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License
# along with OpenNebula addons. If not, see
# <http://www.gnu.org/licenses/>
# --------------------------------------------------------------------------
require 'acct/watch_helper'
class AcctClient
def initialize(filters={})
@filters=filters
@deltas=[]
@users={}
end
def account(time_start=nil, time_end=nil, user_id=nil)
@filters[:start]=time_start if time_start
@filters[:end]=time_end if time_end
@filters[:user]=user_id if user_id
get_users_consumption
@users
end
private
def get_users_consumption
# Get all the deltas that match the filters
@deltas=calculate_deltas.map {|q| q.values }
@users=slices_by_user
user_slices_and_deltas_to_vms
end
def slices_by_user
# Get all VM slices that match the filters
query=get_vm_slices(@filters)
# This hash will hold the users with the resources consumed
users={}
query.each do |reg|
vm=reg.vm
uid=vm.uid.to_i
# Create a new user register if it still does not exist
user=users[uid]||={
:vm_slices => [],
}
user[:vm_slices] << reg.values
end
users
end
def user_slices_and_deltas_to_vms
@users.each do |user, data|
# Get the VM ids array for this user
vms=data[:vm_slices].map {|vm| vm[:id] }.sort.uniq
data[:vms]={}
vms.each do |vm|
# Get the slices array for this VM
slices=data[:vm_slices].select {|slice| slice[:id]==vm }
data[:vms][vm]={
:slices => [],
:time => 0,
}
# Get the deltas sum for this VM
vm_delta=@deltas.find {|d| d[:vm_id]==vm }
data[:vms][vm][:network]=vm_delta
data[:vms][vm][:vmid]=vm
# Calculate the time consumed by the VM
slices.each do |slice|
data[:vms][vm][:slices] << slice
time=calculate_time(slice,
@filters[:start], @filters[:end])
data[:vms][vm][:time]+=time
end
end
# Delete redundant slices data
data.delete(:vm_slices)
end
end
def get_vm_slices(filters={})
vms=WatchHelper::Register
query=vms.join(:vms, :id => :vm_id)
query=query.filter({:vms__uid => filters[:user]}) if filters[:user]
query=query.filter(
{:retime => 0} | (:retime > filters[:start])) if filters[:start]
query=query.filter(:rstime <= filters[:end]) if filters[:end]
query
end
def get_deltas(filters={})
if filters[:data]
query=filters[:data]
else
query=WatchHelper::VmDelta
end
query=query.filter( :ptimestamp >= filters[:start] ) if filters[:start]
query=query.filter( :ptimestamp <= filters[:end] ) if filters[:end]
query=query.filter( { :vm_id => filters[:vmid] } ) if filters[:vmid]
query
end
def calculate_deltas
query=WatchHelper::VmDelta.select(
:ptimestamp, :vm_id,
'sum(net_tx) AS net_tx'.lit, 'sum(net_rx) AS net_rx'.lit)
query=query.group(:vm_id)
new_filters=@filters.merge(:data => query)
get_deltas(new_filters)
end
def calculate_time(slice, period_start, period_end)
ts=slice[:rstime].to_i
te=slice[:retime].to_i
pstart=period_start.to_i
pend=period_end.to_i
pend=Time.now.to_i if pend==0
ts=pstart if ts<pstart
if te>pend or te==0
te=pend
end
te-ts
end
end
if $0 == __FILE__
require 'json'
acct=AcctClient.new(
:start => 1319476322,
:end => 1319637455
)
a=acct.account()
puts JSON.pretty_generate(a)
end
+14 -6
View File
@@ -107,11 +107,15 @@ class AuthDriver < OpenNebulaDriver
#build path for the auth action
#/var/lib/one/remotes/auth/<driver>/authenticate
authN_path = File.join(@local_scripts_path, driver)
command = File.join(authN_path,ACTION[:authN].downcase)
command << ' ' << user << ' ' << password << ' ' << secret
local_action(command, request_id, ACTION[:authN])
command = File.join(authN_path, ACTION[:authN].downcase)
command << " '" << user.gsub("'", '\'"\'"\'') << "' '" << password.gsub("'", '\'"\'"\'') << "' " << secret
rc = LocalCommand.run(command, log_method(request_id))
result , info = get_info_from_execution(rc)
send_message(ACTION[:authN], result, request_id, info)
end
# Authenticate a user based in a string of the form user:secret when using the
@@ -136,12 +140,16 @@ class AuthDriver < OpenNebulaDriver
result = RESULT[:failure]
end
send_message(ACTION[:authZ],result,request_id,"-")
send_message(ACTION[:authZ], result, request_id, "-")
else
command = @authZ_cmd.clone
command << ' ' << user_id << ' ' << requests.join(' ')
local_action(command, request_id, ACTION[:authZ])
rc = LocalCommand.run(command, log_method(request_id))
result , info = get_info_from_execution(rc)
send_message(ACTION[:authZ], result, request_id, info)
end
end
end
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/ruby
# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ---------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"]
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
ETC_LOCATION="/etc/one/"
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
ETC_LOCATION=ONE_LOCATION+"/etc/"
end
$: << RUBY_LIB_LOCATION
require 'yaml'
require 'ldap_auth'
user=ARGV[0]
pass=ARGV[1]
secret=ARGV[2]
options=YAML.load(File.read(ETC_LOCATION+'/auth/ldap_auth.conf'))
ldap=LdapAuth.new(options)
user_name=ldap.find_user(user)
if !user_name
STDERR.puts "User #{user} not found"
exit(-1)
end
if options[:group]
if !ldap.is_in_group?(user_name, options[:group])
STDERR.puts "User #{user} is not in group #{options[:group]}"
exit(-1)
end
end
if ldap.authenticate(user_name, secret)
puts "ldap #{user} #{user_name}"
exit(0)
else
STDERR.puts "Bad user/password"
exit(-1)
end
+35
View File
@@ -0,0 +1,35 @@
# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ---------------------------------------------------------------------------- #
# Ldap user able to query, if not set connects as anonymous
#:user: 'admin'
#:password: 'password'
# Ldap authentication method
:auth_method: :simple
# Ldap server
:host: localhost
:port: 389
# base hierarchy where to search for users and groups
:base: 'dc=domain'
# group the users need to belong to. If not set any user will do
:group: 'cn=cloud,ou=groups,dc=domain'
# field that holds the user name, if not set 'cn' will be used
:user_field: 'cn'
+96
View File
@@ -0,0 +1,96 @@
# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ---------------------------------------------------------------------------- #
require 'rubygems'
require 'net/ldap'
class LdapAuth
def initialize(options)
@options={
:host => 'localhost',
:port => 389,
:user => nil,
:password => nil,
:base => nil,
:auth_method => :simple,
:user_field => 'cn'
}.merge(options)
ops={}
if @options[:user]
ops[:auth] = {
:method => @options[:auth_method],
:username => @options[:user],
:password => @options[:password]
}
end
ops[:host]=@options[:host] if @options[:host]
ops[:port]=@options[:port].to_i if @options[:port]
@ldap=Net::LDAP.new(ops)
end
def find_user(name)
begin
result=@ldap.search(
:base => @options[:base],
:filter => "#{@options[:user_field]}=#{name}")
if result && result.first
result.first.dn
else
result=@ldap.search(:base => name)
if result && result.first
name
else
nil
end
end
rescue
nil
end
end
def is_in_group?(user, group)
result=@ldap.search(:base => group, :filter => "(member=#{user})")
if result && result.first
true
else
false
end
end
def authenticate(user, password)
ldap=@ldap.clone
auth={
:method => @options[:auth_method],
:username => user,
:password => password
}
if ldap.bind(auth)
true
else
false
end
end
end
@@ -0,0 +1,70 @@
# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ---------------------------------------------------------------------------- #
$: << ".."
require 'ldap_auth'
options={
:host => 'ubuntu-test',
:base => 'dc=localdomain'
}
describe LdapAuth do
before(:all) do
@ldap=LdapAuth.new(options)
end
it 'should find user dn' do
name=@ldap.find_user('user01')
name.should=='cn=user01,dc=localdomain'
name=@ldap.find_user('user02')
name.should=='cn=user02,dc=localdomain'
name=@ldap.find_user('user03')
name.should==nil
name=@ldap.find_user('cn=user01,dc=localdomain')
name.should=='cn=user01,dc=localdomain'
end
it 'should tell if a user is in a group' do
group='cn=cloud,ou=groups,dc=localdomain'
result=@ldap.is_in_group?('cn=user01,dc=localdomain', group)
result.should==true
result=@ldap.is_in_group?('cn=user02,dc=localdomain', group)
result.should==false
end
it 'should authenticate user' do
result=@ldap.authenticate('cn=user01,dc=localdomain', 'password01')
result.should==true
result=@ldap.authenticate('cn=user02,dc=localdomain', 'password02')
result.should==true
result=@ldap.authenticate('cn=user01,dc=localdomain', 'password02')
result.should==false
result=@ldap.authenticate('user01,dc=localdomain', 'password01')
result.should==false
end
end
+32 -2
View File
@@ -78,7 +78,29 @@ class Quota
IMAGE_USAGE = {
:STORAGE => {
:proc_info => lambda {|template| File.size(template['PATH']) },
:proc_info => lambda {|template|
if template['TYPE'] == 'DATABLOCK'
template['SIZE'].to_i
elsif template['PATH']
File.size(template['PATH'])
elsif template['SAVED_VM_ID']
vm_id = template['SAVED_VM_ID'].to_i
disk_id = template['SAVED_DISK_ID'].to_i
client = OpenNebula::Client.new
vm = OpenNebula::VirtualMachine.new_with_id(vm_id, client)
vm.info
im_id = vm["DISK[DISK_ID=#{disk_id}]/IMAGE_ID"].to_i
im = OpenNebula::Image.new_with_id(im_id, client)
im.info
im['SIZE'].to_i
else
0
end
},
:xpath => 'SIZE'
}
}
@@ -91,7 +113,15 @@ class Quota
def initialize
conf = YAML.load_file(CONF_FILE)
@conf=CONF.merge(conf) {|key,h1,h2|
h1.merge(h2) if h1.instance_of?(Hash) && h2.instance_of?(Hash)
if h1.instance_of?(Hash) && h2.instance_of?(Hash)
h1.merge(h2)
else
if h2
h2
else
h1
end
end
}
@client = OpenNebula::Client.new
+1 -1
View File
@@ -21,7 +21,7 @@ include OpenNebula
module OpenNebulaHelper
ONE_VERSION=<<-EOT
OpenNebula 3.1.0
OpenNebula 3.1.80
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
Licensed under the Apache License, Version 2.0 (the "License"); you may
+1
View File
@@ -59,6 +59,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
puts str % ["STATE", host.state_str]
puts str % ["IM_MAD", host['IM_MAD']]
puts str % ["VM_MAD", host['VM_MAD']]
puts str % ["VN_MAD", host['VN_MAD']]
puts str % ["TM_MAD", host['TM_MAD']]
puts str % ["LAST MONITORING TIME", host['LAST_MON_TIME']]
puts
+3 -3
View File
@@ -37,14 +37,14 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
return -1, "Can not read file: #{arg}"
end
else
password = arg
password = arg.dup
end
if options[:driver] == OpenNebula::User::X509_AUTH
password.delete!("\s")
end
if options[:sha1]
if options[:sha1] || options[:driver] == OpenNebula::User::CIPHER_AUTH
require 'digest/sha1'
password = Digest::SHA1.hexdigest(password)
end
@@ -166,7 +166,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
CLIHelper.print_header(str_h1 % "USER #{user['ID']} INFORMATION")
puts str % ["ID", user.id.to_s]
puts str % ["NAME", user.name]
puts str % ["GROUP", user.gid]
puts str % ["GROUP", user['GNAME']]
puts str % ["PASSWORD", user['PASSWORD']]
puts str % ["AUTH_DRIVER", user['AUTH_DRIVER']]
+2 -1
View File
@@ -99,9 +99,10 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false)
puts vm.template_str
if vm['/VM/HISTORY_RECORDS/HISTORY']
if vm.has_elements?("/VM/HISTORY_RECORDS")
puts
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE HISTORY",false)
format_history(vm)
end
+22 -6
View File
@@ -59,6 +59,9 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
puts str % ["PUBLIC", OpenNebulaHelper.boolean_to_str(vn['PUBLIC'])]
puts str % ["TYPE", vn.type_str]
puts str % ["BRIDGE", vn["BRIDGE"]]
puts str % ["VLAN", OpenNebulaHelper.boolean_to_str(vn['VLAN'])]
puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if vn["PHYDEV"]
puts str % ["VLAN ID", vn["VLAN_ID"]] if vn["VLAN_ID"]
puts str % ["USED LEASES", vn['TOTAL_LEASES']]
puts
@@ -66,13 +69,26 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
puts vn.template_str(false)
leases_str = vn.template_like_str('/VNET/LEASES', false)
if !leases_str.empty?
if vn.type_str == "RANGED"
puts
CLIHelper.print_header(str_h1 % ["LEASES INFORMATION"], false)
puts leases_str
CLIHelper.print_header(str_h1 % ["RANGE"], false)
puts str % ["IP_START", vn['RANGE/IP_START']]
puts str % ["IP_END", vn['RANGE/IP_END']]
end
lease_types = [ ["LEASES ON HOLD", 'LEASE[USED=1 and VID=-1]'],
["USED LEASES", 'LEASE[USED=1 and VID>-1]'],
["FREE LEASES", 'LEASE[USED=0]'] ]
lease_types.each { |pair|
leases_str = vn.template_like_str('/VNET/LEASES', false, pair[1])
if !leases_str.empty?
puts
CLIHelper.print_header(str_h1 % [pair[0]], false)
puts leases_str
end
}
end
def format_pool(options)
@@ -126,4 +142,4 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
table
end
end
end
+235
View File
@@ -0,0 +1,235 @@
#!/usr/bin/env ruby
# --------------------------------------------------------------------------
# Copyright 2010-2011, C12G Labs S.L.
#
# This file is part of OpenNebula addons.
#
# OpenNebula addons are free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or the hope That it will be useful, but (at your
# option) any later version.
#
# OpenNebula addons are distributed in WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License
# along with OpenNebula addons. If not, see
# <http://www.gnu.org/licenses/>
# --------------------------------------------------------------------------
ONE_LOCATION=ENV['ONE_LOCATION']
$: << ONE_LOCATION+'/lib/ruby'
$: << ONE_LOCATION+'/lib/ruby/cli'
require 'rubygems'
require 'acct/oneacct'
require 'cli/one_helper'
require 'cli/command_parser'
require 'json'
require 'optparse'
require 'optparse/time'
REG_DATE=/((\d{4})\/)?(\d\d?)(\/(\d\d?))?/
REG_TIME=/(\d\d?):(\d\d?)(:(\d\d?))?/
class AcctHelper
def format_vm(options=nil)
table = CLIHelper::ShowTable.new(nil, nil) do
column :VMID, "VM ID", :size=>4 do |d|
d[:vmid]
end
column :MEMORY, "Consumed memory", :right, :size=>8 do |d|
OpenNebulaHelper.unit_to_str(
d[:slices].first[:mem]*1024,
{})
end
column :CPU, "Group of the User", :right, :size=>8 do |d|
d[:slices].first[:cpu]
end
column :NETRX, "Group of the User", :right, :size=>10 do |d|
OpenNebulaHelper.unit_to_str(
d[:network][:net_rx]/1024.0,
{})
end
column :NETTX, "Group of the User", :right, :size=>10 do |d|
OpenNebulaHelper.unit_to_str(
d[:network][:net_tx]/1024.0,
{})
end
column :TIME, "Group of the User", :right, :size=>15 do |d|
OpenNebulaHelper.time_to_str(d[:time])
end
default :VMID, :MEMORY, :CPU, :NETRX, :NETTX, :TIME
end
table
end
def list_vms(data)
format_vm().show(data)
end
def list_users(filters)
a=gen_accounting(filters)
a.each do |user, data|
CLIHelper.scr_bold
CLIHelper.scr_underline
puts "# User #{user}"
CLIHelper.scr_restore
puts
vms=data[:vms].map do |k, v|
v
end
self.list_vms(vms)
puts
puts
end
end
def gen_accounting(filters)
acct=AcctClient.new(filters)
acct.account()
end
def gen_json(filters)
begin
require 'json'
rescue LoadError
STDERR.puts "JSON gem is needed to give the result in this format"
exit(-1)
end
acct=gen_accounting(filters)
acct.to_json
end
def xml_tag(tag, value)
"<#{tag}>#{value}</#{tag}>\n"
end
def gen_xml(filters)
acct=gen_accounting(filters)
xml=""
acct.each do |user, data|
xml<<"<user id=\"#{user}\">\n"
data[:vms].each do |vmid, vm|
xml<<" <vm id=\"#{vmid}\">\n"
xml<<" "<<xml_tag(:name, vm[:name])
xml<<" "<<xml_tag(:time, vm[:time])
xml<<" "<<xml_tag(:cpu, vm[:slices].first[:cpu])
xml<<" "<<xml_tag(:mem, vm[:slices].first[:mem])
xml<<" "<<xml_tag(:net_rx, vm[:network][:net_rx])
xml<<" "<<xml_tag(:net_tx, vm[:network][:net_tx])
vm[:slices].each do |slice|
xml<<" <slice seq=\"#{slice[:seq]}\">\n"
slice.each do |key, value|
xml<<" "<<xml_tag(key, value)
end
xml<<" </slice>\n"
end
xml<<" </vm>\n"
end
xml<<"</user>\n"
end
xml
end
end
@options=Hash.new
@options[:format]=:table
opts=OptionParser.new do |opts|
opts.on('-s', '--start TIME', Time,
'Start date and time to take into account') do |ext|
@options[:start]=ext
end
opts.on("-e", "--end TIME", Time,
"End date and time" ) do |ext|
@options[:end]=ext
end
opts.on("-u", "--user user", Integer,
"User id to make accounting" ) do |ext|
@options[:user]=ext.to_i
end
opts.on("-j", "--json",
"Output in json format" ) do |ext|
@options[:format]=:json
end
opts.on("-x", "--xml",
"Output in xml format" ) do |ext|
@options[:format]=:xml
end
opts.on()
end
begin
opts.parse!(ARGV)
rescue OptionParser::ParseError => e
STDERR.puts "Error: " << e.message
exit(-1)
end
acct_helper=AcctHelper.new
filters=Hash.new
filters[:start]=@options[:start].to_i if @options[:start]
filters[:end]=@options[:end].to_i if @options[:end]
filters[:user]=@options[:user].to_i if @options[:user]
case @options[:format]
when :table
acct_helper.list_users(filters)
when :json
puts acct_helper.gen_json(filters)
when :xml
puts acct_helper.gen_xml(filters)
end
+3 -2
View File
@@ -60,9 +60,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
Creates a new Host
EOT
command :create, create_desc, :hostname, :im_mad, :vmm_mad, :tm_mad do
command :create, create_desc, :hostname, :im_mad, :vmm_mad,
:tm_mad, :vnm_mad do
helper.create_resource(options) do |host|
host.allocate(args[0], args[1], args[2], args[3])
host.allocate(args[0], args[1], args[2], args[4], args[3])
end
end
+17 -3
View File
@@ -275,11 +275,25 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
chauth_desc = <<-EOT.unindent
Changes the User's auth driver
Changes the User's auth driver and its password (optional)
Examples:
oneuser chauth my_user core
oneuser chauth my_user core new_password
oneuser chauth my_user core -r /tmp/mypass
oneuser chauth my_user --ssh --key /home/oneadmin/.ssh/id_rsa
oneuser chauth my_user --ssh -r /tmp/public_key
oneuser chauth my_user --x509 --cert /tmp/my_cert.pem
EOT
command :chauth, chauth_desc, :userid, :auth, [:password, nil],
command :chauth, chauth_desc, :userid, [:auth, nil], [:password, nil],
:options=>create_options do
if options[:driver]
driver = options[:driver]
elsif args[1]
driver = args[1]
else
exit_with_code 0, "An Auth driver should be specified"
end
helper = OneUserHelper.new
@@ -297,7 +311,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
helper.perform_action(args[0],
options,
"Auth driver and password changed") do |user|
user.chauth(args[1], pass)
user.chauth(driver, pass)
end
end
+23 -4
View File
@@ -93,8 +93,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
Adds a lease to the Virtual Network
EOT
command :addleases, 'Adds a lease to the Virtual Network', :vnetid, :ip,
[:mac, nil] do
command :addleases, addleases_desc, :vnetid, :ip, [:mac, nil] do
helper.perform_action(args[0],options,"lease added") do |vn|
vn.addleases(args[1], args[2])
end
@@ -110,6 +109,26 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
hold_desc = <<-EOT.unindent
Holds a Virtual Network lease, marking it as used
EOT
command :hold, hold_desc, :vnetid, :ip do
helper.perform_action(args[0],options,"lease on hold") do |vn|
vn.hold(args[1])
end
end
release_desc = <<-EOT.unindent
Releases a Virtual Network lease on hold
EOT
command :release, release_desc, :vnetid, :ip do
helper.perform_action(args[0],options,"lease released") do |vn|
vn.release(args[1])
end
end
publish_desc = <<-EOT.unindent
Publishes the given Virtual Network. A public Virtual Network can be
seen and used by other Users in the Virtual Network's group
@@ -136,7 +155,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 +165,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|
+29 -18
View File
@@ -33,7 +33,8 @@ class CloudAuth
# Default interval for timestamps. Tokens will be generated using the same
# timestamp for this interval of time.
EXPIRE_DELTA = 36000
# THIS VALUE CANNOT BE LOWER THAN EXPIRE_MARGIN
EXPIRE_DELTA = 1800
# Tokens will be generated if time > EXPIRE_TIME - EXPIRE_MARGIN
EXPIRE_MARGIN = 300
@@ -44,8 +45,7 @@ class CloudAuth
def initialize(conf)
@conf = conf
@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 + EXPIRE_DELTA
if AUTH_MODULES.include?(@conf[:auth])
require 'CloudAuth/' + AUTH_MODULES[@conf[:auth]]
@@ -64,27 +64,47 @@ class CloudAuth
begin
require core_auth[0]
@server_auth = Kernel.const_get(core_auth[1]).new_client
token = @server_auth.login_token(expiration_time)
@oneadmin_client ||= OpenNebula::Client.new(token, @conf[:one_xmlrpc])
rescue => e
raise e.message
end
end
def client(username)
# Generate a new OpenNebula client for the target User, if the username
# is nil the Client is generated for the server_admin
# ussername:: _String_ Name of the User
# [return] _Client_
def client(username=nil)
token = @server_auth.login_token(expiration_time,username)
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
def auth(env, params={})
username = do_auth(env, params)
if username.nil?
update_userpool_cache
do_auth(env, params)
else
username
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
@token_expiration_time = time_now + EXPIRE_DELTA
end
@token_expiration_time
@@ -96,15 +116,6 @@ class CloudAuth
@user_pool
end
def update_userpool_cache
@user_pool ||= OpenNebula::UserPool.new(@oneadmin_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"
+1 -1
View File
@@ -15,7 +15,7 @@
#--------------------------------------------------------------------------- #
module EC2CloudAuth
def auth(env, params={})
def do_auth(env, params={})
username = params['AWSAccessKeyId']
one_pass = get_password(username)
return nil unless one_pass
+3 -3
View File
@@ -15,7 +15,7 @@
#--------------------------------------------------------------------------- #
module OCCICloudAuth
def auth(env, params={})
def do_auth(env, params={})
auth = Rack::Auth::Basic::Request.new(env)
if auth.provided? && auth.basic?
@@ -28,6 +28,6 @@ module OCCICloudAuth
end
end
return nil
end
return nil
end
end
@@ -15,7 +15,7 @@
#--------------------------------------------------------------------------- #
module SunstoneCloudAuth
def auth(env, params={})
def do_auth(env, params={})
auth = Rack::Auth::Basic::Request.new(env)
if auth.provided? && auth.basic?
@@ -28,6 +28,6 @@ module SunstoneCloudAuth
end
end
return nil
end
return nil
end
end
+1 -1
View File
@@ -15,7 +15,7 @@
#--------------------------------------------------------------------------- #
module X509CloudAuth
def auth(env, params={})
def do_auth(env, params={})
# For https, the web service should be set to include the user cert in the environment.
cert_line = env['HTTP_SSL_CLIENT_CERT']
cert_line = nil if cert_line == '(null)' # For Apache mod_ssl
+1 -1
View File
@@ -173,7 +173,7 @@ module CloudCLI
def version_text
version=<<EOT
OpenNebula 3.1.0
OpenNebula 3.1.80
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
Licensed under the Apache License, Version 2.0 (the "License"); you may
-2
View File
@@ -33,8 +33,6 @@
# cipher, for symmetric cipher encryption of tokens
# x509, for x509 certificate encryption of tokens
:core_auth: cipher
# Life-time in seconds for token renewal (that used to handle OpenNebula auths)
:token_expiration_delta: 1800
# VM types allowed and its template file (inside templates directory)
:instance_types:
-3
View File
@@ -24,9 +24,6 @@
# SSL proxy that serves the API (set if is being used)
#:ssl_server: fqdm.of.the.server
# Configuration for OpenNebula's Virtual Networks
#:bridge: NAME_OF_DEFAULT_BRIDGE
# Authentication driver for incomming requests
# occi, for OpenNebula's user-password scheme
# x509, for x509 certificates based authentication
+25
View File
@@ -0,0 +1,25 @@
#
# This template is processed by the OCCI Server to include specific data for
# the VNET, you should not need to modify the ruby code.
# You can add common attributes for your VNET templates (e.g. VLAN, PHYDEV)
#
NAME = "<%= @vnet_info['NAME'] %>"
TYPE = RANGED
NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %>
<% if @vnet_info['SIZE'] != nil %>
NETWORK_SIZE = <%= @vnet_info['SIZE']%>
<% end %>
<% if @vnet_info['DESCRIPTION'] != nil %>
DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>"
<% end %>
<% if @vnet_info['PUBLIC'] != nil %>
PUBLIC = "<%= @vnet_info['PUBLIC'] %>"
<% end %>
#BRIDGE = NAME_OF_DEFAULT_BRIDGE
#PHYDEV = NAME_OF_PHYSICAL_DEVICE
#VLAN = YES|NO
+9 -18
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 and !self['FSTYPE'].empty? %>
<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)
+41 -75
View File
@@ -40,6 +40,9 @@ require 'pp'
COLLECTIONS = ["compute", "instance_type", "network", "storage"]
# FLAG that will filter the elements retrieved from the Pools
POOL_FILTER = Pool::INFO_GROUP
class OCCIServer < CloudServer
# Server initializer
# config_file:: _String_ path of the config file
@@ -109,21 +112,14 @@ class OCCIServer < CloudServer
# [return] _String_,_Integer_ Pool Representation or error, status code
def get_computes(request)
# --- Get User's VMs ---
user_flag = -1
vmpool = VirtualMachinePoolOCCI.new(
@client,
user_flag)
POOL_FILTER)
# --- Prepare XML Response ---
rc = vmpool.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(vmpool, 200)
@@ -136,21 +132,14 @@ class OCCIServer < CloudServer
# => status code
def get_networks(request)
# --- Get User's VNETs ---
user_flag = -1
network_pool = VirtualNetworkPoolOCCI.new(
@client,
user_flag)
POOL_FILTER)
# --- Prepare XML Response ---
rc = network_pool.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(network_pool, 200)
@@ -162,21 +151,14 @@ class OCCIServer < CloudServer
# status code
def get_storages(request)
# --- Get User's Images ---
user_flag = -1
image_pool = ImagePoolOCCI.new(
@client,
user_flag)
POOL_FILTER)
# --- Prepare XML Response ---
rc = image_pool.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(image_pool, 200)
@@ -192,7 +174,6 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = user_pool.info
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
@@ -227,7 +208,9 @@ class OCCIServer < CloudServer
return template, 500 if OpenNebula.is_error?(template)
rc = vm.allocate(template)
return rc, 500 if OpenNebula.is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
vm.info
@@ -246,13 +229,8 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = vm.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(vm, 200)
@@ -269,12 +247,11 @@ class OCCIServer < CloudServer
VirtualMachine.build_xml(params[:id]),
@client)
rc = vm.info
return rc, 404 if OpenNebula::is_error?(rc)
# --- Finalize the VM ---
result = vm.finalize
return result, 500 if OpenNebula::is_error?(result)
if OpenNebula.is_error?(result)
return result, CloudServer::HTTP_ERROR_CODE[result.errno]
end
return "", 204
end
@@ -317,14 +294,16 @@ class OCCIServer < CloudServer
VirtualNetwork.build_xml,
@client,
request.body,
@config[:bridge])
@config[:template_location])
# --- Generate the template and Allocate the new Instance ---
template = network.to_one_template
return template, 500 if OpenNebula.is_error?(template)
rc = network.allocate(template)
return rc, 500 if OpenNebula.is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
network.info
@@ -342,13 +321,8 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = network.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return to_occi_xml(network, 200)
@@ -363,12 +337,11 @@ class OCCIServer < CloudServer
VirtualNetwork.build_xml(params[:id]),
@client)
rc = network.info
return rc, 404 if OpenNebula::is_error?(rc)
# --- Delete the VNET ---
rc = network.delete
return rc, 500 if OpenNebula::is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return "", 204
end
@@ -385,15 +358,15 @@ class OCCIServer < CloudServer
VirtualNetwork.build_xml(params[:id]),
@client)
rc = vnet.info
return rc, 400 if OpenNebula.is_error?(rc)
rc = nil
if vnet_info['PUBLIC'] == 'YES'
rc = vnet.publish
return rc, 400 if OpenNebula.is_error?(rc)
elsif vnet_info['PUBLIC'] == 'NO'
rc = vnet.unpublish
return rc, 400 if OpenNebula.is_error?(rc)
end
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
@@ -432,7 +405,9 @@ class OCCIServer < CloudServer
return template, 500 if OpenNebula.is_error?(template)
rc = image.allocate(template)
return rc, 500 if OpenNebula.is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
image.info
@@ -450,13 +425,8 @@ class OCCIServer < CloudServer
@client)
rc = image.info
if OpenNebula.is_error?(rc)
if rc.message.match("Error getting")
return rc, 404
else
return rc, 500
end
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
@@ -473,12 +443,11 @@ class OCCIServer < CloudServer
Image.build_xml(params[:id]),
@client)
rc = image.info
return rc, 404 if OpenNebula::is_error?(rc)
# --- Delete the Image ---
rc = image.delete
return rc, 500 if OpenNebula::is_error?(rc)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
return "", 204
end
@@ -495,24 +464,22 @@ class OCCIServer < CloudServer
Image.build_xml(params[:id]),
@client)
rc = image.info
return rc, 400 if OpenNebula.is_error?(rc)
rc = nil
if image_info['PERSISTENT'] && image_info['PUBLIC']
error_msg = "It is not allowed more than one change per request"
return OpenNebula::Error.new(error_msg), 400
elsif image_info['PERSISTENT'] == 'YES'
rc = image.persistent
return rc, 400 if OpenNebula.is_error?(rc)
elsif image_info['PERSISTENT'] == 'NO'
rc = image.nonpersistent
return rc, 400 if OpenNebula.is_error?(rc)
elsif image_info['PUBLIC'] == 'YES'
rc = image.publish
return rc, 400 if OpenNebula.is_error?(rc)
elsif image_info['PUBLIC'] == 'NO'
rc = image.unpublish
return rc, 400 if OpenNebula.is_error?(rc)
end
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
@@ -532,7 +499,6 @@ class OCCIServer < CloudServer
# --- Prepare XML Response ---
rc = user.info
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
+2 -2
View File
@@ -100,11 +100,11 @@ class VirtualMachineOCCI < VirtualMachine
def to_one_template()
if @vm_info == nil
error_msg = "Missing COMPUTE section in the XML body"
return OpenNebula::Error.new(error_msg), 400
return OpenNebula::Error.new(error_msg)
end
if @template == nil
return OpenNebula::Error.new("Bad instance type"), 500
return OpenNebula::Error.new("Bad instance type")
end
begin
+30 -24
View File
@@ -15,6 +15,7 @@
#--------------------------------------------------------------------------- #
require 'OpenNebula'
require 'ipaddr'
include OpenNebula
@@ -26,35 +27,23 @@ class VirtualNetworkOCCI < VirtualNetwork
<% if self['TEMPLATE/DESCRIPTION'] != nil %>
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
<% end %>
<ADDRESS><%= self['TEMPLATE/NETWORK_ADDRESS'] %></ADDRESS>
<% if self['TEMPLATE/NETWORK_SIZE'] %>
<SIZE><%= self['TEMPLATE/NETWORK_SIZE'] %></SIZE>
<% if network_address != nil %>
<ADDRESS><%= network_address %></ADDRESS>
<% end %>
<% if network_size != nil %>
<SIZE><%= network_size %></SIZE>
<% end %>
<USED_LEASES><%= self['TOTAL_LEASES'] %></USED_LEASES>
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
</NETWORK>
}
ONE_NETWORK = %q{
NAME = "<%= @vnet_info['NAME'] %>"
TYPE = RANGED
<% if @vnet_info['DESCRIPTION'] != nil %>
DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>"
<% end %>
<% if @vnet_info['PUBLIC'] != nil %>
PUBLIC = "<%= @vnet_info['PUBLIC'] %>"
<% end %>
<% if @bridge %>
BRIDGE = <%= @bridge %>
<% end %>
NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %>
NETWORK_SIZE = <%= @vnet_info['SIZE']%>
}.gsub(/^ /, '')
# Class constructor
def initialize(xml, client, xml_info=nil, bridge=nil)
#
def initialize(xml, client, xml_info=nil, base=nil)
super(xml, client)
@bridge = bridge
@vnet_info = nil
@common_template = base + '/network.erb' if base
if xml_info != nil
xmldoc = XMLElement.build_xml(xml_info, 'NETWORK')
@@ -64,6 +53,18 @@ class VirtualNetworkOCCI < VirtualNetwork
# Creates the OCCI representation of a Virtual Network
def to_occi(base_url)
network_address = nil
network_size = nil
if self['RANGE/IP_START']
network_address = self['RANGE/IP_START']
ip_start = IPAddr.new(network_address, Socket::AF_INET)
ip_end = IPAddr.new(self['RANGE/IP_END'], Socket::AF_INET)
network_size = ip_end.to_i - ip_start.to_i
end
begin
occi = ERB.new(OCCI_NETWORK)
occi_text = occi.result(binding)
@@ -78,11 +79,16 @@ class VirtualNetworkOCCI < VirtualNetwork
def to_one_template()
if @vnet_info == nil
error_msg = "Missing NETWORK section in the XML body"
error = OpenNebula::Error.new(error_msg)
return OpenNebula::Error.new(error_msg), 400
end
begin
template = ERB.new(File.read(@common_template)).result(binding)
rescue Exception => e
error = OpenNebula::Error.new(e.message)
return error
end
one = ERB.new(ONE_NETWORK)
return one.result(binding)
return template
end
end
+4
View File
@@ -33,11 +33,13 @@ Host::Host(
const string& _hostname,
const string& _im_mad_name,
const string& _vmm_mad_name,
const string& _vnm_mad_name,
const string& _tm_mad_name):
PoolObjectSQL(id,_hostname,-1,-1,"","",table),
state(INIT),
im_mad_name(_im_mad_name),
vmm_mad_name(_vmm_mad_name),
vnm_mad_name(_vnm_mad_name),
tm_mad_name(_tm_mad_name),
last_monitored(0)
{
@@ -200,6 +202,7 @@ string& Host::to_xml(string& xml) const
"<STATE>" << state << "</STATE>" <<
"<IM_MAD>" << im_mad_name << "</IM_MAD>" <<
"<VM_MAD>" << vmm_mad_name << "</VM_MAD>" <<
"<VN_MAD>" << vnm_mad_name << "</VN_MAD>" <<
"<TM_MAD>" << tm_mad_name << "</TM_MAD>" <<
"<LAST_MON_TIME>" << last_monitored << "</LAST_MON_TIME>" <<
host_share.to_xml(share_xml) <<
@@ -231,6 +234,7 @@ int Host::from_xml(const string& xml)
rc += xpath(im_mad_name, "/HOST/IM_MAD", "not_found");
rc += xpath(vmm_mad_name, "/HOST/VM_MAD", "not_found");
rc += xpath(vnm_mad_name, "/HOST/VN_MAD", "not_found");
rc += xpath(tm_mad_name, "/HOST/TM_MAD", "not_found");
rc += xpath(last_monitored, "/HOST/LAST_MON_TIME", 0);
+12 -1
View File
@@ -139,6 +139,7 @@ int HostPool::allocate (
const string& hostname,
const string& im_mad_name,
const string& vmm_mad_name,
const string& vnm_mad_name,
const string& tm_mad_name,
string& error_str)
{
@@ -165,6 +166,11 @@ int HostPool::allocate (
goto error_vmm;
}
if ( vnm_mad_name.empty() )
{
goto error_vnm;
}
if ( tm_mad_name.empty() )
{
goto error_tm;
@@ -179,7 +185,8 @@ int HostPool::allocate (
// Build a new Host object
host = new Host(-1, hostname, im_mad_name, vmm_mad_name, tm_mad_name);
host = new Host(-1, hostname, im_mad_name, vmm_mad_name, vnm_mad_name,
tm_mad_name);
// Insert the Object in the pool
@@ -204,6 +211,10 @@ error_vmm:
oss << "VMM_MAD_NAME cannot be empty.";
goto error_common;
error_vnm:
oss << "VNM_MAD_NAME cannot be empty.";
goto error_common;
error_tm:
oss << "TM_MAD_NAME cannot be empty.";
goto error_common;
+4 -4
View File
@@ -96,7 +96,7 @@ public:
{
string err;
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
CPPUNIT_ASSERT( oid >= 0 );
sleep(1);
@@ -114,7 +114,7 @@ public:
{
string err;
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
CPPUNIT_ASSERT( oid >= 0 );
host = hpool->get(oid, true);
@@ -140,7 +140,7 @@ public:
{
string err;
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
CPPUNIT_ASSERT( oid >= 0 );
host = hpool->get(oid, true);
@@ -166,7 +166,7 @@ public:
{
string err;
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
CPPUNIT_ASSERT( oid >= 0 );
host = hpool->get(oid, true);
+26 -25
View File
@@ -25,6 +25,7 @@ using namespace std;
const string im_mad = "im_mad";
const string vmm_mad = "vmm_mad";
const string vnm_mad = "vnm_mad";
const string tm_mad = "tm_mad";
const string names[] = {"Host one", "Second host"};
@@ -32,7 +33,7 @@ const string names[] = {"Host one", "Second host"};
const string xmls[] =
{
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE>"
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD>"
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD>"
"<LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE>"
"<DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE>"
"<MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU>"
@@ -41,7 +42,7 @@ const string xmls[] =
"<RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST>",
"<HOST><ID>1</ID><NAME>Second host</NAME><STATE>0</STATE>"
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD>"
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD>"
"<LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE>"
"<DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE>"
"<MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU>"
@@ -53,34 +54,34 @@ const string xmls[] =
// This xml dump result has the LAST_MON_TIMEs modified to 0000000000
const string xml_dump =
"<HOST_POOL><HOST><ID>0</ID><NAME>a</NAME><STATE>0</STATE><IM_MAD>im_mad</I"
"M_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
"M_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
"</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM"
"_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM"
">0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_"
"MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><U"
"SED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST>"
"<ID>1</ID><NAME>a name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MA"
"D>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
"D>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
"ON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</ME"
"M_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM>"
"<MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CP"
"U>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</U"
"SED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>2</ID><N"
"AME>a_name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</V"
"M_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
"M_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
"T_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU"
"_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</"
"MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CP"
"U><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUN"
"NING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>3</ID><NAME>another "
"name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD>"
"<TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
"<VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
"E><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE"
">0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CP"
"U><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USE"
"D_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_V"
"MS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>4</ID><NAME>host</NAME><ST"
"ATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad"
"ATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad"
"</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE>"
"<DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE>"
"<MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0"
@@ -90,28 +91,28 @@ const string xml_dump =
const string xml_dump_like_a =
"<HOST_POOL><HOST><ID>0</ID><NAME>a</NAME><STATE>0</STATE><IM_MAD>im_mad</I"
"M_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
"M_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
"</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM"
"_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM"
">0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_"
"MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><U"
"SED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST>"
"<ID>1</ID><NAME>a name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MA"
"D>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
"D>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
"ON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</ME"
"M_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM>"
"<MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CP"
"U>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</U"
"SED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>2</ID><N"
"AME>a_name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</V"
"M_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
"M_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
"T_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU"
"_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</"
"MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CP"
"U><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUN"
"NING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>3</ID><NAME>another "
"name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD>"
"<TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
"<VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
"E><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE"
">0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CP"
"U><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USE"
@@ -119,10 +120,10 @@ const string xml_dump_like_a =
"MS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST></HOST_POOL>";
const string host0_updated =
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE><ATT_A><![CDATA[VALUE_A]]></ATT_A><ATT_B><![CDATA[VALUE_B]]></ATT_B></TEMPLATE></HOST>";
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE><ATT_A><![CDATA[VALUE_A]]></ATT_A><ATT_B><![CDATA[VALUE_B]]></ATT_B></TEMPLATE></HOST>";
const string host_0_cluster =
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><CLUSTER>cluster_a</CLUSTER><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST>";
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><CLUSTER>cluster_a</CLUSTER><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST>";
/* ************************************************************************* */
/* ************************************************************************* */
@@ -162,7 +163,7 @@ protected:
int oid;
string err;
return ((HostPool*)pool)->allocate(&oid, names[index], im_mad,
vmm_mad, tm_mad, err);
vmm_mad, vnm_mad, tm_mad, err);
};
void check(int index, PoolObjectSQL* obj)
@@ -184,7 +185,7 @@ protected:
if( xml_str != xmls[index] )
{
cout << endl << xml_str << endl << "========"
<< endl << xmls[index];
<< endl << xmls[index] << endl;
}
//*/
CPPUNIT_ASSERT( xml_str == xmls[index]);
@@ -242,16 +243,16 @@ public:
// If we try to allocate two hosts with the same name and drivers,
// should fail
rc = hp->allocate(&oid_0, names[0], im_mad, vmm_mad, tm_mad, err);
rc = hp->allocate(&oid_0, names[0], im_mad, vmm_mad, vnm_mad, tm_mad, err);
CPPUNIT_ASSERT( oid_0 == 0 );
CPPUNIT_ASSERT( rc == oid_0 );
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, tm_mad, err);
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, vnm_mad, tm_mad, err);
CPPUNIT_ASSERT( oid_1 == -1 );
CPPUNIT_ASSERT( rc == oid_1 );
// the hostname can not be repeated if the drivers change
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, tm_mad_2, err);
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, vnm_mad, tm_mad_2, err);
CPPUNIT_ASSERT( oid_1 == -1 );
CPPUNIT_ASSERT( rc == oid_1 );
@@ -272,7 +273,7 @@ public:
for(int i=0; i<5; i++)
{
((HostPool*)pool)->allocate(&oid, names[i],
im_mad, vmm_mad, tm_mad, err);
im_mad, vmm_mad, vnm_mad, tm_mad, err);
}
ostringstream oss;
@@ -287,7 +288,7 @@ public:
if( result != xml_dump )
{
cout << endl << result << endl << "========"
<< endl << xml_dump;
<< endl << xml_dump << endl;
}
//*/
@@ -305,7 +306,7 @@ public:
for(int i=0; i<5; i++)
{
((HostPool*)pool)->allocate(&oid, names[i],
im_mad, vmm_mad, tm_mad, err);
im_mad, vmm_mad, vnm_mad, tm_mad, err);
}
@@ -321,7 +322,7 @@ public:
if( result != xml_dump_like_a )
{
cout << endl << result << endl << "========"
<< endl << xml_dump_like_a;
<< endl << xml_dump_like_a << endl;
}
//*/
@@ -346,7 +347,7 @@ public:
{
oss << "host" << i;
hp->allocate(&oid, oss.str().c_str(), im_mad, vmm_mad, tm_mad, err);
hp->allocate(&oid, oss.str().c_str(), im_mad, vmm_mad, vnm_mad, tm_mad, err);
CPPUNIT_ASSERT(oid == i);
if (i >=8 )
@@ -404,7 +405,7 @@ public:
{
oss << "host" << j;
hp->allocate(&oid, oss.str().c_str(),im_mad,vmm_mad,tm_mad,err);
hp->allocate(&oid, oss.str().c_str(),im_mad,vmm_mad,vnm_mad,tm_mad,err);
}
the_time2 = time(0) - the_time;
@@ -433,7 +434,7 @@ public:
for (i=10000,oss.str(""); i<30000 ; i++,oss.str(""))
{
oss << "host" << i;
hp->allocate(&oid,oss.str().c_str(),im_mad,vmm_mad,tm_mad,err);
hp->allocate(&oid,oss.str().c_str(),im_mad,vmm_mad,vnm_mad,tm_mad,err);
host = hp->get(oid, false);
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env ruby
# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ---------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
ETC_LOCATION = "/etc/one" if !defined?(ETC_LOCATION)
RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
ETC_LOCATION = ONE_LOCATION+"/etc" if !defined?(ETC_LOCATION)
RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
require 'OpenNebula'
include OpenNebula
begin
client = Client.new()
rescue Exception => e
puts "Error: #{e}"
exit(-1)
end
def add_info(name, value)
value = "0" if value.nil? or value.to_s.empty?
@result_str << "#{name}=#{value} "
end
def print_info
puts @result_str
end
@result_str = ""
@host = ARGV[2]
if !@host
exit -1
end
load ETC_LOCATION + "/vmwarerc"
if USERNAME.class!=String || PASSWORD.class!=String
warn "Bad ESX credentials, aborting"
exit -1
end
data = perform_action("virsh -c #{LIBVIRT_URI} --readonly nodeinfo")
data.split(/\n/).each{|line|
if line.match('^CPU\(s\)')
$total_cpu = line.split(":")[1].strip.to_i * 100
elsif line.match('^CPU frequency')
$cpu_speed = line.split(":")[1].strip.split(" ")[0]
elsif line.match('^Memory size')
$total_memory = line.split(":")[1].strip.split(" ")[0]
end
}
# Loop through all vms
used_memory = 0
used_cpu = 0
vms = VirtualMachinePool.new(client)
rc = vms.info
if OpenNebula.is_error?(rc)
warn "Couldn't reach OpenNebula, aborting."
exit -1
end
vm_ids_array = vms.retrieve_elements("/VM_POOL/VM[STATE=3 or STATE=5]/HISTORY_RECORDS/HISTORY[HOSTNAME=\"#{@host}\"]/../ID")
if vm_ids_array
vm_ids_array.each do |vm_id|
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, client)
rc = vm.info
if OpenNebula.is_error?(rc)
warn "Couldn't reach OpenNebula, aborting."
exit -1
end
used_memory = used_memory + (vm['TEMPLATE/MEMORY'].to_i * 1024)
used_cpu = used_cpu + (vm['TEMPLATE/CPU'].to_f * 100)
end
end
# 80% of the total free calculated memory to take hypervisor into account
free_memory = ($total_memory.to_i - used_memory) * 0.8
# assume all the host's CPU is devoted to running Virtual Machines
free_cpu = ($total_cpu.to_f - used_cpu)
add_info("HYPERVISOR","vmware")
add_info("TOTALCPU",$total_cpu)
add_info("FREECPU",free_cpu.to_i)
add_info("CPUSPEED",$cpu_speed)
add_info("TOTALMEMORY",$total_memory)
add_info("FREEMEMORY",free_memory.to_i)
print_info
+14 -8
View File
@@ -54,12 +54,16 @@ class ImageDriver < OpenNebulaDriver
@options={
:concurrency => 10,
:threaded => true,
:retries => 0
:retries => 0,
:local_actions => {
'MV' => nil,
'CP' => nil,
'RM' => nil,
'MKFS' => nil
}
}.merge!(options)
super('', @options)
@actions_path = "#{VAR_LOCATION}/remotes/image/#{fs_type}"
super("image/#{fs_type}", @options)
register_action(ACTION[:mv].to_sym, method("mv"))
register_action(ACTION[:cp].to_sym, method("cp"))
@@ -69,19 +73,21 @@ class ImageDriver < OpenNebulaDriver
# Image Manager Protocol Actions (generic implementation
def mv(id, src, dst)
local_action("#{@actions_path}/mv #{src} #{dst} #{id}",id,ACTION[:mv])
do_action("#{src} #{dst} #{id}", id, nil,
ACTION[:mv])
end
def cp(id, src)
local_action("#{@actions_path}/cp #{src} #{id}",id,ACTION[:cp])
do_action("#{src} #{id}", id, nil, ACTION[:cp])
end
def rm(id, dst)
local_action("#{@actions_path}/rm #{dst} #{id}",id,ACTION[:rm])
do_action("#{dst} #{id}", id, nil, ACTION[:rm])
end
def mkfs(id, fs, size)
local_action("#{@actions_path}/mkfs #{fs} #{size} #{id}",id,ACTION[:mkfs])
do_action("#{fs} #{size} #{id}", id, nil,
ACTION[:mkfs])
end
end
+24 -1
View File
@@ -41,8 +41,28 @@ DST=`generate_image_path`
case $SRC in
http://*)
log "Downloading $SRC to the image repository"
exec_and_log "$WGET -O $DST $SRC" \
"Error downloading $SRC"
exec_and_log "chmod 0660 $DST"
;;
vmware://*)
SRC=`echo $SRC|sed 's/vmware:\/\///g'`
if [ `check_restricted $SRC` -eq 1 ]; then
log_error "Not allowed to copy images from $RESTRICTED_DIRS"
error_message "Not allowed to copy image file $SRC"
exit -1
fi
log "Copying local disk folder $SRC to the image repository"
exec_and_log "cp -rf $SRC $DST" \
"Error copying $SRC to $DST"
exec_and_log "chmod 0770 $DST"
;;
*)
@@ -53,13 +73,16 @@ http://*)
fi
log "Copying local image $SRC to the image repository"
exec_and_log "cp -f $SRC $DST" \
"Error copying $SRC to $DST"
exec_and_log "chmod 0660 $DST"
;;
esac
# ---------------- Get the size of the image & fix perms ------------
exec_and_log "chmod 0660 $DST"
SIZE=`fs_du $DST`
+10
View File
@@ -82,4 +82,14 @@ function check_restricted {
done
echo 0
}
# Change the permissions of all the files inside directoriers (= VMware disks)
function fix_owner_perms {
find $IMAGE_REPOSITORY_PATH -type d \
-mindepth 1 \
-maxdepth 1 \
-execdir chown \
-R $SUDO_USER '{}' \;
}
+6 -2
View File
@@ -44,7 +44,6 @@ fi
# ------------ Move the image to the repository ------------
case $SRC in
http://*)
log "Downloading $SRC to the image repository"
@@ -62,7 +61,12 @@ http://*)
;;
esac
exec_and_log "chmod 0660 $DST"
if [ -d $DST ]; then
exec_and_log "chmod 0770 $DST"
fix_owner_perms
else
exec_and_log "chmod 0660 $DST"
fi
# ---------------- Get the size of the image ------------
SIZE=`fs_du $DST`
+1 -1
View File
@@ -37,6 +37,6 @@ SRC=$1
if [ -e $SRC ] ; then
log "Removing $SRC from the image repository"
exec_and_log "rm $SRC" \
exec_and_log "rm -r $SRC" \
"Error deleting $SRC"
fi
+12 -11
View File
@@ -47,6 +47,7 @@ const string templates[] =
static int hid = 123;
static string hostname = "test_hostname";
static string vmm_mad = "vmm_mad";
static string vnm_mad = "vnm_mad";
static string tm_mad = "tm_mad";
static string vmdir = "vmdir";
@@ -225,7 +226,7 @@ private:
vm->lock();
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -489,7 +490,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -573,7 +574,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -594,7 +595,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -615,7 +616,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -637,7 +638,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -661,7 +662,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -685,7 +686,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -749,7 +750,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -772,7 +773,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
@@ -795,7 +796,7 @@ public:
{
vm = allocate_running(0);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
CPPUNIT_ASSERT( rc == 0 );
-1
View File
@@ -16,7 +16,6 @@
require 'thread'
=begin rdoc
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
This class provides support to handle actions. Class methods, or actions, can be
registered in the action manager. The manager will wait for actions to be
+194
View File
@@ -0,0 +1,194 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# This module provides an abstraction to generate an execution context for
# OpenNebula Drivers. The module has been designed to be included as part
# of a driver and not to be used standalone.
module DriverExecHelper
# Action result strings for messages
RESULT = {
:success => "SUCCESS",
:failure => "FAILURE"
}
def self.failed?(rc_str)
return rc_str == RESULT[:failure]
end
#Initialize module variables
def initialize_helper(directory, options)
@config = read_configuration
@remote_scripts_base_path = @config['SCRIPTS_REMOTE_DIR']
@local_actions = options[:local_actions]
if ENV['ONE_LOCATION'] == nil
@local_scripts_base_path = "/var/lib/one/remotes"
else
@local_scripts_base_path = "#{ENV['ONE_LOCATION']}/var/remotes"
end
# dummy paths
@remote_scripts_path = File.join(@remote_scripts_base_path, directory)
@local_scripts_path = File.join(@local_scripts_base_path, directory)
end
#
# METHODS FOR COMMAND LINE & ACTION PATHS
#
# Given the action name and the parameter returns full path of the script
# and appends its parameters. It uses @local_actions hash to know if the
# actions is remote or local. If the local actions has defined an special
# script name this is used, otherwise the action name in downcase is
# used as the script name.
#
# @param [String, Symbol] action name of the action
# @param [String] parameters arguments for the script
# @param [String, nil] default_name alternative name for the script
# @return [String] command line needed to execute the action
def action_command_line(action, parameters, default_name=nil)
if action_is_local? action
script_path=@local_scripts_path
else
script_path=@remote_scripts_path
end
File.join(script_path, action_script_name(action, default_name))+
" "+parameters
end
# True if the action is meant to be executed locally
#
# @param [String, Symbol] action name of the action
def action_is_local?(action)
@local_actions.include? action.to_s.upcase
end
# Name of the script file for the given action
#
# @param [String, Symbol] action name of the action
# @param [String, nil] default_name alternative name for the script
def action_script_name(action, default_name=nil)
name=@local_actions[action.to_s.upcase]
if name
name
else
default_name || action.to_s.downcase
end
end
#
# METHODS FOR LOGS & COMMAND OUTPUT
#
# Sends a log message to ONE. The +message+ can be multiline, it will
# be automatically splitted by lines.
def log(number, message)
in_error_message=false
msg=message.strip
msg.each_line {|line|
severity='I'
l=line.strip
if l=='ERROR MESSAGE --8<------'
in_error_message=true
next
elsif l=='ERROR MESSAGE ------>8--'
in_error_message=false
next
else
if in_error_message
severity='E'
elsif line.match(/^(ERROR|DEBUG|INFO):(.*)$/)
line=$2
case $1
when 'ERROR'
severity='E'
when 'DEBUG'
severity='D'
when 'INFO'
severity='I'
else
severity='I'
end
end
end
send_message("LOG", severity, number, line.strip)
}
end
# Generates a proc with that calls log with a hardcoded number. It will
# be used to add loging to command actions
def log_method(num)
lambda {|message|
log(num, message)
}
end
#This method returns the result in terms
def get_info_from_execution(command_exe)
if command_exe.code == 0
result = RESULT[:success]
info = command_exe.stdout
else
result = RESULT[:failure]
info = command_exe.get_error_message
end
info = "-" if info == nil || info.empty?
[result, info]
end
#
#
# Simple parser for the config file generated by OpenNebula
def read_configuration
one_config=nil
if ENV['ONE_LOCATION']
one_config = ENV['ONE_LOCATION']+'/var/config'
else
one_config = '/var/lib/one/config'
end
config=Hash.new
cfg=''
begin
open(one_config) do |file|
cfg=file.read
end
cfg.split(/\n/).each do |line|
m=line.match(/^([^=]+)=(.*)$/)
if m
name=m[1].strip.upcase
value=m[2].strip
config[name]=value
end
end
rescue Exception => e
STDERR.puts "Error reading config: #{e.inspect}"
STDERR.flush
end
config
end
end
+106 -269
View File
@@ -17,9 +17,7 @@
require "ActionManager"
require "CommandManager"
# Author:: dsa-research.org
# Copyright:: (c) OpenNebula Project Leads (OpenNebula.org)
# License:: Apache License
require "DriverExecHelper"
# This class provides basic messaging and logging functionality
# to implement OpenNebula Drivers. A driver is a program that
@@ -30,11 +28,116 @@ require "CommandManager"
# for each action it wants to receive. The method must be associated
# with the action name through the register_action function
class OpenNebulaDriver < ActionManager
include DriverExecHelper
# @return [String] Base path for scripts
attr_reader :local_scripts_base_path, :remote_scripts_base_path
# @return [String] Path for scripts
attr_reader :local_scripts_path, :remote_scripts_path
# Initialize OpenNebulaDriver object
#
# @param [String] directory path inside the remotes directory where the
# scripts are located
# @param [Hash] options named options to change the object's behaviour
# @option options [Number] :concurrency (10) max number of threads
# @option options [Boolean] :threaded (true) enables or disables threads
# @option options [Number] :retries (0) number of retries to copy scripts
# to the remote host
# @option options [Hash] :local_actions ({}) hash with the actions
# executed locally and the name of the script if it differs from the
# default one. This hash can be constructed using {parse_actions_list}
def initialize(directory, options={})
@options={
:concurrency => 10,
:threaded => true,
:retries => 0,
:local_actions => {}
}.merge!(options)
super(@options[:concurrency], @options[:threaded])
@retries = @options[:retries]
@send_mutex = Mutex.new
#Set default values
initialize_helper(directory, @options)
register_action(:INIT, method("init"))
end
# Sends a message to the OpenNebula core through stdout
def send_message(action="-", result=RESULT[:failure], id="-", info="-")
@send_mutex.synchronize {
STDOUT.puts "#{action} #{result} #{id} #{info}"
STDOUT.flush
}
end
# Calls remotes or local action checking the action name and
# @local_actions. Optional arguments can be specified as a hash
#
# @param [String] parameters arguments passed to the script
# @param [Number, String] id action identifier
# @param [String] host hostname where the action is going to be executed
# @param [String, Symbol] aname name of the action
# @param [Hash] ops extra options for the command
# @option ops [String] :stdin text to be writen to stdin
# @option ops [String] :script_name default script name for the action,
# action name is used by defaults
# @option ops [String] :respond if defined will send result to ONE core
def do_action(parameters, id, host, aname, ops={})
options={
:stdin => nil,
:script_name => nil,
:respond => true,
:ssh_stream => nil
}.merge(ops)
params = parameters+" #{id} #{host}"
command = action_command_line(aname, params, options[:script_name])
if action_is_local?(aname)
execution = LocalCommand.run(command, log_method(id))
elsif options[:ssh_stream]
if options[:stdin]
cmdin = "cat << EOT | #{command}"
stdin = "#{options[:stdin]}\nEOT\n"
else
cmdin = command
stdin = nil
end
execution = options[:ssh_stream].run(cmdin, stdin, command)
else
execution = RemotesCommand.run(command,
host,
@remote_scripts_base_path,
log_method(id),
options[:stdin],
@retries)
end
result, info = get_info_from_execution(execution)
if options[:respond]
send_message(aname,result,id,info)
end
[result, info]
end
# Start the driver. Reads from STDIN and executes methods associated with
# the messages
def start_driver
loop_thread = Thread.new { loop }
start_listener
loop_thread.kill
end
# This function parses a string with this form:
#
# 'deploy,shutdown,poll=poll_ganglia, cancel '
@@ -69,238 +172,6 @@ class OpenNebulaDriver < ActionManager
actions
end
# Action result strings for messages
RESULT = {
:success => "SUCCESS",
:failure => "FAILURE"
}
# Initialize OpenNebulaDriver object
#
# @param [String] directory path inside the remotes directory where the
# scripts are located
# @param [Hash] options named options to change the object's behaviour
# @option options [Number] :concurrency (10) max number of threads
# @option options [Boolean] :threaded (true) enables or disables threads
# @option options [Number] :retries (0) number of retries to copy scripts
# to the remote host
# @option options [Hash] :local_actions ({}) hash with the actions
# executed locally and the name of the script if it differs from the
# default one. This hash can be constructed using {parse_actions_list}
def initialize(directory, options={})
@options={
:concurrency => 10,
:threaded => true,
:retries => 0,
:local_actions => {}
}.merge!(options)
super(@options[:concurrency], @options[:threaded])
@retries = @options[:retries]
@local_actions = @options[:local_actions]
@send_mutex = Mutex.new
# set default values
@config = read_configuration
@remote_scripts_base_path = @config['SCRIPTS_REMOTE_DIR']
if ENV['ONE_LOCATION'] == nil
@local_scripts_base_path = "/var/lib/one/remotes"
else
@local_scripts_base_path = "#{ENV['ONE_LOCATION']}/var/remotes"
end
# dummy paths
@remote_scripts_path = File.join(@remote_scripts_base_path, directory)
@local_scripts_path = File.join(@local_scripts_base_path, directory)
register_action(:INIT, method("init"))
end
# Sends a message to the OpenNebula core through stdout
def send_message(action="-", result=RESULT[:failure], id="-", info="-")
@send_mutex.synchronize {
STDOUT.puts "#{action} #{result} #{id} #{info}"
STDOUT.flush
}
end
# Calls remotes or local action checking the action name and
# @local_actions. Optional arguments can be specified as a hash
#
# @param [String] parameters arguments passed to the script
# @param [Number, String] id action identifier
# @param [String] host hostname where the action is going to be executed
# @param [String, Symbol] aname name of the action
# @param [Hash] ops extra options for the command
# @option ops [String] :stdin text to be writen to stdin
# @option ops [String] :script_name default script name for the action,
# action name is used by defaults
def do_action(parameters, id, host, aname, ops={})
options={
:stdin => nil,
:script_name => nil
}.merge(ops)
params=parameters+" #{id} #{host}"
command=action_command_line(aname, params, options[:script_name])
if action_is_local? aname
local_action(command, id, aname)
else
remotes_action(command, id, host, aname, @remote_scripts_base_path,
options[:stdin])
end
end
# Given the action name and the parameter returns full path of the script
# and appends its parameters. It uses @local_actions hash to know if the
# actions is remote or local. If the local actions has defined an special
# script name this is used, otherwise the action name in downcase is
# used as the script name.
#
# @param [String, Symbol] action name of the action
# @param [String] parameters arguments for the script
# @param [String, nil] default_name alternative name for the script
# @return [String] command line needed to execute the action
def action_command_line(action, parameters, default_name=nil)
if action_is_local? action
script_path=@local_scripts_path
else
script_path=@remote_scripts_path
end
File.join(script_path, action_script_name(action, default_name))+
" "+parameters
end
# True if the action is meant to be executed locally
#
# @param [String, Symbol] action name of the action
def action_is_local?(action)
@local_actions.include? action.to_s.upcase
end
# Name of the script file for the given action
#
# @param [String, Symbol] action name of the action
# @param [String, nil] default_name alternative name for the script
def action_script_name(action, default_name=nil)
name=@local_actions[action.to_s.upcase]
if name
name
else
default_name || action.to_s.downcase
end
end
# Execute a command associated to an action and id in a remote host.
#
# @param [String] command command line to execute the script
# @param [Number, String] id action identifier
# @param [String] host hostname where the action is going to be executed
# @param [String, Symbol] aname name of the action
# @param [String] remote_dir path where the remotes reside
# @param [String, nil] std_in input of the string from the STDIN
def remotes_action(command, id, host, aname, remote_dir, std_in=nil)
command_exe = RemotesCommand.run(command,
host,
remote_dir,
log_method(id),
std_in,
@retries)
if command_exe.code == 0
result = RESULT[:success]
info = command_exe.stdout
else
result = RESULT[:failure]
info = command_exe.get_error_message
end
info = "-" if info == nil || info.empty?
send_message(aname,result,id,info)
end
# Execute a command associated to an action and id on localhost
#
# @param [String] command command line to execute the script
# @param [Number, String] id action identifier
# @param [String, Symbol] aname name of the action
def local_action(command, id, aname)
command_exe = LocalCommand.run(command, log_method(id))
if command_exe.code == 0
result = RESULT[:success]
info = command_exe.stdout
else
result = RESULT[:failure]
info = command_exe.get_error_message
end
info = "-" if info == nil || info.empty?
send_message(aname,result,id,info)
end
# Sends a log message to ONE. The +message+ can be multiline, it will
# be automatically splitted by lines.
def log(number, message)
in_error_message=false
msg=message.strip
msg.each_line {|line|
severity='I'
l=line.strip
if l=='ERROR MESSAGE --8<------'
in_error_message=true
next
elsif l=='ERROR MESSAGE ------>8--'
in_error_message=false
next
else
if in_error_message
severity='E'
elsif line.match(/^(ERROR|DEBUG|INFO):(.*)$/)
line=$2
case $1
when 'ERROR'
severity='E'
when 'DEBUG'
severity='D'
when 'INFO'
severity='I'
else
severity='I'
end
end
end
send_message("LOG", severity, number, line.strip)
}
end
# Generates a proc with that calls log with a hardcoded number. It will
# be used to add loging to command actions
def log_method(num)
lambda {|message|
log(num, message)
}
end
# Start the driver. Reads from STDIN and executes methods associated with
# the messages
def start_driver
loop_thread = Thread.new { loop }
start_listener
loop_thread.kill
end
private
def init
@@ -333,40 +204,6 @@ private
end
end
end
def read_configuration
one_config=nil
if ENV['ONE_LOCATION']
one_config=ENV['ONE_LOCATION']+'/var/config'
else
one_config='/var/lib/one/config'
end
config=Hash.new
cfg=''
begin
open(one_config) do |file|
cfg=file.read
end
cfg.split(/\n/).each do |line|
m=line.match(/^([^=]+)=(.*)$/)
if m
name=m[1].strip.upcase
value=m[2].strip
config[name]=value
end
end
rescue Exception => e
STDERR.puts "Error reading config: #{e.inspect}"
STDERR.flush
end
config
end
end
################################################################
+17 -26
View File
@@ -15,6 +15,8 @@
#--------------------------------------------------------------------------- #
require "OpenNebulaDriver"
require "CommandManager"
require 'base64'
require 'rexml/document'
# Author:: dsa-research.org
# Copyright:: (c) 2011 Universidad Computense de Madrid
@@ -85,26 +87,15 @@ class VirtualMachineDriver < OpenNebulaDriver
register_action(ACTION[:poll].to_sym, method("poll"))
end
# Converts a deployment file from its remote path to the local (front-end)
# path
def get_local_deployment_file(rfile)
lfile = nil
# Decodes the encoded XML driver message received from the core
#
# @param [String] drv_message the driver message
# @return [REXML::Element] the root element of the decoded XML message
def decode(drv_message)
message = Base64.decode64(drv_message)
xml_doc = REXML::Document.new(message)
one_location = ENV["ONE_LOCATION"]
if one_location == nil
var_location = "/var/lib/one/"
else
var_location = one_location + "/var/"
end
m = rfile.match(/.*?\/(\d+)\/images\/(deployment.\d+)$/)
lfile = "#{var_location}#{m[1]}/#{m[2]}" if m
lfile = nil if lfile and !File.exists?(lfile)
return lfile
xml_doc.root
end
# Execute a command associated to an action and id in a remote host.
@@ -118,37 +109,37 @@ class VirtualMachineDriver < OpenNebulaDriver
end
# Virtual Machine Manager Protocol Actions (generic implementation)
def deploy(id, host, remote_dfile, not_used)
def deploy(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:deploy],RESULT[:failure],id,error)
end
def shutdown(id, host, deploy_id, not_used)
def shutdown(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:shutdown],RESULT[:failure],id,error)
end
def cancel(id, host, deploy_id, not_used)
def cancel(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:cancel],RESULT[:failure],id,error)
end
def save(id, host, deploy_id, file)
def save(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:save],RESULT[:failure],id,error)
end
def restore(id, host, deploy_id, file)
def restore(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:restore],RESULT[:failure],id,error)
end
def migrate(id, host, deploy_id, dest_host)
def migrate(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:migrate],RESULT[:failure],id,error)
end
def poll(id, host, deploy_id, not_used)
def poll(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:poll],RESULT[:failure],id,error)
end
+10 -3
View File
@@ -43,11 +43,18 @@ module OpenNebula
# This function is used to pass error message to the mad
def self.error_message(message)
STDERR.puts "ERROR MESSAGE --8<------"
STDERR.puts message
STDERR.puts "ERROR MESSAGE ------>8--"
STDERR.puts format_error_message(message)
end
#This function formats an error message for OpenNebula Copyright e
def self.format_error_message(message)
error_str = "ERROR MESSAGE --8<------\n"
error_str << message
error_str << "\nERROR MESSAGE ------>8--"
return error_str
end
# Executes a command, if it fails returns error message and exits
# If a second parameter is present it is used as the error message when
# the command fails
+238
View File
@@ -0,0 +1,238 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
require 'CommandManager'
require 'open3'
require 'scripts_common'
class SshStream
attr_reader :stream_out, :stream_err, :stdin
attr_reader :out, :err
#
#
EOF_ERR = "EOF_ERR"
EOF_OUT = "EOF_OUT"
RC_STR = "ExitCode: "
SSH_RC_STR = "ExitSSHCode: "
EOF_CMD = "echo \"#{RC_STR}$? #{EOF_ERR}\" 1>&2; echo \"#{EOF_OUT}\""
SSH_CMD = "ssh"
#
#
#
def initialize(host)
@host = host
end
def opened?
defined?(@stdin)
end
def alive?
@alive == true
end
def open
@stdin, @stdout, @stderr=Open3::popen3("#{SSH_CMD} #{@host} bash -s ; echo #{SSH_RC_STR} $? 1>&2")
@stream_out = ""
@stream_err = ""
@out = ""
@err = ""
@alive = true
end
def close
begin
@stdin.puts "\nexit"
rescue #rescue from EPIPE if ssh command exited already
end
@stdin.close if not @stdin.closed?
@stdout.close if not @stdout.closed?
@stderr.close if not @stderr.closed?
@alive = false
end
def exec(command)
return if ! @alive
@out = ""
@err = ""
begin
cmd="(#{command}); #{EOF_CMD}"
sliced=cmd.scan(/.{1,100}/)
sliced.each do |slice|
@stdin.write slice
@stdin.flush
end
@stdin.write "\n"
@stdin.flush
rescue
end
end
def wait_for_command
done_out = false
done_err = false
code = -1
while not (done_out and done_err ) and @alive
rc, rw, re= IO.select([@stdout, @stderr],[],[])
rc.each { |fd|
begin
c = fd.read_nonblock(100)
next if !c
rescue #rescue from EOF if ssh command finishes and closes fds
next
end
if fd == @stdout
@out << c
done_out = true if @out.slice!("#{EOF_OUT}\n")
else
@err << c
tmp = @err.scan(/^#{SSH_RC_STR}(\d+)$/)
if tmp[0]
message = "Error connecting to #{@host}"
code = tmp[0][0].to_i
@err << OpenNebula.format_error_message(message)
@alive = false
break
end
tmp = @err.scan(/^#{RC_STR}(\d*) #{EOF_ERR}\n/)
if tmp[0]
code = tmp[0][0].to_i
done_err = true
@err.slice!(" #{EOF_ERR}\n")
end
end
}
end
@stream_out << @out
@stream_err << @err
return code
end
def exec_and_wait(command)
exec(command)
wait_for_command
end
end
class SshStreamCommand < RemotesCommand
def initialize(host, remote_dir, logger=nil, stdin=nil)
super('true', host, logger, stdin)
@remote_dir = remote_dir
@stream = SshStream.new(host)
@stream.open
end
def run(command, stdin=nil, base_cmd = nil)
@stream.open unless @stream.opened?
if base_cmd #Check if base command is on remote host
chk_cmd = "if [ ! -x \"#{base_cmd.match(/\S*/)[0]}\" ]; \
then exit #{MAGIC_RC} 1>&2; \
fi"
if @stream.exec_and_wait(chk_cmd) == MAGIC_RC
RemotesCommand.update_remotes(@host, @remote_dir, @logger)
end
end
@stream.exec(command)
@stream.stdin.write(stdin) if stdin
@code = @stream.wait_for_command
@stdout = @stream.out
@stderr = @stream.err
if @code != 0
log("Command execution fail: #{command}")
end
log(@stderr)
return self
end
end
if $0 == __FILE__
ssh=SshStream.new('localhost')
ssh.open
ssh.exec("date | tee /tmp/test.javi")
code=ssh.wait_for_command
puts "Code: #{code}"
puts "output: #{ssh.out}"
ssh.exec "cat << EOT | cat"
ssh.stdin.puts "blah blah\nmas blah\nrequeteblah"
ssh.stdin.puts "EOT"
code=ssh.wait_for_command
puts "Code: #{code}"
puts "output: #{ssh.out}"
code=ssh.exec_and_wait("whoami")
puts "Code: #{code}"
puts "output: #{ssh.out}"
code=ssh.exec_and_wait("touch /etc/pepe.txt")
puts "Code: #{code}"
puts "output: #{ssh.out}"
puts "output err: #{ssh.err}"
ssh.close
cssh = SshStreamCommand.new('no_host',
'/tmp',
lambda { |e| STDOUT.puts "error: #{e}" },
nil)
cssh.run('whoami')
end
+60
View File
@@ -0,0 +1,60 @@
# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ---------------------------------------------------------------------------- #
# ---------------------------------------------------------------------------- #
# Set up the environment for the driver #
# ---------------------------------------------------------------------------- #
ONE_LOCATION = ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
BIN_LOCATION = "/usr/bin" if !defined?(BIN_LOCATION)
ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION)
RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
BIN_LOCATION = ONE_LOCATION + "/bin" if !defined?(BIN_LOCATION)
ETC_LOCATION = ONE_LOCATION + "/etc/" if !defined?(ETC_LOCATION)
if !defined?(RUBY_LIB_LOCATION)
RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby"
end
end
$: << RUBY_LIB_LOCATION
require "OpenNebulaDriver"
require "CommandManager"
# Do host sustitution in the libvirt URI
LIBVIRT_URI.gsub!('@HOST@', @host)
# Common functions
def perform_action(command)
command = BIN_LOCATION + "/tty_expect -u " + USERNAME + " -p " + PASSWORD + " " + command
action_result = LocalCommand.run(command)
if action_result.code == 0
return action_result.stdout
else
log(command, action_result.stderr, action_result.stdout)
return action_result.code
end
end
def log(cmd, stdout, stderr)
STDERR.puts "[VMWARE] cmd failed [" + cmd +
"]. Stderr: " + stderr + ". Stdout: " + stdout
end
+22
View File
@@ -0,0 +1,22 @@
# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ---------------------------------------------------------------------------- #
Import('env')
import os
env['LIBS'] = "util"
env.Program('tty_expect.c')
+168
View File
@@ -0,0 +1,168 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2010-2011, C12G Labs S.L. */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
#include <pty.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int expect_char(int pty, char * expected, int seconds)
{
fd_set rfds;
struct timeval tv;
int rc;
char c;
do
{
if (seconds != 0)
{
FD_ZERO(&rfds);
FD_SET(pty, &rfds);
tv.tv_sec = seconds;
tv.tv_usec = 0;
rc = select(pty+1,&rfds,0,0, &tv);
if ( rc <= 0 ) // timeout
{
return -1;
}
}
rc = read(pty, (void *) &c, sizeof(char));
if ( rc > 0 )
{
if(expected == 0)
{
write(1,&c,sizeof(char));
}
if (expected != 0 && c == *expected)
{
return 0;
}
}
}
while ( rc > 0 );
return -1;
}
void write_answer(int pty, const char * answer)
{
int len, i;
len = strlen(answer);
for (i=0; i<len; i++)
{
write(pty,(void *) &(answer[i]),sizeof(char));
}
write(pty,(void *)"\n",sizeof(char));
}
static const char * myexpect_usage =
"\n myexpect [-h] <-p password> <-u username> <command>\n\n"
"SYNOPSIS\n"
" Wraps the execution of a command and sends username & password\n\n"
"OPTIONS\n"
"\t-h\tprints this help.\n"
"\t-p\tthe password\n"
"\t-u\tthe username\n"
"\t<virsh command>\tcomplete virsh command\n";
int main (int argc, char **argv)
{
char * password = 0;
char * username = 0;
char expect = ':';
int opt, pty, pid, rc;
while((opt = getopt(argc,argv,"+hp:u:")) != -1)
switch(opt)
{
case 'h':
printf("%s",myexpect_usage);
exit(0);
break;
case 'p':
password = strdup(optarg);
break;
case 'u':
username = strdup(optarg);
break;
default:
fprintf(stderr,"Wrong option. Check usage\n");
fprintf(stderr,"%s",myexpect_usage);
exit(-1);
break;
}
if (password == 0 || username == 0 || optind >= argc )
{
fprintf(stderr,"Wrong number of arguments. Check usage\n");
fprintf(stderr,"%s",myexpect_usage);
exit(-1);
}
pid = forkpty(&pty,0,0,0);
if(pid == 0)
{
struct termios tios;
tcgetattr(pty, &tios);
tios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
tios.c_oflag &= ~(ONLCR);
tcsetattr(pty, TCSANOW, &tios);
execvp(argv[optind],&(argv[optind]));
exit(-1);
}
else if (pid == -1)
{
perror("fork\n");
}
expect_char(pty,&expect,1);
sleep(1);
write_answer(pty,username);
expect_char(pty,&expect,1);
sleep(1);
write_answer(pty,password);
expect_char(pty,0,0);
wait(&rc);
return WEXITSTATUS(rc);
}
@@ -72,6 +72,9 @@ public class Host extends PoolElement{
* @param vmm The name of the virtual machine manager mad name
* (vmm_mad_name), this values are taken from the oned.conf with the
* tag name VM_MAD (name)
* @param vnm The name of the virtual network manager mad name
* (vnm_mad_name), this values are taken from the oned.conf with the
* tag name VN_MAD (name)
* @param tm The transfer manager mad name to be used with this host
* @return If successful the message contains the associated
* id generated for this host
@@ -80,9 +83,10 @@ public class Host extends PoolElement{
String hostname,
String im,
String vmm,
String vnm,
String tm)
{
return client.call(ALLOCATE, hostname, im, vmm, tm);
return client.call(ALLOCATE, hostname, im, vmm, vnm, tm);
}
/**
@@ -36,7 +36,8 @@ public class VirtualNetwork extends PoolElement{
private static final String RMLEASES = METHOD_PREFIX + "rmleases";
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String UPDATE = METHOD_PREFIX + "update";
private static final String HOLD = METHOD_PREFIX + "hold";
private static final String RELEASE = METHOD_PREFIX + "release";
/**
* Creates a new virtual network representation.
@@ -140,6 +141,32 @@ public class VirtualNetwork extends PoolElement{
return client.call(RMLEASES, id, template);
}
/**
* Holds a VirtualNetwork lease, marking it as used
*
* @param client XML-RPC Client.
* @param id The virtual network id (nid) of the target network.
* @param template IP to hold, e.g. "LEASES = [ IP = 192.168.0.5 ]"
* @return A encapsulated response.
*/
public static OneResponse hold(Client client, int id, String template)
{
return client.call(HOLD, id, template);
}
/**
* Releases a VirtualNetwork lease on hold
*
* @param client XML-RPC Client.
* @param id The virtual network id (nid) of the target network.
* @param template IP to release, e.g. "LEASES = [ IP = 192.168.0.5 ]"
* @return A encapsulated response.
*/
public static OneResponse release(Client client, int id, String template)
{
return client.call(RELEASE, id, template);
}
/**
* Changes the owner/group
*
@@ -271,6 +298,30 @@ public class VirtualNetwork extends PoolElement{
return rmLeases(client, id, lease_template);
}
/**
* Holds a VirtualNetwork lease, marking it as used
*
* @param ip IP to hold, e.g. "192.168.0.5"
* @return A encapsulated response.
*/
public OneResponse hold(String ip)
{
String lease_template = "LEASES = [ IP = " + ip + " ]";
return hold(client, id, lease_template);
}
/**
* Releases a VirtualNetwork lease on hold
*
* @param ip IP to release, e.g. "192.168.0.5"
* @return A encapsulated response.
*/
public OneResponse release(String ip)
{
String lease_template = "LEASES = [ IP = " + ip + " ]";
return release(client, id, lease_template);
}
/**
* Changes the owner/group
*
+4 -2
View File
@@ -63,7 +63,8 @@ public class HostTest
@Before
public void setUp() throws Exception
{
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "tm_dummy");
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "vnm_dummy",
"tm_dummy");
int hid = !res.isError() ? Integer.parseInt(res.getMessage()) : -1;
host = new Host(hid, client);
@@ -83,7 +84,8 @@ public class HostTest
{
String name = "allocate_test";
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "tm_dummy");
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "vmm_dummy",
"tm_dummy");
assertTrue( !res.isError() );
// assertTrue( res.getMessage().equals("0") );
+2 -2
View File
@@ -80,11 +80,11 @@ public class VirtualMachineTest
res = Host.allocate(client, "host_A",
"im_dummy", "vmm_dummy", "tm_dummy");
"im_dummy", "vmm_dummy", "vmm_dummy", "tm_dummy");
hid_A = Integer.parseInt( res.getMessage() );
res = Host.allocate(client, "host_B",
"im_dummy", "vmm_dummy", "tm_dummy");
"im_dummy", "vmm_dummy", "vmm_dummy", "tm_dummy");
hid_B = Integer.parseInt( res.getMessage() );
}
+48
View File
@@ -209,6 +209,54 @@ public class VirtualNetworkTest
fixed_vnet.delete();
}
@Test
public void holdFixed()
{
res = VirtualNetwork.allocate(client, fixed_template);
assertTrue( !res.isError() );
VirtualNetwork fixed_vnet =
new VirtualNetwork(Integer.parseInt(res.getMessage()), client);
res = fixed_vnet.hold("130.10.0.1");
assertTrue( !res.isError() );
res = fixed_vnet.hold("130.10.0.5");
assertTrue( res.isError() );
res = fixed_vnet.release("130.10.0.1");
assertTrue( !res.isError() );
res = fixed_vnet.release("130.10.0.1");
assertTrue( res.isError() );
res = fixed_vnet.release("130.10.0.5");
assertTrue( res.isError() );
fixed_vnet.delete();
}
@Test
public void holdRanged()
{
res = vnet.hold("192.168.0.10");
assertTrue( !res.isError() );
res = vnet.hold("192.168.100.1");
assertTrue( res.isError() );
res = vnet.release("192.168.0.10");
assertTrue( !res.isError() );
res = vnet.release("192.168.0.10");
assertTrue( res.isError() );
res = vnet.release("192.168.100.1");
assertTrue( res.isError() );
vnet.delete();
}
@Test
public void update()
{
+8 -8
View File
@@ -78,15 +78,15 @@ module OpenNebula
# Allocates a new Host in OpenNebula
#
# +hostname+ A string containing the name of the new Host.
# @param hostname [String] Name of the new Host.
# @param im [String] Name of the im_driver
# @param vmm [String] Name of the vmm_driver
# @param tm [String] Name of the tm_driver
#
# +im+ A string containing the name of the im_driver
#
# +vmm+ A string containing the name of the vmm_driver
#
# +tm+ A string containing the name of the tm_driver
def allocate(hostname,im,vmm,tm)
super(HOST_METHODS[:allocate],hostname,im,vmm,tm)
# @return [Integer, OpenNebula::Error] the new VM ID in case of
# success, error otherwise
def allocate(hostname,im,vmm,vnm,tm)
super(HOST_METHODS[:allocate],hostname,im,vmm,vnm,tm)
end
# Deletes the Host
+3
View File
@@ -38,6 +38,9 @@ module OpenNebula
# Driver name for default core authentication
CORE_AUTH = "core"
# Driver name for default core authentication
CIPHER_AUTH = "server_cipher"
# Driver name for ssh authentication
SSH_AUTH = "ssh"
+29 -1
View File
@@ -32,7 +32,9 @@ module OpenNebula
:addleases => "vn.addleases",
:rmleases => "vn.rmleases",
:chown => "vn.chown",
:update => "vn.update"
:update => "vn.update",
:hold => "vn.hold",
:release => "vn.release"
}
VN_TYPES=%w{RANGED FIXED}
@@ -128,6 +130,32 @@ module OpenNebula
return rc
end
# Holds a virtual network Lease as used
# @param ip [String] IP to hold
def hold(ip)
return Error.new('ID not defined') if !@pe_id
lease_template = "LEASES = [ IP = #{ip} ]"
rc = @client.call(VN_METHODS[:hold], @pe_id, lease_template)
rc = nil if !OpenNebula.is_error?(rc)
return rc
end
# Releases a virtual network Lease on hold
# @param ip [String] IP to release
def release(ip)
return Error.new('ID not defined') if !@pe_id
lease_template = "LEASES = [ IP = #{ip} ]"
rc = @client.call(VN_METHODS[:release], @pe_id, lease_template)
rc = nil if !OpenNebula.is_error?(rc)
return rc
end
# Changes the owner/group
# uid:: _Integer_ the new owner id. Set to -1 to leave the current one
# gid:: _Integer_ the new group id. Set to -1 to leave the current one
+2 -2
View File
@@ -201,7 +201,7 @@ module OpenNebula
template_like_str('TEMPLATE', indent)
end
def template_like_str(root_element, indent=true)
def template_like_str(root_element, indent=true, xpath_exp=nil)
if NOKOGIRI
xml_template=@xml.xpath(root_element).to_s
rexml=REXML::Document.new(xml_template).root
@@ -217,7 +217,7 @@ module OpenNebula
ind_tab=' '
end
str=rexml.collect {|n|
str=rexml.elements.collect(xpath_exp) {|n|
if n.class==REXML::Element
str_line=""
if n.has_elements?
+215
View File
@@ -0,0 +1,215 @@
# -------------------------------------------------------------------------- *
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# Licensed under the Apache License, Version 2.0 (the "License"); you may *
# not use this file except in compliance with the License. You may obtain *
# a copy of the License at *
# *
# http://www.apache.org/licenses/LICENSE-2.0 *
# *
# Unless required by applicable law or agreed to in writing, software *
# distributed under the License is distributed on an "AS IS" BASIS, *
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
# See the License for the specific language governing permissions and *
# limitations under the License. *
# -------------------------------------------------------------------------- *
require 'digest/sha1'
require "rexml/document"
include REXML
require 'ipaddr'
module Migrator
def db_version
"3.1.80"
end
def one_version
"OpenNebula 3.1.80"
end
def up
puts " > Networking isolation hooks have been moved to Host drivers.\n"<<
" If you were using a networking hook, enter its name, or press enter\n"<<
" to use the default dummy vn_mad driver.\n\n"
vn_mad = ""
while !( ["802.1Q", "dummy", "ebtables", "ovswitch"].include?(vn_mad) ) do
print " Driver name (802.1Q, dummy, ebtables, ovswitch): "
vn_mad = gets.chomp
vn_mad = "dummy" if vn_mad.empty?
end
# 0 = all, 1 = none, 2 = interactive
vlan_option = 1
if ( vn_mad == "ebtables" || vn_mad == "ovswitch" )
puts
puts " > A new attribute, VLAN = YES/NO will be added to each VNET.\n"<<
" For driver '#{vn_mad}', please choose if you want to isolate all networks (all),\n"<<
" none (none), or be asked individually for each VNET (interactive)\n"
vlan = ""
while !( ["all", "none", "interactive"].include?(vlan) ) do
print " Isolate VNETs (all, none, interactive): "
vlan = gets.chomp
end
case vlan
when "all"
vlan_option = 0
when "none"
vlan_option = 1
when "interactive"
vlan_option = 2
end
end
# New VN_MAD element for hosts
@db.run "ALTER TABLE host_pool RENAME TO old_host_pool;"
@db.run "CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, last_mon_time INTEGER, UNIQUE(name));"
@db.fetch("SELECT * FROM old_host_pool") do |row|
doc = Document.new(row[:body])
vn_mad_elem = doc.root.add_element("VN_MAD")
vn_mad_elem.text = vn_mad
@db[:host_pool].insert(
:oid => row[:oid],
:name => row[:name],
:body => doc.root.to_s,
:state => row[:state],
:last_mon_time => row[:last_mon_time])
end
@db.run "DROP TABLE old_host_pool;"
# New VLAN and RANGE for vnets
@db.run "ALTER TABLE network_pool RENAME TO old_network_pool;"
@db.run "CREATE TABLE network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, public INTEGER, UNIQUE(name,uid));"
@db.fetch("SELECT * FROM old_network_pool") do |row|
doc = Document.new(row[:body])
type = ""
doc.root.each_element("TYPE") { |e|
type = e.text
}
if type == "0" # RANGED
range_elem = doc.root.add_element("RANGE")
ip_start_elem = range_elem.add_element("IP_START")
ip_end_elem = range_elem.add_element("IP_END")
net_address = ""
doc.root.each_element("TEMPLATE/NETWORK_ADDRESS") { |e|
net_address = e.text
}
net_valid = false
while !net_valid do
begin
net_address = IPAddr.new(net_address, Socket::AF_INET)
net_valid = true
rescue ArgumentError
puts
puts " > Error processing VNET ##{row[:oid]} '#{row[:name]}'\n"<<
" This network address is invalid: '#{net_address}'\n"
print " Please enter a valid network address: "
net_address = gets.chomp
end
end
st_size = ""
doc.root.each_element("TEMPLATE/NETWORK_SIZE") { |e|
st_size = e.text
}
if ( st_size == "C" || st_size == "c" )
host_bits = 8
elsif ( st_size == "B" || st_size == "b" )
host_bits = 16
elsif ( st_size == "A" || st_size == "a" )
host_bits = 24
else
size = st_size.to_i
host_bits = (Math.log(size+2)/Math.log(2)).ceil
end
net_mask = 0xFFFFFFFF << host_bits
net_address = net_address.to_i & net_mask
ip_start_elem.text = IPAddr.new((net_address + 1), Socket::AF_INET).to_s
ip_end_elem.text = IPAddr.new((net_address + (1 << host_bits) - 2), Socket::AF_INET).to_s
end
phydev_present = false
doc.root.each_element("PHYDEV") { |e|
phydev_present = true
}
vlan_elem = doc.root.add_element("VLAN")
if phydev_present
vlan_elem.text = "1"
else
case vlan_option
when 0
vlan_elem.text = "1"
when 1
vlan_elem.text = "0"
when 2
vlan = ""
while !( ["y", "n"].include?(vlan) ) do
print " > Isolate VNET ##{row[:oid]} '#{row[:name]}'? (y/n) : "
vlan = gets.chomp
end
if ( vlan == "y" )
vlan_elem.text = "1"
else
vlan_elem.text = "0"
end
end
end
@db[:network_pool].insert(
:oid => row[:oid],
:name => row[:name],
:body => doc.root.to_s,
:uid => row[:uid],
:gid => row[:gid],
:public => row[:public])
end
@db.run "DROP TABLE old_network_pool;"
# Add empty HISTORY_RECORDS element to VMs without any records
@db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
@db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER);"
@db.run "INSERT INTO vm_pool SELECT * FROM old_vm_pool;"
@db.fetch("SELECT * FROM old_vm_pool") do |row|
doc = Document.new(row[:body])
found = false
doc.root.each_element("HISTORY_RECORDS") { |e|
found = true
}
if !found
doc.root.add_element("HISTORY_RECORDS")
end
end
@db.run "DROP TABLE old_vm_pool;"
return true
end
end
+23 -7
View File
@@ -215,6 +215,12 @@ label{
text-align:left;
}
.dataTables_wrapper label {
float: none;
width: auto;
padding: 0 0;
text-align:right;
}
div.tip {
display: inline-block;
@@ -286,13 +292,14 @@ textarea:focus{
}
.add_remove_button {
font-size:0.8em;
height:25px;
font-size:0.8em !important;
height:25px !important;
margin-bottom:4px;
}
.add_button {
margin-left:177px;
margin-left:148px;
width: 58px !important;
}
.remove_button {
@@ -411,7 +418,7 @@ tr.even:hover{
}
.top_button {
font-size: 0.8em;
font-size: 0.8em!important;
height: 25px;
margin: 3px 2px;
vertical-align: middle;
@@ -465,15 +472,15 @@ tr.even:hover{
font-size: 1.2em;
}
.jGrowl-notification, .jGrowl-closer, .jGrowl-notify-submit {
.jGrowl-notification, .jGrowl-notify-submit {
border: 2px #444444 solid;
background-color: #F3F3F3;
background-color: #F3F3F3!important;
color: #666666;
}
.jGrowl-notify-error {
border: 2px #660000 solid;
background-color: #F39999;
background-color: #F39999!important;
color: #660000;
}
@@ -578,4 +585,13 @@ ul.dd_right{
}
ul.dd_left{
}
.ui-widget{
font: 10pt Arial, Verdana, Geneva, Helvetica, sans-serif;
}
.ui-layout-resizer-open-hover, /* hover-color to 'resize' */
.ui-layout-resizer-dragging {
background: #EEE;
}
+13 -17
View File
@@ -44,19 +44,26 @@ body {
}
#header {
padding:0;
padding: 0 10px 0 10px;
background-color: #353735;
border:0;
}
#footer {
padding:0;
padding-top: 9px;
font-size: 0.8em;
color: white;
text-align: center;
background-color: #353735;
border:0;
}
#header {
padding: 0 10px 0 10px;
background-color: #353735;
#footer a {
color: white;
text-decoration: underline;
}
#logo {
padding-top: 6px;
font-weight: bold;
@@ -87,18 +94,6 @@ body {
color: #88C140;
}
#footer {
padding-top: 9px;
font-size: 0.8em;
color: white;
text-align: center;
}
#footer a {
color: white;
text-decoration: underline;
}
#logo-wrapper {
float: right;
margin-top: 0px;
@@ -108,6 +103,7 @@ body {
#menu {
padding-right: 0;
padding-left: 0;
border:0;
border-right: 1px solid #353735;
background-image: -webkit-gradient(
linear,
@@ -42,7 +42,7 @@ var create_vdc_tmpl =
<label for="vdcadminname">Admin name:</label>\
<input type="text" name="vdcadminname" id="vdcadminname" /><br />\
<label for="vdcadminpass">Admin pass:</label>\
<input type="password" name="vdcadminpass" id="vdcadminpass" />\
<input type="password" name="vdcadminpass" id="vdcadminpass" /><br />\
<label for="zone">Zone:</label>\
<select id="zoneid" name="zone">\
</select><br />\
@@ -51,12 +51,13 @@ var create_vdc_tmpl =
<input type="checkbox" name="vdc_force_hosts" id="vdc_force_hosts" />\
<div class="tip">Allows hosts belonging to other VDCs to be re-added to this one. They will appear greyed-out in the lists.</div>\
<div class="clear"></div>\
<label style="margin-left:205px;font-size:0.8em;color:#bbbbbb">Drag & Drop</label>\
<label style="margin-left:195px;font-size:0.8em;color:#bbbbbb">Available / Selected</label>\
<label style="margin-left:265px;font-size:0.8em;color:#bbbbbb">Drag & Drop</label>\
<label style="margin-left:243px;font-size:0.8em;color:#bbbbbb">Available / Selected</label><br />\
<div class="clear"></div>\
<label>Hosts:</label>\
<div id="vdc_hosts_lists" class="dd_lists">\
<ul id="vdc_available_hosts_list" class="dd_list dd_left"></ul>\
<ul id="vdc_selected_hosts_list" class="dd_list dd_right"></ul>\
<div id="vdc_hosts_lists" class="dd_lists" style="width:250px">\
<ul id="vdc_available_hosts_list" class="dd_list dd_left" style="width:115px"></ul>\
<ul id="vdc_selected_hosts_list" class="dd_list dd_right" style="width:115px"></ul>\
</div>\
</fieldset>\
<fieldset>\
@@ -278,7 +279,7 @@ function updateVDCInfo(req,vdc_json){
var zone_host = "";
var zone_port = "";
var sun_link = "";
var zone_match = zone_endpoint.match(/^http:\/\/(\w+):(\d+)\/RPC2$/);
var zone_match = zone_endpoint.match(/^https?:\/\/([\w.-]+):(\d+)\/([\W\w]+)$/);
if (zone_match){
zone_host = zone_match[1];
@@ -428,10 +429,14 @@ function setupCreateVDCDialog(){
$('div#dialogs').append('<div title="Create VDC" id="create_vdc_dialog"></div>');
var dialog = $('div#create_vdc_dialog');
dialog.html(create_vdc_tmpl);
var height = Math.floor($(window).height()*0.8);
dialog.dialog({
autoOpen: false,
modal: true,
width: 420
height: height,
width: 500
});
$('button',dialog).button();
+5 -5
View File
@@ -6,14 +6,14 @@
<!-- Vendor Libraries -->
<link rel="stylesheet" type="text/css" href="vendor/dataTables/demo_table_jui.css" />
<link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.7.custom.css" />
<link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="vendor/jGrowl/jquery.jgrowl.css" />
<link rel="stylesheet" type="text/css" href="vendor/jQueryLayout/layout-default-latest.css" />
<script type="text/javascript" src="vendor/jQuery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="vendor/jQuery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="vendor/jGrowl/jquery.jgrowl_minimized.js"></script>
<script type="text/javascript" src="vendor/jQueryUI/jquery-ui-1.8.7.custom.min.js"></script>
<script type="text/javascript" src="vendor/jQueryLayout/jquery.layout.min-1.2.0.js"></script>
<script type="text/javascript" src="vendor/jQueryUI/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="vendor/jQueryLayout/jquery.layout-latest.min.js"></script>
<script type="text/javascript" src="vendor/dataTables/jquery.dataTables.min.js"></script>
<!-- End Vendor Libraries -->
@@ -59,7 +59,7 @@
</div>
</div>
<div id="footer" class="ui-layout-south">
Copyright 2002-2011 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.0
Copyright 2002-2011 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.80
</div>
+1 -1
View File
@@ -5,7 +5,7 @@
<link rel="stylesheet" type="text/css" href="css/login.css" />
<!-- Vendor Libraries -->
<script type="text/javascript" src="vendor/jQuery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="vendor/jQuery/jquery-1.7.1.min.js"></script>
<!-- End Vendor Libraries -->
<script type="text/javascript" src="js/ozones.js"></script>
<script type="text/javascript" src="js/login.js"></script>
+15
View File
@@ -198,6 +198,8 @@ PoolObjectSQL * PoolSQL::get(
}
else
{
map<string,PoolObjectSQL *>::iterator name_index;
objectsql = create();
objectsql->oid = oid;
@@ -214,6 +216,19 @@ PoolObjectSQL * PoolSQL::get(
}
string okey = key(objectsql->name,objectsql->uid);
name_index = name_pool.find(okey);
if ( name_index != name_pool.end() )
{
name_index->second->lock();
PoolObjectSQL * tmp_ptr = name_index->second;
name_pool.erase(okey);
pool.erase(tmp_ptr->oid);
delete tmp_ptr;
}
pool.insert(make_pair(objectsql->oid,objectsql));
name_pool.insert(make_pair(okey, objectsql));
+12 -3
View File
@@ -170,7 +170,10 @@ public:
//Should be set to MAX_POOL -1
for (int i=0 ; i < 14999 ; i++)
{
create_allocate(i,"A Test object");
ostringstream name;
name << "A Test object " << i;
create_allocate(i,name.str());
obj_lock = pool->get(i, true);
CPPUNIT_ASSERT(obj_lock != 0);
@@ -178,16 +181,22 @@ public:
for (int i=14999 ; i < 15200 ; i++) //Works with just 1 cache line
{
create_allocate(i,"A Test object");
ostringstream name;
name << "A Test object " << i;
create_allocate(i,name.str());
}
for (int i=14999; i < 15200 ; i++)
{
ostringstream name;
name << "A Test object " << i;
obj = pool->get(i, true);
CPPUNIT_ASSERT(obj != 0);
CPPUNIT_ASSERT(obj->number == i);
CPPUNIT_ASSERT(obj->text == "A Test object");
CPPUNIT_ASSERT(obj->text == name.str());
obj->unlock();
}
+4
View File
@@ -246,6 +246,8 @@ void RequestManager::register_xml_methods()
// VirtualNetwork Methods
xmlrpc_c::methodPtr vn_addleases(new VirtualNetworkAddLeases());
xmlrpc_c::methodPtr vn_rmleases(new VirtualNetworkRemoveLeases());
xmlrpc_c::methodPtr vn_hold(new VirtualNetworkHold());
xmlrpc_c::methodPtr vn_release(new VirtualNetworkRelease());
// Update Template Methods
xmlrpc_c::methodPtr image_update(new ImageUpdateTemplate());
@@ -357,6 +359,8 @@ void RequestManager::register_xml_methods()
/* Network related methods*/
RequestManagerRegistry.addMethod("one.vn.addleases", vn_addleases);
RequestManagerRegistry.addMethod("one.vn.rmleases", vn_rmleases);
RequestManagerRegistry.addMethod("one.vn.hold", vn_hold);
RequestManagerRegistry.addMethod("one.vn.release", vn_release);
RequestManagerRegistry.addMethod("one.vn.allocate", vn_allocate);
RequestManagerRegistry.addMethod("one.vn.publish", vn_publish);
RequestManagerRegistry.addMethod("one.vn.update", vn_update);
+4 -2
View File
@@ -212,11 +212,13 @@ int HostAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
string host = xmlrpc_c::value_string(paramList.getString(1));
string im_mad = xmlrpc_c::value_string(paramList.getString(2));
string vmm_mad = xmlrpc_c::value_string(paramList.getString(3));
string tm_mad = xmlrpc_c::value_string(paramList.getString(4));
string vnm_mad = xmlrpc_c::value_string(paramList.getString(4));
string tm_mad = xmlrpc_c::value_string(paramList.getString(5));
HostPool * hpool = static_cast<HostPool *>(pool);
return hpool->allocate(&id, host, im_mad, vmm_mad, tm_mad, error_str);
return hpool->allocate(&id, host, im_mad, vmm_mad, vnm_mad, tm_mad,
error_str);
}
/* -------------------------------------------------------------------------- */
+21 -14
View File
@@ -88,7 +88,8 @@ bool RequestManagerVirtualMachine::vm_authorization(int oid,
int RequestManagerVirtualMachine::get_host_information(int hid,
string& name,
string& vmm,
string& vmm,
string& vnm,
string& tm,
RequestAttributes& att)
{
@@ -110,6 +111,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
name = host->get_name();
vmm = host->get_vmm_mad();
vnm = host->get_vnm_mad();
tm = host->get_tm_mad();
host->unlock();
@@ -142,6 +144,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
int hid,
const string& hostname,
const string& vmm_mad,
const string& vnm_mad,
const string& tm_mad,
RequestAttributes& att)
{
@@ -154,13 +157,13 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
nd.get_configuration_attribute("VM_DIR",vmdir);
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
rc = vmpool->update_history(vm);
if ( rc != 0 )
{
failure_response(INTERNAL,
failure_response(INTERNAL,
request_error("Can not update virtual machine history",""),
att);
@@ -170,7 +173,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
vmpool->update(vm);
return 0;
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@@ -232,7 +235,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
}
switch (rc)
{
{
case 0:
success_response(id, att);
break;
@@ -247,7 +250,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
att);
break;
case -3:
failure_response(ACTION,
failure_response(ACTION,
request_error("Virtual machine action not supported",""),
att);
break;
@@ -273,6 +276,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
string hostname;
string vmm_mad;
string vnm_mad;
string tm_mad;
int id = xmlrpc_c::value_int(paramList.getInt(1));
@@ -283,7 +287,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
if (get_host_information(hid,hostname,vmm_mad,tm_mad, att) != 0)
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad, att) != 0)
{
return;
}
@@ -295,7 +299,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
if ( vm->get_state() != VirtualMachine::PENDING )
{
failure_response(ACTION,
failure_response(ACTION,
request_error("Wrong state to perform action",""),
att);
@@ -303,7 +307,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
if ( add_history(vm,hid,hostname,vmm_mad,tm_mad,att) != 0)
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
{
vm->unlock();
return;
@@ -329,6 +333,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
string hostname;
string vmm_mad;
string vnm_mad;
string tm_mad;
int id = xmlrpc_c::value_int(paramList.getInt(1));
@@ -340,7 +345,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return;
}
if (get_host_information(hid,hostname,vmm_mad,tm_mad,att) != 0)
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
{
return;
}
@@ -354,7 +359,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
(vm->get_lcm_state() != VirtualMachine::RUNNING) ||
(vm->hasPreviousHistory() && vm->get_previous_reason() == History::NONE))
{
failure_response(ACTION,
failure_response(ACTION,
request_error("Wrong state to perform action",""),
att);
@@ -362,7 +367,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return;
}
if ( add_history(vm,hid,hostname,vmm_mad,tm_mad,att) != 0)
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
{
vm->unlock();
return;
@@ -412,6 +417,8 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
oss << "NAME= \"" << img_name << "\"" << endl;
oss << "PUBLIC = NO " << endl;
oss << "SOURCE = - " << endl;
oss << "SAVED_DISK_ID = " << disk_id << endl;
oss << "SAVED_VM_ID = " << id << endl;
if ( img_type != "" )
{
@@ -440,7 +447,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
allocate_error(AuthRequest::IMAGE, error_str), att);
return;
}
// ------------------ Store image id to save the disk ------------------
if ( (vm = get_vm(id, att)) == 0 )
@@ -479,7 +486,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
img->unlock();
}
failure_response(INTERNAL,
failure_response(INTERNAL,
request_error("Can not save_as disk",error_str),
att);
return;
+1 -1
View File
@@ -80,7 +80,7 @@ void RequestManagerVirtualNetwork::
if ( rc < 0 )
{
failure_response(INTERNAL,
request_error("Error modifiying network leases",error_str),
request_error("Error modifying network leases",error_str),
att);
vn->unlock();
+4 -3
View File
@@ -14,9 +14,10 @@
# cipher, for symmetric cipher encryption of tokens
# x509, for x509 certificate encryption of tokens
:core_auth: cipher
# Life-time in seconds for token renewal (that used to handle OpenNebula auths)
:token_expiration_delta: 1800
# VNC Configuration
:vnc_proxy_base_port: 29876
:novnc_path:
# Default language setting
:lang: en_US
@@ -27,9 +27,10 @@ module OpenNebulaJSON
end
self.allocate(host_hash['name'],
host_hash['im_mad'],
host_hash['vm_mad'],
host_hash['tm_mad'])
host_hash['im_mad'],
host_hash['vm_mad'],
host_hash['vnm_mad'],
host_hash['tm_mad'])
end
def delete
@@ -26,9 +26,9 @@ module OpenNebulaJSON
return user_hash
end
password = Digest::SHA1.hexdigest(user_hash['password'])
self.allocate(user_hash['name'], password, user_hash['auth_driver'])
self.allocate(user_hash['name'],
user_hash['password'],
user_hash['auth_driver'])
end
def perform_action(template_json)
@@ -40,7 +40,7 @@ module OpenNebulaJSON
rc = case action_hash['perform']
when "passwd" then self.passwd(action_hash['params'])
when "chgrp" then self.chgrp(action_hash['params'])
when "chauth" then self.chauth(action_hash['params'])
when "chauth" then self.chauth(action_hash['params'])
when "update" then self.update(action_hash['params'])
when "addgroup" then self.addgroup(action_hash['params'])
when "delgroup" then self.delgroup(action_hash['params'])
@@ -52,8 +52,7 @@ module OpenNebulaJSON
end
def passwd(params=Hash.new)
password = Digest::SHA1.hexdigest(params['password'])
super(password)
super(params['password'])
end
def chgrp(params=Hash.new)
@@ -65,7 +64,7 @@ module OpenNebulaJSON
end
def update(params=Hash.new)
super(params['raw_template'])
super(params['template_raw'])
end
def addgroup(params=Hash.new)
@@ -43,11 +43,13 @@ module OpenNebulaJSON
rc = case action_hash['perform']
when "addleases" then self.addleases(action_hash['params'])
when "rmleases" then self.rmleases(action_hash['params'])
when "rmleases" then self.rmleases(action_hash['params'])
when "publish" then self.publish
when "unpublish" then self.unpublish
when "update" then self.update(action_hash['params'])
when "chown" then self.chown(action_hash['params'])
when "hold" then self.hold(action_hash['params'])
when "release" then self.release(action_hash['params'])
else
error_msg = "#{action_hash['perform']} action not " <<
" available for this resource"
@@ -70,5 +72,13 @@ module OpenNebulaJSON
def chown(params=Hash.new)
super(params['owner_id'].to_i,params['group_id'].to_i)
end
def hold(params=Hash.new)
super(params['ip'])
end
def release(params=Hash.new)
super(params['ip'])
end
end
end
+180 -165
View File
@@ -18,45 +18,45 @@ body {
font: 9pt Arial, Verdana, Geneva, Helvetica, sans-serif;
}
p{
margin:0 10px 10px;
}
p {
margin:0 10px 10px;
}
a {
color: #000C96; text-decoration: none;
}
color: #000C96; text-decoration: none;
}
a:hover {
color: #127FE4; text-decoration: none;
}
color: #127FE4; text-decoration: none;
}
select, button {
padding: 2px;
}
padding: 2px;
}
h2 {
float:left;
font-size:20px;
margin-bottom: 5px;
padding-bottom: 0}
float:left;
font-size:20px;
margin-bottom: 5px;
padding-bottom: 0}
h3 {
border-bottom: 1px solid #CCCCCC;
color: #353735;
font-size: 14px;
font-weight: normal;
padding: 5px 8px;
margin: 0 0;
border-bottom: 1px solid #CCCCCC;
color: #353735;
font-size: 14px;
font-weight: normal;
padding: 5px 8px;
margin: 0 0;
}
table#dashboard_table{
width:100%;
margin: 0;
}
width:100%;
margin: 0;
}
table#dashboard_table tr {
vertical-align: top;
}
table#dashboard_table > tbody > tr > td{
width:50%;
width:50%;
}
div.panel {
@@ -130,16 +130,16 @@ ul.multi_action_menu li:hover { background-color: #D3D3D3;}
div.action_block {
display:inline;
margin-right: 5px;
border-right: 1px solid #D3D3D3;
}
display:inline;
margin-right: 5px;
border-right: 1px solid #D3D3D3;
}
div.action_blocks {
margin-bottom: 0.5em;
text-align: right;
margin-top: 0.5em;
}
margin-bottom: 0.5em;
text-align: right;
margin-top: 0.5em;
}
input, textarea, select {
border: 0;
@@ -148,51 +148,51 @@ input, textarea, select {
input, textarea {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-moz-border-radius: 3px;
}
form.create_form{
margin:0;
padding:0;}
margin:0;
padding:0;}
fieldset{
margin:0 0;
border:none;
border-top:1px solid #ccc;
padding: 10px 5px;}
margin:0 0;
border:none;
border-top:1px solid #ccc;
padding: 10px 5px;}
fieldset div{
margin-bottom:.5em;
padding:0;
display:block;
}
margin-bottom:.5em;
padding:0;
display:block;
}
fieldset input,
fieldset textarea{
width:180px;
/*border-top:1px solid #555;
border-left:1px solid #555;
border-bottom:1px solid #ccc;
border-right:1px solid #ccc;*/
padding:1px;color:#333;
vertical-align: top;
margin: 0 2px;
margin-bottom: 4px;
}
width:180px;
/*border-top:1px solid #555;
border-left:1px solid #555;
border-bottom:1px solid #ccc;
border-right:1px solid #ccc;*/
padding:1px;color:#333;
vertical-align: top;
margin: 0 2px;
margin-bottom: 4px;
}
fieldset select{
width:184px;
/*border-top:1px solid #555;
border-left:1px solid #555;
border-bottom:1px solid #ccc;
border-right:1px solid #ccc;*/
padding:1px;
color:#333;
vertical-align: top;
margin: 0 2px;
margin-bottom: 4px;
}
width:184px;
/*border-top:1px solid #555;
border-left:1px solid #555;
border-bottom:1px solid #ccc;
border-right:1px solid #ccc;*/
padding:1px;
color:#333;
vertical-align: top;
margin: 0 2px;
margin-bottom: 4px;
}
/*Chrome hack*/
input[type="radio"],input[type="checkbox"] {
@@ -200,14 +200,14 @@ input[type="radio"],input[type="checkbox"] {
}
legend{
margin-top:0;
margin-bottom: 5px;
padding:0 .5em;
color:#036;
background:transparent;
font-size:1.0em;
font-weight:bold;
}
margin-top:0;
margin-bottom: 5px;
padding:0 .5em;
color:#036;
background:transparent;
font-size:1.0em;
font-weight:bold;
}
label{
float: left;
@@ -216,23 +216,30 @@ label{
text-align:left;
}
.dataTables_wrapper label {
float: none;
width: auto;
padding: 0 0;
text-align:right;
}
div.tip {
display: inline-block;
padding-left: 5px;
vertical-align: middle;
float:none;
}
display: inline-block;
padding-left: 5px;
vertical-align: middle;
float:none;
}
div.tip span.ui-icon{
display:inline-block;
display:inline-block;
}
div.tip span.man_icon {
display:none;
display:none;
}
.img_man .man_icon {
display:inline-block!important;
display:inline-block!important;
}
span.tipspan,div.full_info {
@@ -250,51 +257,51 @@ span.tipspan,div.full_info {
font-size:10px;
}
.vm_section input {
float:none;
float:none;
}
.vm_section legend{
display:none!important;
display:none!important;
}
.vm_section fieldset {
border:none!important;
border:none!important;
}
div.show_hide {
float:none;
clear:both;
float:none;
clear:both;
}
.vm_param label{
float:left;
float:left;
}
fieldset div.vm_section {
margin-top:-8px;
margin-bottom:0px;
margin-top:-8px;
margin-bottom:0px;
}
input:focus,
textarea:focus{
background:#efefef;
color:#000;
background:#efefef;
color:#000;
}
.form_buttons {
margin-top:25px;
text-align:right;
margin-top:25px;
text-align:right;
}
.add_remove_button {
font-size:0.8em;
height:25px;
margin-bottom:4px;
font-size:0.8em !important;
height:25px !important;
margin-bottom:4px;
}
.add_button {
margin-left:148px;
width:74px;
margin-left:148px;
width:58px !important;
}
.remove_button {
@@ -312,15 +319,15 @@ tr.odd td, tr.even td{
}
tr.odd:hover{
background-color: #E69138 !important;
background-color: #E69138 !important;
}
tr.even:hover{
background-color: #E69138 !important;
background-color: #E69138 !important;
}
.show_hide label{
width: 100%;
width: 100%;
}
.clear {
@@ -334,8 +341,8 @@ tr.even:hover{
}
.action_block_info{
width: 235px;
margin: auto;
width: 235px;
margin: auto;
}
.icon_right {
@@ -343,34 +350,34 @@ tr.even:hover{
margin-left: 20px;
position: relative;
top: 2px;
}
}
.icon_left {
float: left;
margin-right: 20px;
position: relative;
top: 0px;
/*border:1px solid;*/
/*border:1px solid;*/
}
.info_table{
background: none repeat scroll 0 0 #FFFFFF;
border-collapse: collapse;
margin: 20px;
text-align: left;
display: inline-block;
width:43%;
vertical-align:top;
overflow:auto;
}
background: none repeat scroll 0 0 #FFFFFF;
border-collapse: collapse;
margin: 20px;
text-align: left;
display: inline-block;
width:43%;
vertical-align:top;
overflow:auto;
}
.info_table > thead th,h3 {
border-bottom: 2px solid #353735;
color: #353735;
font-size: 14px;
font-weight: normal;
padding: 10px 8px;
border-bottom: 2px solid #353735;
color: #353735;
font-size: 14px;
font-weight: normal;
padding: 10px 8px;
}
@@ -381,16 +388,16 @@ tr.even:hover{
padding-bottom: 6px;
padding-left: 8px;
padding-right: 8px;
}
}
/*.info_table > tbody, .info_table > thead, info_table > tbody > tr {
width: 100%;
}*/
width: 100%;
}*/
.info_table td.key_td{
min-width: 150px;
text-align:left;
font-weight:bold;
min-width: 150px;
text-align:left;
font-weight:bold;
}
.info_table td.graph_td{
@@ -400,8 +407,8 @@ tr.even:hover{
}
.info_table td.value_td{
text-align:left;
width:100%;
text-align:left;
width:100%;
}
#dialog > div > div {
@@ -410,43 +417,43 @@ tr.even:hover{
}
.loading_img {
vertical-align:middle;
display:inline;
overflow:hide;
vertical-align:middle;
display:inline;
overflow:hide;
}
.top_button {
font-size: 0.8em;
font-size: 0.8em!important;
height: 25px;
margin: 3px 2px;
vertical-align: middle;
/*width: 89px;*/
/*width: 89px;*/
}
.top_button button {
font-size: 0.9em;
height: 25px;
vertical-align: middle;
font-size: 0.9em;
height: 25px;
vertical-align: middle;
}
.image_button {
font-size: 0.8em;
margin: 3px 2px;
vertical-align: middle;
border:0;
font-size: 0.8em;
margin: 3px 2px;
vertical-align: middle;
border:0;
}
/*
.multi_action_slct{
font-size: 0.7em;
vertical-align:middle;
margin:3px 0;
height: 25px;
}*/
.multi_action_slct{
font-size: 0.7em;
vertical-align:middle;
margin:3px 0;
height: 25px;
}*/
.ui-icon-refresh{
position:relative!important;
top:14px!important;
position:relative!important;
top:14px!important;
}
#vm_log {
@@ -471,15 +478,15 @@ tr.even:hover{
font-size: 1.2em;
}
.jGrowl-notification, .jGrowl-closer, .jGrowl-notify-submit {
.jGrowl-notification, .jGrowl-notify-submit {
border: 2px #444444 solid;
background-color: #F3F3F3;
background-color: #F3F3F3!important;
color: #666666;
}
.jGrowl-notify-error {
border: 2px #660000 solid;
background-color: #F39999;
background-color: #F39999!important;
color: #660000;
}
@@ -508,21 +515,21 @@ tr.even:hover{
ul.action_list{
/*background: #EDEDED;*/
border: 1px solid #525252;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.25, #E9E9E9),
color-stop(0.63, #F5F5F5)
);
background-image: -moz-linear-gradient(
center bottom,
#E9E9E9 25%,
#F5F5F5 63%
);
position:absolute;
/*background: #EDEDED;*/
border: 1px solid #525252;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.25, #E9E9E9),
color-stop(0.63, #F5F5F5)
);
background-image: -moz-linear-gradient(
center bottom,
#E9E9E9 25%,
#F5F5F5 63%
);
position:absolute;
z-index:1;
list-style-type:none;
text-align:left;
@@ -549,7 +556,15 @@ ul.action_list li a:hover{
}
.progress_bar{
height:10px;
background: #8F9392;
height:10px;
background: #8F9392;
}
.ui-widget{
font: 10pt Arial, Verdana, Geneva, Helvetica, sans-serif;
}
.ui-layout-resizer-open-hover, /* hover-color to 'resize' */
.ui-layout-resizer-dragging {
background: #EEE;
}
+27 -17
View File
@@ -44,19 +44,28 @@ body {
}
#header {
padding:0;
padding: 0 10px 0 10px;
background-color: #353735;
border:0;
}
#footer {
padding:0;
padding-top: 9px;
font-size: 0.8em;
color: white;
text-align: center;
background-color: #353735;
border:0;
}
#header {
padding: 0 10px 0 10px;
background-color: #353735;
#footer a {
color: white;
text-decoration: underline;
}
#logo {
padding-top: 6px;
font-weight: bold;
@@ -87,18 +96,6 @@ body {
color: #E69138;
}
#footer {
padding-top: 9px;
font-size: 0.8em;
color: white;
text-align: center;
}
#footer a {
color: white;
text-decoration: underline;
}
#logo-wrapper {
float: right;
margin-top: 0px;
@@ -108,6 +105,7 @@ body {
#menu {
padding-right: 0;
padding-left: 0;
border:0;
border-right: 1px solid #353735;
background-image: -webkit-gradient(
linear,
@@ -171,3 +169,15 @@ background-image: -moz-linear-gradient(
#navigation li:hover a, .navigation-active-li-a {
color: #ffffff !important;
}
#language {
float:right;
margin-top:2px;
margin-right:25px;
width: 100px;
}
#language select {
width: 100px;
height: 22px;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

+3 -3
View File
@@ -75,7 +75,7 @@ $(document).ready(function () {
applyDefaultStyles: false
, center__paneSelector: ".outer-center"
, west__paneSelector: ".outer-west"
, west__size: 130
, west__size: 133
, north__size: 26
, south__size: 26
, spacing_open: 0 // ALL panes
@@ -101,8 +101,8 @@ $(document).ready(function () {
, center__paneSelector: ".inner-center"
, south__paneSelector: ".inner-south"
, south__size: dialog_height
, spacing_open: 8 // ALL panes
, spacing_closed: 12 // ALL panes
, spacing_open: 5 // ALL panes
, spacing_closed: 5 // ALL panes
});
});
+94
View File
@@ -0,0 +1,94 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
var lang=""
var locale = {};
var datatable_lang = "";
function tr(str){
var tmp = locale[str];
if ( tmp == null || tmp == "" ) {
//console.debug("Missing translation: "+str);
tmp = str;
}
return tmp;
};
//Pops up loading new language dialog. Retrieves the user template, updates the LANG variable.
//Updates template and session configuration and reloads the view.
function setLang(lang_str){
var lang_tmp="";
var dialog = $('<div title="Changing language">Loading new language... please wait '+spinner+'</div>').dialog({
draggable:false,
modal:true,
resizable:false,
buttons:{},
width: 460,
minHeight: 50
});
var updateUserTemplate = function(request,user_json){
var template = user_json.USER.TEMPLATE;
var template_str="";
template["LANG"] = lang_tmp;
//convert json to ONE template format - simple conversion
$.each(template,function(key,value){
template_str += (key + '=' + '"' + value + '"\n');
});
var obj = {
data: {
id: uid,
extra_param: template_str
},
error: onError
};
OpenNebula.User.update(obj);
$.post('config',JSON.stringify({lang:lang_tmp}),function(){window.location.href = "."});
};
lang_tmp = lang_str;
if (whichUI() == "sunstone"){
var obj = {
data : {
id: uid,
},
success: updateUserTemplate
};
OpenNebula.User.show(obj);
} else {
dialog.dialog('close');
};
};
$(document).ready(function(){
if (lang)
$('#lang_sel option[value="'+lang+'"]').attr('selected','selected');
$('#lang_sel').change(function(){
setLang($(this).val());
});
//Update static translations
$('#doc_link').text(tr("Documentation"));
$('#support_link').text(tr("Support"));
$('#community_link').text(tr("Community"));
$('#welcome').text(tr("Welcome"));
$('#logout').text(tr("Sign out"));
});
+14
View File
@@ -511,6 +511,20 @@ var OpenNebula = {
"rmleases",
action_obj);
},
"hold" : function(params){
var action_obj = params.data.extra_param;
OpenNebula.Action.simple_action(params,
OpenNebula.Network.resource,
"hold",
action_obj);
},
"release" : function(params){
var action_obj = params.data.extra_param;
OpenNebula.Action.simple_action(params,
OpenNebula.Network.resource,
"release",
action_obj);
},
"update": function(params){
var action_obj = {"template_raw" : params.data.extra_param };
OpenNebula.Action.simple_action(params,
+73 -69
View File
@@ -25,12 +25,12 @@ var acls_tab_content =
<table id="datatable_acls" class="display">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
<th>ID</th>\
<th>Applies to</th>\
<th>Affected resources</th>\
<th>Resource ID / Owned by</th>\
<th>Allowed operations</th>\
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Applies to")+'</th>\
<th>'+tr("Affected resources")+'</th>\
<th>'+tr("Resource ID / Owned by")+'</th>\
<th>'+tr("Allowed operations")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyaclss">\
@@ -42,48 +42,48 @@ var create_acl_tmpl =
'<form id="create_acl_form" action="">\
<fieldset>\
<div>\
<label for="applies">This rule applies to:</label>\
<label for="applies">'+tr("This rule applies to")+':</label>\
<select name="applies" id="applies"></select>\
<div class="clear"></div>\
<label style="height:9em">Affected resources:</label>\
<input type="checkbox" name="res_host" class="resource_cb" value="HOST">Hosts</input><br />\
<input type="checkbox" name="res_vm" class="resource_cb" value="VM">Virtual Machines</input><br />\
<input type="checkbox" name="res_net" class="resource_cb" value="NET">Virtual Networks</input><br />\
<input type="checkbox" name="res_image" class="resource_cb" value="IMAGE">Images</input><br />\
<input type="checkbox" name="res_template" class="resource_cb" value="TEMPLATE">Templates</input><br />\
<input type="checkbox" name="res_user" class="resource_cb" value="USER">Users</input><br />\
<input type="checkbox" name="res_group" class="resource_cb" value="GROUP">Groups</input><br />\
<label style="height:9em">'+tr("Affected resources")+':</label>\
<input type="checkbox" name="res_host" class="resource_cb" value="HOST">'+tr("Hosts")+'</input><br />\
<input type="checkbox" name="res_vm" class="resource_cb" value="VM">'+tr("Virtual Machines")+'</input><br />\
<input type="checkbox" name="res_net" class="resource_cb" value="NET">'+tr("Virtual Networks")+'</input><br />\
<input type="checkbox" name="res_image" class="resource_cb" value="IMAGE">'+tr("Images")+'</input><br />\
<input type="checkbox" name="res_template" class="resource_cb" value="TEMPLATE">'+tr("Templates")+'</input><br />\
<input type="checkbox" name="res_user" class="resource_cb" value="USER">'+tr("Users")+'</input><br />\
<input type="checkbox" name="res_group" class="resource_cb" value="GROUP">'+tr("Groups")+'</input><br />\
<div class="clear"></div>\
<label for="mode_select" style="height:3em;">Resource subset:</label>\
<input type="radio" class="res_subgroup" name="mode_select" value="*" id="res_subgroup_all">All</input><br />\
<input type="radio" class="res_subgroup" name="mode_select" value="res_id" id="res_subgroup_id">Specific ID</input><br />\
<input type="radio" class="res_subgroup" name="mode_select" value="belonging_to" id="res_subgroup_group">Owned by group</input><br />\
<label for="mode_select" style="height:3em;">'+tr("Resource subset")+':</label>\
<input type="radio" class="res_subgroup" name="mode_select" value="*" id="res_subgroup_all">'+tr("All")+'</input><br />\
<input type="radio" class="res_subgroup" name="mode_select" value="res_id" id="res_subgroup_id">'+tr("Specific ID")+'</input><br />\
<input type="radio" class="res_subgroup" name="mode_select" value="belonging_to" id="res_subgroup_group">'+tr("Owned by group")+'</input><br />\
<div class="clear"></div>\
<label for="res_id">Resource ID:</label>\
<label for="res_id">'+tr("Resource ID")+':</label>\
<input type="text" name="res_id" id="res_id"></input>\
<div class="clear"></div>\
<label for="belonging_to">Group:</label>\
<label for="belonging_to">'+tr("Group")+':</label>\
<select name="belonging_to" id="belonging_to"></select>\
<div class="clear"></div>\
<label style="height:12em;">Allowed operations:</label>\
<input type="checkbox" name="right_create" class="right_cb" value="CREATE">Create</input><br />\
<input type="checkbox" name="right_delete" class="right_cb" value="DELETE">Delete</input><br />\
<input type="checkbox" name="right_use" class="right_cb" value="USE">Use</input><br />\
<input type="checkbox" name="right_manage" class="right_cb" value="MANAGE">Manage</input><br />\
<input type="checkbox" name="right_info" class="right_cb" value="INFO">Get Information</input><br />\
<input type="checkbox" name="right_info_pool" class="right_cb" value="INFO_POOL">Get Pool of resources</input><br />\
<input type="checkbox" name="right_info_pool_mine" class="right_cb" value="INFO_POOL_MINE">Get Pool of my/group\'s resources</input><br />\
<input type="checkbox" name="right_chown" class="right_cb" value="CHOWN">Change owner</input><br />\
<input type="checkbox" name="right_deploy" class="right_cb" value="DEPLOY">Deploy</input><br />\
<label style="height:12em;">'+tr("Allowed operations")+':</label>\
<input type="checkbox" name="right_create" class="right_cb" value="CREATE">'+tr("Create")+'</input><br />\
<input type="checkbox" name="right_delete" class="right_cb" value="DELETE">'+tr("Delete")+'</input><br />\
<input type="checkbox" name="right_use" class="right_cb" value="USE">'+tr("Use")+'</input><br />\
<input type="checkbox" name="right_manage" class="right_cb" value="MANAGE">'+tr("Manage")+'</input><br />\
<input type="checkbox" name="right_info" class="right_cb" value="INFO">'+tr("Get Information")+'</input><br />\
<input type="checkbox" name="right_info_pool" class="right_cb" value="INFO_POOL">'+tr("Get Pool of resources")+'</input><br />\
<input type="checkbox" name="right_info_pool_mine" class="right_cb" value="INFO_POOL_MINE">'+tr("Get Pool of my/group\'s resources")+'</input><br />\
<input type="checkbox" name="right_chown" class="right_cb" value="CHOWN">'+tr("Change owner")+'</input><br />\
<input type="checkbox" name="right_deploy" class="right_cb" value="DEPLOY">'+tr("Deploy")+'</input><br />\
<div class="clear"></div>\
<label for="acl_preview">ACL String preview:</label>\
<label for="acl_preview">'+tr("ACL String preview")+':</label>\
<input type="text" name="acl_preview" id="acl_preview" style="width:400px;"></input>\
</div>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="create_acl_submit" value="Acl.create">Create</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" id="create_acl_submit" value="Acl.create">'+tr("Create")+'</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>';
@@ -143,21 +143,21 @@ var acl_actions = {
var acl_buttons = {
"Acl.refresh" : {
type: "image",
text: "Refresh list",
text: tr("Refresh list"),
img: "images/Refresh-icon.png"
},
"Acl.create_dialog" : {
type: "create_dialog",
text: "+ New"
text: tr("+ New")
},
"Acl.delete" : {
type: "action",
text: "Delete"
text: tr("Delete")
}
}
var acls_tab = {
title: "ACLs",
title: tr("ACLs"),
content: acls_tab_content,
buttons: acl_buttons
}
@@ -179,14 +179,14 @@ function aclElements(){
function parseUserAcl(user){
var user_str="";
if (user[0] == '*'){
user_str = "All";
user_str = tr("All");
} else {
if (user[0] == '#'){
user_str="User ";
user_str=tr("User")+" ";
user_str+= getUserName(user.substring(1));
}
else if (user[0] == '@'){
user_str="Group ";
user_str=tr("Group ");
user_str+= getGroupName(user.substring(1));
};
};
@@ -197,14 +197,14 @@ function parseUserAcl(user){
function parseResourceAcl(user){
var user_str="";
if (user[0] == '*'){
user_str = "All";
user_str = tr("All");
} else {
if (user[0] == '#'){
user_str="ID ";
user_str=tr("ID")+" ";
user_str+= user.substring(1);
}
else if (user[0] == '@'){
user_str="Group ";
user_str=tr("Group")+" ";
user_str+= getGroupName(user.substring(1));
};
};
@@ -232,25 +232,25 @@ function parseAclString(string) {
for (var i=0; i<resources_array.length;i++){
switch (resources_array[i]){
case "HOST":
resources_str+="Hosts, ";
resources_str+=tr("Hosts")+", ";
break;
case "VM":
resources_str+="Virtual Machines, ";
resources_str+=tr("Virtual Machines")+", ";
break;
case "NET":
resources_str+="Virtual Networks, ";
resources_str+=tr("Virtual Networks")+", ";
break;
case "IMAGE":
resources_str+="Images, ";
resources_str+=(tr("Images")+", ");
break;
case "TEMPLATE":
resources_str+="VM Templates, ";
resources_str+=tr("VM Templates")+", ";
break;
case "USER":
resources_str+="Users, ";
resources_str+=tr("Users")+", ";
break;
case "GROUP":
resources_str+="Groups, ";
resources_str+=tr("Groups")+", ";
break;
};
};
@@ -303,7 +303,7 @@ function updateAclsView(request,list){
}
function setupCreateAclDialog(){
dialogs_context.append('<div title="Create ACL" id="create_acl_dialog"></div>');
dialogs_context.append('<div title=\"'+tr("Create ACL")+'\" id="create_acl_dialog"></div>');
$create_acl_dialog = $('#create_acl_dialog',dialogs_context);
var dialog = $create_acl_dialog;
dialog.html(create_acl_tmpl);
@@ -316,9 +316,9 @@ function setupCreateAclDialog(){
height: height
});
$('#res_subgroup_all',dialog).attr("checked","checked");
$('#res_id',dialog).attr("disabled","disabled");
$('#belonging_to',dialog).attr("disabled","disabled");
$('#res_subgroup_all',dialog).attr('checked','checked');
$('#res_id',dialog).attr('disabled','disabled');
$('#belonging_to',dialog).attr('disabled','disabled');
$('button',dialog).button();
@@ -327,16 +327,16 @@ function setupCreateAclDialog(){
var context = $(this).parent();
switch (value) {
case "*":
$('#res_id',context).attr("disabled","disabled");
$('#belonging_to',context).attr("disabled","disabled");
$('#res_id',context).attr('disabled','disabled');
$('#belonging_to',context).attr('disabled','disabled');
break;
case "res_id":
$('#res_id',context).removeAttr("disabled");
$('#belonging_to').attr("disabled","disabled");
$('#res_id',context).removeAttr('disabled');
$('#belonging_to').attr('disabled','disabled');
break;
case "belonging_to":
$('#res_id',context).attr("disabled","disabled");
$('#belonging_to',context).removeAttr("disabled");
$('#res_id',context).attr('disabled','disabled');
$('#belonging_to',context).removeAttr('disabled');
break;
};
});
@@ -391,13 +391,13 @@ function setupCreateAclDialog(){
$('#create_acl_form',dialog).submit(function(){
var user = $('#applies',this).val();
if (!user.length) {
notifyError("Please specify to who this ACL applies");
notifyError(tr("Please specify to who this ACL applies"));
return false;
};
var resources = $('.resource_cb:checked',this).length;
if (!resources) {
notifyError("Please select at least one resource");
notifyError(tr("Please select at least one resource"));
return false;
}
@@ -406,7 +406,7 @@ function setupCreateAclDialog(){
case "res_id":
var l=$('#res_id',this).val().length;
if (!l){
notifyError("Please provide a resource ID for the resource(s) in this rule");
notifyError(tr("Please provide a resource ID for the resource(s) in this rule"));
return false;
}
break;
@@ -441,15 +441,15 @@ function popUpCreateAclDialog(){
var users = $('<select>'+users_select+'</select>');
$('.empty_value',users).remove();
$('option',users).addClass("user");
users.prepend('<option value="">---Users---</option>');
users.prepend('<option value="">---'+tr("Users")+'---</option>');
var groups = $('<select>'+groups_select+'</select>');
$('.empty_value',groups).remove();
$('option',groups).addClass("group");
groups.prepend('<option value="">---Groups---</option>');
groups.prepend('<option value="">---'+tr("Groups")+'---</option>');
var dialog = $create_acl_dialog;
$('#applies',dialog).html('<option value="*">All</option>'+
$('#applies',dialog).html('<option value="*">'+tr("All")+'</option>'+
users.html()+groups.html());
$('#belonging_to',dialog).html(groups_select);
@@ -461,7 +461,7 @@ function popUpCreateAclDialog(){
function setAclAutorefresh(){
setInterval(function(){
var checked = $('input.check_item:checked',dataTable_acls);
var filter = $("#datatable_acls_filter input",dataTable_acls.parents("#datatable_acls_wrapper")).attr("value");
var filter = $("#datatable_acls_filter input",dataTable_acls.parents("#datatable_acls_wrapper")).attr('value');
if (!checked.length && !filter.length){
Sunstone.runAction("Acl.autorefresh");
}
@@ -480,7 +480,11 @@ $(document).ready(function(){
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "60px", "aTargets": [0] },
{ "sWidth": "35px", "aTargets": [1] }
]
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
});
dataTable_acls.fnClearTable();
addElement([
+30 -26
View File
@@ -50,40 +50,44 @@ var dashboard_tab_content =
<tr>\
<td>\
<div class="panel">\
<h3>Summary of resources</h3>\
<h3>' + tr("Summary of resources") + '</h3>\
<div class="panel_info">\
\
<table class="info_table">\
<tr>\
<td class="key_td">Hosts (total/active)</td>\
<td class="key_td">' + tr("Hosts (total/active)") + '</td>\
<td class="value_td"><span id="total_hosts"></span><span id="active_hosts" class="green"></span></td>\
</tr>\
<tr>\
<td class="key_td">Groups</td>\
<td class="key_td">' + tr("Groups") + '</td>\
<td class="value_td"><span id="total_groups"></span></td>\
</tr>\
<tr>\
<td class="key_td">VM Templates (total/public)</td>\
<td class="key_td">' + tr("VM Templates (total/public)") + '</td>\
<td class="value_td"><span id="total_templates"></span><span id="public_templates"></span></td>\
</tr>\
<tr>\
<td class="key_td">VM Instances (total/<span class="green">running</span>/<span class="red">failed</span>)</td>\
<td class="key_td">' +
tr("VM Instances")+ ' (' +
tr("total") + '/<span class="green">' +
tr("running") + '</span>/<span class="red">' +
tr("failed") + '</span>)</td>\
<td class="value_td"><span id="total_vms"></span><span id="running_vms" class="green"></span><span id="failed_vms" class="red"></span></td>\
</tr>\
<tr>\
<td class="key_td">Virtual Networks (total/public)</td>\
<td class="key_td">' + tr("Virtual Networks (total/public)") + '</td>\
<td class="value_td"><span id="total_vnets"></span><span id="public_vnets"></span></td>\
</tr>\
<tr>\
<td class="key_td">Images (total/public)</td>\
<td class="key_td">' + tr("Images (total/public)") + '</td>\
<td class="value_td"><span id="total_images"></span><span id="public_images"></span></td>\
</tr>\
<tr>\
<td class="key_td">Users</td>\
<td class="key_td">' + tr("Users")+'</td>\
<td class="value_td"><span id="total_users"></span></td>\
</tr>\
<tr>\
<td class="key_td">ACL Rules</td>\
<td class="key_td">' + tr("ACL Rules") + '</td>\
<td class="value_td"><span id="total_acls"></span></td>\
</tr>\
</table>\
@@ -95,18 +99,18 @@ var dashboard_tab_content =
<tr>\
<td>\
<div class="panel">\
<h3>Quickstart</h3>\
<h3>' + tr("Quickstart") + '</h3>\
<form id="quickstart_form"><fieldset>\
<table style="width:100%;"><tr style="vertical-align:middle;"><td style="width:70%">\
<label style="font-weight:bold;width:40px;height:10em;">New:</label>\
<input type="radio" name="quickstart" value="Host.create_dialog">Host</input><br />\
<input type="radio" name="quickstart" value="VM.create_dialog">VM Instance</input><br />\
<input type="radio" name="quickstart" value="Template.create_dialog">VM Template</input><br />\
<input type="radio" name="quickstart" value="Network.create_dialog">Virtual Network</input><br />\
<input type="radio" name="quickstart" value="Image.create_dialog">Image</input><br />\
<input type="radio" name="quickstart" value="User.create_dialog">User</input><br />\
<input type="radio" name="quickstart" value="Group.create_dialog">Group</input><br />\
<input type="radio" name="quickstart" value="Acl.create_dialog">Acl</input><br />\
<label style="font-weight:bold;width:40px;height:10em;">' + tr("New")+': </label>\
<input type="radio" name="quickstart" value="Host.create_dialog">' + tr("Host") + '</input><br />\
<input type="radio" name="quickstart" value="VM.create_dialog">' + tr("VM Instance") + '</input><br />\
<input type="radio" name="quickstart" value="Template.create_dialog">' + tr("VM Template") + '</input><br />\
<input type="radio" name="quickstart" value="Network.create_dialog">' + tr("Virtual Network") + '</input><br />\
<input type="radio" name="quickstart" value="Image.create_dialog">' + tr("Image") + '</input><br />\
<input type="radio" name="quickstart" value="User.create_dialog">' + tr("User") + '</input><br />\
<input type="radio" name="quickstart" value="Group.create_dialog">' + tr("Group") + '</input><br />\
<input type="radio" name="quickstart" value="Acl.create_dialog">' + tr("Acl") + '</input><br />\
</td></tr></table>\
</div>\
</td>\
@@ -118,19 +122,19 @@ var dashboard_tab_content =
<tr>\
<td>\
<div class="panel">\
<h3>Historical monitoring information</h3>\
<h3>' + tr("Historical monitoring information") + '</h3>\
<div class="panel_info">\
<table class="info_table">\
<tr><td class="key_td graph_td">Hosts CPU</td>\
<tr><td class="key_td graph_td">' + tr("Hosts CPU") + '</td>\
<td class="graph_td" id="graph1_legend"></td></tr>\
<tr><td id="graph1" colspan="2">'+spinner+'</td></tr>\
<tr><td class="key_td graph_td">Hosts memory</td>\
<tr><td class="key_td graph_td">' + tr("Hosts memory") + '</td>\
<td class="graph_td" id="graph2_legend"></td></tr>\
<tr><td id="graph2" colspan="2">'+spinner+'</td></tr>\
<tr><td class="key_td graph_td">Total VM count</td>\
<tr><td class="key_td graph_td">' + tr("Total VM count") + '</td>\
<td class="graph_td" id="graph3_legend"></td></tr>\
<tr><td id="graph3" colspan="2">'+spinner+'</td></tr>\
<tr><td class="key_td graph_td">VM Network stats</td>\
<tr><td class="key_td graph_td">' + tr("VM Network stats") + '</td>\
<td class="graph_td" id="graph4_legend"></td></tr>\
<tr><td id="graph4" colspan="2">'+spinner+'</td></tr>\
</table>\
@@ -143,7 +147,7 @@ var dashboard_tab_content =
</tr></table>';
var dashboard_tab = {
title: 'Dashboard',
title: tr("Dashboard"),
content: dashboard_tab_content
}
@@ -163,7 +167,7 @@ function plot_global_graph(data,info){
for (var i=0; i<labels_array.length; i++) {
serie = {
label: labels_array[i],
label: tr(labels_array[i]),
data: monitoring[labels_array[i]]
};
series.push(serie);
@@ -50,24 +50,27 @@ var dashboard_tab_content =
<tr>\
<td>\
<div class="panel">\
<h3>Summary of resources</h3>\
<h3>'+tr("Summary of resources")+'</h3>\
<div class="panel_info">\
\
<table class="info_table">\
<tr>\
<td class="key_td">VM Templates (total/public)</td>\
<td class="key_td">'+tr("VM Templates (total/public)")+'</td>\
<td class="value_td"><span id="total_templates"></span><span id="public_templates"></span></td>\
</tr>\
<tr>\
<td class="key_td">VM Instances (total/<span class="green">running</span>/<span class="red">failed</span>)</td>\
<td class="key_td">'+tr("VM Instances")+' ('+
tr("total")+'/<span class="green">'+
tr("running")+'</span>/<span class="red">'+
tr("failed")+'</span>)</td>\
<td class="value_td"><span id="total_vms"></span><span id="running_vms" class="green"></span><span id="failed_vms" class="red"></span></td>\
</tr>\
<tr>\
<td class="key_td">Virtual Networks (total/public)</td>\
<td class="key_td">'+tr("Virtual Networks (total/public)")+'</td>\
<td class="value_td"><span id="total_vnets"></span><span id="public_vnets"></span></td>\
</tr>\
<tr>\
<td class="key_td">Images (total/public)</td>\
<td class="key_td">'+tr("Images (total/public)")+'</td>\
<td class="value_td"><span id="total_images"></span><span id="public_images"></span></td>\
</tr>\
</table>\
@@ -79,14 +82,14 @@ var dashboard_tab_content =
<tr>\
<td>\
<div class="panel">\
<h3>Quickstart</h3>\
<h3>'+tr("Quickstart")+'</h3>\
<form id="quickstart_form"><fieldset>\
<table style="width:100%;"><tr style="vertical-align:middle;"><td style="width:70%">\
<label style="font-weight:bold;width:40px;height:4em;">New:</label>\
<input type="radio" name="quickstart" value="Template.create_dialog">VM Template</input><br />\
<input type="radio" name="quickstart" value="VM.create_dialog">VM Instance</input><br />\
<input type="radio" name="quickstart" value="Network.create_dialog">Virtual Network</input><br />\
<input type="radio" name="quickstart" value="Image.create_dialog">Image</input><br />\
<input type="radio" name="quickstart" value="Template.create_dialog">'+tr("VM Template")+'</input><br />\
<input type="radio" name="quickstart" value="VM.create_dialog">'+tr("VM Instance")+'</input><br />\
<input type="radio" name="quickstart" value="Network.create_dialog">'+tr("Virtual Network")+'</input><br />\
<input type="radio" name="quickstart" value="Image.create_dialog">'+tr("Image")+'</input><br />\
</td></tr></table>\
</div>\
</td>\
@@ -98,19 +101,19 @@ var dashboard_tab_content =
<tr>\
<td>\
<div class="panel">\
<h3>Historical monitoring information</h3>\
<h3>'+tr("Historical monitoring information")+'</h3>\
<div class="panel_info">\
<table class="info_table">\
<tr><td class="key_td graph_td">Total VM count</td>\
<tr><td class="key_td graph_td">'+tr("Total VM count")+'</td>\
<td class="graph_td" id="graph1_legend"></td></tr>\
<tr><td id="graph1" colspan="2">'+spinner+'</td></tr>\
<tr><td class="key_td graph_td">Total VM CPU</td>\
<tr><td class="key_td graph_td">'+tr("Total VM CPU")+'</td>\
<td class="graph_td" id="graph2_legend"></td></tr>\
<tr><td id="graph2" colspan="2">'+spinner+'</td></tr>\
<tr><td class="key_td graph_td">Total VM Memory</td>\
<tr><td class="key_td graph_td">'+tr("Total VM Memory")+'</td>\
<td class="graph_td" id="graph3_legend"></td></tr>\
<tr><td id="graph3" colspan="2">'+spinner+'</td></tr>\
<tr><td class="key_td graph_td">VM Network stats</td>\
<tr><td class="key_td graph_td">'+tr("VM Network stats")+'</td>\
<td class="graph_td" id="graph4_legend"></td></tr>\
<tr><td id="graph4" colspan="2">'+spinner+'</td></tr>\
</table>\
@@ -123,7 +126,7 @@ var dashboard_tab_content =
</tr></table>';
var dashboard_tab = {
title: 'Dashboard',
title: tr("Dashboard"),
content: dashboard_tab_content
}
+18 -14
View File
@@ -25,10 +25,10 @@ var groups_tab_content =
<table id="datatable_groups" class="display">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
<th>ID</th>\
<th>Name</th>\
<th>Users</th>\
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Users")+'</th>\
</tr>\
</thead>\
<tbody id="tbodygroups">\
@@ -40,14 +40,14 @@ var create_group_tmpl =
'<form id="create_group_form" action="">\
<fieldset style="border:none;">\
<div>\
<label for="name">Group name:</label>\
<label for="name">'+tr("Group name")+':</label>\
<input type="text" name="name" id="name" /><br />\
</div>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="create_group_submit" value="Group.create">Create</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" id="create_group_submit" value="Group.create">'+tr("Create")+'</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>';
@@ -118,12 +118,12 @@ var group_actions = {
var group_buttons = {
"Group.refresh" : {
type: "image",
text: "Refresh list",
text: tr("Refresh list"),
img: "images/Refresh-icon.png"
},
"Group.create_dialog" : {
type: "create_dialog",
text: "+ New Group"
text: tr("+ New Group")
},
// "Group.chown" : {
// type: "confirm_with_select",
@@ -135,12 +135,12 @@ var group_buttons = {
"Group.delete" : {
type: "action",
text: "Delete"
text: tr("Delete")
}
};
var groups_tab = {
title: 'Groups',
title: tr("Groups"),
content: groups_tab_content,
buttons: group_buttons
}
@@ -228,7 +228,7 @@ function updateGroupsView(request, group_list){
//Prepares the dialog to create
function setupCreateGroupDialog(){
dialogs_context.append('<div title="Create group" id="create_group_dialog"></div>');
dialogs_context.append('<div title=\"'+tr("Create group")+'\" id="create_group_dialog"></div>');
$create_group_dialog = $('#create_group_dialog',dialogs_context);
var dialog = $create_group_dialog;
@@ -259,7 +259,7 @@ function popUpCreateGroupDialog(){
function setGroupAutorefresh(){
setInterval(function(){
var checked = $('input.check_item:checked',dataTable_groups);
var filter = $("#datatable_groups_filter input",dataTable_groups.parents("#datatable_groups_wrapper")).attr("value");
var filter = $("#datatable_groups_filter input",dataTable_groups.parents("#datatable_groups_wrapper")).attr('value');
if (!checked.length && !filter.length){
Sunstone.runAction("Group.autorefresh");
}
@@ -276,7 +276,11 @@ $(document).ready(function(){
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "60px", "aTargets": [0] },
{ "sWidth": "35px", "aTargets": [1] }
]
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
});
dataTable_groups.fnClearTable();
+79 -61
View File
@@ -19,13 +19,13 @@
var HOST_HISTORY_LENGTH = 40;
var host_graphs = [
{
title : "CPU Monitoring information",
title : tr("CPU Monitoring information"),
monitor_resources : "cpu_usage,used_cpu,max_cpu",
humanize_figures : false,
history_length : HOST_HISTORY_LENGTH
},
{
title: "Memory monitoring information",
title: tr("Memory monitoring information"),
monitor_resources : "mem_usage,used_mem,max_mem",
humanize_figures : true,
history_length : HOST_HISTORY_LENGTH
@@ -40,13 +40,13 @@ var hosts_tab_content =
<table id="datatable_hosts" class="display">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
<th>ID</th>\
<th>Name</th>\
<th>Running VMs</th>\
<th>CPU Use</th>\
<th>Memory use</th>\
<th>Status</th>\
<th class="check"><input type="checkbox" class="check_all" value="">' + tr("All") + '</input></th>\
<th>' + tr("id") + '</th>\
<th>' + tr("Name") + '</th>\
<th>' + tr("Running VMs") + '</th>\
<th>' + tr("CPU Use") + '</th>\
<th>' + tr("Memory use") + '</th>\
<th>' + tr("Status") + '</th>\
</tr>\
</thead>\
<tbody id="tbodyhosts">\
@@ -57,42 +57,51 @@ var hosts_tab_content =
var create_host_tmpl =
'<div class="create_form"><form id="create_host_form" action="">\
<fieldset>\
<legend style="display:none;">Host parameters</legend>\
<label for="name">Name: </label><input type="text" name="name" id="name" />\
<legend style="display:none;">' + tr("Host parameters") + '</legend>\
<label for="name">' + tr("Name") + ':</label><input type="text" name="name" id="name" />\
</fieldset>\
<h3>Drivers</h3>\
<h3>' + tr("Drivers") + '</h3>\
<fieldset>\
<div class="manager clear" id="vmm_mads">\
<label>Virtualization Manager:</label>\
<label>' + tr("Virtualization Manager") + ':</label>\
<select id="vmm_mad" name="vmm">\
<option value="vmm_kvm">KVM</option>\
<option value="vmm_xen">XEN</option>\
<option value="vmm_ec2">EC2</option>\
<option value="vmm_dummy">Dummy</option>\
<option value="vmm_kvm">' + tr("KVM") + '</option>\
<option value="vmm_xen">' + tr("XEN") + '</option>\
<option value="vmm_ec2">' + tr("EC2") + '</option>\
<option value="vmm_dummy">' + tr("Dummy") + '</option>\
</select>\
</div>\
<div class="manager clear" id="im_mads">\
<label>Information Manager:</label>\
<label>' + tr("Information Manager") + ':</label>\
<select id="im_mad" name="im">\
<option value="im_kvm">KVM</option>\
<option value="im_xen">XEN</option>\
<option value="im_ec2">EC2</option>\
<option value="im_dummy">Dummy</option>\
<option value="im_kvm">' + tr("KVM") + '</option>\
<option value="im_xen">' + tr("XEN") + '</option>\
<option value="im_ec2">' + tr("EC2") + '</option>\
<option value="im_dummy">' + tr("Dummy") + '</option>\
</select>\
</div>\
<div class="manager clear" id="vnm_mads">\
<label>Virtual Network Manager:</label>\
<select id="vnm_mad" name="vn">\
<option value="dummy">Dummy</option>\
<option value="etables">Etables</option>\
<option value="ovswitch">Open vSwitch</option>\
<option value="802.1Q">802.1Q</option>\
</select>\
</div>\
<div class="manager clear" id="tm_mads">\
<label>Transfer Manager:</label>\
<label>' + tr("Transfer Manager") + ':</label>\
<select id="tm_mad" name="tm">\
<option value="tm_shared">SHARED</option>\
<option value="tm_ssh">SSH</option>\
<option value="tm_dummy">Dummy</option>\
<option value="tm_shared">' + tr("Shared") + '</option>\
<option value="tm_ssh">' + tr("SSH") + '</option>\
<option value="tm_dummy">' + tr("Dummy") + '</option>\
</select>\
</div>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<div><button class="button" id="create_host_submit" value="OpenNebula.Host.create">Create</button>\
<button class="button" type="reset" value="reset">Reset</button></div>\
<div><button class="button" id="create_host_submit" value="OpenNebula.Host.create">' + tr("Create") + '</button>\
<button class="button" type="reset" value="reset">' + tr("Reset") + '</button></div>\
</div>\
</fieldset>\
</form></div>';
@@ -233,7 +242,7 @@ var host_actions = {
type: "single",
call: OpenNebula.Host.update,
callback: function() {
notifyMessage("Template updated correctly");
notifyMessage(tr("Template updated correctly"));
},
error: onError
}
@@ -242,51 +251,51 @@ var host_actions = {
var host_buttons = {
"Host.refresh" : {
type: "image",
text: "Refresh list",
text: tr("Refresh list"),
img: "images/Refresh-icon.png"
},
"Host.create_dialog" : {
type: "create_dialog",
text: "+ New"
text: tr("+ New")
},
"Host.update_dialog" : {
type: "action",
text: "Update a template",
text: tr("Update a template"),
alwaysActive: true
},
"Host.enable" : {
type: "action",
text: "Enable"
text: tr("Enable")
},
"Host.disable" : {
type: "action",
text: "Disable"
text: tr("Disable")
},
"Host.delete" : {
type: "action",
text: "Delete host"
text: tr("Delete host")
}
};
var host_info_panel = {
"host_info_tab" : {
title: "Host information",
title: tr("Host information"),
content:""
},
"host_template_tab" : {
title: "Host template",
title: tr("Host template"),
content: ""
},
"host_monitoring_tab": {
title: "Monitoring information",
title: tr("Monitoring information"),
content: ""
}
};
var hosts_tab = {
title: 'Hosts',
title: tr("Hosts"),
content: hosts_tab_content,
buttons: host_buttons
}
@@ -420,62 +429,66 @@ function updateHostInfo(request,host){
//Information tab
var info_tab = {
title : "Host information",
title : tr("Host information"),
content :
'<table id="info_host_table" class="info_table">\
<thead>\
<tr><th colspan="2">Host information - '+host_info.NAME+'</th></tr>\
<tr><th colspan="2">' + tr("Host information") + ' - '+host_info.NAME+'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">ID</td>\
<td class="key_td">' + tr("id") + '</td>\
<td class="value_td">'+host_info.ID+'</td>\
</tr>\
<tr>\
<td class="key_td">State</td>\
<td class="value_td">'+OpenNebula.Helper.resource_state("host",host_info.STATE)+'</td>\
<td class="key_td">' + tr("State") + '</td>\
<td class="value_td">'+tr(OpenNebula.Helper.resource_state("host",host_info.STATE))+'</td>\
</tr>\
<tr>\
<td class="key_td">IM MAD</td>\
<td class="key_td">' + tr("IM MAD") + '</td>\
<td class="value_td">'+host_info.IM_MAD+'</td>\
</tr>\
<tr>\
<td class="key_td">VM MAD</td>\
<td class="key_td">' + tr("VM MAD") + '</td>\
<td class="value_td">'+host_info.VM_MAD+'</td>\
</tr>\
<tr>\
<td class="key_td">TM MAD</td>\
<td class="key_td">'+ tr("VN MAD") +'</td>\
<td class="value_td">'+host_info.VN_MAD+'</td>\
</tr>\
<tr>\
<td class="key_td">'+ tr("TM MAD") +'</td>\
<td class="value_td">'+host_info.TM_MAD+'</td>\
</tr>\
</tbody>\
</table>\
<table id="host_shares_table" class="info_table">\
<thead>\
<tr><th colspan="2">Host shares</th></tr>\
<tr><th colspan="2">' + tr("Host shares") + '</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">Max Mem</td>\
<td class="key_td">' + tr("Max Mem") + '</td>\
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.MAX_MEM)+'</td>\
</tr>\
<tr>\
<td class="key_td">Used Mem (real)</td>\
<td class="key_td">' + tr("Used Mem (real)") + '</td>\
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.USED_MEM)+'</td>\
</tr>\
<tr>\
<td class="key_td">Used Mem (allocated)</td>\
<td class="key_td">' + tr("Used Mem (allocated)") + '</td>\
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.MAX_USAGE)+'</td>\
</tr>\
<tr>\
<td class="key_td">Used CPU (real)</td>\
<td class="key_td">' + tr("Used CPU (real)") + '</td>\
<td class="value_td">'+host_info.HOST_SHARE.USED_CPU+'</td>\
</tr>\
<tr>\
<td class="key_td">Used CPU (allocated)</td>\
<td class="key_td">' + tr("Used CPU (allocated)") + '</td>\
<td class="value_td">'+host_info.HOST_SHARE.CPU_USAGE+'</td>\
</tr>\
<tr>\
<td class="key_td">Running VMs</td>\
<td class="key_td">' + tr("Running VMs") + '</td>\
<td class="value_td">'+host_info.HOST_SHARE.RUNNING_VMS+'</td>\
</tr>\
</tbody>\
@@ -484,16 +497,16 @@ function updateHostInfo(request,host){
//Template tab
var template_tab = {
title : "Host template",
title : tr("Host template"),
content :
'<table id="host_template_table" class="info_table" style="width:80%">\
<thead><tr><th colspan="2">Host template</th></tr></thead>'+
<thead><tr><th colspan="2">' + tr("Host template") + '</th></tr></thead>'+
prettyPrintJSON(host_info.TEMPLATE)+
'</table>'
}
var monitor_tab = {
title: "Monitoring information",
title: tr("Monitoring information"),
content : generateMonitoringDivs(host_graphs,"host_monitor_")
}
@@ -513,7 +526,7 @@ function updateHostInfo(request,host){
//Prepares the host creation dialog
function setupCreateHostDialog(){
dialogs_context.append('<div title="Create host" id="create_host_dialog"></div>');
dialogs_context.append('<div title=\"'+tr("Create host")+'\" id="create_host_dialog"></div>');
$create_host_dialog = $('div#create_host_dialog');
var dialog = $create_host_dialog;
@@ -529,7 +542,7 @@ function setupCreateHostDialog(){
//Handle the form submission
$('#create_host_form',dialog).submit(function(){
if (!($('#name',this).val().length)){
notifyError("Host name missing!");
notifyError(tr("Host name missing!"));
return false;
}
var host_json = {
@@ -537,6 +550,7 @@ function setupCreateHostDialog(){
"name": $('#name',this).val(),
"tm_mad": $('#tm_mad :selected',this).val(),
"vm_mad": $('#vmm_mad :selected',this).val(),
"vnm_mad": $('#vnm_mad :selected',this).val(),
"im_mad": $('#im_mad :selected',this).val()
}
}
@@ -559,7 +573,7 @@ function popUpCreateHostDialog(){
function setHostAutorefresh() {
setInterval(function(){
var checked = $('input.check_item:checked',dataTable_hosts);
var filter = $("#datatable_hosts_filter input",dataTable_hosts.parents('#datatable_hosts_wrapper')).attr("value");
var filter = $("#datatable_hosts_filter input",dataTable_hosts.parents('#datatable_hosts_wrapper')).attr('value');
if (!checked.length && !filter.length){
Sunstone.runAction("Host.autorefresh");
}
@@ -596,7 +610,11 @@ $(document).ready(function(){
{ "sWidth": "35px", "aTargets": [1] },
{ "sWidth": "100px", "aTargets": [6] },
{ "sWidth": "200px", "aTargets": [4,5] }
]
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
});
//preload it
+151 -142
View File
@@ -23,18 +23,18 @@ var images_tab_content =
<table id="datatable_images" class="display">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
<th>ID</th>\
<th>Owner</th>\
<th>Group</th>\
<th>Name</th>\
<th>Size</th>\
<th>Type</th>\
<th>Registration time</th>\
<th>Public</th>\
<th>Persistent</th>\
<th>Status</th>\
<th>#VMS</th>\
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Size")+'</th>\
<th>'+tr("Type")+'</th>\
<th>'+tr("Registration time")+'</th>\
<th>'+tr("Public")+'</th>\
<th>'+tr("Persistent")+'</th>\
<th>'+tr("Status")+'</th>\
<th>'+tr("#VMS")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyimages">\
@@ -44,114 +44,116 @@ var images_tab_content =
var create_image_tmpl =
'<div id="img_tabs">\
<ul><li><a href="#img_easy">Wizard</a></li>\
<li><a href="#img_manual">Advanced mode</a></li>\
<ul><li><a href="#img_easy">'+tr("Wizard")+'</a></li>\
<li><a href="#img_manual">'+tr("Advanced mode")+'</a></li>\
</ul>\
<div id="img_easy">\
<form id="create_image_form_easy" action="">\
<p style="font-size:0.8em;text-align:right;"><i>Fields marked with <span style="display:inline-block;" class="ui-icon ui-icon-alert" /> are mandatory</i><br />\
<p style="font-size:0.8em;text-align:right;"><i>'+
tr("Fields marked with")+' <span style="display:inline-block;" class="ui-icon ui-icon-alert" /> '+
tr("are mandatory")+'</i><br />\
<fieldset>\
<div class="img_param img_man">\
<label for="img_name">Name:</label>\
<label for="img_name">'+tr("Name")+':</label>\
<input type="text" name="img_name" id="img_name" />\
<div class="tip">Name that the Image will get. Every image must have a unique name.</div>\
<div class="tip">'+tr("Name that the Image will get. Every image must have a unique name.")+'</div>\
</div>\
<div class="img_param">\
<label for="img_desc">Description:</label>\
<label for="img_desc">'+tr("Description")+':</label>\
<textarea name="img_desc" id="img_desc" style="height:4em"></textarea>\
<div class="tip">Human readable description of the image for other users.</div>\
<div class="tip">'+tr("Human readable description of the image for other users.")+'</div>\
</div>\
</fieldset>\
<fieldset>\
<div class="img_param">\
<label for="img_type">Type:</label>\
<label for="img_type">'+tr("Type")+':</label>\
<select name="img_type" id="img_type">\
<option value="OS">OS</option>\
<option value="CDROM">CD-ROM</option>\
<option value="DATABLOCK">Datablock</option>\
<option value="OS">'+tr("OS")+'</option>\
<option value="CDROM">'+tr("CD-ROM")+'</option>\
<option value="DATABLOCK">'+tr("Datablock")+'</option>\
</select>\
<div class="tip">Type of the image, explained in detail in the following section. If omitted, the default value is the one defined in oned.conf (install default is OS).</div>\
<div class="tip">'+tr("Type of the image, explained in detail in the following section. If omitted, the default value is the one defined in oned.conf (install default is OS).")+'</div>\
</div>\
<div class="img_param">\
<label for="img_public">Public:</label>\
<label for="img_public">'+tr("Public")+':</label>\
<input type="checkbox" id="img_public" name="img_public" value="YES" />\
<div class="tip">Public scope of the image</div>\
<div class="tip">'+tr("Public scope of the image")+'</div>\
</div>\
<div class="img_param">\
<label for="img_persistent">Persistent:</label>\
<label for="img_persistent">'+tr("Persistent")+':</label>\
<input type="checkbox" id="img_persistent" name="img_persistent" value="YES" />\
<div class="tip">Persistence of the image</div>\
<div class="tip">'+tr("Persistence of the image")+'</div>\
</div>\
<div class="img_param">\
<label for="img_dev_prefix">Device prefix:</label>\
<label for="img_dev_prefix">'+tr("Device prefix")+':</label>\
<input type="text" name="img_dev_prefix" id="img_dev_prefix" />\
<div class="tip">Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”. If omitted, the default value is the one defined in oned.conf (installation default is “hd”).</div>\
<div class="tip">'+tr("Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”. If omitted, the default value is the one defined in oned.conf (installation default is “hd”).")+'</div>\
</div>\
<div class="img_param">\
<label for="img_bus">Bus:</label>\
<label for="img_bus">'+tr("Bus")+':</label>\
<select name="img_bus" id="img_bus">\
<option value="IDE">IDE</option>\
<option value="SCSI">SCSI</option>\
<option value="virtio">Virtio (KVM)</option>\
<option value="IDE">'+tr("IDE")+'</option>\
<option value="SCSI">'+tr("SCSI")+'</option>\
<option value="virtio">'+tr("Virtio (KVM)")+'</option>\
</select>\
<div class="tip">Type of disk device to emulate.</div>\
<div class="tip">'+tr("Type of disk device to emulate.")+'</div>\
</div>\
<div class="img_param">\
<label for="img_driver">Driver:</label>\
<label for="img_driver">'+tr("Driver")+':</label>\
<input type="text" name="img_driver" id="img_driver" />\
<div class="tip">Specific image mapping driver. KVM: raw, qcow2 and Xen:tap:aio:, file:</div>\
<div class="tip">'+tr("Specific image mapping driver. KVM: raw, qcow2. XEN: tap:aio, file:")+'</div>\
</div>\
</fieldset>\
<fieldset>\
<div class="" id="src_path_select">\
<label style="height:3em;">Path vs. source:</label>\
<label style="height:3em;">'+tr("Path vs. source")+':</label>\
<input type="radio" name="src_path" id="path_img" value="path" />\
<label style="float:none">Provide a path</label><br />\
<label style="float:none">'+tr("Provide a path")+'</label><br />\
<input type="radio" name="src_path" id="source_img" value="source" />\
<label style="float:none">Provide a source</label><br />\
<label style="float:none">'+tr("Provide a source")+'</label><br />\
<input type="radio" name="src_path" id="datablock_img" value="datablock" />\
<label style="float:none;vertical-align:top">Create an empty datablock</label>\
<div class="tip">Please choose path if you have a file-based image. Choose source otherwise or create an empty datablock disk.</div><br />\
<label style="float:none;vertical-align:top">'+tr("Create an empty datablock")+'</label>\
<div class="tip">'+tr("Please choose path if you have a file-based image. Choose source otherwise or create an empty datablock disk.")+'</div><br />\
</div>\
<div class="img_param">\
<label for="img_path">Path:</label>\
<label for="img_path">'+tr("Path")+':</label>\
<input type="text" name="img_path" id="img_path" />\
<div class="tip">Path to the original file that will be copied to the image repository. If not specified for a DATABLOCK type image, an empty image will be created.</div>\
<div class="tip">'+tr("Path to the original file that will be copied to the image repository. If not specified for a DATABLOCK type image, an empty image will be created.")+'</div>\
</div>\
<div class="img_param">\
<label for="img_source">Source:</label>\
<label for="img_source">'+tr("Source")+':</label>\
<input type="text" name="img_source" id="img_source" />\
<div class="tip">Source to be used in the DISK attribute. Useful for not file-based images.</div>\
<div class="tip">'+tr("Source to be used in the DISK attribute. Useful for not file-based images.")+'</div>\
</div>\
<div class="img_size">\
<label for="img_size">Size:</label>\
<label for="img_size">'+tr("Size")+':</label>\
<input type="text" name="img_size" id="img_size" />\
<div class="tip">Size of the datablock in MB.</div>\
<div class="tip">'+tr("Size of the datablock in MB.")+'</div>\
</div>\
<div class="img_param">\
<label for="img_fstype">FS type:</label>\
<label for="img_fstype">'+tr("FS type")+':</label>\
<input type="text" name="img_fstype" id="img_fstype" />\
<div class="tip">Type of file system to be built. This can be any value understood by mkfs unix command.</div>\
<div class="tip">'+tr("Type of file system to be built. This can be any value understood by mkfs unix command.")+'</div>\
</div>\
</fieldset>\
<fieldset>\
<div class="">\
<label for="custom_var_image_name">Name:</label>\
<label for="custom_var_image_name">'+tr("Name")+':</label>\
<input type="text" id="custom_var_image_name" name="custom_var_image_name" />\
<label for="custom_var_image_value">Value:</label>\
<label for="custom_var_image_value">'+tr("Value")+':</label>\
<input type="text" id="custom_var_image_value" name="custom_var_image_value" />\
<button class="add_remove_button add_button" id="add_custom_var_image_button" value="add_custom_image_var">Add</button>\
<button class="add_remove_button" id="remove_custom_var_image_button" value="remove_custom_image_var">Remove selected</button>\
<button class="add_remove_button add_button" id="add_custom_var_image_button" value="add_custom_image_var">'+tr("Add")+'</button>\
<button class="add_remove_button" id="remove_custom_var_image_button" value="remove_custom_image_var">'+tr("Remove selected")+'</button>\
<div class="clear"></div>\
<label for="custom_var_image_box">Custom attributes:</label>\
<label for="custom_var_image_box">'+tr("Custom attributes")+':</label>\
<select id="custom_var_image_box" name="custom_var_image_box" style="height:100px;" multiple>\
</select>\
</div>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="create_image_submit" value="user/create">Create</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" id="create_image_submit" value="user/create">'+tr("Create")+'</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>\
@@ -159,16 +161,16 @@ var create_image_tmpl =
<div id="img_manual">\
<form id="create_image_form_manual" action="">\
<fieldset style="border-top:none;">\
<h3 style="margin-bottom:10px;">Write the image template here</h3>\
<h3 style="margin-bottom:10px;">'+tr("Write the image template here")+'</h3>\
<textarea id="template" rows="15" style="width:100%;">\
</textarea>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="create_vn_submit_manual" value="vn/create">\
Create\
'+tr("Create")+'\
</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>\
@@ -177,27 +179,26 @@ var create_image_tmpl =
var update_image_tmpl =
'<form action="javascript:alert(\'js error!\');">\
<h3 style="margin-bottom:10px;">Please, choose and modify the image you want to update:</h3>\
<h3 style="margin-bottom:10px;">'+tr("Please, choose and modify the image you want to update")+':</h3>\
<fieldset style="border-top:none;">\
<label for="image_template_update_select">Select an image:</label>\
<label for="image_template_update_select">'+tr("Select an image")+':</label>\
<select id="image_template_update_select" name="image_template_update_select"></select>\
<div class="clear"></div>\
<div>\
<label for="image_template_update_public">Public:</label>\
<label for="image_template_update_public">'+tr("Public")+':</label>\
<input type="checkbox" name="image_template_update_public" id="image_template_update_public" />\
</div>\
<div>\
<label for="image_template_update_public">Persistent:</label>\
<label for="image_template_update_public">'+tr("Persistent")+':</label>\
<input type="checkbox" name="image_template_update_persistent" id="image_template_update_persistent" />\
</div>\
<label for="image_template_update_textarea">Template:</label>\
<label for="image_template_update_textarea">'+tr("Template")+':</label>\
<div class="clear"></div>\
<textarea id="image_template_update_textarea" style="width:100%; height:14em;"></textarea>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="image_template_update_button" value="Image.update_template">\
Update\
<button class="button" id="image_template_update_button" value="Image.update_template">'+tr("Update")+'\
</button>\
</div>\
</fieldset>\
@@ -277,7 +278,7 @@ var image_actions = {
type: "single",
call: OpenNebula.Image.update,
callback: function() {
notifyMessage("Template updated correctly");
notifyMessage(tr("Template updated correctly"));
},
error: onError
},
@@ -396,30 +397,30 @@ var image_actions = {
var image_buttons = {
"Image.refresh" : {
type: "image",
text: "Refresh list",
text: tr("Refresh list"),
img: "images/Refresh-icon.png"
},
"Image.create_dialog" : {
type: "create_dialog",
text: "+ New"
text: tr('+ New')
},
"Image.update_dialog" : {
type: "action",
text: "Update a template",
text: tr("Update a template"),
alwaysActive: true
},
"Image.chown" : {
type: "confirm_with_select",
text: "Change owner",
text: tr("Change owner"),
select: users_sel,
tip: "Select the new owner:",
tip: tr("Select the new owner")+":",
condition: mustBeAdmin
},
"Image.chgrp" : {
type: "confirm_with_select",
text: "Change group",
text: tr("Change group"),
select: groups_sel,
tip: "Select the new group:",
tip: tr("Select the new group")+":",
condition: mustBeAdmin
},
"action_list" : {
@@ -427,51 +428,51 @@ var image_buttons = {
actions: {
"Image.enable" : {
type: "action",
text: "Enable"
text: tr("Enable")
},
"Image.disable" : {
type: "action",
text: "Disable"
text: tr("Disable")
},
"Image.publish" : {
type: "action",
text: "Publish"
text: tr("Publish")
},
"Image.unpublish" : {
type: "action",
text: "Unpublish"
text: tr("Unpublish")
},
"Image.persistent" : {
type: "action",
text: "Make persistent"
text: tr("Make persistent")
},
"Image.nonpersistent" : {
type: "action",
text: "Make non persistent"
text: tr("Make non persistent")
}
}
},
"Image.delete" : {
type: "action",
text: "Delete"
text: tr("Delete")
}
}
var image_info_panel = {
"image_info_tab" : {
title: "Image information",
title: tr("Image information"),
content: ""
},
"image_template_tab" : {
title: "Image template",
title: tr("Image template"),
content: ""
}
}
var images_tab = {
title: "Images",
title: tr("Images"),
content: images_tab_content,
buttons: image_buttons
}
@@ -492,13 +493,13 @@ function imageElementArray(image_json){
var image = image_json.IMAGE;
var type = $('<select>\
<option value="OS">OS</option>\
<option value="CDROM">CD-ROM</option>\
<option value="DATABLOCK">Datablock</option>\
<option value="OS">'+tr("OS")+'</option>\
<option value="CDROM">'+tr("CD-ROM")+'</option>\
<option value="DATABLOCK">'+tr("Datablock")+'</option>\
</select>');
var value = OpenNebula.Helper.image_type(image.TYPE);
$('option[value="'+value+'"]',type).replaceWith('<option value="'+value+'" selected="selected">'+value+'</option>');
$('option[value="'+value+'"]',type).replaceWith('<option value="'+value+'" selected="selected">'+tr(value)+'</option>');
@@ -570,75 +571,76 @@ function updateImagesView(request, images_list){
function updateImageInfo(request,img){
var img_info = img.IMAGE;
var info_tab = {
title: "Image information",
title: tr("Image information"),
content:
'<table id="info_img_table" class="info_table" style="width:80%;">\
<thead>\
<tr><th colspan="2">Image "'+img_info.NAME+'" information</th></tr>\
<tr><th colspan="2">'+tr("Image")+' "'+img_info.NAME+'" '+
tr("information")+'</th></tr>\
</thead>\
<tr>\
<td class="key_td">ID</td>\
<td class="key_td">'+tr("ID")+'</td>\
<td class="value_td">'+img_info.ID+'</td>\
</tr>\
<tr>\
<td class="key_td">Name</td>\
<td class="key_td">'+tr("Name")+'</td>\
<td class="value_td">'+img_info.NAME+'</td>\
</tr>\
<tr>\
<td class="key_td">Owner</td>\
<td class="key_td">'+tr("Owner")+'</td>\
<td class="value_td">'+img_info.UNAME+'</td>\
</tr>\
<tr>\
<td class="key_td">Group</td>\
<td class="key_td">'+tr("Group")+'</td>\
<td class="value_td">'+img_info.GNAME+'</td>\
</tr>\
<tr>\
<td class="key_td">Type</td>\
<td class="key_td">'+tr("Type")+'</td>\
<td class="value_td">'+OpenNebula.Helper.image_type(img_info.TYPE)+'</td>\
</tr>\
<tr>\
<td class="key_td">Register time</td>\
<td class="key_td">'+tr("Register time")+'</td>\
<td class="value_td">'+pretty_time(img_info.REGTIME)+'</td>\
</tr>\
<tr>\
<td class="key_td">Public</td>\
<td class="value_td">'+(parseInt(img_info.PUBLIC) ? "yes" : "no")+'</td>\
<td class="key_td">'+tr("Public")+'</td>\
<td class="value_td">'+(parseInt(img_info.PUBLIC) ? tr("yes") : tr("no"))+'</td>\
</tr>\
<tr>\
<td class="key_td">Persistent</td>\
<td class="value_td">'+(parseInt(img_info.PERSISTENT) ? "yes" : "no")+'</td>\
<td class="key_td">'+tr("Persistent")+'</td>\
<td class="value_td">'+(parseInt(img_info.PERSISTENT) ? tr("yes") : tr("no"))+'</td>\
</tr>\
<tr>\
<td class="key_td">Source</td>\
<td class="key_td">'+tr("Source")+'</td>\
<td class="value_td">'+(typeof img_info.SOURCE === "string" ? img_info.SOURCE : "--")+'</td>\
</tr>\
<tr>\
<td class="key_td">Path</td>\
<td class="key_td">'+tr("Path")+'</td>\
<td class="value_td">'+(typeof img_info.PATH === "string" ? img_info.PATH : "--")+'</td>\
</tr>\
<tr>\
<td class="key_td">Filesystem type</td>\
<td class="key_td">'+tr("Filesystem type")+'</td>\
<td class="value_td">'+(typeof img_info.FSTYPE === "string" ? img_info.FSTYPE : "--")+'</td>\
</tr>\
<tr>\
<td class="key_td">Size (Mb)</td>\
<td class="key_td">'+tr("Size (Mb)")+'</td>\
<td class="value_td">'+img_info.SIZE+'</td>\
</tr>\
<tr>\
<td class="key_td">State</td>\
<td class="key_td">'+tr("State")+'</td>\
<td class="value_td">'+OpenNebula.Helper.resource_state("image",img_info.STATE)+'</td>\
</tr>\
<tr>\
<td class="key_td">Running #VMS</td>\
<td class="key_td">'+tr("Running #VMS")+'</td>\
<td class="value_td">'+img_info.RUNNING_VMS+'</td>\
</tr>\
</table>'
}
var template_tab = {
title: "Image template",
title: tr("Image template"),
content: '<table id="img_template_table" class="info_table" style="width:80%;">\
<thead><tr><th colspan="2">Image template</th></tr></thead>'+
<thead><tr><th colspan="2">'+tr("Image template")+'</th></tr></thead>'+
prettyPrintJSON(img_info.TEMPLATE)+
'</table>'
}
@@ -652,7 +654,7 @@ function updateImageInfo(request,img){
// Prepare the image creation dialog
function setupCreateImageDialog(){
dialogs_context.append('<div title="Create Image" id="create_image_dialog"></div>');
dialogs_context.append('<div title="'+tr("Create Image")+'" id="create_image_dialog"></div>');
$create_image_dialog = $('#create_image_dialog',dialogs_context);
var dialog = $create_image_dialog;
dialog.html(create_image_tmpl);
@@ -669,8 +671,8 @@ function setupCreateImageDialog(){
$('#img_tabs',dialog).tabs();
$('button',dialog).button();
$('#img_type option',dialog).first().attr("selected","selected");
$('#datablock_img',dialog).attr("disabled","disabled");
$('#img_type option',dialog).first().attr('selected','selected');
$('#datablock_img',dialog).attr('disabled','disabled');
$('select#img_type',dialog).change(function(){
var value = $(this).val();
@@ -680,23 +682,23 @@ function setupCreateImageDialog(){
$('#datablock_img',context).removeAttr("disabled");
break;
default:
$('#datablock_img',context).attr("disabled","disabled");
$('#path_img',context).attr("checked","checked");
$('#datablock_img',context).attr('disabled','disabled');
$('#path_img',context).attr('checked','checked');
$('#img_source,#img_fstype,#img_size',context).parent().hide();
$('#img_path',context).parent().show();
}
});
$('#img_source,#img_fstype,#img_size',dialog).parent().hide();
$('#path_img',dialog).attr("checked","checked");
$('#path_img',dialog).attr('checked','checked');
$('#img_path',dialog).parent().addClass("img_man");
$('#img_public',dialog).click(function(){
$('#img_persistent',$create_image_dialog).removeAttr("checked");
$('#img_persistent',$create_image_dialog).removeAttr('checked');
});
$('#img_persistent',dialog).click(function(){
$('#img_public',$create_image_dialog).removeAttr("checked");
$('#img_public',$create_image_dialog).removeAttr('checked');
});
@@ -732,7 +734,7 @@ function setupCreateImageDialog(){
var name = $('#custom_var_image_name',$create_image_dialog).val();
var value = $('#custom_var_image_value',$create_image_dialog).val();
if (!name.length || !value.length) {
notifyError("Custom attribute name and value must be filled in");
notifyError(tr("Custom attribute name and value must be filled in"));
return false;
}
option= '<option value=\''+value+'\' name=\''+name+'\'>'+
@@ -755,7 +757,7 @@ function setupCreateImageDialog(){
var exit = false;
$('.img_man',this).each(function(){
if (!$('input',this).val().length){
notifyError("There are mandatory parameters missing");
notifyError(tr("There are mandatory parameters missing"));
exit = true;
return false;
}
@@ -799,7 +801,7 @@ function setupCreateImageDialog(){
source = $('#img_source',this).val();
img_json["SOURCE"] = source;
break;
case "datablock":
case "datablock":
size = $('#img_size',this).val();
fstype = $('#img_fstype',this).val();
img_json["SIZE"] = size;
@@ -809,7 +811,7 @@ function setupCreateImageDialog(){
//Time to add custom attributes
$('#custom_var_image_box option',$create_image_dialog).each(function(){
var attr_name = $(this).attr("name");
var attr_name = $(this).attr('name');
var attr_value = $(this).val();
img_json[attr_name] = attr_value;
});
@@ -839,7 +841,7 @@ function popUpCreateImageDialog(){
function setupImageTemplateUpdateDialog(){
//Append to DOM
dialogs_context.append('<div id="image_template_update_dialog" title="Update image template"></div>');
dialogs_context.append('<div id="image_template_update_dialog" title="'+tr("Update image template")+'"></div>');
var dialog = $('#image_template_update_dialog',dialogs_context);
//Put HTML in place
@@ -860,21 +862,22 @@ function setupImageTemplateUpdateDialog(){
var id = $(this).val();
if (id && id.length){
var dialog = $('#image_template_update_dialog');
$('#image_template_update_textarea',dialog).val("Loading...");
$('#image_template_update_textarea',dialog).val(tr("Loading")+
"...");
var img_public = is_public_image(id);
var img_persistent = is_persistent_image(id)
if (img_public){
$('#image_template_update_public',dialog).attr("checked","checked")
$('#image_template_update_public',dialog).attr('checked','checked')
} else {
$('#image_template_update_public',dialog).removeAttr("checked")
$('#image_template_update_public',dialog).removeAttr('checked')
}
if (img_persistent){
$('#image_template_update_persistent',dialog).attr("checked","checked")
$('#image_template_update_persistent',dialog).attr('checked','checked')
} else {
$('#image_template_update_persistent',dialog).removeAttr("checked")
$('#image_template_update_persistent',dialog).removeAttr('checked')
}
Sunstone.runAction("Image.fetch_template",id);
@@ -928,12 +931,12 @@ function popUpImageTemplateUpdateDialog(){
var dialog = $('#image_template_update_dialog');
$('#image_template_update_select',dialog).html(select);
$('#image_template_update_textarea',dialog).val("");
$('#image_template_update_public',dialog).removeAttr("checked")
$('#image_template_update_persistent',dialog).removeAttr("checked")
$('#image_template_update_public',dialog).removeAttr('checked')
$('#image_template_update_persistent',dialog).removeAttr('checked')
if (sel_elems.length >= 1){ //several items in the list are selected
//grep them
var new_select= sel_elems.length > 1? '<option value="">Please select</option>' : "";
var new_select= sel_elems.length > 1? '<option value="">'+tr("Please select")+'</option>' : "";
$('option','<select>'+select+'</select>').each(function(){
var val = $(this).val();
if ($.inArray(val,sel_elems) >= 0){
@@ -942,7 +945,7 @@ function popUpImageTemplateUpdateDialog(){
});
$('#image_template_update_select',dialog).html(new_select);
if (sel_elems.length == 1) {
$('#image_template_update_select option',dialog).attr("selected","selected");
$('#image_template_update_select option',dialog).attr('selected','selected');
$('#image_template_update_select',dialog).trigger("change");
}
@@ -958,7 +961,7 @@ function setImageAutorefresh() {
setInterval(function(){
var checked = $('input.check_item:checked',dataTable_images);
var filter = $("#datatable_images_filter input",
dataTable_images.parents("#datatable_images_wrapper")).attr("value");
dataTable_images.parents("#datatable_images_wrapper")).attr('value');
if (!checked.length && !filter.length){
Sunstone.runAction("Image.autorefresh");
}
@@ -967,23 +970,23 @@ function setImageAutorefresh() {
function is_public_image(id){
var data = getElementData(id,"#image",dataTable_images)[7];
return $(data).attr("checked");
return $(data).attr('checked');
};
function is_persistent_image(id){
var data = getElementData(id,"#image",dataTable_images)[8];
return $(data).attr("checked");
return $(data).attr('checked');
};
function setupImageActionCheckboxes(){
$('input.action_cb#cb_public_image',dataTable_images).live("click",function(){
var $this = $(this)
var id=$this.attr("elem_id");
if ($this.attr("checked")){
var id=$this.attr('elem_id');
if ($this.attr('checked')){
if (!is_persistent_image(id))
Sunstone.runAction("Image.publish",id);
else {
notifyError("Image cannot be public and persistent");
notifyError(tr("Image cannot be public and persistent"));
return false;
};
} else Sunstone.runAction("Image.unpublish",id);
@@ -993,12 +996,12 @@ function setupImageActionCheckboxes(){
$('input.action_cb#cb_persistent_image',dataTable_images).live("click",function(){
var $this = $(this)
var id=$this.attr("elem_id");
if ($this.attr("checked")){
var id=$this.attr('elem_id');
if ($this.attr('checked')){
if (!is_public_image(id))
Sunstone.runAction("Image.persistent",id);
else {
notifyError("Image cannot be public and persistent");
notifyError(tr("Image cannot be public and persistent"));
return false;
};
} else Sunstone.runAction("Image.nonpersistent",id);
@@ -1009,7 +1012,7 @@ function setupImageActionCheckboxes(){
$('select.action_cb#select_chtype_image', dataTable_images).live("change",function(){
var $this = $(this);
var value = $this.val();
var id = $this.attr("elem_id");
var id = $this.attr('elem_id');
Sunstone.runAction("Image.chtype", id, value);
});
@@ -1030,7 +1033,11 @@ $(document).ready(function(){
{ "sWidth": "35px", "aTargets": [1,5,11] },
{ "sWidth": "100px", "aTargets": [6] },
{ "sWidth": "150px", "aTargets": [7] }
]
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
});
dataTable_images.fnClearTable();
@@ -1048,4 +1055,6 @@ $(document).ready(function(){
initCheckAllBoxes(dataTable_images);
tableCheckboxesListener(dataTable_images);
imageInfoListener();
})
File diff suppressed because it is too large. Load diff
+44 -40
View File
@@ -27,11 +27,11 @@ var users_tab_content =
<table id="datatable_users" class="display">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
<th>ID</th>\
<th>Name</th>\
<th>Group</th>\
<th>Authentication driver</th>\
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Authentication driver")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyusers">\
@@ -43,18 +43,18 @@ var create_user_tmpl =
'<form id="create_user_form" action="">\
<fieldset>\
<div>\
<label for="username">Username:</label>\
<label for="username">'+tr("Username")+':</label>\
<input type="text" name="username" id="username" /><br />\
<label for="pass">Password:</label>\
<label for="pass">'+tr("Password")+':</label>\
<input type="password" name="pass" id="pass" />\
<label for="driver">Authentication:</label>\
<label for="driver">'+tr("Authentication")+':</label>\
<select name="driver" id="driver">\
<option value="core" selected="selected">Core</option>\
<option value="ssh">SSH</option>\
<option value="x509">x509</option>\
<option value="server_cipher">Server (Cipher)</option>\
<option value="server_x509">Server (x509)</option>\
<option value="public">Public</option>\
<option value="core" selected="selected">'+tr("Core")+'</option>\
<option value="ssh">'+tr("SSH")+'</option>\
<option value="x509">'+tr("x509")+'</option>\
<option value="server_cipher">'+tr("Server (Cipher)")+'</option>\
<option value="server_x509">'+tr("Server (x509)")+'</option>\
<option value="public">'+tr("Public")+'</option>\
</select>\
</div>\
</fieldset>\
@@ -69,15 +69,15 @@ var create_user_tmpl =
var update_pw_tmpl = '<form id="update_user_pw_form" action="">\
<fieldset>\
<div>\
<div>This will change the password for the selected users:</div>\
<label for="new_password">New password:</label>\
<div>'+tr("This will change the password for the selected users")+':</div>\
<label for="new_password">'+tr("New password")+':</label>\
<input type="password" name="new_password" id="new_password" />\
</div>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="update_pw_submit" value="user/create">Change</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" id="update_pw_submit" value="User.update">'+tr("Change")+'</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>';
@@ -222,7 +222,7 @@ var user_actions = {
type: "single",
call: OpenNebula.User.update,
callback: function() {
notifyMessage("Template updated correctly");
notifyMessage(tr("Template updated correctly"));
},
error: onError
}
@@ -232,40 +232,40 @@ var user_actions = {
var user_buttons = {
"User.refresh" : {
type: "image",
text: "Refresh list",
text: tr("Refresh list"),
img: "images/Refresh-icon.png"
},
"User.create_dialog" : {
type: "create_dialog",
text: "+ New"
text: tr("+ New")
},
"User.update_dialog" : {
type: "action",
text: "Update a template",
text: tr("Update a template"),
alwaysActive: true
},
"User.update_password" : {
type : "action",
text : "Change password",
text : tr("Change password"),
},
"User.chgrp" : {
type: "confirm_with_select",
text: "Change group",
text: tr("Change group"),
select: groups_sel,
tip: "This will change the main group of the selected users. Select the new group:"
tip: tr("This will change the main group of the selected users. Select the new group")+":"
},
"User.chauth" : {
type: "confirm_with_select",
text: "Change authentication",
text: tr("Change authentication"),
select: function() {
return '<option value="core" selected="selected">Core</option>\
<option value="ssh">SSH</option>\
<option value="x509">x509</option>\
<option value="server_cipher">Server (Cipher)</option>\
<option value="server_x509">Server (x509)</option>\
<option value="public">Public</option>'
return '<option value="core" selected="selected">'+tr("Core")+'</option>\
<option value="ssh">'+tr("SSH")+'</option>\
<option value="x509">'+tr("x509")+'</option>\
<option value="server_cipher">'+tr("Server (Cipher)")+'</option>\
<option value="server_x509">'+tr("Server (x509)")+'</option>\
<option value="public">'+tr("Public")+'</option>'
},
tip: "Please choose the new type of authentication for the selected users:"
tip: tr("Please choose the new type of authentication for the selected users")+":"
},
// "User.addgroup" : {
// type: "confirm_with_select",
@@ -288,7 +288,7 @@ var user_buttons = {
}
var users_tab = {
title: "Users",
title: tr("Users"),
content: users_tab_content,
buttons: user_buttons
}
@@ -358,7 +358,7 @@ function updateUsersView(request,users_list){
// Prepare the user creation dialog
function setupCreateUserDialog(){
dialogs_context.append('<div title="Create user" id="create_user_dialog"></div>');
dialogs_context.append('<div title=\"'+tr("Create user")+'\" id="create_user_dialog"></div>');
$create_user_dialog = $('#create_user_dialog',dialogs_context);
var dialog = $create_user_dialog;
dialog.html(create_user_tmpl);
@@ -378,7 +378,7 @@ function setupCreateUserDialog(){
var driver = $('#driver', this).val();
if (!user_name.length || !user_password.length){
notifyError("User name and password must be filled in");
notifyError(tr("User name and password must be filled in"));
return false;
}
@@ -395,7 +395,7 @@ function setupCreateUserDialog(){
}
function setupUpdatePasswordDialog(){
dialogs_context.append('<div title="Change password" id="update_user_pw_dialog"></div>');
dialogs_context.append('<div title="'+tr("Change password")+'" id="update_user_pw_dialog"></div>');
$update_pw_dialog = $('#update_user_pw_dialog',dialogs_context);
var dialog = $update_pw_dialog;
dialog.html(update_pw_tmpl);
@@ -413,7 +413,7 @@ function setupUpdatePasswordDialog(){
var pw=$('#new_password',this).val();
if (!pw.length){
notifyError("Fill in a new password");
notifyError(tr("Fill in a new password"));
return false;
}
@@ -439,7 +439,7 @@ function setUserAutorefresh(){
setInterval(function(){
var checked = $('input.check_item:checked',dataTable_users);
var filter = $("#datatable_users_filter input",
dataTable_users.parents("#datatable_users_wrapper")).attr("value");
dataTable_users.parents("#datatable_users_wrapper")).attr('value');
if (!checked.length && !filter.length){
Sunstone.runAction("User.autorefresh");
}
@@ -458,7 +458,11 @@ $(document).ready(function(){
{ "sWidth": "60px", "aTargets": [0] },
{ "sWidth": "35px", "aTargets": [1] },
{ "sWidth": "150px", "aTargets": [4] }
]
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
});
dataTable_users.fnClearTable();
addElement([
+112 -108
View File
@@ -25,22 +25,22 @@ function loadVNC(){
loadVNC();
var vm_graphs = [
{ title : "CPU",
{ title : tr("CPU"),
monitor_resources : "cpu_usage",
humanize_figures : false,
history_length : VM_HISTORY_LENGTH
},
{ title : "Memory",
{ title : tr("Memory"),
monitor_resources : "mem_usage",
humanize_figures : true,
history_length : VM_HISTORY_LENGTH
},
{ title : "Network transmission",
{ title : tr("Network transmission"),
monitor_resources : "net_tx",
humanize_figures : true,
history_length : VM_HISTORY_LENGTH
},
{ title : "Network reception",
{ title : tr("Network reception"),
monitor_resources : "net_rx",
humanize_figures : true,
history_length : VM_HISTORY_LENGTH
@@ -54,17 +54,17 @@ var vms_tab_content =
<table id="datatable_vmachines" class="display">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
<th>ID</th>\
<th>Owner</th>\
<th>Group</th>\
<th>Name</th>\
<th>Status</th>\
<th>CPU</th>\
<th>Memory</th>\
<th>Hostname</th>\
<th>Start Time</th>\
<th>VNC Access</th>\
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Status")+'</th>\
<th>'+tr("CPU")+'</th>\
<th>'+tr("Memory")+'</th>\
<th>'+tr("Hostname")+'</th>\
<th>'+tr("Start Time")+'</th>\
<th>'+tr("VNC Access")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyvmachines">\
@@ -75,19 +75,19 @@ var vms_tab_content =
var create_vm_tmpl ='<form id="create_vm_form" action="">\
<fieldset>\
<div>\
<label for="vm_name">VM Name:</label>\
<label for="vm_name">'+tr("VM Name")+':</label>\
<input type="text" name="vm_name" id="vm_name" /><br />\
<label for="template_id">Select template:</label>\
<label for="template_id">'+tr("Select template")+':</label>\
<select id="template_id">\
</select><br />\
<label for="vm_n_times">Deploy # VMs:</label>\
<label for="vm_n_times">'+tr("Deploy # VMs")+':</label>\
<input type="text" name="vm_n_times" id="vm_n_times" value="1">\
</div>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="create_vm_proceed" value="VM.create">Create</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" id="create_vm_proceed" value="VM.create">'+tr("Create")+'</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>';
@@ -372,36 +372,36 @@ var vm_actions = {
var vm_buttons = {
"VM.refresh" : {
type: "image",
text: "Refresh list",
text: tr("Refresh list"),
img: "images/Refresh-icon.png"
},
"VM.create_dialog" : {
type: "action",
text: "+ New",
text: tr("+ New"),
alwaysActive: true
},
"VM.chown" : {
type: "confirm_with_select",
text: "Change owner",
text: tr("Change owner"),
select: users_sel,
tip: "Select the new owner:",
tip: tr("Select the new owner")+":",
condition: mustBeAdmin
},
"VM.chgrp" : {
type: "confirm_with_select",
text: "Change group",
text: tr("Change group"),
select: groups_sel,
tip: "Select the new group:",
tip: tr("Select the new group")+":",
condition: mustBeAdmin
},
"VM.shutdown" : {
type: "confirm",
text: "Shutdown",
tip: "This will initiate the shutdown process in the selected VMs"
text: tr("Shutdown"),
tip: tr("This will initiate the shutdown process in the selected VMs")
},
"action_list" : {
@@ -409,97 +409,97 @@ var vm_buttons = {
actions: {
"VM.deploy" : {
type: "confirm_with_select",
text: "Deploy",
tip: "This will deploy the selected VMs on the chosen host",
text: tr("Deploy"),
tip: tr("This will deploy the selected VMs on the chosen host"),
select: hosts_sel,
condition: mustBeAdmin
},
"VM.migrate" : {
type: "confirm_with_select",
text: "Migrate",
tip: "This will migrate the selected VMs to the chosen host",
text: tr("Migrate"),
tip: tr("This will migrate the selected VMs to the chosen host"),
select: hosts_sel,
condition: mustBeAdmin
},
"VM.livemigrate" : {
type: "confirm_with_select",
text: "Live migrate",
tip: "This will live-migrate the selected VMs to the chosen host",
text: tr("Live migrate"),
tip: tr("This will live-migrate the selected VMs to the chosen host"),
select: hosts_sel,
condition: mustBeAdmin
},
"VM.hold" : {
type: "confirm",
text: "Hold",
tip: "This will hold selected pending VMs from being deployed"
text: tr("Hold"),
tip: tr("This will hold selected pending VMs from being deployed")
},
"VM.release" : {
type: "confirm",
text: "Release",
tip: "This will release held machines"
text: tr("Release"),
tip: tr("This will release held machines")
},
"VM.suspend" : {
type: "confirm",
text: "Suspend",
tip: "This will suspend selected machines"
text: tr("Suspend"),
tip: tr("This will suspend selected machines")
},
"VM.resume" : {
type: "confirm",
text: "Resume",
tip: "This will resume selected stopped or suspended VMs"
text: tr("Resume"),
tip: tr("This will resume selected stopped or suspended VMs")
},
"VM.stop" : {
type: "confirm",
text: "Stop",
text: tr("Stop"),
tip: "This will stop selected VMs"
},
"VM.restart" : {
type: "confirm",
text: "Restart",
tip: "This will redeploy selected VMs (in UNKNOWN or BOOT state)"
text: tr("Restart"),
tip: tr("This will redeploy selected VMs (in UNKNOWN or BOOT state)")
},
"VM.resubmit" : {
type: "confirm",
text: "Resubmit",
tip: "This will resubmits VMs to PENDING state"
text: tr("Resubmit"),
tip: tr("This will resubmits VMs to PENDING state")
},
"VM.saveasmultiple" : {
type: "action",
text: "Save as"
text: tr("Save as")
},
"VM.cancel" : {
type: "confirm",
text: "Cancel",
tip: "This will cancel selected VMs"
text: tr("Cancel"),
tip: tr("This will cancel selected VMs")
}
}
},
"VM.delete" : {
type: "confirm",
text: "Delete",
tip: "This will delete the selected VMs from the database"
text: tr("Delete"),
tip: tr("This will delete the selected VMs from the database")
}
}
var vm_info_panel = {
"vm_info_tab" : {
title: "Virtual Machine information",
title: tr("Virtual Machine information"),
content: ""
},
"vm_template_tab" : {
title: "VM template",
title: tr("VM template"),
content: ""
},
"vm_log_tab" : {
title: "VM log",
title: tr("VM log"),
content: ""
}
}
var vms_tab = {
title: "Virtual Machines",
title: tr("Virtual Machines"),
content: vms_tab_content,
buttons: vm_buttons
}
@@ -617,73 +617,73 @@ function updateVMInfo(request,vm){
};
var info_tab = {
title : "VM information",
title : tr("VM information"),
content:
'<table id="info_vm_table" class="info_table">\
<thead>\
<tr><th colspan="2">Virtual Machine information - '+vm_info.NAME+'</th></tr>\
<tr><th colspan="2">'+tr("Virtual Machine information")+' - '+vm_info.NAME+'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">ID</td>\
<td class="key_td">'+tr("ID")+'</td>\
<td class="value_td">'+vm_info.ID+'</td>\
</tr>\
<tr>\
<td class="key_td">Name</td>\
<td class="key_td">'+tr("Name")+'</td>\
<td class="value_td">'+vm_info.NAME+'</td>\
</tr>\
<tr>\
<td class="key_td">Owner</td>\
<td class="key_td">'+tr("Owner")+'</td>\
<td class="value_td">'+vm_info.UNAME+'</td>\
</tr>\
<tr>\
<td class="key_td">Group</td>\
<td class="key_td">'+tr("Group")+'</td>\
<td class="value_td">'+vm_info.GNAME+'</td>\
</tr>\
<tr>\
<td class="key_td">State</td>\
<td class="value_td">'+vm_state+'</td>\
<td class="key_td">'+tr("State")+'</td>\
<td class="value_td">'+tr(vm_state)+'</td>\
</tr>\
<tr>\
<td class="key_td">LCM State</td>\
<td class="value_td">'+OpenNebula.Helper.resource_state("vm_lcm",vm_info.LCM_STATE)+'</td>\
<td class="key_td">'+tr("LCM State")+'</td>\
<td class="value_td">'+tr(OpenNebula.Helper.resource_state("vm_lcm",vm_info.LCM_STATE))+'</td>\
</tr>\
<tr>\
<td class="key_td">Hostname</td>\
<td class="key_td">'+tr("Hostname")+'</td>\
<td class="value_td">'+ hostname +'</td>\
</tr>\
<tr>\
<td class="key_td">Start time</td>\
<td class="key_td">'+tr("Start time")+'</td>\
<td class="value_td">'+pretty_time(vm_info.STIME)+'</td>\
</tr>\
<tr>\
<td class="key_td">Deploy ID</td>\
<td class="key_td">'+tr("Deploy ID")+'</td>\
<td class="value_td">'+(typeof(vm_info.DEPLOY_ID) == "object" ? "-" : vm_info.DEPLOY_ID)+'</td>\
</tr></tbody>\
</table>\
<table id="vm_monitoring_table" class="info_table">\
<thead>\
<tr><th colspan="2">Monitoring information</th></tr>\
<tr><th colspan="2">'+tr("Monitoring information")+'</th></tr>\
</thead>\
<tbody>\
<tr>\
<td class="key_td">Net_TX</td>\
<td class="key_td">'+tr("Net_TX")+'</td>\
<td class="value_td">'+vm_info.NET_TX+'</td>\
</tr>\
<tr>\
<td class="key_td">Net_RX</td>\
<td class="key_td">'+tr("Net_RX")+'</td>\
<td class="value_td">'+vm_info.NET_RX+'</td>\
</tr>\
<tr>\
<td class="key_td">Used Memory</td>\
<td class="key_td">'+tr("Used Memory")+'</td>\
<td class="value_td">'+humanize_size(vm_info.MEMORY)+'</td>\
</tr>\
<tr>\
<td class="key_td">Used CPU</td>\
<td class="key_td">'+tr("Used CPU")+'</td>\
<td class="value_td">'+vm_info.CPU+'</td>\
</tr>\
<tr>\
<td class="key_td">VNC Session</td>\
<td class="key_td">'+tr("VNC Session")+'</td>\
<td class="value_td">'+vncIcon(vm_info)+'</td>\
</tr>\
</tbody>\
@@ -691,21 +691,21 @@ function updateVMInfo(request,vm){
}
var template_tab = {
title: "VM Template",
title: tr("VM Template"),
content:
'<table id="vm_template_table" class="info_table" style="width:80%">\
<thead><tr><th colspan="2">VM template</th></tr></thead>'+
<thead><tr><th colspan="2">'+tr("VM template")+'</th></tr></thead>'+
prettyPrintJSON(vm_info.TEMPLATE)+
'</table>'
}
var log_tab = {
title: "VM log",
title: tr("VM log"),
content: '<div>'+spinner+'</div>'
}
var monitoring_tab = {
title: "Monitoring information",
title: tr("Monitoring information"),
content: generateMonitoringDivs(vm_graphs,"vm_monitor_")
}
@@ -726,7 +726,7 @@ function updateVMInfo(request,vm){
// which is a lot.
function setupCreateVMDialog(){
dialogs_context.append('<div title="Create Virtual Machine" id="create_vm_dialog"></div>');
dialogs_context.append('<div title=\"'+tr("Create Virtual Machine")+'\" id="create_vm_dialog"></div>');
//Insert HTML in place
$create_vm_dialog = $('#create_vm_dialog')
var dialog = $create_vm_dialog;
@@ -748,7 +748,7 @@ function setupCreateVMDialog(){
var n_times_int=1;
if (!template_id.length){
notifyError("You have not selected a template");
notifyError(tr("You have not selected a template"));
return false;
}
@@ -781,7 +781,7 @@ function popUpCreateVMDialog(){
//Prepares a dialog to saveas a VM
function setupSaveasDialog(){
//Append to DOM
dialogs_context.append('<div id="saveas_vm_dialog" title="VM Save As"></div>');
dialogs_context.append('<div id="saveas_vm_dialog" title=\"'+tr("VM Save As")+'\"></div>');
$saveas_vm_dialog = $('#saveas_vm_dialog',dialogs_context);
var dialog = $saveas_vm_dialog;
@@ -791,8 +791,8 @@ function setupSaveasDialog(){
<div id="saveas_tabs">\
</div>\
<div class="form_buttons">\
<button id="vm_saveas_proceed" value="">OK</button>\
<button id="vm_saveas_cancel" value="">Cancel</button>\
<button id="vm_saveas_proceed" value="">'+tr("OK")+'</button>\
<button id="vm_saveas_cancel" value="">'+tr("Cancel")+'</button>\
</div>\
</fieldset>\
</form>');
@@ -815,8 +815,8 @@ function setupSaveasDialog(){
var type = $('#image_type',this).val();
if (!id.length || !disk_id.length || !image_name.length) {
notifyError("Skipping VM "+id+
". No disk id or image name specified");
notifyError(tr("Skipping VM ")+id+". "+
tr("No disk id or image name specified"));
}
else {
var obj = {
@@ -853,25 +853,25 @@ function popUpSaveasDialog(elems){
var li = '<li><a href="#saveas_tab_'+this+'">VM '+this+'</a></li>'
$('#saveas_tabs ul',dialog).append(li);
var tab = '<div class="saveas_tab" id="saveas_tab_'+this+'">\
<div id="vm_id_text">Saveas for VM with ID <span id="vm_id">'+this+'</span></div>\
<div id="vm_id_text">'+tr("Saveas for VM with ID")+' <span id="vm_id">'+this+'</span></div>\
<fieldset>\
<div>\
<label for="vm_disk_id">Select disk:</label>\
<label for="vm_disk_id">'+tr("Select disk")+':</label>\
<select id="vm_disk_id" name="vm_disk_id">\
<option value="">Retrieving...</option>\
<option value="">'+tr("Retrieving")+'...</option>\
</select>\
</div>\
<div>\
<label for="image_name">Image name:</label>\
<label for="image_name">'+tr("Image name")+':</label>\
<input type="text" id="image_name" name="image_name" value="" />\
</div>\
<div>\
<label for="img_attr_value">Type:</label>\
<label for="img_attr_value">'+tr("Type")+':</label>\
<select id="image_type" name="image_type">\
<option value="">Default (current image type)</option>\
<option value="os">OS</option>\
<option value="datablock">Datablock</option>\
<option value="cdrom">CD-ROM</option>\
<option value="">'+tr("Default (current image type)")+'</option>\
<option value="os">'+tr("OS")+'</option>\
<option value="datablock">'+tr("Datablock")+'</option>\
<option value="cdrom">'+tr("CD-ROM")+'</oqption>\
</select>\
</div>\
</fieldset>\
@@ -891,15 +891,15 @@ function saveasDisksCallback(req,response){
var gen_option = function(id, name, source){
if (name){
return '<option value="'+id+'">'+name+' (disk id: '+id+')</option>';
return '<option value="'+id+'">'+name+" ("+tr("disk id")+"): "+id+')</option>';
}
else {
return '<option value="'+id+'">'+source+' (disk id: '+id+')</option>';
return '<option value="'+id+'">'+source+" ("+tr("disk id")+"): "+id+')</option>';
}
}
var disks = vm_info.TEMPLATE.DISK;
if (!disks) { select = '<option value="">No disks defined</option>';}
if (!disks) { select = '<option value="">'+tr("No disks defined")+'</option>';}
else if (disks.constructor == Array) //several disks
{
for (var i=0;i<disks.length;i++){
@@ -918,7 +918,7 @@ function setVMAutorefresh(){
setInterval(function(){
var checked = $('input.check_item:checked',dataTable_vMachines);
var filter = $("#datatable_vmachines_filter input",
dataTable_vMachines.parents('#datatable_vmachines_wrapper')).attr("value");
dataTable_vMachines.parents('#datatable_vmachines_wrapper')).attr('value');
if (!checked.length && !filter.length){
Sunstone.runAction("VM.autorefresh");
};
@@ -963,14 +963,14 @@ function updateVNCState(rfb, state, oldstate, msg) {
function setupVNC(){
//Append to DOM
dialogs_context.append('<div id="vnc_dialog" title="VNC connection"></div>');
dialogs_context.append('<div id="vnc_dialog" title=\"'+tr("VNC connection")+'\"></div>');
$vnc_dialog = $('#vnc_dialog',dialogs_context);
var dialog = $vnc_dialog;
dialog.html('\
<div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">\
<table border=0 width="100%"><tr>\
<td><div id="VNC_status">Loading</div></td>\
<td><div id="VNC_status">'+tr("Loading")+'</div></td>\
<td width="1%"><div id="VNC_buttons">\
<input type=button value="Send CtrlAltDel"\
id="sendCtrlAltDelButton">\
@@ -978,7 +978,7 @@ function setupVNC(){
</tr></table>\
</div>\
<canvas id="VNC_canvas" width="640px" height="20px">\
Canvas not supported.\
'+tr("Canvas not supported.")+'\
</canvas>\
');
@@ -996,16 +996,16 @@ function setupVNC(){
});
dialog.bind( "dialogclose", function(event, ui) {
var id = $vnc_dialog.attr("vm_id");
var id = $vnc_dialog.attr('vm_id');
rfb.disconnect();
Sunstone.runAction("VM.stopvnc",id);
});
$('.vnc',main_tabs_context).live("click",function(){
//Which VM is it?
var id = $(this).attr("vm_id");
var id = $(this).attr('vm_id');
//Set attribute to dialog
$vnc_dialog.attr("vm_id",id);
$vnc_dialog.attr('vm_id',id);
//Request proxy server start
Sunstone.runAction("VM.startvnc",id);
return false;
@@ -1040,10 +1040,10 @@ function vncIcon(vm){
var gr_icon;
if (graphics && graphics.TYPE == "vnc" && state == "RUNNING"){
gr_icon = '<a class="vnc" href="#" vm_id="'+vm.ID+'">';
gr_icon += '<img src="images/vnc_on.png" alt="Open VNC Session" /></a>';
gr_icon += '<img src="images/vnc_on.png" alt=\"'+tr("Open VNC Session")+'\" /></a>';
}
else {
gr_icon = '<img src="images/vnc_off.png" alt="VNC Disabled" />';
gr_icon = '<img src="images/vnc_off.png" alt=\"'+tr("VNC Disabled")+'\" />';
}
return gr_icon;
}
@@ -1071,7 +1071,11 @@ $(document).ready(function(){
{ "sWidth": "35px", "aTargets": [1,10] },
{ "sWidth": "150px", "aTargets": [5,9] },
{ "sWidth": "100px", "aTargets": [2,3] }
]
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
});
dataTable_vMachines.fnClearTable();
+294 -200
View File
@@ -23,15 +23,15 @@ var vnets_tab_content =
<table id="datatable_vnetworks" class="display">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
<th>ID</th>\
<th>Owner</th>\
<th>Group</th>\
<th>Name</th>\
<th>Type</th>\
<th>Bridge</th>\
<th>Public</th>\
<th>Total Leases</th>\
<th class="check"><input type="checkbox" class="check_all" value="">'+tr("All")+'</input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Type")+'</th>\
<th>'+tr("Bridge")+'</th>\
<th>'+tr("Public")+'</th>\
<th>'+tr("Total Leases")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyvnetworks">\
@@ -42,40 +42,40 @@ var vnets_tab_content =
var create_vn_tmpl =
'<div id="vn_tabs">\
<ul>\
<li><a href="#easy">Wizard</a></li>\
<li><a href="#manual">Advanced mode</a></li>\
<li><a href="#easy">'+tr("Wizard")+'</a></li>\
<li><a href="#manual">'+tr("Advanced mode")+'</a></li>\
</ul>\
<div id="easy">\
<form id="create_vn_form_easy" action="">\
<fieldset>\
<label for="name">Name:</label>\
<label for="name">'+tr("Name")+':</label>\
<input type="text" name="name" id="name" /><br />\
</fieldset>\
<fieldset>\
<label for="bridge">Bridge:</label>\
<label for="bridge">'+tr("Bridge")+':</label>\
<input type="text" name="bridge" id="bridge" /><br />\
</fieldset>\
<fieldset>\
<label style="height:2em;">Network type:</label>\
<input type="radio" name="fixed_ranged" id="fixed_check" value="fixed" checked="checked">Fixed network</input><br />\
<input type="radio" name="fixed_ranged" id="ranged_check" value="ranged">Ranged network</input><br />\
<label style="height:2em;">'+tr("Network type")+':</label>\
<input type="radio" name="fixed_ranged" id="fixed_check" value="fixed" checked="checked">'+tr("Fixed network")+'</input><br />\
<input type="radio" name="fixed_ranged" id="ranged_check" value="ranged">'+tr("Ranged network")+'</input><br />\
</fieldset>\
<div class="clear"></div>\
<div id="easy_tabs">\
<div id="fixed">\
<fieldset>\
<label for="leaseip">Lease IP:</label>\
<label for="leaseip">'+tr("Lease IP")+':</label>\
<input type="text" name="leaseip" id="leaseip" /><br />\
<label for="leasemac">Lease MAC (opt):</label>\
<label for="leasemac">'+tr("Lease MAC (opt):")+'</label>\
<input type="text" name="leasemac" id="leasemac" />\
<div class="clear"></div>\
<button class="add_remove_button add_button" id="add_lease" value="add/lease">\
Add\
'+tr("Add")+'\
</button>\
<button class="add_remove_button" id="remove_lease" value="remove/lease">\
Remove selected\
'+tr("Remove selected")+'\
</button>\
<label for="leases">Current leases:</label>\
<label for="leases">'+tr("Current leases")+':</label>\
<select id="leases" name="leases" style="height:10em;" multiple>\
<!-- insert leases -->\
</select><br />\
@@ -83,10 +83,16 @@ var create_vn_tmpl =
</div>\
<div id="ranged">\
<fieldset>\
<label for="net_address">Network Address:</label>\
<label for="net_address">'+tr("Network Address")+':</label>\
<input type="text" name="net_address" id="net_address" /><br />\
<label for="net_size">Network size:</label>\
<input type="text" name="net_size" id="net_size" />\
<label for="net_mask">'+tr("Network Mask")+':</label>\
<input type="text" name="net_mask" id="net_mask" /><br />\
<label for="custom_pool" style="height:2em;">'+tr("Define a subnet by IP range")+':</label>\
<input type="checkbox" name="custom_pool" id="custom_pool" style="margin-bottom:2em;" value="yes" /><br />\
<label for="ip_start">'+tr("IP Start")+':</label>\
<input type="text" name="ip_start" id="ip_start" disabled="disabled" /><br />\
<label for="ip_end">'+tr("IP End")+':</label>\
<input type="text" name="ip_end" id="ip_end" disabled="disabled" />\
</fieldset>\
</div>\
</div>\
@@ -94,14 +100,14 @@ var create_vn_tmpl =
</fieldset>\
<fieldset>\
<div class="">\
<label for="custom_var_vnet_name">Name:</label>\
<input type="text" id="custom_var_vnet_name" name="custom_var_vnet_name" />\
<label for="custom_var_vnet_value">Value:</label>\
<input type="text" id="custom_var_vnet_value" name="custom_var_vnet_value" />\
<button class="add_remove_button add_button" id="add_custom_var_vnet_button" value="add_custom_vnet_var">Add</button>\
<button class="add_remove_button" id="remove_custom_var_vnet_button" value="remove_custom_vnet_var">Remove selected</button>\
<label for="custom_var_vnet_name">'+tr("Name")+':</label>\
<input type="text" id="custom_var_vnet_name" name="custom_var_vnet_name" /><br />\
<label for="custom_var_vnet_value">'+tr("Value")+':</label>\
<input type="text" id="custom_var_vnet_value" name="custom_var_vnet_value" /><br />\
<button class="add_remove_button add_button" id="add_custom_var_vnet_button" value="add_custom_vnet_var">'+tr("Add")+'</button>\
<button class="add_remove_button" id="remove_custom_var_vnet_button" value="remove_custom_vnet_var">'+tr("Remove selected")+'</button>\
<div class="clear"></div>\
<label for="custom_var_vnet_box">Custom attributes:</label>\
<label for="custom_var_vnet_box">'+tr("Custom attributes")+':</label>\
<select id="custom_var_vnet_box" name="custom_var_vnet_box" style="height:100px;" multiple>\
</select>\
</div>\
@@ -109,16 +115,16 @@ var create_vn_tmpl =
<fieldset>\
<div class="form_buttons">\
<button class="button" id="create_vn_submit_easy" value="vn/create">\
Create\
'+tr("Create")+'\
</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>\
</div>\
<div id="manual">\
<form id="create_vn_form_manual" action="">\
<h3 style="margin-bottom:10px;">Write the Virtual Network template here</h3>\
<h3 style="margin-bottom:10px;">'+tr("Write the Virtual Network template here")+'</h3>\
<fieldset style="border-top:none;">\
<textarea id="template" rows="15" style="width:100%;"></textarea>\
<div class="clear"></div>\
@@ -126,9 +132,9 @@ var create_vn_tmpl =
<fieldset>\
<div class="form_buttons">\
<button class="button" id="create_vn_submit_manual" value="vn/create">\
Create\
'+tr("Create")+'\
</button>\
<button class="button" type="reset" value="reset">Reset</button>\
<button class="button" type="reset" value="reset">'+tr("Reset")+'</button>\
</div>\
</fieldset>\
</form>\
@@ -137,23 +143,23 @@ var create_vn_tmpl =
var update_vnet_tmpl =
'<form action="javascript:alert(\'js error!\');">\
<h3 style="margin-bottom:10px;">Please, choose and modify the virtual network you want to update:</h3>\
<h3 style="margin-bottom:10px;">'+tr("Please, choose and modify the virtual network you want to update")+':</h3>\
<fieldset style="border-top:none;">\
<label for="vnet_template_update_select">Select a network:</label>\
<label for="vnet_template_update_select">'+tr("Select a network")+':</label>\
<select id="vnet_template_update_select" name="vnet_template_update_select"></select>\
<div class="clear"></div>\
<div>\
<label for="vnet_template_update_public">Public:</label>\
<label for="vnet_template_update_public">'+tr("Public")+':</label>\
<input type="checkbox" name="vnet_template_update_public" id="vnet_template_update_public" />\
</div>\
<label for="vnet_template_update_textarea">Template:</label>\
<label for="vnet_template_update_textarea">'+tr("Template")+':</label>\
<div class="clear"></div>\
<textarea id="vnet_template_update_textarea" style="width:100%; height:14em;"></textarea>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="vnet_template_update_button" value="Network.update_template">\
Update\
'+tr("Update")+'\
</button>\
</div>\
</fieldset>\
@@ -248,7 +254,7 @@ var vnet_actions = {
call: OpenNebula.Network.addleases,
callback: vnShow,
error: onError,
notify: true
notify: false,
},
"Network.rmleases" : {
@@ -256,27 +262,23 @@ var vnet_actions = {
call: OpenNebula.Network.rmleases,
callback: vnShow,
error: onError,
notify: true
notify: false,
},
"Network.modifyleases" : {
type: "custom",
call: function(action,obj){
nodes = getSelectedNodes(dataTable_vNetworks);
$.each(nodes,function(){
Sunstone.runAction(action,this,obj);
});
}
"Network.hold" : {
type: "single",
call: OpenNebula.Network.hold,
callback: vnShow,
error: onError,
notify: false,
},
"Network.addleases_dialog" : {
type: "custom",
call: popUpAddLeaseDialog
},
"Network.rmleases_dialog" : {
type: "custom",
call: popUpRemoveLeaseDialog
"Network.release" : {
type: "single",
call: OpenNebula.Network.release,
callback: vnShow,
error: onError,
notify: false,
},
"Network.chown" : {
@@ -328,36 +330,36 @@ var vnet_actions = {
var vnet_buttons = {
"Network.refresh" : {
type: "image",
text: "Refresh list",
text: tr("Refresh list"),
img: "images/Refresh-icon.png"
},
"Network.create_dialog" : {
type: "create_dialog",
text: "+ New"
text: tr("+ New")
},
"Network.update_dialog" : {
type: "action",
text: "Update a template",
text: tr("Update a template"),
alwaysActive: true
},
"Network.publish" : {
type: "action",
text: "Publish"
text: tr("Publish")
},
"Network.unpublish" : {
type: "action",
text: "Unpublish"
text: tr("Unpublish")
},
"Network.chown" : {
type: "confirm_with_select",
text: "Change owner",
text: tr("Change owner"),
select: users_sel,
tip: "Select the new owner:",
tip: tr("Select the new owner")+":",
condition: mustBeAdmin
},
@@ -365,43 +367,29 @@ var vnet_buttons = {
type: "confirm_with_select",
text: "Change group",
select: groups_sel,
tip: "Select the new group:",
tip: tr("Select the new group")+":",
condition: mustBeAdmin,
},
"action_list" : {
type: "select",
actions: {
"Network.addleases_dialog" : {
type: "action",
text: "Add lease"
},
"Network.rmleases_dialog" : {
type: "action",
text: "Remove lease"
}
}
},
"Network.delete" : {
type: "action",
text: "Delete"
text: tr("Delete")
}
}
var vnet_info_panel = {
"vnet_info_tab" : {
title: "Virtual network information",
title: tr("Virtual network information"),
content: ""
},
"vnet_template_tab" : {
title: "Virtual network template",
"vnet_leases_tab" : {
title: tr("Lease management"),
content: ""
}
},
}
var vnets_tab = {
title: "Virtual Networks",
title: tr("Virtual Networks"),
content: vnets_tab_content,
buttons: vnet_buttons
}
@@ -455,6 +443,9 @@ function updateVNetworkElement(request, vn_json){
id = vn_json.VNET.ID;
element = vNetworkElementArray(vn_json);
updateSingleElement(element,dataTable_vNetworks,'#vnetwork_'+id);
//we update this too, even if it's not shown.
$('#leases_form').replaceWith(printLeases(vn_json.VNET));
}
//Callback to delete a vnet element from the table
@@ -466,6 +457,8 @@ function deleteVNetworkElement(req){
function addVNetworkElement(request,vn_json){
var element = vNetworkElementArray(vn_json);
addElement(element,dataTable_vNetworks);
//we update this too, even if it's not shown.
$('#leases_form').replaceWith(printLeases(vn_json.VNET));
}
//updates the list of virtual networks
@@ -488,77 +481,165 @@ function updateVNetworkInfo(request,vn){
var info_tab_content =
'<table id="info_vn_table" class="info_table">\
<thead>\
<tr><th colspan="2">Virtual Network '+vn_info.ID+' information</th></tr>\
<tr><th colspan="2">'+tr("Virtual Network")+' '+vn_info.ID+' '+
tr("information")+'</th></tr>\
</thead>\
<tr>\
<td class="key_td">ID</td>\
<td class="key_td">'+tr("ID")+'</td>\
<td class="value_td">'+vn_info.ID+'</td>\
<tr>\
<tr>\
<td class="key_td">Owner</td>\
<td class="key_td">'+tr("Name")+'</td>\
<td class="value_td">'+vn_info.NAME+'</td>\
<tr>\
<tr>\
<td class="key_td">'+tr("Owner")+'</td>\
<td class="value_td">'+vn_info.UNAME+'</td>\
</tr>\
<tr>\
<td class="key_td">Group</td>\
<td class="key_td">'+tr("Group")+'</td>\
<td class="value_td">'+vn_info.GNAME+'</td>\
</tr>\
<tr>\
<td class="key_td">Public</td>\
<td class="key_td">'+tr("Public")+'</td>\
<td class="value_td">'+(parseInt(vn_info.PUBLIC) ? "yes" : "no" )+'</td>\
</tr>\
<tr>\
<td class="key_td">Physical device</td>\
<td class="value_td">'+(vn_info.PHYDEV ? vn_info.PHYDEV : "--" )+'</td>\
<td class="key_td">'+tr("Physical device")+'</td>\
<td class="value_td">'+ (typeof(vn_info.PHYDEV) == "object" ? "--": vn_info.PHYDEV) +'</td>\
</tr>\
</table>\
<table id="vn_leases_info_table" class="info_table">\
<thead>\
<tr><th colspan="2">Leases information</th></tr>\
</thead>'+
printLeases(vn_info.LEASES)+
'</table>';;
<tr>\
<td class="key_td">'+tr("VNET ID")+'</td>\
<td class="value_td">'+ (typeof(vn_info.VLAN_ID) == "object" ? "--": vn_info.VLAN_ID) +'</td>\
</tr>\
</table>';
info_tab_content += '\
<table id="vn_template_table" class="info_table">\
<thead><tr><th colspan="2">'+tr("Virtual Network template (attributes)")+'</th></tr></thead>'+
prettyPrintJSON(vn_info.TEMPLATE)+
'</table>';
var leases_tab_content = printLeases(vn_info);
var info_tab = {
title: "Virtual Network information",
title: tr("Virtual Network information"),
content: info_tab_content
}
};
var template_tab = {
title: "Virtual Network template",
content:
'<table id="vn_template_table" class="info_table" style="width:80%">\
<thead><tr><th colspan="2">Virtual Network template</th></tr></thead>'+
prettyPrintJSON(vn_info.TEMPLATE)+
'</table>'
}
var leases_tab = {
title: "Lease management",
content: leases_tab_content
};
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_info_tab",info_tab);
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_template_tab",template_tab);
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_leases_tab",leases_tab);
Sunstone.popUpInfoPanel("vnet_info_panel");
}
function printLeases(leases){
if (!leases.LEASE) //empty
{
return "";
function printLeases(vn_info){
var html ='<form style="display:inline-block;width:80%" id="leases_form" vnid="'+vn_info.ID+'"><table id="vn_leases_info_table" class="info_table" style="width:100%;">\
<thead>\
<tr><th colspan="2">'+tr("Leases information")+'</th></tr>\
</thead><tbody>';
if (vn_info.TYPE == "0"){
html += '<tr>\
<td class="key_td">'+tr("IP Start")+'</td>\
<td class="value_td">'+vn_info.RANGE.IP_START+'</td>\
</tr>\
<tr>\
<td class="key_td">'+tr("IP End")+'</td>\
<td class="value_td">'+vn_info.RANGE.IP_END+'</td>\
</tr\>\
<tr>\
<td class="key_td">'+tr("Network mask")+'</td>\
<td class="value_td">'+( vn_info.TEMPLATE.NETWORK_MASK ? vn_info.TEMPLATE.NETWORK_MASK : "--" )+'</td>\
</tr\>\
<tr><td class="key_td">\
<label for="panel_hold_lease">'+tr("Hold lease")+':</label></td><td class="value_td"><input type="text" id="panel_hold_lease" style="width:9em;"/>\
<button id="panel_hold_lease_button">'+tr("Hold")+'</button>\
</td></tr>';
} else {
html += '<tr><td class="key_td">\
<label for="panel_add_lease">'+tr("Add lease")+':</label></td><td class="value_td"><input type="text" id="panel_add_lease" style="width:9em;"/>\
<button id="panel_add_lease_button">'+tr("Add")+'</button>\
</td></tr>';
};
if (leases.LEASE.constructor == Array) //>1 lease
var leases = vn_info.LEASES.LEASE;
if (!leases) //empty
{
return prettyPrintJSON(leases.LEASE);
html+='<tr id="no_leases_tr"><td class="key_td">\
'+tr("No leases to show")+'\
</td>\
<td class="value_td">\
</td></tr>';
return html;
}
else {//1 lease
return prettyPrintJSON([leases.LEASE]);
else if (leases.constructor != Array) //>1 lease
{
leases = [leases];
};
var lease;
var state=null;
for (var i=0; i<leases.length; i++){
lease = leases[i];
if (lease.USED != "0" && lease.VID == "-1") { //hold
state = 2;
} else { //free
state = parseInt(lease.USED,10);
};
html+='<tr ip="'+lease.IP+'"><td class="key_td">';
html+='<img style="vertical-align:middle;margin-right:5px;" ';
switch (state){
case 0: //free
html += 'src="images/green_bullet.png" />';
break;
case 1: //used
html += 'src="images/red_bullet.png" />';
break;
case 2: //hold
html += 'src="images/yellow_bullet.png" />';
break;
};
html += lease.IP + '</td>';
html += '<td class="value_td">\
'+lease.MAC+'&nbsp;&nbsp;&nbsp';
switch (state){
case 0:
html += '<a class="hold_lease" href="#">'+tr("hold")+'</a> | <a class="delete_lease" href="#">'+tr("delete")+'</a>';
break;
case 1:
html += tr("Used by VM")+' '+lease.VID;
break;
case 2:
html += '<a class="release_lease" href="#">'+tr("release")+'</a>';
break;
};
html += '</td></tr>';
};
html += '</tbody></table></form>';
return html;
}
//Prepares the vnet creation dialog
function setupCreateVNetDialog() {
dialogs_context.append('<div title="Create Virtual Network" id="create_vn_dialog"></div>');
dialogs_context.append('<div title=\"'+tr("Create Virtual Network")+'\" id="create_vn_dialog"></div>');
$create_vn_dialog = $('#create_vn_dialog',dialogs_context)
var dialog = $create_vn_dialog;
dialog.html(create_vn_tmpl);
@@ -597,7 +678,7 @@ function setupCreateVNetDialog() {
//We don't add anything to the list if there is nothing to add
if (lease_ip == null) {
notifyError("Please provide a lease IP");
notifyError(tr("Please provide a lease IP"));
return false;
};
@@ -622,6 +703,17 @@ function setupCreateVNetDialog() {
return false;
});
$('#custom_pool', dialog).change(function(){
if ($(this).is(':checked')){
$('#ip_start', $create_vn_dialog).removeAttr('disabled');
$('#ip_end', $create_vn_dialog).removeAttr('disabled');
}
else {
$('#ip_start', $create_vn_dialog).attr('disabled','disabled');
$('#ip_end', $create_vn_dialog).attr('disabled','disabled');
};
});
$('#add_custom_var_vnet_button', dialog).click(
function(){
@@ -652,7 +744,7 @@ function setupCreateVNetDialog() {
//Fetch values
var name = $('#name',this).val();
if (!name.length){
notifyError("Virtual Network name missing!");
notifyError(tr("Virtual Network name missing!"));
return false;
}
var bridge = $('#bridge',this).val();
@@ -681,9 +773,13 @@ function setupCreateVNetDialog() {
else { //type ranged
var network_addr = $('#net_address',this).val();
var network_size = $('#net_size',this).val();
var network_mask = $('#net_mask',this).val();
var custom = $('#custom_pool',this).is(':checked');
var ip_start = $('#ip_start',this).val();
var ip_end = $('#ip_end',this).val();
if (!network_addr.length){
notifyError("Please provide a network address");
notifyError(tr("Please provide a network address"));
return false;
};
@@ -692,15 +788,22 @@ function setupCreateVNetDialog() {
"vnet" : {
"type" : "RANGED",
"bridge" : bridge,
"network_size" : network_size,
"network_mask" : network_mask,
"network_address" : network_addr,
"name" : name }
};
if (custom){
if (ip_start.length)
network_json["vnet"]["ip_start"] = ip_start;
if (ip_end.length)
network_json["vnet"]["ip_start"] = ip_end;
};
};
//Time to add custom attributes
$('#custom_var_vnet_box option',$create_vn_dialog).each(function(){
var attr_name = $(this).attr("name");
var attr_name = $(this).attr('name');
var attr_value = $(this).val();
network_json["vnet"][attr_name] = attr_value;
});
@@ -728,7 +831,7 @@ function popUpCreateVnetDialog() {
function setupVNetTemplateUpdateDialog(){
//Append to DOM
dialogs_context.append('<div id="vnet_template_update_dialog" title="Update network template"></div>');
dialogs_context.append('<div id="vnet_template_update_dialog" title="'+tr("Update network template")+'"></div>');
var dialog = $('#vnet_template_update_dialog',dialogs_context);
//Put HTML in place
@@ -749,14 +852,14 @@ function setupVNetTemplateUpdateDialog(){
var id = $(this).val();
if (id && id.length){
var dialog = $('#vnet_template_update_dialog');
$('#vnet_template_update_textarea',dialog).val("Loading...");
$('#vnet_template_update_textarea',dialog).val(tr("Loading")+"...");
var vnet_public = is_public_vnet(id);
if (vnet_public){
$('#vnet_template_update_public',dialog).attr("checked","checked")
$('#vnet_template_update_public',dialog).attr('checked','checked')
} else {
$('#vnet_template_update_public',dialog).removeAttr("checked")
$('#vnet_template_update_public',dialog).removeAttr('checked')
}
Sunstone.runAction("Network.fetch_template",id);
@@ -802,7 +905,7 @@ function popUpVNetTemplateUpdateDialog(){
var dialog = $('#vnet_template_update_dialog');
$('#vnet_template_update_select',dialog).html(select);
$('#vnet_template_update_textarea',dialog).val("");
$('#vnet_template_update_public',dialog).removeAttr("checked")
$('#vnet_template_update_public',dialog).removeAttr('checked')
if (sel_elems.length >= 1){ //several items in the list are selected
//grep them
@@ -815,7 +918,7 @@ function popUpVNetTemplateUpdateDialog(){
});
$('#vnet_template_update_select',dialog).html(new_select);
if (sel_elems.length == 1) {
$('#vnet_template_update_select option',dialog).attr("selected","selected");
$('#vnet_template_update_select option',dialog).attr('selected','selected');
$('#vnet_template_update_select',dialog).trigger("change");
}
@@ -826,78 +929,65 @@ function popUpVNetTemplateUpdateDialog(){
}
function setupAddRemoveLeaseDialog() {
dialogs_context.append('<div title="Lease management" id="lease_vn_dialog"></div>');
$lease_vn_dialog = $('#lease_vn_dialog',dialogs_context)
var dialog = $lease_vn_dialog;
dialog.html(
'<form id="lease_vn_form" action="javascript:alert(\'js error!\');">\
<fieldset>\
<div>Please specify:</div>\
<label for="add_lease_ip">Lease IP:</label>\
<input type="text" name="add_lease_ip" id="add_lease_ip" /><br />\
<label id="add_lease_mac_label" for="add_lease_mac">Lease MAC:</label>\
<input type="text" name="add_lease_mac" id="add_lease_mac" />\
</select>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button id="lease_vn_proceed" class="" value="">OK</button>\
<button class="confirm_cancel" value="">Cancel</button>\
</div>\
</fieldset>\
</form>'
);
//Prepare the jquery-ui dialog. Set style options here.
dialog.dialog({
autoOpen: false,
modal: true,
width: 410,
height: 220
});
$('button',dialog).button();
$('#lease_vn_form',dialog).submit(function(){
var ip = $('#add_lease_ip',this).val();
var mac = $('#add_lease_mac',this).val();
var obj = {ip: ip, mac: mac};
if (!mac.length) { delete obj.mac; };
Sunstone.runAction("Network.modifyleases",
$('#lease_vn_proceed',this).val(),
obj);
$lease_vn_dialog.dialog('close');
function setupLeasesOps(){
$('button#panel_add_lease_button').live("click",function(){
var lease = $(this).prev().val();
//var mac = $(this).previous().val();
var id = $(this).parents('form').attr('vnid');
if (lease.length){
var obj = {ip: lease};
Sunstone.runAction('Network.addleases',id,obj);
}
return false;
});
}
function popUpAddLeaseDialog() {
$lease_vn_dialog.dialog("option","title","Add lease");
$('#add_lease_mac',$lease_vn_dialog).show();
$('#add_lease_mac_label',$lease_vn_dialog).show();
$('#lease_vn_proceed',$lease_vn_dialog).val("Network.addleases");
$lease_vn_dialog.dialog("open");
}
$('button#panel_hold_lease_button').live("click",function(){
var lease = $(this).prev().val();
//var mac = $(this).previous().val();
var id = $(this).parents('form').attr('vnid');
if (lease.length){
var obj = {ip: lease};
Sunstone.runAction('Network.hold',id,obj);
}
return false;
});
function popUpRemoveLeaseDialog() {
$lease_vn_dialog.dialog("option","title","Remove lease");
$('#add_lease_mac',$lease_vn_dialog).hide();
$('#add_lease_mac_label',$lease_vn_dialog).hide();
$('#lease_vn_proceed',$lease_vn_dialog).val("Network.rmleases");
$lease_vn_dialog.dialog("open");
$('form#leases_form a.delete_lease').live("click",function(){
var lease = $(this).parents('tr').attr('ip');
var id = $(this).parents('form').attr('vnid');
var obj = { ip: lease};
Sunstone.runAction('Network.rmleases',id,obj);
//Set spinner
$(this).parents('tr').html('<td class="key_td">'+spinner+'</td><td class="value_td"></td>');
return false;
});
$('a.hold_lease').live("click",function(){
var lease = $(this).parents('tr').attr('ip');
var id = $(this).parents('form').attr('vnid');
var obj = { ip: lease};
Sunstone.runAction('Network.hold',id,obj);
//Set spinner
$(this).parents('tr').html('<td class="key_td">'+spinner+'</td><td class="value_td"></td>');
return false;
});
$('a.release_lease').live("click",function(){
var lease = $(this).parents('tr').attr('ip');
var id = $(this).parents('form').attr('vnid');
var obj = { ip: lease};
Sunstone.runAction('Network.release',id,obj);
//Set spinner
$(this).parents('tr').html('<td class="key_td">'+spinner+'</td><td class="value_td"></td>');
return false;
});
}
function setVNetAutorefresh() {
setInterval(function(){
var checked = $('input.check_item:checked',dataTable_vNetworks);
var filter = $("#datatable_vnetworks_filter input",
dataTable_vNetworks.parents("#datatable_vnetworks_wrapper")).attr("value");
dataTable_vNetworks.parents("#datatable_vnetworks_wrapper")).attr('value');
if (!checked.length && !filter.length){
Sunstone.runAction("Network.autorefresh");
}
@@ -906,14 +996,14 @@ function setVNetAutorefresh() {
function is_public_vnet(id) {
var data = getElementData(id,"#vnetwork",dataTable_vNetworks)[7];
return $(data).attr("checked");
return $(data).is(":checked");
};
function setupVNetActionCheckboxes(){
$('input.action_cb#cb_public_vnet',dataTable_vNetworks).live("click",function(){
var $this = $(this)
var id=$this.attr("elem_id");
if ($this.attr("checked"))
var id=$this.attr('elem_id');
if ($this.attr('checked'))
Sunstone.runAction("Network.publish",id);
else Sunstone.runAction("Network.unpublish",id);
@@ -935,7 +1025,11 @@ $(document).ready(function(){
{ "sWidth": "60px", "aTargets": [0,5,6,7,8] },
{ "sWidth": "35px", "aTargets": [1] },
{ "sWidth": "100px", "aTargets": [2,3] }
]
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
});
dataTable_vNetworks.fnClearTable();
@@ -946,7 +1040,7 @@ $(document).ready(function(){
setupCreateVNetDialog();
setupVNetTemplateUpdateDialog();
setupAddRemoveLeaseDialog();
setupLeasesOps();
setupVNetActionCheckboxes();
setVNetAutorefresh();
+24 -22
View File
@@ -112,13 +112,13 @@ function recountCheckboxes(dataTable){
};
//enable checkall box
if (total_length == checked_length){
$('.check_all',dataTable).attr("checked","checked");
$('.check_all',dataTable).attr('checked','checked');
} else {
$('.check_all',dataTable).removeAttr("checked");
$('.check_all',dataTable).removeAttr('checked');
};
} else { //no elements cheked
//disable action buttons, uncheck checkAll
$('.check_all',dataTable).removeAttr("checked");
$('.check_all',dataTable).removeAttr('checked');
$('.top_button, .list_button',context).button("disable");
last_action_b.button("disable");
};
@@ -186,10 +186,12 @@ function stringJSON(json){
function notifySubmit(action, args, extra_param){
var action_text = action.replace(/OpenNebula\./,'').replace(/\./,' ');
var msg = "<h1>Submitted</h1>";
var msg = '<h1>'+tr("Submitted")+'</h1>';
if (!args || (typeof args == 'object' && args.constructor != Array)){
msg += action_text;
} else {
msg += action_text + ": " + args;
};
if (extra_param && extra_param.constructor != Object) {
@@ -201,13 +203,13 @@ function notifySubmit(action, args, extra_param){
//Notification on error
function notifyError(msg){
msg = "<h1>Error</h1>" + msg;
msg = "<h1>"+tr("Error")+"</h1>" + msg;
$.jGrowl(msg, {theme: "jGrowl-notify-error", position: "bottom-right", sticky: true });
}
//Standard notification
function notifyMessage(msg){
msg = "<h1>Info</h1>" + msg;
msg = "<h1>"+tr("Info")+"</h1>" + msg;
$.jGrowl(msg, {theme: "jGrowl-notify-submit", position: "bottom-right"});
}
@@ -248,7 +250,7 @@ function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_to
border-bottom:'+border_bottom+';\
padding-top:'+padding_top_bottom+'px;\
padding-bottom:'+padding_top_bottom+'px;">'
+field+
+tr(field)+
'</td>\
<td class="value_td" style=\
"border-bottom:'+border_bottom+';\
@@ -275,7 +277,7 @@ function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_to
border-bottom:'+border_bottom+';\
padding-top:'+padding_top_bottom+'px;\
padding-bottom:'+padding_top_bottom+'px">'+
field+
tr(field)+
'</td>\
<td class="value_td" style="\
border-bottom:'+border_bottom+';\
@@ -297,11 +299,11 @@ function initCheckAllBoxes(datatable){
$('input.check_all',datatable).css({"border":"2px"});
$('input.check_all',datatable).change(function(){
var table = $(this).parents('table');
var checked = $(this).attr("checked");
var checked = $(this).attr('checked');
if (checked) { //check all
$('tbody input.check_item',table).attr("checked","checked");
$('tbody input.check_item',table).attr('checked','checked');
} else { //uncheck all
$('tbody input.check_item',table).removeAttr("checked");
$('tbody input.check_item',table).removeAttr('checked');
};
recountCheckboxes(table);
});
@@ -332,7 +334,7 @@ function onError(request,error_json) {
if (!message){
if (!onError.disabled){
notifyError("Cannot contact server: is it running and reachable?");
notifyError(tr("Cannot contact server: is it running and reachable?"));
onError.disabled=true;
}
return false;
@@ -340,7 +342,7 @@ function onError(request,error_json) {
if (message.match(/^Network is unreachable .+$/)){
if (!onError.disabled){
notifyError("Network is unreachable: is OpenNebula running?");
notifyError(tr("Network is unreachable: is OpenNebula running?"));
onError.disabled=true;
};
return false;
@@ -361,7 +363,7 @@ function onError(request,error_json) {
} else if (m = message.match(auth_error)) {
method = m[1];
object = m[3];
reason = "Unauthorized";
reason = tr("Unauthorized");
};
if (m) {
@@ -498,7 +500,7 @@ function makeSelectOptions(dataTable,
status_cols,
bad_status_values){
var nodes = dataTable.fnGetData();
var select = '<option class="empty_value" value="">Please select</option>';
var select = '<option class="empty_value" value="">'+tr("Please select")+'</option>';
var array;
for (var j=0; j<nodes.length;j++){
var elem = nodes[j];
@@ -632,23 +634,23 @@ function shortenedInfoFields(context){
function setupTemplateUpdateDialog(){
//Append to DOM
dialogs_context.append('<div id="template_update_dialog" title="Update template"></div>');
dialogs_context.append('<div id="template_update_dialog" title=\"'+tr("Update template")+'"></div>');
var dialog = $('#template_update_dialog',dialogs_context);
//Put HTML in place
dialog.html(
'<form action="javascript:alert(\'js error!\');">\
<h3 style="margin-bottom:10px;">Please, choose and modify the template you want to update:</h3>\
<h3 style="margin-bottom:10px;">'+tr("Please, choose and modify the template you want to update")+':</h3>\
<fieldset style="border-top:none;">\
<label for="template_update_select">Select a template:</label>\
<label for="template_update_select">'+tr("Select a template")+':</label>\
<select id="template_update_select" name="template_update_select"></select>\
<div class="clear"></div>\
<textarea id="template_update_textarea" style="width:100%; height:14em;">Select a template</textarea>\
<textarea id="template_update_textarea" style="width:100%; height:14em;">'+tr("Select a template")+'</textarea>\
</fieldset>\
<fieldset>\
<div class="form_buttons">\
<button class="button" id="template_update_button" value="">\
Update\
'+tr("Update")+'\
</button>\
</div>\
</fieldset>\
@@ -706,7 +708,7 @@ function popUpTemplateUpdateDialog(elem_str,select_items,sel_elems){
if (sel_elems.length >= 1){ //several items in the list are selected
//grep them
var new_select= sel_elems.length > 1? '<option value="">Please select</option>' : "";
var new_select= sel_elems.length > 1? '<option value="">'+tr("Please select")+'</option>' : "";
$('option','<select>'+select_items+'</select>').each(function(){
var val = $(this).val();
if ($.inArray(val,sel_elems) >= 0){
@@ -715,7 +717,7 @@ function popUpTemplateUpdateDialog(elem_str,select_items,sel_elems){
});
$('#template_update_select',dialog).html(new_select);
if (sel_elems.length == 1) {
$('#template_update_select option',dialog).attr("selected","selected");
$('#template_update_select option',dialog).attr('selected','selected');
$('#template_update_select',dialog).trigger("change");
}
};
+20 -14
View File
@@ -314,7 +314,7 @@ $(document).ready(function(){
$('.action_button').live("click",function(){
var error = 0;
var table = null;
var value = $(this).attr("value");
var value = $(this).attr('value');
var action = SunstoneCfg["actions"][value];
if (!action) {
notifyError("Action "+value+" not defined.");
@@ -549,8 +549,8 @@ function initListButtons(){
$('.multi_action_slct',main_tabs_context).each(function(){
//prepare replacement buttons
var buttonset = $('<div style="display:inline-block;" class="top_button"></div');
var button1 = $('<button class="last_action_button action_button confirm_button confirm_with_select_button" value="">Previous action</button>').button();
button1.attr("disabled","disabled");
var button1 = $('<button class="last_action_button action_button confirm_button confirm_with_select_button" value="">'+tr("Previous action")+'</button>').button();
button1.attr('disabled','disabled');
var button2 = $('<button class="list_button" value="">See more</button>').button({
text:false,
icons: { primary: "ui-icon-triangle-1-s" }
@@ -563,7 +563,7 @@ function initListButtons(){
var options = $('option', $(this));
var list = $('<ul class="action_list"></ul>');
$.each(options,function(){
var classes = $(this).attr("class");
var classes = $(this).attr('class');
var item = $('<li></li>');
var a = $('<a href="#" class="'+classes+'" value="'+$(this).val()+'">'+$(this).text()+'</a>');
a.val($(this).val());
@@ -590,7 +590,7 @@ function initListButtons(){
prev_action_button.removeClass("confirm_with_select_button");
prev_action_button.removeClass("confirm_button");
prev_action_button.removeClass("action_button");
prev_action_button.addClass($(this).attr("class"));
prev_action_button.addClass($(this).attr('class'));
prev_action_button.button("option","label",$(this).text());
prev_action_button.button("enable");
$(this).parents('ul').hide("blind",100);
@@ -612,19 +612,19 @@ function initListButtons(){
//Prepares the standard confirm dialogs
function setupConfirmDialogs(){
dialogs_context.append('<div id="confirm_dialog" title="Confirmation of action"></div>');
dialogs_context.append('<div id="confirm_dialog" title=\"'+tr("Confirmation of action")+'\"></div>');
var dialog = $('div#confirm_dialog',dialogs_context);
//add the HTML with the standard question and buttons.
dialog.html(
'<form action="javascript:alert(\'js error!\');">\
<div id="confirm_tip">You have to confirm this action.</div>\
<div id="confirm_tip">'+tr("You have to confirm this action.")+'</div>\
<br />\
<div id="question">Do you want to proceed?</div>\
<div id="question">'+tr("Do you want to proceed?")+'</div>\
<br />\
<div class="form_buttons">\
<button id="confirm_proceed" class="action_button" value="">OK</button>\
<button class="confirm_cancel" value="">Cancel</button>\
<button id="confirm_proceed" class="action_button" value="">'+tr("OK")+'</button>\
<button class="confirm_cancel" value="">'+tr("Cancel")+'</button>\
</div>\
</form>');
@@ -646,17 +646,17 @@ function setupConfirmDialogs(){
return false;
});
dialogs_context.append('<div id="confirm_with_select_dialog" title="Confirmation of action"></div>');
dialogs_context.append('<div id="confirm_with_select_dialog" title=\"'+tr("Confirmation of action")+'\"></div>');
dialog = $('div#confirm_with_select_dialog',dialogs_context);
dialog.html(
'<form action="javascript:alert(\'js error!\');">\
<div id="confirm_with_select_tip">You need to select something.</div>\
<div id="confirm_with_select_tip">'+tr("You need to select something.")+'</div>\
<select style="margin: 10px 0;" id="confirm_select">\
</select>\
<div class="form_buttons">\
<button id="confirm_with_select_proceed" class="" value="">OK</button>\
<button class="confirm_cancel" value="">Cancel</button>\
<button id="confirm_with_select_proceed" class="" value="">'+tr("OK")+'</button>\
<button class="confirm_cancel" value="">'+tr("Cancel")+'</button>\
</div>\
</form>');
@@ -686,6 +686,12 @@ function setupConfirmDialogs(){
var value = $(this).val();
var action = SunstoneCfg["actions"][value];
var param = $('select#confirm_select',context).val();
if (!param.length){
notifyError("You must select a value");
return false;
};
if (!action) { notifyError("Action "+value+" not defined."); return false;};
switch (action.type){
case "multiple": //find the datatable
+476
View File
@@ -0,0 +1,476 @@
//Translated by
lang="en_US"
datatable_lang=""
locale={
"Accept (default)":"",
"Acl":"",
"ACL Rules":"",
"ACLs":"",
"ACL String preview":"",
"ACPI":"",
"Add":"",
"Add context variables":"",
"Add custom variables":"",
"Add disk/image":"",
"Add disks/images":"",
"Add Graphics":"",
"Add Hypervisor raw options":"",
"Add inputs":"",
"Add lease":"",
"Add network":"",
"Add placement options":"",
"Advanced mode":"",
"Affected resources":"",
"All":"",
"Allowed operations":"",
"Amount of RAM required for the VM, in Megabytes.":"",
"Applies to":"",
"Architecture":"",
"are mandatory":"",
"Arguments for the booting kernel":"",
"Authentication":"",
"Authentication driver":"",
"Block":"",
"Boolean expression that rules out provisioning hosts from list of machines suitable to run this VM":"",
"Boot":"",
"Boot device type":"",
"Bootloader":"",
"Boot method":"",
"Boot/OS options":"",
"Bridge":"",
"Bus":"",
"Cancel":"",
"Cannot contact server: is it running and reachable?":"",
"Canvas not supported.":"",
"Capacity":"",
"Capacity options":"",
"cdrom":"",
"CD-ROM":"",
"Change":"",
"Change authentication":"",
"Change group":"",
"Change owner":"",
"Change password":"",
"Clone":"",
"Clone this image":"",
"Community":"",
"Confirmation of action":"",
"Context":"",
"Context variable name and value must be filled in":"",
"Core":"",
"CPU":"",
"CPU architecture to virtualization":"",
"CPU Monitoring information":"",
"CPU Use":"",
"Create":"",
"Create ACL":"",
"Create an empty datablock":"",
"Create group":"",
"Create host":"",
"Create Image":"",
"Create user":"",
"Create Virtual Machine":"",
"Create Virtual Network":"",
"Create VM Template":"",
"Current disks":"",
"Current inputs":"",
"Current leases":"",
"Current NICs":"",
"Current variables":"",
"Custom attribute name and value must be filled in":"",
"Custom attributes":"",
"Custom variable name and value must be filled in":"",
"Custom variables":"",
"Dashboard":"",
"Data":"",
"Datablock":"",
"Default":"",
"Default (current image type)":"",
"Define a subnet by IP range":"",
"Delete":"",
"Delete host":"",
"Deploy":"",
"Deploy ID":"",
"Deploy # VMs":"",
"Description":"",
"Device prefix":"",
"Device to be mounted as root":"",
"Device to map image disk. If set, it will overwrite the default device mapping":"",
"Disable":"",
"disabled":"",
"Disallow access to the VM through the specified ports in the TCP protocol":"",
"Disallow access to the VM through the specified ports in the UDP protocol":"",
"Disk":"",
"Disk file location path or URL":"",
"disk id":"",
"Disks":"",
"Disk type":"",
"Documentation":"",
"Do you want to proceed?":"",
"Driver":"",
"Driver default":"",
"Drivers":"",
"Drop":"",
"Dummy":"",
"EC2":"",
"Enable":"",
"Error":"",
"failed":"",
"fd":"",
"Features":"",
"Fields marked with":"",
"File":"",
"Filesystem type":"",
"Filesystem type for the fs images":"",
"Fill in a new password":"",
"Fixed network":"",
"Floppy":"",
"Fold / Unfold all sections":"",
"Format":"",
"FS":"",
"FS type":"",
"Get Information":"",
"Get Pool of my/group\'s resources":"",
"Get Pool of resources":"",
"Graphics":"",
"Graphics type":"",
"Group":"",
"Group ":"",
"Group name":"",
"Groups":"",
"Hardware that will emulate this network interface. With Xen this is the type attribute of the vif.":"",
"hd":"",
"Historical monitoring information":"",
"hold":"",
"Hold":"",
"Hold lease":"",
"Host":"",
"Host information":"",
"Hostname":"",
"Host name missing!":"",
"Host parameters":"",
"Hosts":"",
"Hosts CPU":"",
"Host shares":"",
"Hosts memory":"",
"Hosts (total/active)":"",
"Host template":"",
"Human readable description of the image for other users.":"",
"HW address associated with the network interface":"",
"Icmp":"",
"ICMP policy":"",
"id":"",
"ID":"",
"IDE":"",
"Image":"",
"Image cannot be public and persistent":"",
"Image information":"",
"Image name":"",
"Images":"",
"Images (total/public)":"",
"Image template":"",
"IM MAD":"",
"Info":"",
"information":"",
"Information":"",
"Information Manager":"",
"Initrd":"",
"Inputs":"",
"Instantiate":"",
"IP":"",
"IP End":"",
"IP Start":"",
"IP to listen on":"",
"Kernel":"",
"Kernel commands":"",
"Keyboard configuration locale to use in the VNC display":"",
"Keymap":"",
"KVM":"",
"LCM State":"",
"Lease IP":"",
"Lease MAC (opt):":"",
"Lease management":"",
"Leases information":"",
"Listen IP":"",
"Live migrate":"",
"Loading":"",
"MAC":"",
"Make non persistent":"",
"Make persistent":"",
"Manage":"",
"Manual":"",
"Max Mem":"",
"Memory":"",
"Memory monitoring information":"",
"Memory use":"",
"Migrate":"",
"Model":"",
"Monitoring information":"",
"Mount image as read-only":"",
"Mouse":"",
"Name":"",
"Name for the context variable":"",
"Name for the custom variable":"",
"Name for the tun device created for the VM":"",
"Name of a shell script to be executed after creating the tun device for the VM":"",
"Name of the bridge the network device is going to be attached to":"",
"Name of the image to use":"",
"Name of the network to attach this device":"",
"Name that the Image will get. Every image must have a unique name.":"",
"Name that the VM will get for description purposes. If NAME is not supplied a name generated by one will be in the form of one-&lt;VID&gt;.":"",
"Net_RX":"",
"Net_TX":"",
"network":"",
"Network":"",
"Network Address":"",
"Network is unreachable: is OpenNebula running?":"",
"Network mask":"",
"Network Mask":"",
"Network reception":"",
"Network transmission":"",
"Network type":"",
"New":"",
"+ New":"",
"+ New Group":"",
"New password":"",
"No":"",
"No disk id or image name specified":"",
"No disks defined":"",
"No leases to show":"",
"None":"",
"Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.":"",
"OK":"",
"Open VNC Session":"",
"Optional, please select":"",
"OS":"",
"OS and Boot options":"",
"Owned by group":"",
"Owner":"",
"PAE":"",
"Password":"",
"Password for the VNC server":"",
"Path":"",
"Path to the bootloader executable":"",
"Path to the initrd image":"",
"Path to the original file that will be copied to the image repository. If not specified for a DATABLOCK type image, an empty image will be created.":"",
"Path to the OS kernel to boot the image":"",
"Path vs. source":"",
"Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.":"",
"Permits access to the VM only through the specified ports in the TCP protocol":"",
"Permits access to the VM only through the specified ports in the UDP protocol":"",
"Persistence of the image":"",
"Persistent":"",
"Physical address extension mode allows 32-bit guests to address more than 4 GB of memory":"",
"Physical device":"",
"Placement":"",
"Please choose":"",
"Please, choose and modify the image you want to update":"",
"Please, choose and modify the template you want to update":"",
"Please, choose and modify the virtual network you want to update":"",
"Please choose path if you have a file-based image. Choose source otherwise or create an empty datablock disk.":"",
"Please choose the new type of authentication for the selected users":"",
"Please provide a lease IP":"",
"Please provide a network address":"",
"Please provide a resource ID for the resource(s) in this rule":"",
"Please select":"",
"Please select at least one resource":"",
"Please specify to who this ACL applies":"",
"Port":"",
"Port blacklist":"",
"Port for the VNC server":"",
"Port whitelist":"",
"Predefined":"",
"Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”. If omitted, the default value is the one defined in oned.conf (installation default is “hd”).":"",
"Previous action":"",
"Provide a path":"",
"Provide a source":"",
"PS2":"",
"Public":"",
"Public scope of the image":"",
"Publish":"",
"Quickstart":"",
"Ranged network":"",
"Rank":"",
"Raw":"",
"Raw data to be passed directly to the hypervisor":"",
"Read only":"",
"Refresh list":"",
"Register time":"",
"Registration time":"",
"release":"",
"Release":"",
"Remove selected":"",
"Request an specific IP from the Network":"",
"Requirements":"",
"Reset":"",
"Resource ID":"",
"Resource ID / Owned by":"",
"Resource subset":"",
"Restart":"",
"Resubmit":"",
"Resume":"",
"Retrieving":"",
"Root":"",
"running":"",
"Running VMs":"",
"Running #VMS":"",
"Save":"",
"Save as":"",
"Saveas for VM with ID":"",
"Save this image after shutting down the VM":"",
"Script":"",
"SCSI":"",
"SDL":"",
"Select a network":"",
"Select an image":"",
"Select a template":"",
"Select boot method":"",
"Select disk":"",
"Select template":"",
"Select the new group":"",
"Select the new owner":"",
"Server (Cipher)":"",
"Server (x509)":"",
"Setup Networks":"",
"Shared":"",
"Shutdown":"",
"Sign out":"",
"Size":"",
"Size in MB":"",
"Size (Mb)":"",
"Size of the datablock in MB.":"",
"Skipping VM ":"",
"Source":"",
"Source to be used in the DISK attribute. Useful for not file-based images.":"",
"Specific ID":"",
"Specific image mapping driver. KVM: raw, qcow2. XEN: tap:aio, file:":"",
"Specific image mapping driver. KVM: raw, qcow2. Xen:tap:aio:, file:. VMware unsupported":"",
"SSH":"",
"Start time":"",
"Start Time":"",
"State":"",
"Status":"",
"Stop":"",
"Submitted":"",
"Summary of resources":"",
"Support":"",
"Suspend":"",
"Swap":"",
"Tablet":"",
"Target":"",
"Tcp black ports":"",
"Tcp firewall mode":"",
"Tcp white ports":"",
"Template":"",
"Template information":"",
"Templates":"",
"Template updated correctly":"",
"There are mandatory fields missing in the capacity section":"",
"There are mandatory fields missing in the OS Boot options section":"",
"There are mandatory parameters missing":"",
"There are mandatory parameters missing in this section":"",
"This field sets which attribute will be used to sort the suitable hosts for this VM. Basically, it defines which hosts are more suitable than others":"",
"This rule applies to":"",
"This will cancel selected VMs":"",
"This will change the main group of the selected users. Select the new group":"",
"This will change the password for the selected users":"",
"This will delete the selected VMs from the database":"",
"This will deploy the selected VMs on the chosen host":"",
"This will hold selected pending VMs from being deployed":"",
"This will initiate the shutdown process in the selected VMs":"",
"This will live-migrate the selected VMs to the chosen host":"",
"This will migrate the selected VMs to the chosen host":"",
"This will redeploy selected VMs (in UNKNOWN or BOOT state)":"",
"This will release held machines":"",
"This will resubmits VMs to PENDING state":"",
"This will resume selected stopped or suspended VMs":"",
"This will suspend selected machines":"",
"TM MAD":"",
"total":"",
"Total Leases":"",
"Total VM count":"",
"Total VM CPU":"",
"Total VM Memory":"",
"Transfer Manager":"",
"Type":"",
"Type of disk device to emulate.":"",
"Type of disk device to emulate: ide, scsi":"",
"Type of file system to be built. This can be any value understood by mkfs unix command.":"",
"Type of the image, explained in detail in the following section. If omitted, the default value is the one defined in oned.conf (install default is OS).":"",
"Udp black ports":"",
"Udp firewall mode":"",
"Udp white ports":"",
"Unauthorized":"",
"Unpublish":"",
"Update":"",
"Update a template":"",
"Update image template":"",
"Update network template":"",
"Update template":"",
"USB":"",
"Use":"",
"Used by VM":"",
"Used CPU":"",
"Used CPU (allocated)":"",
"Used CPU (real)":"",
"Used Mem (allocated)":"",
"Used Memory":"",
"Used Mem (real)":"",
"Useful for power management, for example, normally required for graceful shutdown to work":"",
"User":"",
"Username":"",
"User name and password must be filled in":"",
"Users":"",
"Value":"",
"Value of the context variable":"",
"Value of the custom variable":"",
"VCPU":"",
"Virtio":"",
"Virtio (KVM)":"",
"Virtualization Manager":"",
"Virtual Machine information":"",
"Virtual Machines":"",
"Virtual Network":"",
"Virtual network information":"",
"Virtual Network information":"",
"Virtual Network name missing!":"",
"Virtual Networks":"",
"Virtual Networks (total/public)":"",
"Virtual Network template (attributes)":"",
"VM information":"",
"VM Instance":"",
"VM Instances":"",
"VM log":"",
"VM MAD":"",
"VM Name":"",
"VM Network stats":"",
"#VMS":"",
"VM Save As":"",
"VM template":"",
"VM Template":"",
"VM Templates":"",
"VM Templates (total/public)":"",
"VNC":"",
"VNC Access":"",
"VNC connection":"",
"VNC Disabled":"",
"VNC Session":"",
"VNET ID":"",
"VN MAD":"",
"Welcome":"",
"Wizard":"",
"Wizard KVM":"",
"Wizard VMware":"",
"Wizard XEN":"",
"Write the image template here":"",
"Write the Virtual Machine template here":"",
"Write the Virtual Network template here":"",
"x509":"",
"XEN":"",
"Xen templates must specify a boot method":"",
"yes":"",
"Yes":"",
"You have not selected a template":"",
"You have to confirm this action.":"",
"You need to select something.":"",
};
@@ -0,0 +1,31 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
tr_strings = `grep -h -o -R -e 'tr("[[:print:]]*")' ../js/* | cut -d'"' -f 2 | sort -u`
puts "//Translated by"
puts 'lang="en_US"'
puts 'datatable_lang=""'
puts "locale={"
tr_strings.each_line do | line |
puts " \"#{line.chomp}\":\"\","
end
puts "};"
+519
View File
@@ -0,0 +1,519 @@
//Translated by JSC "VIVOSS and OI", 2011
//Переведено ЗАО «ВИВОСС и ОИ», 2011
lang="ru"
datatable_lang = "ru_datatable.txt"
locale={
"information":"информация",
"#VMS":"Кол-во ВМ",
"+ New Group":"Создать группу",
"+ New":"Добавить",
". No disk id or image name specified":". Не указано название образа или № диска",
"ACL Rules":"Правила контроля доступа",
"ACL String preview:":"Предпросмотр правила:",
"ACLs":"Списки контроля",
"ACPI":"ACPI",
//"ACTIVE":"",
"Accept (default)":"Принять (по умолчанию)",
"Acl create":"Список контроля создан",
"Acl delete":"Удален список контроля с номером ",
"Acl":"Список контроля доступа",
"Add Graphics":"Добавить графические устройства",
"Add Hypervisor raw options":"Добавить исходные опции гипервизора",
"Add context variables":"Добавить контекстные переменные",
"Add custom variables":"Добавить пользовательские переменные",
"Add disk/image":"Добавить диск/образ",
"Add disks/images":"Добавить диски/образы",
"Add inputs":"Добавить устройства ввода",
"Add lease":"Добавить адрес",
"Add network":"Добавить сеть",
"Add placement options":"Добавить опции размещения",
"Add to group":"Включить в группу",
"Add":"Добавить",
"Advanced mode":"Расширенный режим",
"Affected resources":"Затрагиваемые правилом ресурсы",
"All":"Все",
"Allowed operations":"Разрешенные действия",
"Amount of RAM required for the VM, in Megabytes.":"Объем ОЗУ (в МБ), необходимый для ВМ.",
"Applies to":"Применено к",
"ARCH":"Архитектура",
"Architecture:":"Архитектура:",
"Arguments for the booting kernel":"Параметры для загрузки ядра",
"BOOT":"Тип ус-ва загрузки",
"BRIDGE":"Шлюз",
"BUS":"Тип шины",
"Block":"Block",
"Boolean expression that rules out provisioning hosts from list of machines suitable to run this VM":"Логическое выражение, исключающее элементы из списка узлов, подходящих для запуска данной ВМ",
"Boot device type":"Тип устройства загрузки",
"Boot method:":"Метод загрузки:",
"Boot/OS options":"Загрузка и тип ОС",
"Boot:":"Загрузка:",
"Bootloader:":"Загрузчик:",
"Bridge":"Шлюз",
"Bus:":"Тип шины:",
"CD-ROM":"CD-ROM",
"CLONE":"Образ клонируется",
"CPU Monitoring information":"Мониторинг ЦП",
"CPU Use":"Использование ЦП",
"CPU architecture to virtualization":"Архитектура ЦП для виртуализации",
"CPU":"ЦП",
"CPUSPEED":"Тактовая частота ЦП",
"Cancel":"Отменить",
"Canvas not supported.":"Canvas не поддерживается.",
"Capacity options":"Настройки производительности",
"Capacity":"Производительность",
"Change group":"Сменить группу",
"Change owner":"Сменить владельца",
"Clone this image":"Клонировать образ",
"Clone:":"Образ клонируется:",
"Confirmation of action":"Подтверждение действия",
"Context variable name and value must be filled in":"Поля «Имя переменной» и «Значение» должны быть заполнены",
"Context":"Контекст",
"Create ACL":"Создать список контроля",
"Create VM Template":"Создать шаблон ВМ",
"Create Virtual Machine":"Создать виртуальную машину",
"Create Virtual Network":"Создать виртуальную сеть",
"Create an empty datablock":"Создать пустой блок данных", //!!
"Create group":"Создать группу",
"Create host":"Создать узел",
"Create user":"Создать пользователя",
"Create":"Создать",
"Current NICs:":"Текущие контроллеры сет. интерфейса:",
"Current disks:":"Текущие диски:",
"Current inputs:":"Текущие УВВ:",
"Current leases:":"Текущие адреса:",
"Current variables:":"Текущее значение:",
"Custom variable name and value must be filled in":"Поля «Имя переменной» и «Значение» должны быть заполнены",
"Custom variables":"Пользовательские переменные",
"DESCRIPTION":"Краткое описание",
"DEV_PREFIX":"Префикс устройства",
//"DISABLED":"",
"DISK":"Сведения о диске",
"DISK_ID":"№ диска",
"DRIVER":"Драйвер",
"Dashboard":"Инф. панель",
"Data:":"Данные:",
"Datablock":"Блок данных",
"Default":"По умолчанию",
"Delete from group":"Исключить из группы",
"Delete host":"Удалить узел",
"Delete":"Удалить",
"Deploy # VMs:":"Кол-во экземпляров ВМ для размещения:",
"Deploy ID":"№ размещения",
"Deploy":"Разместить на узле",
"Description:":"Описание:",
"Device prefix:":"Префикс устройства:",
"Device to be mounted as root":"Устройство, монтируемое как корневое",
"Device to map image disk. If set, it will overwrite the default device mapping":"Устройство для образа диска. Если установлено, то оно перезапищет устройсво картографирования по умолчанию.",
"Disable":"Отключить",
"Disallow access to the VM through the specified ports in the TCP protocol":"Запретить доступ к ВМ через указанные порты для TCP протокола",
"Disallow access to the VM through the specified ports in the UDP protocol":"Запретить доступ к ВМ через указанные порты для UDP протокола",
"Disk file location path or URL":"Путь расположения файла диска или URL",
"Disk type":"Тип диска",
"Disk":"Диск",
"Disks":"Диски",
"Do you want to proceed?":"Хотите продолжить?",
"Driver default":"Драйвер по умолчанию",
"Driver:":"Драйвер:",
"Drivers":"Драйверы",
"Drop":"Сбросить",
"Dummy":"Заглушка",
"EC2":"EC2",
"ERROR":"Сведения об ошибках",
"Enable":"Включить",
"Error":"Ошибка",
"FEATURES":"Особенности",
//"FIXED":"",
"FREECPU":"Незадействованный ресурс ЦП",
"FREEMEMORY":"Свободно ОЗУ",
"FS type:":"Тип ФС:",
"FS":"FS",
"Features":"Особенности",
"Fields marked with":"Поля помеченные",
"File":"Файл",
"Filesystem type for the fs images":"Тип файловой системы для образов ФС",
"Fixed network":"Фиксированные адреса",
"Floppy":"Floppy",
"Fold / Unfold all sections":"Свернуть/развернуть все разделы",
"Format:":"Формат:",
"GRAPHICS":"Параметры графического доступа",
"Get Information":"Получить информацию",
"Get Pool of my/group\'s resources":"Получить пул доступных мне/группе ресурсов",
"Get Pool of resources":"Получить пул ресурсов",
"Graphics type:":"Тип ГУ:",
"Graphics":"Графические устройства",
"Group create":"Группа создана",
"Group delete":"Группа удалена",
"Group name:":"Название группы:",
"Group":"Группа пользователей",
"Groups":"Группы",
"HOSTNAME":"Название узла",
"HW address associated with the network interface":"MAC-адрес, связанный с сетевым интерфейсом",
"HYPERVISOR":"Гипервизор",
"Hardware that will emulate this network interface. With Xen this is the type attribute of the vif.":"Аппаратное устройствое, которое будет отвечать за эмуляцию сетевого интерфейса. Для Xen это атрибут vif.",
"Historical monitoring information":"Мониторинг состояния",
"Hold":"Запретить размещение",
"Host information":"Состояние узла",
"Host parameters":"Параметры узла",
"Host shares":"Ресурсы узла",
"Host template":"Шаблон узла",
"Host":"Узел",
"Hostname":"Название узла",
"Hosts (total/active)":"Узлы (всего/из них активных)",
"Hosts CPU":"Загрузка ЦП",
"Hosts memory":"Загрузка ОЗУ",
"Hosts":"Узлы",
"Human readable description of the image for other users.":"Краткое описание образа.",
"ICMP policy":"Политика ICMP",
"ID":"№",
"IDE":"IDE",
"IM MAD":"Модуль ср-ва мониторинга",
"IMAGE":"Используемый образ",
"IMAGE_ID":"№ образа",
//"INIT":"",
"IP to listen on":"IP-адрес для прослушивания",
"IP":"IP-адрес",
"IP:":"IP:",
"Icmp:":"Icmp:",
"Image information":"Информация об образе",
"Image name:":"Название образа:",
"Image template":"Шаблон образа",
"Images (total/public)":"Образы (всего/из них открытых)",
"Images":"Образы ВМ",
"Image":"Образ",
"Info":"Информация",
"Information Manager:":"Cредство мониторинга:",
"Information":"Информация",
"information":" ",
"Initrd:":"Диск нач. иниц.(initrd):",
"Inputs":"Устройства ввода",
"Instantiate":"Создать экземпляр ВМ",
"KVM":"KVM",
"Kernel commands:":"Команды ядра:",
"Kernel:":"Ядро:",
"Keyboard configuration locale to use in the VNC display":"Раскладка клавиатуры, используемая при работе с VNC-дисплеем",
"Keymap":"Раскладка клавиатуры",
"LCM State":"Текущее состояние ВМ",
"LEASES":"АДРЕСА",
"LISTEN":"Прослушивать IP",
"Lease IP:":"IP-адрес:",
"Lease MAC (opt):":"MAC-адрес (необяз.):",
"Lease MAC:":"MAC-адрес:",
"Leases information":"Сведения по имеющимся адресам виртуальной сети",
"Listen IP:":"Прослушивать IP:",
"Live migrate":"Перенести запущенную ВМ",
"Loading":"Идет загрузка",
"MAC":"MAC-адрес",
"MAC:":"MAC-адрес:",
"MEMORY":"Объем ОЗУ",
"MESSAGE":"Сообщение",
"MODELNAME":"Модель ЦП",
//"MONITORED":"",
//"MONITORING":"",
"Make non persistent":"Сделать непостоянным",
"Make persistent":"Сделать постоянным",
"Manage":"Управлять",
"Manual":"В ручную",
"Max Mem":"Доступно ОЗУ",
"Memory monitoring information":"Мониторинг ОЗУ",
"Memory use":"Использование ОЗУ",
"Memory":"Память",
"Migrate":"Перенести ВМ",
"Model:":"Модель:",
"Monitoring information":"Мониторинг",
"Mount image as read-only":"Монтировать образ только для чтения",
"Mouse":"Мышь",
"NAME":"Название",
"Name for the context variable":"Имя контекстной переменной",
"Name for the custom variable":"Имя пользовательской переменной",
"Name for the tun device created for the VM":"Имя сетевого туннеля, созданного для ВМ",
"Name of a shell script to be executed after creating the tun device for the VM":"shell-скрипт, который будет выполнен после создания сетевого туннеля для ВМ",
"Name of the bridge the network device is going to be attached to":"Шлюз, с которым будет связано сетевое устройство",
"Name of the image to use":"Название образа для использования",
"Name of the network to attach this device":"Сеть, подключаемая к данному устройству",
"Name that the Image will get. Every image must have a unique name.":"Название, которое получит образ. Каждый образ должен обладать уникальным названием.",
"Name that the VM will get for description purposes. If NAME is not supplied a name generated by one will be in the form of one-&lt;VID&gt;.":"Название, которое получит ВМ. Если название не будет указано, то оно будет сгенерировано в формате one-&lt;№ ВМ&gt;.",
"Name":"Название",
"Net_RX":"Принято",
"Net_TX":"Отправлено",
"NETRX":"Принято по сети",
"NETTX":"Отправлено по сети",
"NETWORK":"Название вирт. сети",
"NETWORK_ADDRESS":"Адрес сети",
"NETWORK_ID":"№ вирт. сети",
"NETWORK_SIZE":"Размер сети",
"NIC":"Контроллер сетевого интерфейса",
"NO":"нет",
"Network Address:":"Адрес сети:",
"Network reception":"Сеть: принято",
"Network size:":"Размер сети:",
"Network transmission":"Сеть: отправлено",
"Network type:":"Тип сети:",
"Network":"Сеть",
"New: ":"Создать новый ресурс: ",
"No disks defined":"Дисков не обнаружено",
"No":"Нет",
"None":"Никакой",
"Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.":"Количество виртуальных процессоров. Это значение опционально, используется поведение гипервизора по умолчанию - один виртуальный ЦП.",
"OK":"OK",
"OS and Boot options":"Опции загрузки и ОС",
"OS":"ОС",
"Open VNC Session":"Открыть VNC-сессию",
"Optional, please select":"Опционально, пожалуйста выберите",
"Owned by group":"Принадлежит группе",
"Owner":"Владелец",
"PAE:":"PAE:",
"PATH":"ПУТЬ",
"PERSISTENT":"Постоянный",
"PORT":"Номер порта доступа",
"PS2":"PS/2",
"Password for the VNC server":"Пароль для VNC сервера",
"Password:":"Пароль:",
"Path to the OS kernel to boot the image":"Путь к ядру ОС для загрузки образа",
"Path to the bootloader executable":"Путь к исполняемому файлу загрузчика",
"Path to the initrd image":"Путь к образу initrd",
"Path to the original file that will be copied to the image repository. If not specified for a DATABLOCK type image, an empty image will be created.":"Путь к исходному файлу, который будет скопирован в хранилище образов. Если путь не указан для типа образа БЛОК ДАННЫХ, то будет создан пустой образ.",
"Path vs. source:":"Исходные данные образа:",
"Path:":"Путь к эталонному файлу образа:",
"Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.":"Процент процессорного времени ЦП, предоставлемого ВМ, разделенный на 100. Например, для выделения половины процессорного времени следует указать 0.5.",
"Permits access to the VM only through the specified ports in the TCP protocol":"Разрешить доступ к ВМ только через указанные порты протокола TCP",
"Permits access to the VM only through the specified ports in the UDP protocol":"Разрешить доступ к ВМ только через указанные порты протокола UPD",
"Persistence of the image":"Если образ является постоянным, то при каждом завершении работы с полученной на его основе виртуальной машиной все изменения будут сохранены в образе.\n\n Важно помнить, что сохранение выполнится только в случае завершения работы соответствующей ВМ при помощи операций «Выключить» и «Отменить».\n\nПостоянный образ всегда хранится в одном экземпляре.",
"Persistent":"Постоянный",
"Physical address extension mode allows 32-bit guests to address more than 4 GB of memory":"Режим расширенной физической адресации позволяет использовать 32-битным ВМ больше 4-х ГБ ",
"Placement":"Размещение",
"Please choose path if you have a file-based image. Choose source otherwise or create an empty datablock disk.":"«Путь к эталонному файлу образа» — образ создается путем копирования эталонного файла образа в хранилище образов.\n\n«Источник» — в данное поле следует указывать местоположение образа (в качестве образа будет использован ресурс, непосредственно указанный в поле «Источник», а не копия этого ресурса).",
"Please choose":"Пожалуйста выберите",
"Please provide a lease IP":"Необходимо указать IP-адрес",
"Please provide a network address":"Укажите адрес сети",
"Please provide a resource ID for the resource(s) in this rule":"Необходимо указать № ресурса(ов) для данного правила)",
"Please select a group to which the selected resources belong to":"Необходимо выбрать группу пользователей, которой принадлежат выбранные ресурсы",
"Please select at least one operation":"Необходимо выбрать по меньшей мере одну операцию",
"Please select at least one resource":"Необходимо выбрать по меньшей мере один ресурс",
"Please select":"Выберите",
"Please specify to who this ACL applies":"Необходимо указать, к кому применять данный список контроля",
"Please specify:":"Укажите:",
"Please, choose and modify the template you want to update:":"Укажите шаблон, который хотите обновить:",
"Port blacklist":"Список запрещенных портов",
"Port for the VNC server":"Порт для сервера VNC",
"Port whitelist":"Список разрешенных портов",
"Port:":"Порт:",
"Predefined":"По умолчанию",
"Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”. If omitted, the default value is the one defined in oned.conf (installation default is “hd”).":"Префикс эмулируемого устройства, на которое будет смонтирован образ. Например, «hd» и «sd». Если не указать префикс, его значение будет считано из конфигурационного файла oned.conf (значение по умолчанию — «hd»).",
"Previous action":"Предыдущее действие",
"Provide a path":"Указать путь к эталонному файлу образа",
"Provide a source":"Указать источник для образа",
"Public scope of the image":"Информация о доступности образа",
"Public":"Открытый",
"Publish":"Сделать открытым",
"Quickstart":"Типовые операции",
//"RANGED":""
"RAW":"RAW",
"READONLY":"Доступен только на чтение",
//"READY":"",
"Ranged network":"Диапазон адресов",
"Rank:":"Степень:",
"Raw data to be passed directly to the hypervisor":"Исходные данные, передаваемые напрямую гипервизору",
"Raw":"Исходная опция",
"Read only:":"Только чтение:",
"Refresh list":"Обновить список",
"Register time":"Время регистрации",
"Registration time":"Время регистрации",
"Release":"Разрешить размещение",
"Remove lease":"Удалить адрес",
"Remove selected":"Удалить выбранные",
"Request an specific IP from the Network":"Запросить определенный IP-адрес из сети",
"Requirements:":"Требования:",
"Reset":"Сбросить",
"Resource ID / Owned by":"№ ресурса / Принадлежит",
"Resource ID:":"№ ресурса:",
"Resource subset:":"Подмножество ресурсов:",
"Restart":"Перезапустить",
"Resubmit":"Разместить повторно",
"Resume":"Возобновить работу ВМ",
"Retrieving...":"Извлечение...",
"Root:":"Корень:",
"Running VMs":"Запущено ВМ",
"SAVE":"Сохранение изменений",
"SCSI":"SCSI",
"SDL":"SDL",
"SHARED":"Общий каталог",
"SOURCE":"Источник",
"Save as":"Сохранить как",
"Save this image after shutting down the VM":"Сохранить образ после выключения ВМ",
"Save:":"Сохранить:",
"Saveas for VM with ID":"Сохранить как для ВМ с №",
"Script:":"Скрипт:",
"Select a template":"Выберите шаблон",
"Select boot method":"Выберите метод загрузки",
"Select disk:":"Выберите диск:",
"Select template:":"Использовать шаблон:",
"Select the group from which to delete users:":"Выберите группу, из которой требуется исключить пользователей:",
"Select the new ":"Выбрать новую группу",
"Select the new group to add users:":"Выберите новую группу, в которую требуется включить пользователей:",
"Select the new group:":"Выберите новую группу:",
"Select the new owner:":"Выбрать нового владельца:",
"Setup Networks":"Настройка сетей",
"Shutdown":"Выключить",
"Size in MB":"Размер в МБ",
"Size of the datablock in MB.":"Размер блока данных в МБ.",
"Size:":"Размер:",
"Skipping VM ":"Пропуск ВМ ",
"Source to be used in the DISK attribute. Useful for not file-based images.":"В качестве источника указывается местоположение образа, который планируется использовать непосредственно.",
"Source":"Источник",
"Specific ID":"Ресурс с конкретным №",
"Specific image mapping driver. KVM: raw, qcow2. Xen:tap:aio:, file:. VMware unsupported":"Формат образа виртуального диска. Для KVM: raw, qcow2. Для Xen: tap:aio:, file:. Форматы VMware не поддерживаются",
"Start Time":"Время запуска",
"Start time":"Время запуска",
"State":"Состояние",
"Status":"Статус",
"Stop":"Остановить",
"Submitted":"Выполнено",
"Summary of resources":"Использование ресурсов",
"Suspend":"Приостановить работу ВМ",
"Swap":"Swap",
"TARGET":"Ус-во загрузки",
"TEMPLATE_ID":"№ шаблона ВМ",
"TM MAD":"Модуль ср-ва передачи",
"TYPE":"Тип",
"Tablet":"Планшетный ПК",
"Target:":"Ус-во загрузки:",
"Tcp black ports:":"Запрещенные TCP-порты:",
"Tcp firewall mode:":"TCP режим брандмауэра:",
"Tcp white ports:":"Разрешенные TCP-порты:",
"Template information":"Сведения о шаблоне",
"Template updated correctly":"Шаблон успешно обновлен",
"Template":"Шаблон",
"Templates":"Шаблоны ВМ",
"There are mandatory fields missing in the OS Boot options section":"В разделе «Загрузка и тип ОС» не заполнены некоторые обязательные поля",
"There are mandatory fields missing in the capacity section":"В разделе «Производительность» не заполнены некоторые обязательные поля",
"There are mandatory parameters missing in this section":"В данном разделе указаны не все обязательные параметры",
"There are mandatory parameters missing":"Указаны не все обязательные параметры",
"This field sets which attribute will be used to sort the suitable hosts for this VM. Basically, it defines which hosts are more suitable than others":"В данном поле устанавливается значение атрибута, используемое для ранжирования узлов, пригодных для размещения ВМ. Значение атрибута определяет, какие из узлов лучше подходят для размещения ВМ.",
"This rule applies to:":"Прим. правило к:",
"This will cancel selected VMs":"Прервать работу выбранных ВМ",
"This will change the main group of the selected users. Select the new group:":"Изменение основной группы для выбранных пользователей. Выберите новую группу:",
"This will delete the selected VMs from the database":"Удалить выбранные ВМ и связанные с ними образы дисков из базы данных и хранилища образов",
"This will deploy the selected VMs on the chosen host":"Разместить выбранные ВМ на определенном узле",
"This will hold selected pending VMs from being deployed":"Приостановить процедуру размещения ВМ на узле",
"This will initiate the shutdown process in the selected VMs":"Запустить процесс выключения выбранных ВМ",
"This will live-migrate the selected VMs to the chosen host":"Перенести выбранные запущенные ВМ, не завершая их работы, с текущих узлов на выбранный",
"This will migrate the selected VMs to the chosen host":"Перенести выбранные остановленные ВМ с текущих узлов на выбранный",
"This will redeploy selected VMs (in UNKNOWN or BOOT state)":"Повторно выполнить процедуру размещения выбранных ВМ, находящихся в состоянии UNKNOWN или BOOT, на узле",
"This will release held machines":"Продолжить ранее приостановленное размещение ВМ на узле",
"This will resubmits VMs to PENDING state":"Повторно выполнить попытку размещения выбранных ВМ на одном из доступных узлов системы виртуализации (перевод в состояние PENDING)",
"This will resume selected stopped or suspended VMs":"Возобновить работу выбранных остановленных или приостановленных ВМ",
"This will stop selected VMs":"Остановить выбранные ВМ",
"This will suspend selected machines":"Приостановить выбранные ВМ",
"TIMESTAMP":"Время",
"TOTALCPU":"Ресурс ЦП",
"TOTALMEMORY":"Объем ОЗУ",
"Total Leases":"Суммарное количество адресов",
"Total VM count":"Количество виртуальных машин",
"Transfer Manager:":"Средство передачи:",
"Type of disk device to emulate.":"Тип эмулируемого дискового устройства",
"Type of disk device to emulate: ide, scsi":"Тип эмулируемого дискового устройства: ide, scsi",
"Type of file system to be built. This can be any value understood by mkfs unix command.":"Тип создаваемой ФС. Может быть указан любой тип, который используется в unix-команде mkfs.",
"Type of the image, explained in detail in the following section. If omitted, the default value is the one defined in oned.conf (install default is OS).":"Тип. Если не указать тип образа, его значение будет считано из конфигурационного файла oned.conf (значение по умолчанию — «OS»).",
"Type":"Тип",
"USB":"USB",
//"USED":"",
"USEDCPU":"Использование ресурса ЦП",
"USEDMEMORY":"Используемый объем ОЗУ",
"USED_BY":"Экземпляров в использовании",
"Udp black ports:":"Запрещенные UPD-порты:",
"Udp firewall mode:":"UPD режим брандмауэра:",
"Udp white ports:":"Разрешенные UPD-порты:",
"Unpublish":"Отменить статус «Открытый»",
"Update a template":"Обновить шаблон",
"Update template":"Обновить шаблон",
"Update":"Обновить",
"Use":"Использовать",
"Used CPU (allocated)":"Использовано ОЗУ(реально)",
"Used CPU (real)":"Использовано ЦП(реально)",
"Used CPU":"Используется ЦП",
"Used Mem (allocated)":"Использовано ОЗУ(выделено)",
"Used Mem (real)":"Использовано ОЗУ(реально)",
"Used Memory":"Используется памяти",
"Useful for power management, for example, normally required for graceful shutdown to work":"Требуется для корректного завершения работы ВМ средствами системы виртуализации",
"User chgrp":"Изменение группы",
"User create":"Пользователь создан",
"User delete":"Пользователь удален",
"User name and password must be filled in":"Необходимо указать и имя пользователя, и пароль",
"User":"Пользователь",
"Username:":"Имя пользователя:",
"Users":"Пользователи",
"VCPU":"Кол-во вирт. ЦП",
"VCPU:":"Кол-во вирт. ЦП:",
"VID":"№ ВМ",
"VM Instance":"Экземпляр ВМ",
"VM Instances (":"Экземпляры ВМ (",
"VM MAD":"Модуль ср-ва виртуализации",
"VM Name:":"Название ВМ:",
"VM Network stats":"Статистика виртуальных сетей",
"VM Save As":"ВМ сохранить как",
"VM Template":"Шаблон ВМ",
"VM Templates (total/public)":"Шаблоны ВМ (всего/из них открытых)",
"VM Templates":"Шаблоны ВМ",
"VM information":"Информация о ВМ",
"VM log":"Журнал ВМ",
"VM template":"Шаблон ВМ",
"VM":"ВМ",
"VMID":"№ ВМ",
"VNC Access":"Доступ по VNC",
"VNC Disabled":"VNC недоступно",
"VNC Session":"VNC сессия",
"VNC connection":"VNC соединение",
"VNC":"VNC",
"Value of the context variable":"Значение контекстной переменной",
"Value of the custom variable":"Значение пользовательской перменной",
"Value:":"Значение:",
"Virtio (KVM)":"Virtio (KVM)",
"Virtio":"Virtio",
"Virtual Machine information":"Информация о виртуальной машине",
"Virtual Machines":"Вирт. машины",
"Virtual Network name missing!":"Отсутствует название виртуальной сети!",
"Virtual Network template":"Шаблон виртуальной сети",
"Virtual Networks (total/public)":"Виртуальные сети (всего/из них открытых)",
"Virtual Networks":"Вирт. сети",
"Virtual Network":"Виртуальная сеть",
"Virtual Network information":"Информация о виртуальной сети",
"Virtual network information":"Информация о виртуальной сети",
"Virtual network template":"Шаблон виртуальной сети",
"Virtualization Manager:":"Средство виртуализации:",
"Wizard KVM":"Шаблон KVM",
"Wizard VMware":"Шаблон VMware",
"Wizard XEN":"Шаблон XEN",
"Wizard":"Мастер настройки",
"Write the Virtual Machine template here":"Отредактируйте параметры шаблона ВМ вручную",
"Write the Virtual Network template here":"Отредактируйте параметры шаблона вирт. сети вручную",
"Write the image template here":"Отредактируйте параметры шаблона образа ВМ вручную",
"XEN":"XEN",
"Xen templates must specify a boot method":"В шаблон Xen необходимо указывать метод загрузки",
"YES":"да",
"Yes":"Да",
"You have not selected a template":"Вы не выбрали шаблон",
"You have to confirm this action.":"Необходимо подтвердить данную операцию.",
"You need to select something.":"Вы должны что-нибудь выбрать.",
"active":"активных",
"are mandatory":"обязательные",
"cdrom":"cdrom",
"cpu_usage":"использование",
"disk id :":"диск №: ",
"error":"ошибок",
"failed":"дефектных",
"fd":"fd",
"hd":"hd",
"id":"№",
"max_cpu":"максимально",
"max_mem":"максимально",
"mem_usage":"использование",
"net_rx":"принято",
"net_tx":"отправлено",
"network":"network",
"no":"никак нет",
"running":"запущенных",
"total":"всего",
"used_cpu":"использовано",
"used_mem":"использовано",
"yes":"да"
};
@@ -0,0 +1,17 @@
{
"sProcessing": "Ждите. Выполняется обработка...",
"sLengthMenu": "Показывать _MENU_ элементов списка",
"sZeroRecords": "Список пуст",
"sInfo": "Показаны элементы списка с _START_ по _END_ из _TOTAL_",
"sInfoEmpty": "Список пуст",
"sInfoFiltered": "(отфильтровано из _MAX_ элементов списка)",
"sInfoPostFix": "",
"sSearch": "Поиск:",
"sUrl": "",
"oPaginate": {
"sFirst": "Первая",
"sPrevious": "Предыдущая",
"sNext": "Следующая",
"sLast": "Последняя"
}
}
+1 -1
View File
@@ -2,5 +2,5 @@ THIRD-PARTY SOFTWARE
* Author: Allan Jardine (www.sprymedia.co.uk)
* Info: www.datatables.net
* Copyright: Copyright 2008-2010 Allan Jardine, all rights reserved.
* Copyright: Copyright 2008-2012 Allan Jardine, all rights reserved.
* License: BSD License. See BSD-LICENSE.txt
+13 -5
View File
@@ -44,7 +44,7 @@
* cursor: hand;
}
.ui-buttonset .ui-button {
.dataTables_paginate .ui-button {
margin-right: -0.1em !important;
}
@@ -52,7 +52,7 @@
width: 350px !important;
}
.ui-toolbar {
.dataTables_wrapper .ui-toolbar {
padding: 5px;
}
@@ -209,15 +209,23 @@ table.display td.center {
*/
.sorting_asc {
background: url('../images/sort_asc.jpg') no-repeat center right;
background: url('../images/sort_asc.png') no-repeat center right;
}
.sorting_desc {
background: url('../images/sort_desc.jpg') no-repeat center right;
background: url('../images/sort_desc.png') no-repeat center right;
}
.sorting {
background: url('../images/sort_both.jpg') no-repeat center right;
background: url('../images/sort_both.png') no-repeat center right;
}
.sorting_asc_disabled {
background: url('../images/sort_asc_disabled.png') no-repeat center right;
}
.sorting_desc_disabled {
background: url('../images/sort_desc_disabled.png') no-repeat center right;
}
Loaded 100 of 252 files, more files were not shown because too many files have changed in this diff. Show more