Ignore:
Timestamp:
May 2, 2009, 6:53:48 PM (15 years ago)
Author:
price
Message:

xen-ips: silently ignore already-present IPs

Also from the first hours of April. You all can imagine
how happy I was to be running this code. =)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-web/code/xen-ips

    r1318 r2322  
    22import random
    33from invirt import database
     4import sqlalchemy.exceptions
    45import sys
    56
     
    3839
    3940def addip(ip):
    40     n = database.NIC(machine=None, mac_addr=randomMAC(), ip=ip, hostname=None)
    41     database.session.save(n)
    42     database.session.flush()
     41    try:
     42        n = database.NIC(machine=None, mac_addr=randomMAC(), ip=ip, hostname=None)
     43        database.session.save(n)
     44        database.session.flush()
     45    except sqlalchemy.exceptions.IntegrityError:
     46        pass
    4347
    4448
Note: See TracChangeset for help on using the changeset viewer.