X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/blobdiff_plain/e37dd15bbf8683bab8454ea0eec8e9968ce982b2..e1fa27cf2da93f2a5bc18aa7a0c8169e4454368e:/code/xen-ips diff --git a/code/xen-ips b/code/xen-ips index 3a69a77..b0b8fed 100755 --- a/code/xen-ips +++ b/code/xen-ips @@ -1,6 +1,7 @@ #!/usr/bin/python import random -from sipb_xen_database import * +from invirt import database +import sqlalchemy.exceptions import sys # stolen directly from xend/server/netif.py @@ -37,9 +38,12 @@ def usage(): print >> sys.stderr, "USAGE: " + sys.argv[0] + " " def addip(ip): - n = NIC(machine_id=None, mac_addr=randomMAC(), ip=ip, hostname=None) - ctx.current.save(n) - ctx.current.flush() + try: + n = database.NIC(machine=None, mac_addr=randomMAC(), ip=ip, hostname=None) + database.session.save(n) + database.session.flush() + except sqlalchemy.exceptions.IntegrityError: + pass if __name__ == '__main__': @@ -48,5 +52,5 @@ if __name__ == '__main__': else: usage() sys.exit(1) - connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen') + database.connect() addip(ip)