John Baublitz created LIBCLOUD-828:
--------------------------------------
Summary: Support for GCE instance groups
Key: LIBCLOUD-828
URL: https://issues.apache.org/jira/browse/LIBCLOUD-828
Project: Libcloud
Issue Type: New Feature
Components: Compute
Reporter: John Baublitz
Priority: Minor
Currently libcloud does not have support for creating managed and unmanaged
instance groups. I propose some changes to the API to support
GCEUnmanagedInstanceGroup, GCEManagedInstanceGroup, GCEInstanceTemplate and
some additional changes to GCENodeDriver. This includes creating new functions
to manage instance groups and editing node creation functions to give the
option to add newly created nodes to an unmanaged instance group. I have
drafted a preliminary diff to show what arguments the proposed functions would
include and am happy to add to it as needed before I start implementing.
This is the preliminary draft of additions without implementations.
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 9f9b8c1..baf79a8 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -476,6 +476,71 @@ class GCEForwardingRule(UuidMixin):
return '<GCEForwardingRule id="%s" name="%s" address="%s">' % (
self.id, self.name, self.address)
+class GCEInstanceGroup(object):
+ def __init__(self, name, driver):
+ pass
+
+ def delete(self):
+ """
+ Destroy this instance group
+
+ :return: True if successful
+ :rtype: ``bool``
+ """
+
+ pass
+
+class GCEUnmanagedInstanceGroup(GCEInstanceGroup):
+ def __init__(self, name, driver):
+ pass
+
+ def delete(self):
+ """
+ Destroy this instance group
+
+ :return: True if successful
+ :rtype: ``bool``
+ """
+
+ pass
+
+class GCEManagedInstanceGroup(GCEInstanceGroup):
+ def __init__(self, name, driver, instance_template):
+ pass
+
+ def update(self):
+ """
+ Update instance group template
+
+ :return: Updated ManagedInstanceGroup object
+ :rtype: :class:`GCEManagedInstanceGroup`
+ """
+
+ pass
+
+ def delete(self):
+ """
+ Destroy this instance group
+
+ :return: True if successful
+ :rtype: ``bool``
+ """
+
+ pass
+
+class GCEInstanceTemplate(object):
+ def __init__(self, name, driver):
+ pass
+
+ def delete(self):
+ """
+ Destroy this instance group
+
+ :return: True if successful
+ :rtype: ``bool``
+ """
+
+ pass
class GCENodeImage(NodeImage):
"""A GCE Node Image class."""
@@ -1673,6 +1738,24 @@ class GCENodeDriver(NodeDriver):
response.get('items', [])]
return list_networks
+ def ex_list_instance_groups(self, ex_zone=None, type='all'):
+ """
+ Return a list of instance groups in the current zone or all zones.
+ type may be 'managed', 'unmanaged', or 'all'.
+
+ :keyword ex_zone: Optional zone name or 'all'
+ :type ex_zone: ``str`` or :class:`GCEZone` or
+ :class:`NodeLocation` or ``None``
+
+ :keyword type: String of value 'managed', 'unmanaged', or 'all'
+ :type type: ``str``
+
+ :return: List of GCEInstanceGroup objects
+ :rtype: ``list`` of :class:`GCEInstanceGroup`
+ """
+
+ pass
+
def list_nodes(self, ex_zone=None):
"""
Return a list of nodes in the current zone or all zones.
@@ -2437,7 +2520,7 @@ class GCENodeDriver(NodeDriver):
def create_node(self, name, size, image, location=None,
ex_network='default', ex_subnetwork=None,
- ex_tags=None, ex_metadata=None,
+ ex_tags=None, ex_metadata=None, ex_instance_group=None,
ex_boot_disk=None, use_existing_disk=True,
external_ip='ephemeral', ex_disk_type='pd-standard',
ex_disk_auto_delete=True, ex_service_accounts=None,
@@ -2489,6 +2572,11 @@ class GCENodeDriver(NodeDriver):
a GCEAddress object should be passed in.
:type external_ip: :class:`GCEAddress` or ``str`` or ``None``
+ :keyword ex_instance_group: Unmanaged instance group to which to add
+ add the nodes.
+ :type ex_instance_group: ``str`` or
+ :class:`GCEUnmanagedInstanceGroup`
+
:keyword ex_disk_type: Specify a pd-standard (default) disk or pd-ssd
for an SSD disk.
:type ex_disk_type: ``str`` or :class:`GCEDiskType`
@@ -2638,6 +2726,80 @@ class GCENodeDriver(NodeDriver):
self.connection.async_request(request, method='POST', data=node_data)
return self.ex_get_node(name, location.name)
+ def ex_create_instance_template(self, template_name, machine_type,
+ ex_disks_gce_struct=None,
+ ex_nic_gce_struct=None):
+ """
+ Create an instance template in Google Compute Engine
+
+ :param template_name: The name of the instance template.
+ :type template_name: ``str``
+
+ :param machine_type: The type of machine for each instance.
+ :type machine_type: ``str`` or :class:`GCENodeSize`
+
+ :keyword ex_disks_gce_struct: Support for passing in the GCE-specific
+ formatted disks[] structure. No attempt
+ is made to ensure proper formatting of
+ the disks[] structure. Using this
+ structure obviates the need of using
+ other disk params like 'ex_boot_disk',
+ etc. See the GCE docs for specific
+ details.
+ :type ex_disks_gce_struct: ``list`` or ``None``
+
+ :keyword ex_nic_gce_struct: Support passing in the GCE-specific
+ formatted networkInterfaces[] structure.
+ No attempt is made to ensure proper
+ formatting of the networkInterfaces[]
+ data. Using this structure obviates the
+ need of using 'external_ip' and
+ 'ex_network'. See the GCE docs for
+ details.
+ :type ex_nic_gce_struct: ``list`` or ``None``
+
+ :return: An instance template object
+ :rtype: :class:`GCEInstanceTemplate`
+ """
+
+ pass
+
+ def ex_create_managed_instance_group(self, base_name, instance_template,
+ group_name, size=1):
+ """
+ Create a managed instance group in Google Compute Engine
+
+ :param base_name: The base name of instances in the instance group.
+ :type base_name: ``str``
+
+ :param instance_template: The name of the instance template.
+ :type instance_template: ``str`` or :class:`GCEInstanceTemplate`
+
+ :param group_name: The name of the group of all of the instances.
+ :type group_name: ``str``
+
+ :keyword size: The number of instances in the instance group.
+ :type size: ``int``
+
+ :return: An instance group object.
+ :rtype: :class:`GCEManagedInstanceGroup`
+ """
+
+ pass
+
+ def ex_create_unmanaged_instance_group(self, group_name):
+ """
+ Create an instance group in Google Compute Engine
+
+ :param group_name: The name of the group of all of the instances.
+ :type group_name: ``str``
+
+ :return: An instance group object.
+ :rtype: :class:`GCEUnmanagedInstanceGroup`
+ """
+
+ pass
+
def ex_create_multiple_nodes(self, base_name, size, image, number,
location=None, ex_network='default',
ex_tags=None, ex_metadata=None,
@@ -2648,6 +2810,7 @@ class GCENodeDriver(NodeDriver):
ex_service_accounts=None,
timeout=DEFAULT_TASK_COMPLETION_TIMEOUT,
description=None,
+ ex_instance_group=None,
ex_can_ip_forward=None,
ex_disks_gce_struct=None,
ex_nic_gce_struct=None,
@@ -2709,6 +2872,11 @@ class GCENodeDriver(NodeDriver):
multiple node creation.)
:type external_ip: ``str`` or None
+ :keyword ex_instance_group: Unmanaged instance group to which to add
+ add the nodes.
+ :type ex_instance_group: ``str`` or
+ :class:`GCEUnmanagedInstanceGroup`
+
:keyword ex_disk_type: Specify a pd-standard (default) disk or pd-ssd
for an SSD disk.
:type ex_disk_type: ``str`` or :class:`GCEDiskType`
@@ -4519,6 +4687,41 @@ class GCENodeDriver(NodeDriver):
response = self.connection.request(request, method='GET').object
return self._to_network(response)
+ def ex_get_instance_group(self, name, zone=None):
+ """
+ Return a GCEInstanceGroup object based on a group name and optional
+ zone.
+
+ :param name: The name of the group
+ :type name: ``str``
+
+ :keyword zone: The zone to search for the node in. If set to 'all',
+ search all zones for the instance.
+ :type zone: ``str`` or :class:`GCEZone` or
+ :class:`NodeLocation` or ``None``
+
+ :return: A Node object for the node
+ :rtype: :class:`Node`
+ """
+
+ pass
+
+ def ex_set_instance_group_template(self, group, instance_template):
+ """
+ Set the instance template for an instance group.
+
+ :param node: Target managed instance group.
+ :type node: ``str`` or :class:`GCEInstanceGroup`
+
+ :param instance_template: Instance template name.
+ :type instance_template: ``str``
+
+ :return: True if successful
+ :rtype: ``bool``
+ """
+
+ pass
+
def ex_get_node(self, name, zone=None):
"""
Return a Node object based on a node name and optional zone.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)