summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/sources/DataSourceEc2.py2
-rw-r--r--tests/unittests/test_ds_identify.py16
-rwxr-xr-xtools/ds-identify3
3 files changed, 16 insertions, 5 deletions
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index 5c017bfb..10107456 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -473,7 +473,7 @@ def identify_aws(data):
def identify_brightbox(data):
- if data['serial'].endswith('brightbox.com'):
+ if data['serial'].endswith('.brightbox.com'):
return CloudNames.BRIGHTBOX
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index 587e6993..de87be29 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -195,6 +195,10 @@ class DsIdentifyBase(CiTestCase):
return self._check_via_dict(
data, RC_FOUND, dslist=[data.get('ds'), DS_NONE])
+ def _test_ds_not_found(self, name):
+ data = copy.deepcopy(VALID_CFG[name])
+ return self._check_via_dict(data, RC_NOT_FOUND)
+
def _check_via_dict(self, data, rc, dslist=None, **kwargs):
ret = self._call_via_dict(data, **kwargs)
good = False
@@ -244,9 +248,13 @@ class TestDsIdentify(DsIdentifyBase):
self._test_ds_found('Ec2-xen')
def test_brightbox_is_ec2(self):
- """EC2: product_serial ends with 'brightbox.com'"""
+ """EC2: product_serial ends with '.brightbox.com'"""
self._test_ds_found('Ec2-brightbox')
+ def test_bobrightbox_is_not_brightbox(self):
+ """EC2: bobrightbox.com in product_serial is not brightbox'"""
+ self._test_ds_not_found('Ec2-brightbox-negative')
+
def test_gce_by_product_name(self):
"""GCE identifies itself with product_name."""
self._test_ds_found('GCE')
@@ -724,7 +732,11 @@ VALID_CFG = {
},
'Ec2-brightbox': {
'ds': 'Ec2',
- 'files': {P_PRODUCT_SERIAL: 'facc6e2f.brightbox.com\n'},
+ 'files': {P_PRODUCT_SERIAL: 'srv-otuxg.gb1.brightbox.com\n'},
+ },
+ 'Ec2-brightbox-negative': {
+ 'ds': 'Ec2',
+ 'files': {P_PRODUCT_SERIAL: 'tricky-host.bobrightbox.com\n'},
},
'GCE': {
'ds': 'GCE',
diff --git a/tools/ds-identify b/tools/ds-identify
index e0d4865c..2447d14f 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -891,9 +891,8 @@ ec2_identify_platform() {
local default="$1"
local serial="${DI_DMI_PRODUCT_SERIAL}"
- # brightbox https://bugs.launchpad.net/cloud-init/+bug/1661693
case "$serial" in
- *brightbox.com) _RET="Brightbox"; return 0;;
+ *.brightbox.com) _RET="Brightbox"; return 0;;
esac
# AWS http://docs.aws.amazon.com/AWSEC2/