#!/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
print >> sys.stderr, "USAGE: " + sys.argv[0] + " <ip>"
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__':
else:
usage()
sys.exit(1)
- connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen')
+ database.connect()
addip(ip)