diff --git a/src/onedb/1.rb b/src/onedb/1.rb
index 86c07f0c04..43260e22b3 100644
--- a/src/onedb/1.rb
+++ b/src/onedb/1.rb
@@ -46,14 +46,16 @@ module Migrator
if( oid == 0 )
gid = 0
+ groupname = "oneadmin"
else
gid = 1
+ groupname = "users"
user_group_ids += "#{oid}"
end
name = row[:user_name]
- body = "#{oid}#{gid}#{name}#{row[:password]}#{row[:enabled]}#{gid}"
+ body = "#{oid}#{gid}#{groupname}#{name}#{row[:password]}#{row[:enabled]}"
@db.run "INSERT INTO user_pool VALUES(#{oid},'#{name}','#{body}');"
end
@@ -131,11 +133,12 @@ module Migrator
name = row[:name]
uid = row[:uid]
gid = (uid == 0) ? 0 : 1
+ group = (uid == 0) ? "oneadmin" : "users"
public = row[:public]
# In OpenNebula 2.0 Image States go from 0 to 3, in 3.0 go
# from 0 to 5, but the meaning is the same for states 0 to 3
- body = "#{oid}#{row[:uid]}#{gid}#{name}#{row[:type]}#{public}#{row[:persistent]}#{row[:regtime]}#{row[:source]}#{row[:state]}#{row[:running_vms]}#{row[:template]}"
+ body = "#{oid}#{row[:uid]}#{gid}#{get_username(row[:uid])}#{group}#{name}#{row[:type]}#{public}#{row[:persistent]}#{row[:regtime]}#{row[:source]}#{row[:state]}#{row[:running_vms]}#{row[:template]}"
@db.run "INSERT INTO image_pool VALUES(#{oid},'#{name}','#{body}', #{uid}, #{gid}, #{public});"
end
@@ -177,6 +180,7 @@ module Migrator
name = row[:name]
uid = row[:uid]
gid = (uid == 0) ? 0 : 1
+ group = (uid == 0) ? "oneadmin" : "users"
last_poll = row[:last_poll]
state = row[:state]
lcm_state = row[:lcm_state]
@@ -187,7 +191,11 @@ module Migrator
history = history_row[:body]
end
- body = "#{oid}#{uid}#{gid}#{name}#{last_poll}#{state}#{lcm_state}#{row[:stime]}#{row[:etime]}#{row[:deploy_id]}#{row[:memory]}#{row[:cpu]}#{row[:net_tx]}#{row[:net_rx]}#{row[:template]}#{history}"
+ if ( history != "" )
+ history = "#{history}"
+ end
+
+ body = "#{oid}#{uid}#{gid}#{get_username(uid)}#{group}#{name}#{last_poll}#{state}#{lcm_state}#{row[:stime]}#{row[:etime]}#{row[:deploy_id]}#{row[:memory]}#{row[:cpu]}#{row[:net_tx]}#{row[:net_rx]}#{row[:template]}#{history}"
@db[:vm_pool].insert(
:oid => oid,
@@ -228,12 +236,13 @@ module Migrator
name = row[:name]
uid = row[:uid]
gid = (uid == 0) ? 0 : 1
+ group = (uid == 0) ? "oneadmin" : "users"
public = row[:public]
# is stored in the DB, but it is not used to rebuild
# the VirtualNetwork object, and it is generated each time the
# network is listed. So setting it to 0 is safe
- body = "#{oid}#{uid}#{gid}#{name}#{row[:type]}#{row[:bridge]}#{public}0#{row[:template]}"
+ body = "#{oid}#{uid}#{gid}#{get_username(uid)}#{group}#{name}#{row[:type]}#{row[:bridge]}#{public}0#{row[:template]}"
@db.run "INSERT INTO network_pool VALUES(#{oid},'#{name}','#{body}', #{uid}, #{gid}, #{public});"
end
@@ -259,11 +268,12 @@ module Migrator
@db.run "CREATE TABLE db_versioning (oid INTEGER PRIMARY KEY, version INTEGER, timestamp INTEGER, comment VARCHAR(256));"
@db.run "CREATE TABLE template_pool (oid INTEGER PRIMARY KEY, name VARCHAR(256), body TEXT, uid INTEGER, gid INTEGER, public INTEGER);"
+ @db.run "CREATE TABLE acl (oid INT PRIMARY KEY, user BIGINT, resource BIGINT, rights BIGINT);"
# The group pool has two default ones
@db.run "CREATE TABLE group_pool (oid INTEGER PRIMARY KEY, name VARCHAR(256), body TEXT, UNIQUE(name));"
- @db.run "INSERT INTO group_pool VALUES(0,'oneadmin','00oneadmin0');"
- @db.run "INSERT INTO group_pool VALUES(1,'users','10users#{user_group_ids}');"
+ @db.run "INSERT INTO group_pool VALUES(0,'oneadmin','0oneadmin0');"
+ @db.run "INSERT INTO group_pool VALUES(1,'users','1users#{user_group_ids}');"
# New pool_control table contains the last_oid used, must be rebuilt
@db.run "CREATE TABLE pool_control (tablename VARCHAR(32) PRIMARY KEY, last_oid BIGINT UNSIGNED)"
@@ -282,4 +292,14 @@ module Migrator
return true
end
+
+ def get_username(uid)
+ username = ""
+
+ @db.fetch("SELECT name FROM user_pool WHERE oid=#{uid}") do |user|
+ username = user[:name]
+ end
+
+ return username
+ end
end