Configures the host cache on the selected host. enabled Boolean flag specifying whether the host cache is enabled. datastore Name of the datastore that contains the host cache. Must be set if enabled is ``true``. swap_size_MiB Swap size in Mibibyte
(
enabled, datastore=None, swap_size_MiB=None, service_instance=None
)
| 7566 | @_gets_service_instance_via_proxy |
| 7567 | @_deprecation_message |
| 7568 | def configure_host_cache( |
| 7569 | enabled, datastore=None, swap_size_MiB=None, service_instance=None |
| 7570 | ): |
| 7571 | """ |
| 7572 | Configures the host cache on the selected host. |
| 7573 | |
| 7574 | enabled |
| 7575 | Boolean flag specifying whether the host cache is enabled. |
| 7576 | |
| 7577 | datastore |
| 7578 | Name of the datastore that contains the host cache. Must be set if |
| 7579 | enabled is ``true``. |
| 7580 | |
| 7581 | swap_size_MiB |
| 7582 | Swap size in Mibibytes. Needs to be set if enabled is ``true``. Must be |
| 7583 | smaller than the datastore size. |
| 7584 | |
| 7585 | service_instance |
| 7586 | Service instance (vim.ServiceInstance) of the vCenter/ESXi host. |
| 7587 | Default is None. |
| 7588 | |
| 7589 | CLI Example: |
| 7590 | |
| 7591 | .. code-block:: bash |
| 7592 | |
| 7593 | salt '*' vsphere.configure_host_cache enabled=False |
| 7594 | |
| 7595 | salt '*' vsphere.configure_host_cache enabled=True datastore=ds1 |
| 7596 | swap_size_MiB=1024 |
| 7597 | """ |
| 7598 | log.debug("Validating host cache input") |
| 7599 | schema = SimpleHostCacheSchema.serialize() |
| 7600 | try: |
| 7601 | jsonschema.validate( |
| 7602 | { |
| 7603 | "enabled": enabled, |
| 7604 | "datastore_name": datastore, |
| 7605 | "swap_size_MiB": swap_size_MiB, |
| 7606 | }, |
| 7607 | schema, |
| 7608 | ) |
| 7609 | except jsonschema.exceptions.ValidationError as exc: |
| 7610 | raise ArgumentValueError(exc) |
| 7611 | if not enabled: |
| 7612 | raise ArgumentValueError("Disabling the host cache is not supported") |
| 7613 | ret_dict = {"enabled": False} |
| 7614 | |
| 7615 | host_ref = _get_proxy_target(service_instance) |
| 7616 | hostname = __proxy__["esxi.get_details"]()["esxi_host"] |
| 7617 | if datastore: |
| 7618 | ds_refs = salt.utils.vmware.get_datastores( |
| 7619 | service_instance, host_ref, datastore_names=[datastore] |
| 7620 | ) |
| 7621 | if not ds_refs: |
| 7622 | raise VMwareObjectRetrievalError( |
| 7623 | f"Datastore '{datastore}' was not found on host '{hostname}'" |
| 7624 | ) |
| 7625 | ds_ref = ds_refs[0] |
nothing calls this directly
no test coverage detected