forked from uncloud/uncloud
add hack code
This commit is contained in:
parent
12e8ccd01c
commit
b877ab13b3
2 changed files with 23 additions and 6 deletions
|
|
@ -48,7 +48,9 @@ class MAC(object):
|
|||
def last_used_index(self):
|
||||
value = self.db.get("last_used_index")
|
||||
if not value:
|
||||
return 0
|
||||
self.db.set("last_used_index", "0")
|
||||
value = self.db.get("last_used_index")
|
||||
|
||||
return int(value)
|
||||
|
||||
def last_used_mac(self):
|
||||
|
|
@ -62,7 +64,7 @@ class MAC(object):
|
|||
def get_next(self, vmuuid=None, as_int=False):
|
||||
last_number = self.last_used_index()
|
||||
|
||||
# FIXME: compare to 48bit minus prefix length
|
||||
# FIXME: compare to 48bit minus prefix length to the power of 2
|
||||
if last_number == int('0xffffff', 16):
|
||||
raise UncloudException("Exhausted all possible mac addresses - try to free some")
|
||||
|
||||
|
|
@ -77,6 +79,8 @@ class MAC(object):
|
|||
db_entry['index'] = next_number
|
||||
db_entry['mac_address'] = next_mac
|
||||
|
||||
# should be one transaction
|
||||
self.db.increment("last_used_index")
|
||||
self.db.set("used/{}".format(next_mac),
|
||||
db_entry, as_json=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue