summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-07-26 14:05:52 -0400
committerScott Moser <smoser@ubuntu.com>2013-07-26 14:05:52 -0400
commit9da084bda820d0ab8500ea6ee13a014f46d3bfab (patch)
treebe83f6368882df37c59e8db075f872b00d88acb6 /cloudinit/sources
parentf8114e58dbbd84ec91a6fb8a8adec9be3bfbab52 (diff)
downloadvyos-cloud-init-9da084bda820d0ab8500ea6ee13a014f46d3bfab.tar.gz
vyos-cloud-init-9da084bda820d0ab8500ea6ee13a014f46d3bfab.zip
azure: fix bouncing of interface
the environment that was set up to include 'interface' was not actually being passed on to 'subp', so when the command ran it wasn't available.
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceAzure.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index d4863429..9503b045 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -31,8 +31,9 @@ LOG = logging.getLogger(__name__)
DS_NAME = 'Azure'
DEFAULT_METADATA = {"instance-id": "iid-AZURE-NODE"}
AGENT_START = ['service', 'walinuxagent', 'start']
-BOUNCE_COMMAND = ("i=$interface; x=0; ifdown $i || x=$?; "
- "ifup $i || x=$?; exit $x")
+BOUNCE_COMMAND = ['sh', '-xc',
+ "i=$interface; x=0; ifdown $i || x=$?; ifup $i || x=$?; exit $x"]
+
BUILTIN_DS_CONFIG = {
'agent_command': AGENT_START,
'data_dir': "/var/lib/waagent",
@@ -185,19 +186,29 @@ def apply_hostname_bounce(hostname, policy, interface, command,
util.subp([hostname_command, hostname])
+ msg = ("phostname=%s hostname=%s policy=%s interface=%s" %
+ (prev_hostname, hostname, policy, interface))
+
if util.is_false(policy):
+ LOG.debug("pubhname: policy false, skipping [%s]", msg)
return
if prev_hostname == hostname and policy != "force":
+ LOG.debug("pubhname: no change, policy != force. skipping. [%s]", msg)
return
env = os.environ.copy()
env['interface'] = interface
+ env['hostname'] = hostname
+ env['old_hostname'] = prev_hostname
if command == "builtin":
command = BOUNCE_COMMAND
- util.subp(command, shell=(not isinstance(command, list)), capture=True)
+ LOG.debug("pubhname: publishing hostname [%s]", msg)
+ shell = not isinstance(command, (list, tuple))
+ (output, err) = util.subp(command, shell=shell, capture=True, env=env)
+ LOG.debug("output: %s. err: %s", output, err)
def crtfile_to_pubkey(fname):