Merge ~dojordan/cloud-init:fix_azure_hostname into cloud-init:master

Proposed by Douglas Jordan
Status: Merged
Approved by: Chad Smith
Approved revision: dbf110cb3a81f815b73536b2ce3da1f29c62c223
Merge reported by: Chad Smith
Merged at revision: f891df345afa57c0c7734e8f04cca9a3d5881778
Proposed branch: ~dojordan/cloud-init:fix_azure_hostname
Merge into: cloud-init:master
Diff against target: 38 lines (+17/-0)
2 files modified
cloudinit/sources/DataSourceAzure.py (+2/-0)
tests/unittests/test_datasource/test_azure.py (+15/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Chad Smith Approve
Review via email: mp+341182@code.launchpad.net

Commit message

This commit fixes get_hostname on the AzureDataSource.

LP: #1754495

Description of the change

This commit fixes get_hostname on the AzureDataSource.

LP #1754495

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:a0fffc2fffc8db3fa32a41f0eda7c2f162e3275c
https://jenkins.ubuntu.com/server/job/cloud-init-ci/830/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/830/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

approve with a minor ask for a unit test.

review: Approve
dbf110c... by Douglas Jordan

Adding UT coverage and checking if iterable type first

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:dbf110cb3a81f815b73536b2ce3da1f29c62c223
https://jenkins.ubuntu.com/server/job/cloud-init-ci/834/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/834/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=f891df34

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/836/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/836/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
2index 4bcbf3a..0bb7fad 100644
3--- a/cloudinit/sources/DataSourceAzure.py
4+++ b/cloudinit/sources/DataSourceAzure.py
5@@ -223,6 +223,8 @@ DEF_PASSWD_REDACTION = 'REDACTED'
6
7
8 def get_hostname(hostname_command='hostname'):
9+ if not isinstance(hostname_command, (list, tuple)):
10+ hostname_command = (hostname_command,)
11 return util.subp(hostname_command, capture=True)[0].strip()
12
13
14diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
15index 254e987..da7da0c 100644
16--- a/tests/unittests/test_datasource/test_azure.py
17+++ b/tests/unittests/test_datasource/test_azure.py
18@@ -643,6 +643,21 @@ fdescfs /dev/fd fdescfs rw 0 0
19 expected_config['config'].append(blacklist_config)
20 self.assertEqual(netconfig, expected_config)
21
22+ @mock.patch("cloudinit.sources.DataSourceAzure.util.subp")
23+ def test_get_hostname_with_no_args(self, subp):
24+ dsaz.get_hostname()
25+ subp.assert_called_once_with(("hostname",), capture=True)
26+
27+ @mock.patch("cloudinit.sources.DataSourceAzure.util.subp")
28+ def test_get_hostname_with_string_arg(self, subp):
29+ dsaz.get_hostname(hostname_command="hostname")
30+ subp.assert_called_once_with(("hostname",), capture=True)
31+
32+ @mock.patch("cloudinit.sources.DataSourceAzure.util.subp")
33+ def test_get_hostname_with_iterable_arg(self, subp):
34+ dsaz.get_hostname(hostname_command=("hostname",))
35+ subp.assert_called_once_with(("hostname",), capture=True)
36+
37
38 class TestAzureBounce(CiTestCase):
39

Subscribers

People subscribed via source and target branches