diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-move-waagent.conf-under-usr-share-oem.patch b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-move-waagent.conf-under-usr-share-oem.patch new file mode 100644 index 0000000000..bd6f6174fc --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0001-move-waagent.conf-under-usr-share-oem.patch @@ -0,0 +1,44 @@ +From c2fd79f7dd3110001f25669e343d8b8fc835e5ce Mon Sep 17 00:00:00 2001 +From: Alex Crawford +Date: Wed, 1 Oct 2014 10:14:41 -0700 +Subject: [PATCH] move waagent.conf under /usr/share/oem + +--- + waagent | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/waagent b/waagent +index 15f817d..35b3755 100644 +--- a/waagent ++++ b/waagent +@@ -2547,14 +2547,14 @@ class LoadBalancerProbeServer(object): + + class ConfigurationProvider(object): + """ +- Parse amd store key:values in /etc/waagent.conf. ++ Parse amd store key:values in /usr/share/oem/waagent.conf. + """ + def __init__(self): + self.values = dict() +- if os.path.isfile("/etc/waagent.conf") == False: +- raise Exception("Missing configuration in /etc/waagent.conf") ++ if os.path.isfile("/usr/share/oem/waagent.conf") == False: ++ raise Exception("Missing configuration in /usr/share/oem/waagent.conf") + try: +- for line in GetFileContents("/etc/waagent.conf").split('\n'): ++ for line in GetFileContents("/usr/share/oem/waagent.conf").split('\n'): + if not line.startswith("#") and "=" in line: + parts = line.split()[0].split('=') + value = parts[1].strip("\" ") +@@ -2563,7 +2563,7 @@ class ConfigurationProvider(object): + else: + self.values[parts[0]] = None + except: +- Error("Unable to parse /etc/waagent.conf") ++ Error("Unable to parse /usr/share/oem/waagent.conf") + raise + return + +-- +1.9.3 + diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0002-various-fixes-for-CoreOS-distro.patch b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0002-various-fixes-for-CoreOS-distro.patch new file mode 100644 index 0000000000..7ebe7718e7 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0002-various-fixes-for-CoreOS-distro.patch @@ -0,0 +1,127 @@ +From b6e20c997c444ce754f0b9d75646a169816dce7b Mon Sep 17 00:00:00 2001 +From: Alex Crawford +Date: Tue, 30 Sep 2014 14:55:55 -0700 +Subject: [PATCH 1/2] various fixes for CoreOS distro + +- Clean up service unit +- Add /etc/machine-id to deprovision blacklist +- Add custom RestartInterface() +- Stop networkd before running DHCP client +- Remove install/uninstall register/deregister functions +--- + waagent | 51 ++++++++++----------------------------------------- + 1 file changed, 10 insertions(+), 41 deletions(-) + +diff --git a/waagent b/waagent +index f4632c5..2271978 100644 +--- a/waagent ++++ b/waagent +@@ -935,22 +935,6 @@ class centosDistro(redhatDistro): + # CoreOSDistro + ############################################################ + +-coreos_systemd_conf = """\ +-[Unit] +-Description=Microsoft Azure Agent +-After=network.target +-After=sshd.service +-ConditionFileIsExecutable=/usr/share/oem/waagent/bin/waagent +-ConditionPathExists=/etc/systemd/system/waagent.service +- +-[Service] +-Type=simple +-ExecStart=/usr/share/oem/python/bin/python /usr/share/oem/waagent/bin/waagent -daemon +- +-[Install] +-WantedBy=multi-user.target +-""" +- + class CoreOSDistro(AbstractDistro): + """ + CoreOS Distro concrete class +@@ -961,7 +945,7 @@ class CoreOSDistro(AbstractDistro): + self.requiredDeps += [ "/usr/bin/systemctl" ] + self.agent_service_name = 'waagent' + self.init_script_file='/etc/systemd/system/waagent.service' +- self.init_file=coreos_systemd_conf ++ self.fileBlackList.append("/etc/machine-id") + self.dhcp_client_name='systemd-networkd' + self.getpidcmd='pidof ' + self.shadow_file_mode=0640 +@@ -997,35 +981,12 @@ class CoreOSDistro(AbstractDistro): + """ + return 0 + +- def installAgentServiceScriptFiles(self): +- try: +- SetFileContents(self.init_script_file, self.init_file) +- os.chmod(self.init_script_file, 0744) +- except OSError, e: +- ErrorWithPrefix('installAgentServiceScriptFiles','Exception: '+str(e)+' occured creating ' + self.init_script_file) +- return 1 +- return 0 +- +- def registerAgentService(self): +- if self.installAgentServiceScriptFiles() == 0: +- return Run('systemctl enable ' + self.agent_service_name) +- else : +- return 1 +- + def startAgentService(self): + return Run('systemctl start ' + self.agent_service_name) + + def stopAgentService(self): + return Run('systemctl stop ' + self.agent_service_name) + +- def uninstallAgentService(self): +- Run('systemctl disable ' + self.agent_service_name) +- return Run('rm ' + self.init_script_file) +- +- def unregisterAgentService(self): +- self.stopAgentService() +- return self.uninstallAgentService() +- + def restartSshService(self): + """ + Service call to re(start) the SSH service +@@ -1034,7 +995,7 @@ class CoreOSDistro(AbstractDistro): + if retcode > 0: + Error("Failed to restart SSH service with return code:" + str(retcode)) + return retcode +-# ++ + def sshDeployPublicKey(self,fprint,path): + """ + We support PKCS8. +@@ -1044,6 +1005,10 @@ class CoreOSDistro(AbstractDistro): + else : + return 0 + ++ def RestartInterface(self, iface): ++ Run("systemctl restart systemd-networkd") ++ ++ + ############################################################ + # debianDistro + ############################################################ +@@ -4307,6 +4272,8 @@ class Agent(Util): + Run("route add 255.255.255.255 dev " + ifname,chk_err=False) # We supress error logging on error. + if MyDistro.dhcp_client_name == 'wickedd-dhcp4': + Run("service " + MyDistro.dhcp_client_name + " stop",chk_err=False) ++ if MyDistro.dhcp_client_name == 'systemd-networkd': ++ Run("systemctl stop " + MyDistro.dhcp_client_name,chk_err=False) + sock.bind(("0.0.0.0", 68)) + sock.sendto(sendData, ("", 67)) + sock.settimeout(10) +@@ -4336,6 +4303,8 @@ class Agent(Util): + Log("DoDhcpWork: Removing broadcast route for DHCP.") + if MyDistro.dhcp_client_name == 'wickedd-dhcp4': + Run("service " + MyDistro.dhcp_client_name + " start",chk_err=False) ++ if MyDistro.dhcp_client_name == 'systemd-networkd': ++ Run("systemctl start " + MyDistro.dhcp_client_name,chk_err=False) + return None + + def UpdateAndPublishHostName(self, name): +-- +1.9.3 + diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0003-refactor-DHCP-start-stop-into-its-own-methods.patch b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0003-refactor-DHCP-start-stop-into-its-own-methods.patch new file mode 100644 index 0000000000..1a77359ca7 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0003-refactor-DHCP-start-stop-into-its-own-methods.patch @@ -0,0 +1,118 @@ +From eebe1780f90058d82b3fc2bb60bdaa1755c1b10a Mon Sep 17 00:00:00 2001 +From: Alex Crawford +Date: Tue, 30 Sep 2014 15:31:00 -0700 +Subject: [PATCH 2/2] refactor DHCP start/stop into its own methods + +--- + waagent | 46 ++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 38 insertions(+), 8 deletions(-) + +diff --git a/waagent b/waagent +index 2271978..15f817d 100644 +--- a/waagent ++++ b/waagent +@@ -184,6 +184,7 @@ class AbstractDistro(object): + self.sudoers_dir_base = '/etc' + self.waagent_conf_file = WaagentConf + self.shadow_file_mode=0600 ++ self.dhcp_enabled = False + + def isSelinuxSystem(self): + """ +@@ -556,6 +557,24 @@ class AbstractDistro(object): + Error("Can't find host key: {0}".format(path)) + return False + ++ def isDHCPEnabled(self): ++ return self.dhcp_enabled ++ ++ def stopDHCP(self): ++ """ ++ Stop the system DHCP client so that tha agent can bind on its port. If ++ the distro has set dhcp_enabled to True, it will need to provide an ++ implementation of this method. ++ """ ++ raise NotImplementedError('stopDHCP method missing') ++ ++ def startDHCP(self): ++ """ ++ Start the system DHCP client. If the distro has set dhcp_enabled to ++ True, it will need to provide an implementation of this method. ++ """ ++ raise NotImplementedError('startDHCP method missing') ++ + ############################################################ + # GentooDistro + ############################################################ +@@ -765,6 +784,7 @@ class SuSEDistro(AbstractDistro): + self.grubKernelBootOptionsFile = '/boot/grub/menu.lst' + self.grubKernelBootOptionsLine = 'kernel' + self.getpidcmd='pidof ' ++ self.dhcp_enabled=True + + def checkPackageInstalled(self,p): + if Run("rpm -q " + p,chk_err=False): +@@ -796,6 +816,12 @@ class SuSEDistro(AbstractDistro): + def unregisterAgentService(self): + self.stopAgentService() + return self.uninstallAgentService() ++ ++ def StartDHCP(self): ++ Run("service " + self.dhcp_client_name + " start", chk_err=False) ++ ++ def StopDHCP(self): ++ Run("service " + self.dhcp_client_name + " stop", chk_err=False) + + ############################################################ + # redhatDistro +@@ -951,6 +977,7 @@ class CoreOSDistro(AbstractDistro): + self.shadow_file_mode=0640 + self.waagent_path='/usr/share/oem/waagent/bin' + self.python_path='/usr/share/oem/python/bin' ++ self.dhcp_enabled=True + if 'PATH' in os.environ: + os.environ['PATH'] = "{0}:{1}".format(os.environ['PATH'], self.python_path) + else: +@@ -1008,6 +1035,12 @@ class CoreOSDistro(AbstractDistro): + def RestartInterface(self, iface): + Run("ip link set dev " + iface + " down && ip link set dev " + iface + " up") + ++ def StartDHCP(self): ++ Run("systemctl start " + self.dhcp_client_name, chk_err=False) ++ ++ def StopDHCP(self): ++ Run("systemctl stop " + self.dhcp_client_name, chk_err=False) ++ + + ############################################################ + # debianDistro +@@ -4270,10 +4303,9 @@ class Agent(Util): + ifname=MyDistro.GetInterfaceName() + Log("DoDhcpWork: Missing default route - adding broadcast route for DHCP.") + Run("route add 255.255.255.255 dev " + ifname,chk_err=False) # We supress error logging on error. +- if MyDistro.dhcp_client_name == 'wickedd-dhcp4': +- Run("service " + MyDistro.dhcp_client_name + " stop",chk_err=False) +- if MyDistro.dhcp_client_name == 'systemd-networkd': +- Run("systemctl stop " + MyDistro.dhcp_client_name,chk_err=False) ++ if MyDistro.isDHCPEnabled(): ++ MyDistro.StopDHCP() ++ + sock.bind(("0.0.0.0", 68)) + sock.sendto(sendData, ("", 67)) + sock.settimeout(10) +@@ -4301,10 +4333,8 @@ class Agent(Util): + #We added this route - delete it + Run("route del 255.255.255.255 dev " + ifname,chk_err=False) # We supress error logging on error. + Log("DoDhcpWork: Removing broadcast route for DHCP.") +- if MyDistro.dhcp_client_name == 'wickedd-dhcp4': +- Run("service " + MyDistro.dhcp_client_name + " start",chk_err=False) +- if MyDistro.dhcp_client_name == 'systemd-networkd': +- Run("systemctl start " + MyDistro.dhcp_client_name,chk_err=False) ++ if MyDistro.isDHCPEnabled(): ++ MyDistro.StartDHCP() + return None + + def UpdateAndPublishHostName(self, name): +-- +1.9.3 + diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0004-add-a-hook-for-translating-the-custom-data.patch b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0004-add-a-hook-for-translating-the-custom-data.patch new file mode 100644 index 0000000000..0fe2df04b1 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/0004-add-a-hook-for-translating-the-custom-data.patch @@ -0,0 +1,48 @@ +From a3a728564011481b73e6845202780401842b9002 Mon Sep 17 00:00:00 2001 +From: Alex Crawford +Date: Thu, 2 Oct 2014 08:53:48 -0700 +Subject: [PATCH] add a hook for translating the custom data + +--- + waagent | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/waagent b/waagent +index f4632c5..4efc810 100644 +--- a/waagent ++++ b/waagent +@@ -556,6 +556,12 @@ class AbstractDistro(object): + Error("Can't find host key: {0}".format(path)) + return False + ++ def translateCustomData(self, data): ++ """ ++ Translate the custom data from a Base64 encoding. Default to no-op. ++ """ ++ return data ++ + ############################################################ + # GentooDistro + ############################################################ +@@ -1044,6 +1050,9 @@ class CoreOSDistro(AbstractDistro): + else : + return 0 + ++ def translateCustomData(self, data): ++ return base64.b64decode(data) ++ + ############################################################ + # debianDistro + ############################################################ +@@ -3833,7 +3842,7 @@ class OvfEnv(object): + if len(CDSection) > 0 : + self.CustomData=GetNodeTextData(CDSection[0]) + if len(self.CustomData)>0: +- SetFileContents(LibDir + '/CustomData',self.CustomData) ++ SetFileContents(LibDir + '/CustomData', MyDistro.translateCustomData(self.CustomData)) + Log('Wrote ' + LibDir + '/CustomData') + else : + Error(' contains no data!') +-- +1.9.3 + diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/waagent.conf b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/waagent.conf new file mode 100644 index 0000000000..ecfa378df0 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/files/waagent.conf @@ -0,0 +1,57 @@ +# +# Windows Azure Linux Agent Configuration +# + +# Specified program is invoked with the argument "Ready" when we report ready status +# to the endpoint server. +Role.StateConsumer=None + +# Specified program is invoked with XML file argument specifying role +# configuration. +Role.ConfigurationConsumer=None + +# Specified program is invoked with XML file argument specifying role topology. +Role.TopologyConsumer=None + +# Enable instance creation +Provisioning.Enabled=y + +# Password authentication for root account will be unavailable. +Provisioning.DeleteRootPassword=n + +# Generate fresh host key pair. +Provisioning.RegenerateSshHostKeyPair=n + +# Supported values are "rsa", "dsa" and "ecdsa". +Provisioning.SshHostKeyPairType=ed25519 + +# Monitor host name changes and publish changes via DHCP requests. +Provisioning.MonitorHostName=y + +# Format if unformatted. If 'n', resource disk will not be mounted. +ResourceDisk.Format=y + +# File system on the resource disk +# Typically ext3 or ext4. FreeBSD images should use 'ufs2' here. +ResourceDisk.Filesystem=ext4 + +# Mount point for the resource disk +ResourceDisk.MountPoint=/mnt/resource + +# Create and use swapfile on resource disk. +ResourceDisk.EnableSwap=n + +# Size of the swapfile. +ResourceDisk.SwapSizeMB=0 + +# Respond to load balancer probes if requested by Windows Azure. +LBProbeResponder=y + +# Enable verbose logging (y|n) +Logs.Verbose=n + +# Root device timeout in seconds. +OS.RootDeviceScsiTimeout=300 + +# If "None", the system default version is used. +OS.OpensslPath=None diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/wa-linux-agent-2.0.8.ebuild b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/wa-linux-agent-2.0.8.ebuild new file mode 100644 index 0000000000..82bf6cc635 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/wa-linux-agent/wa-linux-agent-2.0.8.ebuild @@ -0,0 +1,35 @@ +# +# Copyright (c) 2014 CoreOS, Inc.. All rights reserved. +# Distributed under the terms of the GNU General Public License v2 +# $Header:$ +# + +EAPI=4 + +EGIT_REPO_URI="git://github.com/Azure/WALinuxAgent" +EGIT_COMMIT="46710d4c0bc7e5eea6827e803d599f14f2b1df17" # v2.0.8 + +inherit toolchain-funcs git-2 + +DESCRIPTION="Windows Azure Linux Agent" +HOMEPAGE="https://github.com/Azure/WALinuxAgent" +KEYWORDS="amd64" +SRC_URI="" + +LICENSE="Apache-2.0" +SLOT="0" +IUSE="" + +RDEPEND="dev-lang/python-oem" + +src_prepare() { + epatch "${FILESDIR}"/*.patch +} + +src_install() { + into "/usr/share/oem" + dobin "${S}"/waagent + + insinto "/usr/share/oem" + doins "${FILESDIR}"/waagent.conf +} diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/files/cloud-config.yml b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/files/cloud-config.yml index 3477eb670c..52763d4b82 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/files/cloud-config.yml +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/files/cloud-config.yml @@ -1,9 +1,27 @@ #cloud-config coreos: - oem: - id: azure - name: Microsoft Azure - version-id: @@OEM_VERSION_ID@@ - home-url: https://azure.microsoft.com/ - bug-report-url: https://github.com/coreos/bugs/issues + units: + - name: user-cloudinit@var-lib-waagent-CustomData.path + command: start + runtime: true + + - name: waagent.service + command: start + runtime: true + content: | + [Unit] + Description=Microsoft Azure Agent + Wants=network-online.target sshd-keygen.service + After=network-online.target sshd-keygen.service + + [Service] + Type=simple + ExecStart=/usr/share/oem/python/bin/python /usr/share/oem/bin/waagent -daemon + + oem: + id: azure + name: Microsoft Azure + version-id: @@OEM_VERSION_ID@@ + home-url: https://azure.microsoft.com/ + bug-report-url: https://github.com/coreos/bugs/issues diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/oem-azure-0.0.1-r1.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/oem-azure-0.0.1-r2.ebuild similarity index 92% rename from sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/oem-azure-0.0.1-r1.ebuild rename to sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/oem-azure-0.0.1-r2.ebuild index 803b976595..e670ec9dc8 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/oem-azure-0.0.1-r1.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-azure/oem-azure-0.0.1-r2.ebuild @@ -15,7 +15,7 @@ IUSE="" # no source directory S="${WORKDIR}" -RDEPEND="dev-lang/python-oem" +RDEPEND="app-emulation/wa-linux-agent" src_prepare() { sed -e "s\\@@OEM_VERSION_ID@@\\${PVR}\\g" \