vmtutil — Developer Interfaces¶
vmt-util provides additional functions when working with the Turbonomic API.
Classes¶
-
class
vmtutil.VMTSafeEval¶ A wrapper for
ast.NodeTransformer.VMTSafeEvalprovides extension toast.NodeTransformerfor the purpose of parsing custom domain specific languages required in client configurations. In practice this class should not be used directly.See also
Functions¶
-
vmtutil.evaluate(exp, local_map={})¶ Evaluates the expression
expand returns the results.Parameters: Returns: Expression result.
-
vmtutil.cpu_cast(value, unit='GHZ', factor=1000, src_unit='MZH', precision=False)¶ Converts values using the SI (1000) system of units.
cpu_castis a wrapper forunit_castand supports cpu speeds from Hertz (HZ) to Petahertz (PHZ). Source values are expected to be supplied as raw values from Turbonomic, which dfaults to MHZ. This behavior may be overridden using thesrc_unitargument.Parameters: - value – Base cpu unit value to convert.
- unit (str, optional) – Destination unit to convert to (default: GHZ)
- factor (optional) – Memory unit factor (default: 1024)
- src_unit (opitonal) – Source unit to convert from (default: MHZ)
- precision (int, optional) – rounding precision. If False no rounding is applied. (default: False)
Returns: Converted unit value.
-
vmtutil.mem_cast(value, unit='GB', factor=1024, src_unit='KB', precision=False)¶ Converts values using the binary (1024) system of units.
mem_castis a wrapper forunit_castand supports memory sizes from Bytes (B) to Yottabytes (YB). Source values are expected to be supplied as raw values from Turbonomic, which defaults to KB. This behavior may be overridden using thesrc_unitargument.Parameters: - value – Base memory unit value to convert.
- unit (str, optional) – Destination unit to convert to (default: GB)
- factor (optional) – Memory unit factor (default: 1024)
- src_unit (optional) – Source unit to convert from (default: KB)
- precision (int, optional) – rounding precision. If False no rounding is applied. (default: False)
Returns: Converted unit value.
Notes
This function may also be used for converting storage values. However, note that Turbonomic defaults to MB for storage values, instead of KB as it does with memory.
src_unitmust therefore be overridden to ‘MB’.
-
vmtutil.unit_cast(value, ufrom, uto, factor, unit_list, precision=False)¶ Generic unit conversion utility function.
Unit conversions must utilize a scale relative to a constant factor, such as the metric system, or base 2 numbering used in computing.
Parameters: - value – Unit value to be converted
- ufrom (str) – Scale unit converting from.
- uto (str) – Scale unit converting to.
- factor – Scale factor to use in calculating the change.
- unit_list (list) – The scale unit labels.
- precision (int, optional) – rounding precision. If False no rounding is applied. (default: False)
Returns: Converted unit value.