Repository: libcloud Updated Branches: refs/heads/trunk 56548a969 -> 8f54b5f7b
Add an additional argument to libcloud.compute.drivers.GCENodeDriver.create_node to allow for creation of preemptible GCE instances Signed-off-by: Anthony Shaw <[email protected]> Closes #643 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8f54b5f7 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8f54b5f7 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8f54b5f7 Branch: refs/heads/trunk Commit: 8f54b5f7b0621e53882b7bd1d97f3aa2041acd10 Parents: 56548a9 Author: brian <[email protected]> Authored: Wed Nov 25 22:45:41 2015 -0500 Committer: Anthony Shaw <[email protected]> Committed: Fri Nov 27 16:08:34 2015 +1100 ---------------------------------------------------------------------- libcloud/compute/drivers/gce.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/8f54b5f7/libcloud/compute/drivers/gce.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index 3a49ba7..b74b2a7 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -2235,7 +2235,8 @@ class GCENodeDriver(NodeDriver): ex_disk_auto_delete=True, ex_service_accounts=None, description=None, ex_can_ip_forward=None, ex_disks_gce_struct=None, ex_nic_gce_struct=None, - ex_on_host_maintenance=None, ex_automatic_restart=None): + ex_on_host_maintenance=None, ex_automatic_restart=None, + ex_preemptible=None): """ Create a new node and return a node object for the node. @@ -2343,6 +2344,11 @@ class GCENodeDriver(NodeDriver): default value for the instance type.) :type ex_automatic_restart: ``bool`` or ``None`` + :keyword ex_preemptible: Defines whether the instance is preemptible. + (If not supplied, the instance will + not be preemptible) + :type ex_preemptible: ``bool`` or ``None`` + :return: A Node object for the new node. :rtype: :class:`Node` """ @@ -2396,7 +2402,8 @@ class GCENodeDriver(NodeDriver): ex_disks_gce_struct, ex_nic_gce_struct, ex_on_host_maintenance, - ex_automatic_restart) + ex_automatic_restart, + ex_preemptible) self.connection.async_request(request, method='POST', data=node_data) return self.ex_get_node(name, location.name) @@ -4528,7 +4535,8 @@ class GCENodeDriver(NodeDriver): description=None, ex_can_ip_forward=None, ex_disks_gce_struct=None, ex_nic_gce_struct=None, ex_on_host_maintenance=None, - ex_automatic_restart=None): + ex_automatic_restart=None, + ex_preemptible=None): """ Returns a request and body to create a new node. This is a helper method to support both :class:`create_node` and @@ -4634,6 +4642,11 @@ class GCENodeDriver(NodeDriver): default value for the instance type.) :type ex_automatic_restart: ``bool`` or ``None`` + :keyword ex_preemptible: Defines whether the instance is preemptible. + (If not supplied, the instance will + not be preemptible) + :type ex_preemptible: ``bool`` or ``None`` + :return: A tuple containing a request string and a node_data dict. :rtype: ``tuple`` of ``str`` and ``dict`` """ @@ -4764,6 +4777,8 @@ class GCENodeDriver(NodeDriver): scheduling['onHostMaintenance'] = 'MIGRATE' if ex_automatic_restart is not None: scheduling['automaticRestart'] = ex_automatic_restart + if ex_preemptible is not None: + scheduling['preemptible'] = ex_preemptible if scheduling: node_data['scheduling'] = scheduling
