summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-08-23 16:48:33 -0400
committerScott Moser <smoser@brickies.net>2016-08-23 16:48:33 -0400
commit77127544ce661951b285a4fedbba88a35dc1f9d5 (patch)
treedfd0ec65d1df5173100b7ced3399096c9ffe034d
parent6e390fe6326523f0580874e4e23d248a320c5881 (diff)
downloadcloud-init-git-77127544ce661951b285a4fedbba88a35dc1f9d5.tar.gz
Import version 0.6.3-0ubuntu1.10ubuntu/0.6.3-0ubuntu1.10
Imported using git-dsc-commit.
-rw-r--r--debian/changelog11
-rw-r--r--debian/patches/lp-1272115-fix_smartos_compliance.patch170
-rw-r--r--debian/patches/series1
3 files changed, 182 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index e0934323..e2734ca8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+cloud-init (0.6.3-0ubuntu1.10) precise-proposed; urgency=low
+
+ * debian/patches/lp-1272115-fix_smartos_compliance.patch: Fix compliance for
+ SmartOS data handling (LP: #1272115):
+ - cloud-init user-data is now named spaced as "cloud-init:user-data"
+ - user-data is written to /var/db/mdata-user-data
+ - user-scripts are fetched and executed each boot
+ - datacenter/region is now named spaced as "sdc:datacenter"
+
+ -- Ben Howard <ben.howard@ubuntu.com> Mon, 27 Jan 2014 13:57:24 -0700
+
cloud-init (0.6.3-0ubuntu1.9) precise-proposed; urgency=low
* debian/patches/lp-1247262-fix_futils_smartos.patch:
diff --git a/debian/patches/lp-1272115-fix_smartos_compliance.patch b/debian/patches/lp-1272115-fix_smartos_compliance.patch
new file mode 100644
index 00000000..1f10d397
--- /dev/null
+++ b/debian/patches/lp-1272115-fix_smartos_compliance.patch
@@ -0,0 +1,170 @@
+Author: Ben Howard <ben.howard@ubuntu.com>
+Bug: https://launchpad.net/bugs/1272115
+Applied-Upstream: yes
+Description: Fixed compliance for SmartOS data dictionary
+--- a/cloudinit/DataSourceSmartOS.py
++++ b/cloudinit/DataSourceSmartOS.py
+@@ -25,12 +25,15 @@
+ # requests on the console. For example, to get the hostname, you
+ # would send "GET hostname" on /dev/ttyS1.
+ #
+-
++# Certain behavior is defined by the DataDictionary
++# http://us-east.manta.joyent.com/jmc/public/mdata/datadict.html
++# Comments with "@datadictionary" are snippets of the definition
+
+ import base64
+ import logging
+ from cloudinit import DataSource as sources
+ from cloudinit import future_util as futil
++from cloudinit import get_cpath
+ from cloudinit import util
+ import os
+ import os.path
+@@ -44,10 +47,12 @@
+ 'local-hostname': ('hostname', True),
+ 'public-keys': ('root_authorized_keys', True),
+ 'user-script': ('user-script', False),
+- 'user-data': ('user-data', False),
++ 'legacy-user-data': ('user-data', False),
++ 'user-data': ('cloud-init:user-data', False),
+ 'iptables_disable': ('iptables_disable', True),
+ 'motd_sys_info': ('motd_sys_info', True),
+- 'availability_zone': ('region', True),
++ 'availability_zone': ('sdc:datacenter_name', True),
++ 'vendordata': ('sdc:operator-script', False),
+ }
+
+ DS_NAME = 'SmartOS'
+@@ -71,7 +76,11 @@
+ 'seed_timeout': 60,
+ 'no_base64_decode': ['root_authorized_keys',
+ 'motd_sys_info',
+- 'iptables_disable'],
++ 'iptables_disable',
++ 'user-data',
++ 'user-script',
++ 'sdc:datacenter_name',
++ ],
+ 'base64_keys': [],
+ 'base64_all': False,
+ 'disk_aliases': {'ephemeral0': '/dev/vdb'},
+@@ -88,6 +97,11 @@
+ 'device': 'ephemeral0'}],
+ }
+
++# @datadictionary: this is legacy path for placing files from metadata
++# per the SmartOS location. It is not preferable, but is done for
++# legacy reasons
++LEGACY_USER_D = "/var/db"
++
+
+ class DataSourceSmartOS(sources.DataSource):
+ def __init__(self, sys_cfg):
+@@ -143,15 +157,33 @@
+ smartos_noun, strip = attribute
+ md[ci_noun] = self.query(smartos_noun, strip=strip)
+
++ # @datadictionary: This key may contain a program that is written
++ # to a file in the filesystem of the guest on each boot and then
++ # executed. It may be of any format that would be considered
++ # executable in the guest instance.
++ user_script_d = os.path.join(get_cpath(), "scripts/per-boot")
++ u_script = md.get('user-script')
++ u_script_f = "%s/99_user_script" % user_script_d
++ u_script_l = "%s/user-script" % LEGACY_USER_D
++ write_boot_content(u_script, u_script_f, link=u_script_l, shebang=True,
++ mode=0700)
++
++ # @datadictionary: This key has no defined format, but its value
++ # is written to the file /var/db/mdata-user-data on each boot prior
++ # to the phase that runs user-script. This file is not to be executed.
++ # This allows a configuration file of some kind to be injected into
++ # the machine to be consumed by the user-script when it runs.
++ u_data = md.get('legacy-user-data')
++ u_data_f = "%s/mdata-user-data" % LEGACY_USER_D
++ write_boot_content(u_data, u_data_f)
++
++ # Handle the cloud-init regular meta
+ if not md['local-hostname']:
+ md['local-hostname'] = system_uuid
+- md['local-hostname'] = md['local-hostname'].strip()
+
+ ud = ''
+ if md['user-data']:
+ ud = md['user-data']
+- elif md['user-script']:
+- ud = md['user-script']
+
+ self.metadata = util.mergedict(md, self.metadata)
+ self.userdata_raw = ud
+@@ -278,6 +310,69 @@
+ return (sys_uuid.lower()).strip(), sys_type.strip()
+
+
++def write_boot_content(content, content_f, link=None, shebang=False,
++ mode=0400):
++ """
++ Write the content to content_f. Under the following rules:
++ 1. If no content, remove the file
++ 2. Write the content
++ 3. If executable and no file magic, add it
++ 4. If there is a link, create it
++
++ @param content: what to write
++ @param content_f: the file name
++ @param link: if defined, location to create a symlink to
++ @param shebang: if no file magic, set shebang
++ @param mode: file mode
++
++ Becuase of the way that Cloud-init executes scripts (no shell),
++ a script will fail to execute if does not have a magic bit (shebang) set
++ for the file. If shebang=True, then the script will be checked for a magic
++ bit and to the SmartOS default of assuming that bash.
++ """
++
++ if not content and os.path.exists(content_f):
++ os.unlink(content_f)
++ if link and os.path.islink(link):
++ os.unlink(link)
++ if not content:
++ return
++
++ content_d = os.path.dirname(content_f)
++ if not os.path.isdir(content_d):
++ os.makedirs(content_d)
++ util.write_file(content_f, content, mode=mode)
++
++ if shebang and not content.startswith("#!"):
++ try:
++ cmd = ["file", "--brief", "--mime-type", content_f]
++ (f_type, _err) = util.subp(cmd)
++ LOG.debug("script %s mime type is %s", content_f, f_type)
++ line_zero = content.splitlines()[0]
++ # must check for explicit shebang on precise, due to libmagic1
++ # (used by file) not detecting non-bash scripts as x-shellscript
++ if f_type.strip() == "text/plain" and "#!" not in line_zero:
++ new_content = "\n".join(["#!/bin/bash", content])
++ util.write_file(content_f, new_content, mode=mode)
++ LOG.debug("added shebang to file %s", content_f)
++
++ except Exception as e:
++ LOG.debug(e)
++ util.logexc(LOG, "Failed to identify script type")
++
++ if link:
++ try:
++ if os.path.islink(link):
++ os.unlink(link)
++ if content and os.path.exists(content_f):
++ link_d = os.path.dirname(link)
++ if not os.path.isdir(link_d):
++ os.makedirs(link_d)
++ os.symlink(content_f, link)
++ except IOError as e:
++ util.logexc(LOG, "failed establishing content link")
++
++
+ # Used to match classes to dependencies
+ datasources = [
+ (DataSourceSmartOS, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
diff --git a/debian/patches/series b/debian/patches/series
index 8591e685..2f782513 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -17,3 +17,4 @@ lp-1233315-add-smartos-support.patch
lp-1231490-azure-ephemeral-format.patch
lp-1233315-1231490-ephmeralX.Y-support.patch
lp-1247262-fix_futils_smartos.patch
+lp-1272115-fix_smartos_compliance.patch