slapformat: Check if we allow bridge before trying extraordinary mesures to get address

parent 73935be5
...@@ -179,7 +179,7 @@ class Computer(object): ...@@ -179,7 +179,7 @@ class Computer(object):
def __getinitargs__(self): def __getinitargs__(self):
return (self.reference, self.interface) return (self.reference, self.interface)
def getAddress(self): def getAddress(self, no_bridge=False):
""" """
Return a list of the interface address not attributed to any partition, (which Return a list of the interface address not attributed to any partition, (which
are therefore free for the computer itself). are therefore free for the computer itself).
...@@ -201,11 +201,15 @@ class Computer(object): ...@@ -201,11 +201,15 @@ class Computer(object):
if address_dict['addr'] not in computer_partition_address_list: if address_dict['addr'] not in computer_partition_address_list:
return address_dict return address_dict
# all addresses on interface are for partition, so lets add new one if not no_bridge:
computer_tap = Tap('compdummy') # all addresses on interface are for partition, so lets add new one
computer_tap.createWithOwner(User('root'), attach_to_tap=True) computer_tap = Tap('compdummy')
self.interface.addTap(computer_tap) computer_tap.createWithOwner(User('root'), attach_to_tap=True)
return self.interface.addAddr() self.interface.addTap(computer_tap)
return self.interface.addAddr()
# Can't find address
return False
def send(self, config): def send(self, config):
""" """
...@@ -976,7 +980,7 @@ def run(config): ...@@ -976,7 +980,7 @@ def run(config):
computer.instance_root = config.instance_root computer.instance_root = config.instance_root
computer.software_root = config.software_root computer.software_root = config.software_root
config.logger.info('Updating computer') config.logger.info('Updating computer')
address = computer.getAddress() address = computer.getAddress(config.no_bridge)
computer.address = address['addr'] computer.address = address['addr']
computer.netmask = address['netmask'] computer.netmask = address['netmask']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment