+ if opts.disk_state:
+ disk_state = utils.FlatToDict(opts.disk_state)
+ else:
+ disk_state = {}
+
+ hv_state = dict(opts.hv_state)
+
+ diskparams = dict(opts.diskparams)
+
+ # set the default values
+ to_ipolicy = [
+ opts.ispecs_mem_size,
+ opts.ispecs_cpu_count,
+ opts.ispecs_disk_count,
+ opts.ispecs_disk_size,
+ opts.ispecs_nic_count,
+ ]
+ for ispec in to_ipolicy:
+ for param in ispec:
+ if isinstance(ispec[param], basestring):
+ if ispec[param].lower() == "default":
+ ispec[param] = constants.VALUE_DEFAULT
+ # create ipolicy object
+ 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,
+ group_ipolicy=True,
+ allowed_values=[constants.VALUE_DEFAULT])
+ for key in ipolicy.keys():
+ utils.ForceDictType(ipolicy[key], constants.ISPECS_PARAMETER_TYPES,
+ allowed_values=[constants.VALUE_DEFAULT])
+
+ op = opcodes.OpGroupSetParams(group_name=args[0],
+ ndparams=opts.ndparams,
+ alloc_policy=opts.alloc_policy,
+ hv_state=hv_state,
+ disk_state=disk_state,
+ diskparams=diskparams,
+ ipolicy=ipolicy)
+