Add support for gce accelerators

This commit is contained in:
jp-harvey 2019-01-02 14:55:10 -08:00 committed by Daniel Wozniak
parent 42ea39aadc
commit 15a0b35f8e

View file

@ -2372,6 +2372,29 @@ def request_instance(vm_):
"'pd-standard', 'pd-ssd'"
)
# GCE accelerator options are only supported as of libcloud >= 2.3.0
# and Python 3+ is required so that libcloud will detect a type of
# 'string' rather than 'unicode'
if LIBCLOUD_VERSION_INFO >= (2, 3, 0) and isinstance("test", str):
kwargs.update(
{
"ex_accelerator_type": config.get_cloud_config_value(
"ex_accelerator_type", vm_, __opts__, default=None
),
"ex_accelerator_count": config.get_cloud_config_value(
"ex_accelerator_count", vm_, __opts__, default=None
),
}
)
if kwargs.get("ex_accelerator_type"):
log.warning(
"An accelerator is being attached to this instance, "
"the ex_on_host_maintenance setting is being set to "
"'TERMINATE' as a result"
)
kwargs.update({"ex_on_host_maintenance": "TERMINATE"})
log.info("Creating GCE instance %s in %s", vm_["name"], kwargs["location"].name)
log.debug("Create instance kwargs %s", kwargs)