summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Z99-cloudinit-warnings.sh4
-rwxr-xr-xtools/build-on-freebsd4
-rwxr-xr-xtools/ds-identify33
-rwxr-xr-xtools/hacking.py5
-rwxr-xr-xtools/mock-meta.py2
-rwxr-xr-xtools/net-convert.py2
6 files changed, 29 insertions, 21 deletions
diff --git a/tools/Z99-cloudinit-warnings.sh b/tools/Z99-cloudinit-warnings.sh
index b237786b..1d413374 100644
--- a/tools/Z99-cloudinit-warnings.sh
+++ b/tools/Z99-cloudinit-warnings.sh
@@ -4,12 +4,12 @@
# Purpose: show user warnings on login.
cloud_init_warnings() {
- local skipf="" warning="" idir="/var/lib/cloud/instance" n=0
+ local warning="" idir="/var/lib/cloud/instance" n=0
local warndir="$idir/warnings"
local ufile="$HOME/.cloud-warnings.skip" sfile="$warndir/.skip"
[ -d "$warndir" ] || return 0
[ ! -f "$ufile" ] || return 0
- [ ! -f "$skipf" ] || return 0
+ [ ! -f "$sfile" ] || return 0
for warning in "$warndir"/*; do
[ -f "$warning" ] || continue
diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd
index 8436498e..ccc10b40 100755
--- a/tools/build-on-freebsd
+++ b/tools/build-on-freebsd
@@ -10,9 +10,7 @@ depschecked=/tmp/c-i.dependencieschecked
pkgs="
dmidecode
e2fsprogs
- gpart
py27-Jinja2
- py27-argparse
py27-boto
py27-cheetah
py27-configobj
@@ -38,7 +36,7 @@ python setup.py build
python setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd
# Install the correct config file:
-cp config/cloud.cfg-freebsd /usr/local/etc/cloud/cloud.cfg
+cp config/cloud.cfg-freebsd /etc/cloud/cloud.cfg
# Enable cloud-init in /etc/rc.conf:
sed -i.bak -e "/cloudinit_enable=.*/d" /etc/rc.conf
diff --git a/tools/ds-identify b/tools/ds-identify
index a43b1291..74d26537 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -216,9 +216,8 @@ has_cdrom() {
[ -e "${PATH_ROOT}/dev/cdrom" ]
}
-read_virt() {
- cached "$DI_VIRT" && return 0
- local out="" r="" virt="${UNAVAILABLE}"
+detect_virt() {
+ local virt="${UNAVAILABLE}" r="" out=""
if [ -d /run/systemd ]; then
out=$(systemd-detect-virt 2>&1)
r=$?
@@ -226,7 +225,13 @@ read_virt() {
virt="$out"
fi
fi
- DI_VIRT=$virt
+ _RET="$virt"
+}
+
+read_virt() {
+ cached "$DI_VIRT" && return 0
+ detect_virt
+ DI_VIRT=${_RET}
}
is_container() {
@@ -318,8 +323,11 @@ parse_yaml_array() {
# ['1'] or [1]
# '1', '2'
local val="$1" oifs="$IFS" ret="" tok=""
- val=${val#[}
- val=${val%]}
+ # i386/14.04 (dash=0.5.7-4ubuntu1): the following outputs "[foo"
+ # sh -c 'n="$1"; echo ${n#[}' -- "[foo"
+ # the fix was to quote the open bracket (val=${val#"["}) (LP: #1689648)
+ val=${val#"["}
+ val=${val%"]"}
IFS=","; set -- $val; IFS="$oifs"
for tok in "$@"; do
trim "$tok"
@@ -714,7 +722,7 @@ ec2_identify_platform() {
# AWS http://docs.aws.amazon.com/AWSEC2/
# latest/UserGuide/identify_ec2_instances.html
- local uuid="" hvuuid="$PATH_ROOT/sys/hypervisor/uuid"
+ local uuid="" hvuuid="${PATH_SYS_HYPERVISOR}/uuid"
# if the (basically) xen specific /sys/hypervisor/uuid starts with 'ec2'
if [ -r "$hvuuid" ] && read uuid < "$hvuuid" &&
[ "${uuid#ec2}" != "$uuid" ]; then
@@ -725,7 +733,7 @@ ec2_identify_platform() {
# product uuid and product serial start with case insensitive
local uuid="${DI_DMI_PRODUCT_UUID}"
case "$uuid:$serial" in
- [Ee][Cc]2*:[Ee][Cc]2)
+ [Ee][Cc]2*:[Ee][Cc]2*)
# both start with ec2, now check for case insenstive equal
nocase_equal "$uuid" "$serial" &&
{ _RET="AWS"; return 0; };;
@@ -955,10 +963,11 @@ found() {
# do not pass an empty line through.
shift
fi
- # always write the None datasource last.
- if [ "$list" != "None" ]; then
- list="${list:+${list}, }None"
- fi
+ # if None is not already in the list, then add it last.
+ case " $list " in
+ *\ None,\ *|*\ None\ ) :;;
+ *) list=${list:+${list}, None};;
+ esac
write_result "datasource_list: [ $list ]" "$@"
return
}
diff --git a/tools/hacking.py b/tools/hacking.py
index 6c320935..e6a05136 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -165,7 +165,8 @@ if __name__ == "__main__":
pep8._main()
finally:
if len(_missingImport) > 0:
- print >> sys.stderr, ("%i imports missing in this test environment"
- % len(_missingImport))
+ sys.stderr.write(
+ "%i imports missing in this test environment\n" %
+ len(_missingImport))
# vi: ts=4 expandtab
diff --git a/tools/mock-meta.py b/tools/mock-meta.py
index 82816e8a..f185dbf2 100755
--- a/tools/mock-meta.py
+++ b/tools/mock-meta.py
@@ -21,8 +21,8 @@ import functools
import json
import logging
import os
-import socket
import random
+import socket
import string
import sys
import yaml
diff --git a/tools/net-convert.py b/tools/net-convert.py
index 870da639..b2db8adf 100755
--- a/tools/net-convert.py
+++ b/tools/net-convert.py
@@ -9,8 +9,8 @@ import yaml
from cloudinit.sources.helpers import openstack
from cloudinit.net import eni
-from cloudinit.net import network_state
from cloudinit.net import netplan
+from cloudinit.net import network_state
from cloudinit.net import sysconfig