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 <riba@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
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},
L{constants.ISPECS_STD}
@param category: Whether to change the default value, or the upper or lower
bound.
@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,
constants.ISPECS_STD]:
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(
version=constants.CONFIG_VERSION,
......
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