Commit a3bea125 authored by Hrvoje Ribicic's avatar Hrvoje Ribicic
Browse files

Add support for ipolicy modifications to mock config

This patch adds a helper function making it easier to modify the
ipolicy within tests.
Signed-off-by: default avatarHrvoje Ribicic <>
Reviewed-by: default avatarHelga Velroyen <>
parent 8ba2f9eb
......@@ -545,6 +545,26 @@ class ConfigMock(config.ConfigWriter):
cluster.enabled_disk_templates = list(enabled_disk_templates)
cluster.ipolicy[constants.IPOLICY_DTS] = list(enabled_disk_templates)
def SetIPolicyField(self, category, field, value):
"""Set a value of a desired ipolicy field.
@type category: one of L{constants.ISPECS_MAX}, L{constants.ISPECS_MIN},
@param category: Whether to change the default value, or the upper or lower
@type field: string
@param field: The field to change.
@type value: any
@param value: The value to assign.
if category not in [constants.ISPECS_MAX, constants.ISPECS_MIN,
raise ValueError("Invalid ipolicy category %s" % category)
ipolicy_dict = self.GetClusterInfo().ipolicy[constants.ISPECS_MINMAX][0]
ipolicy_dict[category][field] = value
def _OpenConfig(self, accept_foreign):
self._config_data = objects.ConfigData(
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