3 from sipb_xen_database import *
6 # stolen directly from xend/server/netif.py
8 """Generate a random MAC address.
10 Uses OUI (Organizationally Unique Identifier) 00-16-3E, allocated to
11 Xensource, Inc. The OUI list is available at
12 http://standards.ieee.org/regauth/oui/oui.txt.
14 The remaining 3 fields are random, with the first bit of the first
17 @return: MAC address string
19 mac = [ 0x00, 0x16, 0x3e,
20 random.randint(0x00, 0x7f),
21 random.randint(0x00, 0xff),
22 random.randint(0x00, 0xff) ]
23 return ':'.join(map(lambda x: "%02x" % x, mac))
25 # ... and stolen from xend/uuid.py
27 """Generate a random UUID."""
29 return [ random.randint(0, 255) for _ in range(0, 16) ]
32 return "-".join(["%02x" * 4, "%02x" * 2, "%02x" * 2, "%02x" * 2,
33 "%02x" * 6]) % tuple(u)
37 print >> sys.stderr, "USAGE: " + sys.argv[0] + " <ip>"
40 n = NIC(machine_id=None, mac_addr=randomMAC(), ip=ip, hostname=None)
45 if __name__ == '__main__':
46 if len(sys.argv) == 2:
51 connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen')