source: trunk/packages/invirt-database-server/invirt-database-tables @ 2069

Last change on this file since 2069 was 2054, checked in by broder, 16 years ago

Conditionalize populating the types table in invirt-database-tables
based on whether the types are in the database already

  • Property svn:executable set to *
File size: 843 bytes
RevLine 
[77]1#!/usr/bin/env python
2
[836]3from invirt import database
[77]4import sys
5
6def usage():
7    print >>sys.stderr, "Usage: %s [create|drop]" %(sys.argv[0],)
8    sys.exit(-1)
9
10if len(sys.argv) == 1:
11    usage()
12
[2053]13def create():
14    database.meta.create_all()
15    session = database.session()
16    session.begin()
[2054]17    if not database.Type.query.get('linux-hvm'):
18        session.save(database.Type(type_id='linux-hvm', description='HVM',
19                                   hvm='t', apic='t', acpi='t', pae='t'))
20    if not database.Type.query.get('linux'):
21        session.save(database.Type(type_id='linux', description='ParaVM',
22                                   hvm='f', apic='f', acpi='f', pae='f'))
[2053]23    session.commit()
24
[836]25database.connect()
[77]26
27if sys.argv[1] == "create":
[2053]28    create()
[241]29elif sys.argv[1] == "drop":
[836]30    database.meta.drop_all()
[77]31else:
[241]32    usage()
Note: See TracBrowser for help on using the repository browser.