Commit f824ae42 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno

Allow "default" as a value for ipolicy templates

Previously the string value was being corrupted.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent d307d38c
......@@ -3812,7 +3812,10 @@ def CreateIPolicyFromOpts(ispecs_mem_size=None,
group_ipolicy, allowed_values)
if ipolicy_disk_templates is not None:
ipolicy_out[constants.IPOLICY_DTS] = list(ipolicy_disk_templates)
if allowed_values and ipolicy_disk_templates in allowed_values:
ipolicy_out[constants.IPOLICY_DTS] = ipolicy_disk_templates
else:
ipolicy_out[constants.IPOLICY_DTS] = list(ipolicy_disk_templates)
if ipolicy_vcpu_ratio is not None:
ipolicy_out[constants.IPOLICY_VCPU_RATIO] = ipolicy_vcpu_ratio
if ipolicy_spindle_ratio is not None:
......
......@@ -1260,15 +1260,18 @@ class TestCreateIPolicyFromOpts(unittest.TestCase):
},
constants.ISPECS_STD: {
},
constants.IPOLICY_DTS: allowedv,
constants.IPOLICY_VCPU_RATIO: allowedv,
constants.IPOLICY_SPINDLE_RATIO: allowedv,
}
pol1 = cli.CreateIPolicyFromOpts(ispecs_mem_size={},
ispecs_cpu_count={"min": allowedv},
ispecs_disk_count={},
ispecs_disk_size={},
ispecs_nic_count={},
ipolicy_disk_templates=None,
ipolicy_vcpu_ratio=None,
ipolicy_spindle_ratio=None,
ipolicy_disk_templates=allowedv,
ipolicy_vcpu_ratio=allowedv,
ipolicy_spindle_ratio=allowedv,
allowed_values=[allowedv])
self.assertEqual(pol1, exp_pol1)
......
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