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

Migrator for ozones v3.4 -> v3.6

This commit is contained in:
Tino Vazquez 2012-06-08 15:33:25 +02:00
parent a1d33714c3
commit b66f1d4564
2 changed files with 55 additions and 0 deletions

View File

@ -588,6 +588,7 @@ BIN_FILES="src/nebula/oned \
src/cli/onedatastore \
src/cli/onecluster \
src/onedb/onedb \
src/onedb/onezonedb/onezonedb \
src/authm_mad/remotes/quota/onequota \
src/mad/utils/tty_expect \
share/scripts/one"

54
src/onedb/onezonedb/onezonedb Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
if [ "$1" != "sqlite" -a "$1" != "mysql" -a "$1" != "postgres" ]; then
echo "$0: The first command needs to be one of {sqlite, mysql}"
exit 1
fi
MIGRATE_CMDS=$(cat <<EOF
drop table zones;
create table zones as select id as ID, name as NAME, onename as ONENAME, onepass as ONEPASS, endpoint as ENDPOI$
drop table o_zones_zones;
drop table vdcs;
create table vdcs as select id as ID, name as NAME, group_id as GROUP_ID, vdcadminname as VDCADMINNAME, vdcadmi$
drop table o_zones_vdcs;
EOF
)
if [ "$1" == "sqlite" ]; then
if [ ! -f $2 ]; then
echo "$0: A valid sqlite DB file needs to be provided as second argument"
exit 1
fi
sqlite3 $2 < <(echo $MIGRATE_CMDS)
fi
if [ "$1" == "mysql" ]; then
if [ -z $2 -a -z $3 ]; then
echo "$0: A valid username and password for mysql server needs to be provided"
echo "Usage: $0 username password <mysql_server_location>"
echo " where <mysql_server_location> is optional and defaults to localhost"
exit 1
fi
if [ -z $4 ]; then
MYSQL_SERVER="localhost"
else
MYSQL_SERVER=$4
fi
mysql -u $2 --password=$3 -h $MYSQL_SERVER ozones < <(echo $MIGRATE_CMDS)
fi
if [ $? -ne 0 ]; then
echo "There was an error during migration"
else
echo "Migration successful"
fi