Commit 976b78ba authored by Iustin Pop's avatar Iustin Pop
Browse files

Add ipolicy_vcpu_ratio to command line



This allows changing this value from the command line.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent ff6c5e55
......@@ -173,6 +173,7 @@ __all__ = [
"SPECS_MEM_SIZE_OPT",
"SPECS_NIC_COUNT_OPT",
"IPOLICY_DISK_TEMPLATES",
"IPOLICY_VCPU_RATIO",
"SPICE_CACERT_OPT",
"SPICE_CERT_OPT",
"SRC_DIR_OPT",
......@@ -811,6 +812,11 @@ IPOLICY_DISK_TEMPLATES = cli_option("--ipolicy-disk-templates",
help="Comma-separated list of"
" enabled disk templates")
IPOLICY_VCPU_RATIO = cli_option("--ipolicy-vcpu-ratio",
dest="ipolicy_vcpu_ratio",
type="float", default=None,
help="The maximum allowed vcpu-to-cpu ratio")
HYPERVISOR_OPT = cli_option("-H", "--hypervisor-parameters", dest="hypervisor",
help="Hypervisor and hypervisor options, in the"
" format hypervisor:option=value,option=value,...",
......@@ -1402,6 +1408,7 @@ INSTANCE_POLICY_OPTS = [
SPECS_MEM_SIZE_OPT,
SPECS_NIC_COUNT_OPT,
IPOLICY_DISK_TEMPLATES,
IPOLICY_VCPU_RATIO,
]
......
......@@ -143,15 +143,15 @@ def InitCluster(opts, args):
utils.ForceDictType(diskparams[templ], constants.DISK_DT_TYPES)
# prepare ipolicy dict
ispecs_dts = opts.ipolicy_disk_templates # hate long var names
ipolicy_raw = \
objects.CreateIPolicyFromOpts(ispecs_mem_size=opts.ispecs_mem_size,
ispecs_cpu_count=opts.ispecs_cpu_count,
ispecs_disk_count=opts.ispecs_disk_count,
ispecs_disk_size=opts.ispecs_disk_size,
ispecs_nic_count=opts.ispecs_nic_count,
ipolicy_disk_templates=ispecs_dts,
fill_all=True)
ipolicy_raw = objects.CreateIPolicyFromOpts(
ispecs_mem_size=opts.ispecs_mem_size,
ispecs_cpu_count=opts.ispecs_cpu_count,
ispecs_disk_count=opts.ispecs_disk_count,
ispecs_disk_size=opts.ispecs_disk_size,
ispecs_nic_count=opts.ispecs_nic_count,
ipolicy_disk_templates=opts.ipolicy_disk_templates,
ipolicy_vcpu_ratio=opts.ipolicy_vcpu_ratio,
fill_all=True)
ipolicy = objects.FillIPolicy(constants.IPOLICY_DEFAULTS, ipolicy_raw)
if opts.candidate_pool_size is None:
......@@ -997,14 +997,15 @@ def SetClusterParams(opts, args):
if ndparams is not None:
utils.ForceDictType(ndparams, constants.NDS_PARAMETER_TYPES)
ispecs_dts = opts.ipolicy_disk_templates
ipolicy = \
objects.CreateIPolicyFromOpts(ispecs_mem_size=opts.ispecs_mem_size,
ispecs_cpu_count=opts.ispecs_cpu_count,
ispecs_disk_count=opts.ispecs_disk_count,
ispecs_disk_size=opts.ispecs_disk_size,
ispecs_nic_count=opts.ispecs_nic_count,
ipolicy_disk_templates=ispecs_dts)
ipolicy = objects.CreateIPolicyFromOpts(
ispecs_mem_size=opts.ispecs_mem_size,
ispecs_cpu_count=opts.ispecs_cpu_count,
ispecs_disk_count=opts.ispecs_disk_count,
ispecs_disk_size=opts.ispecs_disk_size,
ispecs_nic_count=opts.ispecs_nic_count,
ipolicy_disk_templates=opts.ipolicy_disk_templates,
ipolicy_vcpu_ratio=opts.ipolicy_vcpu_ratio,
)
mnh = opts.maintain_node_health
......
......@@ -186,6 +186,7 @@ def CreateIPolicyFromOpts(ispecs_mem_size=None,
ispecs_disk_size=None,
ispecs_nic_count=None,
ipolicy_disk_templates=None,
ipolicy_vcpu_ratio=None,
group_ipolicy=False,
allowed_values=None,
fill_all=False):
......@@ -221,11 +222,17 @@ def CreateIPolicyFromOpts(ispecs_mem_size=None,
for key, val in specs.items(): # {min: .. ,max: .., std: ..}
ipolicy_out[key][name] = val
# no filldict for lists
if not group_ipolicy and fill_all and ipolicy_disk_templates is None:
ipolicy_disk_templates = constants.DISK_TEMPLATES
# no filldict for non-dicts
if not group_ipolicy and fill_all:
if ipolicy_disk_templates is None:
ipolicy_disk_templates = constants.DISK_TEMPLATES
if ipolicy_vcpu_ratio is None:
ipolicy_vcpu_ratio = \
constants.IPOLICY_DEFAULTS[constants.IPOLICY_VCPU_RATIO]
if ipolicy_disk_templates is not None:
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
assert not (frozenset(ipolicy_out.keys()) - constants.IPOLICY_ALL_KEYS)
......
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