diff options
author | Scott Moser <smoser@brickies.net> | 2016-08-23 16:48:34 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2016-08-23 16:48:34 -0400 |
commit | 7d233c000d56cd832e00e2c34dc6fe68d8c24064 (patch) | |
tree | 5eaa4baa91424943edade412a75ba1ef9fb2a479 | |
parent | 92d9a63c8a7bd8f6c14aee7e5f33a2a5dec4ba85 (diff) | |
download | cloud-init-git-7d233c000d56cd832e00e2c34dc6fe68d8c24064.tar.gz |
Import version 0.6.3-0ubuntu1.15ubuntu/0.6.3-0ubuntu1.15
Imported using git-dsc-commit.
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | debian/cloud-init.templates | 6 | ||||
-rw-r--r-- | debian/patches/lp-1378441-backport-gce-data-source.patch | 170 | ||||
-rw-r--r-- | debian/patches/series | 1 |
4 files changed, 181 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog index 0f1863e5..b11b580c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +cloud-init (0.6.3-0ubuntu1.15) precise-proposed; urgency=medium + + * debian/patches/lp-1378441-backport-gce-data-source.patch: backported + Google Compute Engine data source. (LP: #1378441) + + -- Daniel Watkins <daniel.watkins@canonical.com> Thu, 10 Oct 2014 09:24:57 +0100 + cloud-init (0.6.3-0ubuntu1.14) precise-proposed; urgency=medium * debian/patches/lp-1363260-add-cloudsigma_ds.patch: backport from diff --git a/debian/cloud-init.templates b/debian/cloud-init.templates index 2a0678c8..53a7ed3c 100644 --- a/debian/cloud-init.templates +++ b/debian/cloud-init.templates @@ -1,8 +1,8 @@ Template: cloud-init/datasources Type: multiselect -Default: NoCloud, ConfigDrive, Azure, OVF, MAAS, CloudSigma -Choices-C: NoCloud, ConfigDrive, Azure, OVF, MAAS, Ec2, SmartOS, CloudSigma -Choices: NoCloud: Reads info from /var/lib/cloud/seed only, ConfigDrive: Reads data from Openstack Config Drive, Azure: read from MS Azure cdrom. Requires walinux-agent, OVF: Reads data from OVF Transports, MAAS: Reads data from Ubuntu MAAS, Ec2: reads data from EC2 Metadata service, SmartOS: reads data from serial console, CloudSigma: reads data from serial console +Default: NoCloud, ConfigDrive, Azure, OVF, MAAS, CloudSigma, GCE +Choices-C: NoCloud, ConfigDrive, Azure, OVF, MAAS, Ec2, SmartOS, CloudSigma, GCE +Choices: NoCloud: Reads info from /var/lib/cloud/seed only, ConfigDrive: Reads data from Openstack Config Drive, Azure: read from MS Azure cdrom. Requires walinux-agent, OVF: Reads data from OVF Transports, MAAS: Reads data from Ubuntu MAAS, Ec2: reads data from EC2 Metadata service, SmartOS: reads data from serial console, CloudSigma: reads data from serial console, GCE: reads data from Google Compute Engine metadata service Description: Which data sources should be searched? Cloud-init supports searching different "Data Sources" for information that it uses to configure a cloud instance. diff --git a/debian/patches/lp-1378441-backport-gce-data-source.patch b/debian/patches/lp-1378441-backport-gce-data-source.patch new file mode 100644 index 00000000..69c604b5 --- /dev/null +++ b/debian/patches/lp-1378441-backport-gce-data-source.patch @@ -0,0 +1,170 @@ +Origin: upstream +Bug: https://launchpad.net/bugs/1378441 +Forwarded: not-needed +Description: Add support for Google Compute Engine + In order to use cloud-init on GCE, we need a GCE data source. This backports + the GCE datasource from trusty, DataSourceGCE.py. + . + This is accompanied by a debian/cloud-init.templates change to enable debconf + to select the 'GCE' datasource. +Index: precise-proposed/cloudinit/DataSourceGCE.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ precise-proposed/cloudinit/DataSourceGCE.py 2014-10-07 15:43:05.054129022 +0100 +@@ -0,0 +1,156 @@ ++# vi: ts=4 expandtab ++# ++# Author: Vaidas Jablonskis <jablonskis@gmail.com> ++# ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License version 3, as ++# published by the Free Software Foundation. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see <http://www.gnu.org/licenses/>. ++ ++import logging ++import urllib2 ++ ++from cloudinit import util ++from cloudinit import DataSource as sources ++ ++LOG = logging.getLogger(__name__) ++ ++BUILTIN_DS_CONFIG = { ++ 'metadata_url': 'http://metadata.google.internal./computeMetadata/v1/' ++} ++REQUIRED_FIELDS = ('instance-id', 'availability-zone', 'local-hostname') ++ ++ ++class _FakeResponse(object): ++ ++ def __init__(self, code, contents): ++ self.code = code ++ self.contents = contents ++ ++ ++class url_helper(object): ++ # This is a shim designed to look like url_helper.py from future versions ++ # of cloud-init. ++ ++ @staticmethod ++ def readurl(url, headers): ++ request = urllib2.Request(url, headers=headers) ++ response = urllib2.urlopen(request) ++ return _FakeResponse(code=response.getcode(), contents=response.read()) ++ ++ UrlError = urllib2.URLError ++ ++ ++class DataSourceGCE(sources.DataSource): ++ def __init__(self, sys_cfg): ++ sources.DataSource.__init__(self, sys_cfg) ++ self.metadata = dict() ++ self.ds_cfg = util.mergedict( ++ util.get_cfg_by_path(sys_cfg, ["datasource", "GCE"], {}), ++ BUILTIN_DS_CONFIG) ++ self.metadata_address = self.ds_cfg['metadata_url'] ++ ++ # GCE takes sshKeys attribute in the format of '<user>:<public_key>' ++ # so we have to trim each key to remove the username part ++ def _trim_key(self, public_key): ++ try: ++ index = public_key.index(':') ++ if index > 0: ++ return public_key[(index + 1):] ++ except: ++ return public_key ++ ++ def get_data(self): ++ # GCE metadata server requires a custom header since v1 ++ headers = {'X-Google-Metadata-Request': 'True'} ++ ++ # url_map: (our-key, path, required) ++ url_map = [ ++ ('instance-id', 'instance/id', True), ++ ('availability-zone', 'instance/zone', True), ++ ('local-hostname', 'instance/hostname', True), ++ ('public-keys', 'project/attributes/sshKeys', False), ++ ('user-data', 'instance/attributes/user-data', False), ++ ] ++ ++ # if we cannot resolve the metadata server, then no point in trying ++ if not util.is_resolvable_url(self.metadata_address): ++ LOG.debug("%s is not resolvable", self.metadata_address) ++ return False ++ ++ # iterate over url_map keys to get metadata items ++ found = False ++ for (mkey, path, required) in url_map: ++ try: ++ resp = url_helper.readurl(url=self.metadata_address + path, ++ headers=headers) ++ if resp.code == 200: ++ found = True ++ self.metadata[mkey] = resp.contents ++ else: ++ if required: ++ msg = "required url %s returned code %s. not GCE" ++ if not found: ++ LOG.debug(msg, path, resp.code) ++ else: ++ LOG.warn(msg, path, resp.code) ++ return False ++ else: ++ self.metadata[mkey] = None ++ except url_helper.UrlError as e: ++ if required: ++ msg = "required url %s raised exception %s. not GCE" ++ if not found: ++ LOG.debug(msg, path, e) ++ else: ++ LOG.warn(msg, path, e) ++ return False ++ msg = "Failed to get %s metadata item: %s." ++ LOG.debug(msg, path, e) ++ ++ self.metadata[mkey] = None ++ ++ if self.metadata['public-keys']: ++ lines = self.metadata['public-keys'].splitlines() ++ self.metadata['public-keys'] = [self._trim_key(k) for k in lines] ++ ++ return found ++ ++ @property ++ def launch_index(self): ++ # GCE does not provide lauch_index property ++ return None ++ ++ def get_instance_id(self): ++ return self.metadata['instance-id'] ++ ++ def get_public_ssh_keys(self): ++ return self.metadata['public-keys'] ++ ++ def get_hostname(self, fqdn=False, _resolve_ip=False): ++ return self.metadata['local-hostname'] ++ ++ @property ++ def userdata_raw(self): ++ return self.metadata['user-data'] or '' ++ ++ @property ++ def availability_zone(self): ++ return self.metadata['availability-zone'] ++ ++# Used to match classes to dependencies ++datasources = [ ++ (DataSourceGCE, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)), ++] ++ ++ ++# Return a list of data sources that match this set of dependencies ++def get_datasource_list(depends): ++ return sources.list_from_depends(depends, datasources) diff --git a/debian/patches/series b/debian/patches/series index 4c75ddd7..0d93eb3f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -24,3 +24,4 @@ lp-1292648-azure-format-ephemeral-new.patch lp-1302229-fix_futils_azure.patch lp-1363260-add-cloudsigma_ds.patch lp-1336855-grub_xvda.patch +lp-1378441-backport-gce-data-source.patch |