Commit 15ef1567 authored by Vangelis Koukis's avatar Vangelis Koukis
Browse files

Split initial_data.json, minor fixes in models.py.

Split initial_data.json into different fixtures, one for each model.
Fixtures can be loaded as needed using the loaddata command.
See the README for all the details.

Add a complete set of instances for the Flavor model.
Add a uniqueness constraint for the Flavor model.
parent f828cbe6
......@@ -31,7 +31,17 @@ Notes
to
ctype = self.request.META.get('CONTENT_TYPE', type_formencoded).split(";")[0]
3)On Ubuntu 10.04 (tested by mgogoulos) you'll have to install zmq-static with:
3) On Ubuntu 10.04 (tested by mgogoulos) you'll have to install zmq-static with:
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
...
[
{
"model": "db.Disk",
"pk": 1,
"fields": {
"name": "My_Music",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"size" : "20",
"vm" : "1001",
"owner" : "1"
}
},
{
"model": "db.Disk",
"pk": 2,
"fields": {
"name": "My_Videos",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"size" : "300",
"vm" : "1001",
"owner" : "1"
}
}
]
[
{
"model": "db.Flavor",
"pk": 1,
"fields": {
"cpu": 1,
"ram": 1024,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 2,
"fields": {
"cpu": 1,
"ram": 1024,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 3,
"fields": {
"cpu": 1,
"ram": 1024,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 4,
"fields": {
"cpu": 1,
"ram": 2048,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 5,
"fields": {
"cpu": 1,
"ram": 2048,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 6,
"fields": {
"cpu": 1,
"ram": 2048,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 7,
"fields": {
"cpu": 1,
"ram": 4096,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 8,
"fields": {
"cpu": 1,
"ram": 4096,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 9,
"fields": {
"cpu": 1,
"ram": 4096,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 10,
"fields": {
"cpu": 2,
"ram": 1024,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 11,
"fields": {
"cpu": 2,
"ram": 1024,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 12,
"fields": {
"cpu": 2,
"ram": 1024,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 13,
"fields": {
"cpu": 2,
"ram": 2048,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 14,
"fields": {
"cpu": 2,
"ram": 2048,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 15,
"fields": {
"cpu": 2,
"ram": 2048,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 16,
"fields": {
"cpu": 2,
"ram": 4096,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 17,
"fields": {
"cpu": 2,
"ram": 4096,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 18,
"fields": {
"cpu": 2,
"ram": 4096,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 19,
"fields": {
"cpu": 4,
"ram": 1024,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 20,
"fields": {
"cpu": 4,
"ram": 1024,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 21,
"fields": {
"cpu": 4,
"ram": 1024,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 22,
"fields": {
"cpu": 4,
"ram": 2048,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 23,
"fields": {
"cpu": 4,
"ram": 2048,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 24,
"fields": {
"cpu": 4,
"ram": 2048,
"disk": 80
}
},
{
"model": "db.Flavor",
"pk": 25,
"fields": {
"cpu": 4,
"ram": 4096,
"disk": 20
}
},
{
"model": "db.Flavor",
"pk": 26,
"fields": {
"cpu": 4,
"ram": 4096,
"disk": 40
}
},
{
"model": "db.Flavor",
"pk": 27,
"fields": {
"cpu": 4,
"ram": 4096,
"disk": 80
}
}
]
[
{
"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"
}
},
{
"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",
"owner" : 1
}
}
]
......@@ -11,138 +11,5 @@
"user" : 1,
"violations" : 0
}
},
{
"model": "db.Flavor",
"pk": 1,
"fields": {
"cpu": 1,
"ram": 1024,
"disk": 10
}
},
{
"model": "db.Flavor",
"pk": 2,
"fields": {
"cpu": 1,
"ram": 1024,
"disk": 10
}
},
{
"model": "db.VirtualMachine",
"pk": 1001,
"fields": {
"name": "snf-1001",
"created": "2011-02-06 00:00:00",
"updated": "2011-02-06 00:00:00",
"charged": "2011-02-06 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "database server",
"ipfour": "192.168.2.1",
"ipsix": "::1",
"flavor": 1,
"_operstate": "STOPPED"
}
},
{
"model": "db.VirtualMachine",
"pk": 1002,
"fields": {
"name": "snf-1002",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"charged": "2011-02-10 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "mail server",
"ipfour": "192.168.2.2",
"ipsix": "::2",
"flavor": 1,
"_operstate": "BUILD"
}
},
{
"model": "db.VirtualMachine",
"pk": 1003,
"fields": {
"name": "snf-1003",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"charged": "2011-02-10 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "my server",
"ipfour": "192.168.2.3",
"ipsix": "::3",
"flavor": 1,
"_operstate": "STARTED"
}
},
{
"model": "db.VirtualMachine",
"pk": 1004,
"fields": {
"name": "snf-1004",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"charged": "2011-02-10 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "my 2nd server",
"ipfour": "192.168.2.4",
"ipsix": "::4",
"flavor": 1,
"_operstate": "STARTED"
}
},
{
"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"
}
},
{
"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",
"owner" : 1
}
},
{
"model": "db.Disk",
"pk": 1,
"fields": {
"name": "My_Music",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"size" : "20",
"vm" : "1001",
"owner" : "1"
}
},
{
"model": "db.Disk",
"pk": 2,
"fields": {
"name": "My_Videos",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"size" : "300",
"vm" : "1001",
"owner" : "1"
}
}
}
]
[
{
"model": "db.VirtualMachine",
"pk": 1001,
"fields": {
"name": "snf-1001",
"created": "2011-02-06 00:00:00",
"updated": "2011-02-06 00:00:00",
"charged": "2011-02-06 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "database server",
"ipfour": "192.168.2.1",
"ipsix": "::1",
"flavor": 1,
"_operstate": "STOPPED"
}
},
{
"model": "db.VirtualMachine",
"pk": 1002,
"fields": {
"name": "snf-1002",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"charged": "2011-02-10 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "mail server",
"ipfour": "192.168.2.2",
"ipsix": "::2",
"flavor": 1,
"_operstate": "BUILD"
}
},
{
"model": "db.VirtualMachine",
"pk": 1003,
"fields": {
"name": "snf-1003",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"charged": "2011-02-10 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "my server",
"ipfour": "192.168.2.3",
"ipsix": "::3",
"flavor": 1,
"_operstate": "STARTED"
}
},
{
"model": "db.VirtualMachine",
"pk": 1004,
"fields": {
"name": "snf-1004",
"created": "2011-02-10 00:00:00",
"updated": "2011-02-10 00:00:00",
"charged": "2011-02-10 00:00:00",
"sourceimage": 1,
"hostid": "HAL-9000",
"description": "my 2nd server",
"ipfour": "192.168.2.4",
"ipsix": "::4",
"flavor": 1,
"_operstate": "STARTED"
}
}
]
......@@ -134,6 +134,7 @@ class Flavor(models.Model):
class Meta:
verbose_name = u'Virtual machine flavor'
unique_together = ("cpu","ram","disk")
def _get_name(self):
"""Returns flavor name (generated)"""
......
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