Commit d7347ab3 authored by Vangelis Koukis's avatar Vangelis Koukis
Browse files

Add README.DB, minor fixes to fixtures

Add new file README.DB with instructions for PostgreSQL and MySQL setups.
Modify fixtures to include definition of Images in definition of VMs
(vms.json), ensuring referential integrity.
parent 36c9ba32
......@@ -35,13 +35,4 @@ Notes
sudo aptitude install uuid-dev
./bin/pip install pyzmq-static
4) Database initialization: [the following commands assume the DB is at "./database.sqlite"]
recreate db, load db/fixtures/initial_data.json:
$ rm database.sqlite
$ bin/python manage.py syncdb
load fixtures, as necessary [take a look under db/fixtures/]:
$ bin/python manage.py loaddata db/fixtures/flavors.json
$ bin/python manage.py loaddata db/fixtures/vms.json
...
4) Also see README.DB, which describes setting up a DB with various backends.
*** SQLite
Django configuration in ettings.py:
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
DATABASES = {
'default': {
'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
# ATTENTION: This *must* be the absolute path if using sqlite3.
# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
'NAME': PROJECT_PATH + 'database.sqlite', # Or path to database file if using sqlite3.
}
}
Database initialization:
[the following commands assume the DB is at "./database.sqlite"]
recreate db, load db/fixtures/initial_data.json:
$ rm database.sqlite
$ bin/python manage.py syncdb
load fixtures, as necessary [take a look under db/fixtures/]:
$ bin/python manage.py loaddata db/fixtures/flavors.json
$ bin/python manage.py loaddata db/fixtures/vms.json
...
*** MySQL
Django configuration in settings.py:
DATABASES = {
'default': {
'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
# ATTENTION: This *must* be the absolute path if using sqlite3.
# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
'NAME': 'synnefo', # Or path to database file if using sqlite3.
'USER': 'USERNAME', # Not used with sqlite3.
'PASSWORD': 'PASSWORD', # Not used with sqlite3.
'HOST': 'HOST', # Set to empty string for localhost. Not used with sqlite3.
'PORT': 'PORT', # Set to empty string for default. Not used with sqlite3.
# Have MySQL use InnoDB as the storage engine for newly created tables
'OPTIONS': {
'init_command': 'SET storage_engine=INNODB',
}
}
}
Server setup [not necessary for client operation]:
a) Install MySQL server, set password for user 'root'
b) Modify /etc/mysql/my.cnf to bind on public IP if you want to allow
allow connections from foreign hosts.
c) Create database:
$ mysql -u root -p
mysql> create database synnefo;
mysql> show databases;
mysql> GRANT ALL on synnefo.* TO username IDENTIFIED BY 'password';
Client setup:
d) Install the MySQL client
# apt-get install libmysqlclient-dev
$ bin/pip install MySQL-python
libmysqlclient-dev provides mysql_config, otherwise installing MySQL-python fails with:
EnvironmentError: mysql_config not found
*** PostgreSQL
Django configuration in settings.py:
DATABASES = {
'default': {
'ENGINE': 'postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
# ATTENTION: This *must* be the absolute path if using sqlite3.
# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
'NAME': 'DATABASE', # Or path to database file if using sqlite3.
'USER': 'USERNAME', # Not used with sqlite3.
'PASSWORD': 'PASSWORD', # Not used with sqlite3.
'HOST': 'HOST', # Set to empty string for localhost. Not used with sqlite3.
'PORT': 'PORT', # Set to empty string for default. Not used with sqlite3.
}
}
Client setup:
# apt-get install postgresql-client-8.4
attempt a connection:
$ psql -h HOST -p PORT -U USERNAME
# apt-get install libpq-dev
$ bin/pip install psycopg2
[
{
"model": "db.Image",
"pk": 1,
"fields": {
"name": "Debian Squeeze",
"created": "2011-02-06 00:00:00",
"updated": "2011-02-06 00:00:00",
"state": "ACTIVE",
"description": "Full Debian Squeeze Installation",
"size": 5678
}
},
{
"model": "db.Image",
"pk": 2,
"fields": {
"name": "Slackware 13.1",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"state": "ACTIVE",
"description": "Full Slackware 13.1 Installation",
"size": 1234,
"owner" : 1,
"sourcevm": 1001
}
}
]
[
{
"model": "db.Image",
"pk": 1,
"fields": {
"name": "Debian Squeeze",
"created": "2011-02-06 00:00:00",
"updated": "2011-02-06 00:00:00",
"state": "ACTIVE",
"description": "Full Debian Squeeze Installation",
"size": 5678
}
},
{
"model": "db.VirtualMachine",
"pk": 1001,
......@@ -75,5 +87,19 @@
"meta_value": "debian",
"vm": 1001
}
},
{
"model": "db.Image",
"pk": 2,
"fields": {
"name": "Slackware 13.1",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"state": "ACTIVE",
"description": "Full Slackware 13.1 Installation",
"size": 1234,
"owner" : 1,
"sourcevm": 1001
}
}
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment