summaryrefslogtreecommitdiffstats
path: root/cobbler/remote.py
diff options
context:
space:
mode:
Diffstat (limited to 'cobbler/remote.py')
-rw-r--r--cobbler/remote.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/cobbler/remote.py b/cobbler/remote.py
index c814a6e..f3fa070 100644
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -259,6 +259,27 @@ class CobblerXMLRPCInterface:
return self._fix_none(utils.blender(True, obj))
return self._fix_none({})
+ def get_random_mac(self):
+ """
+ Generate a random MAC address.
+ from xend/server/netif.py
+ Generate a random MAC address.
+ Uses OUI 00-16-3E, allocated to
+ Xensource, Inc. Last 3 fields are random.
+ return: MAC address string
+ """
+ self._refresh()
+ mac = [ 0x00, 0x16, 0x3e,
+ random.randint(0x00, 0x7f),
+ random.randint(0x00, 0xff),
+ random.randint(0x00, 0xff) ]
+ mac = ':'.join(map(lambda x: "%02x" % x, mac))
+ systems = self.api.systems()
+ while ( systems.find(mac=mac) ):
+ mac = self.random_mac()
+
+ return mac
+
def _fix_none(self,data):
"""
Convert None in XMLRPC to just '~'. The above