Commit 7e39b007 authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Add the old DRBD secrets reservation code to mocked config

.. so that the unit tests work without the presence of WConfd.

Also fix mocked GenerateMAC, which used _temporary_ids by mistake in the
original ConfigWriter.
Signed-off-by: default avatarPetr Pudlak <>
Reviewed-by: default avatarKlaus Aehlig <>
parent c02daabd
......@@ -31,6 +31,7 @@ from ganeti import constants
from ganeti import errors
from ganeti import objects
from import AddressPool
from ganeti import utils
import mocks
......@@ -57,6 +58,7 @@ class ConfigMock(config.ConfigWriter):
self._mocked_config_store = None
self._temporary_macs = config.TemporaryReservationManager()
self._temporary_secrets = config.TemporaryReservationManager()
super(ConfigMock, self).__init__(cfg_file="/dev/null",
......@@ -667,7 +669,7 @@ class ConfigMock(config.ConfigWriter):
existing = self._AllMACs()
prefix = self._UnlockedGetNetworkMACPrefix(net_uuid)
gen_mac = self._GenerateOneMAC(prefix)
return self._temporary_ids.Generate(existing, gen_mac, ec_id)
return self._temporary_macs.Generate(existing, gen_mac, ec_id)
def ReserveMAC(self, mac, ec_id):
"""Reserve a MAC for an instance.
......@@ -681,3 +683,13 @@ class ConfigMock(config.ConfigWriter):
raise errors.ReservationError("mac already in use")
self._temporary_macs.Reserve(ec_id, mac)
def GenerateDRBDSecret(self, ec_id):
"""Generate a DRBD secret.
This checks the current disks for duplicates.
return self._temporary_secrets.Generate(self._AllDRBDSecrets(),
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