def _get_cpu_policy_constraints(flavor, image_meta):
 (flavor_policy, image_policy) = _get_flavor_image_meta('cpu_policy', flavor, image_meta)
 if (flavor_policy == fields.CPUAllocationPolicy.DEDICATED):
  cpu_policy = flavor_policy
 elif (flavor_policy == fields.CPUAllocationPolicy.SHARED):
  if (image_policy == fields.CPUAllocationPolicy.DEDICATED):
   raise exception.ImageCPUPinningForbidden()
  cpu_policy = flavor_policy
 elif (image_policy == fields.CPUAllocationPolicy.DEDICATED):
  cpu_policy = image_policy
 else:
  cpu_policy = fields.CPUAllocationPolicy.SHARED
 return cpu_policy

def _get_cpu_policy_constraints ( flavor , image_meta ) : ( flavor_policy , image_policy ) = _get_flavor_image_meta ( 'cpu_policy' , flavor , image_meta ) if ( flavor_policy == fields . CPUAllocationPolicy . DEDICATED ) : cpu_policy = flavor_policy elif ( flavor_policy == fields . CPUAllocationPolicy . SHARED ) : if ( image_policy == fields . CPUAllocationPolicy . DEDICATED ) : raise exception . ImageCPUPinningForbidden ( ) cpu_policy = flavor_policy elif ( image_policy == fields . CPUAllocationPolicy . DEDICATED ) : cpu_policy = image_policy else : cpu_policy = fields . CPUAllocationPolicy . SHARED return cpu_policy
validate and return the requested cpu policy .