Browse code

Update WALinuxAgent to 2.2.14

Change-Id: I5787bcc19c53c63aaf7ad403c03decbffa47c60f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3312
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>

suezzelur authored on 2017/07/22 08:00:57
Showing 3 changed files
... ...
@@ -1,22 +1,25 @@
1 1
 Name:           WALinuxAgent
2 2
 Summary:        The Windows Azure Linux Agent
3
-Version:        2.0.18
4
-Release:        4%{?dist}
3
+Version:        2.2.14
4
+Release:        1%{?dist}
5 5
 License:        Apache License Version 2.0
6 6
 Group:          System/Daemons
7
-Url:            http://go.microsoft.com/fwlink/?LinkId=250998
7
+Url:            https://github.com/Azure/WALinuxAgent
8 8
 Source0:        %{name}-%{version}.tar.gz
9 9
 Patch0:         photondistroadd.patch
10
-%define sha1 WALinuxAgent=76238745a0ec598920f37a6445e383dab23c9f1b
10
+%define sha1 WALinuxAgent=f417009479ea7168ee0f2daa38328c167b4f874b
11 11
 Vendor:		VMware, Inc.
12 12
 Distribution:	Photon
13 13
 
14 14
 BuildRequires:  python2
15 15
 BuildRequires:  python2-libs
16 16
 BuildRequires:  python-setuptools
17
+BuildRequires:  python-xml
17 18
 BuildRequires:  systemd
19
+
18 20
 Requires:       python2
19 21
 Requires:       python2-libs
22
+Requires:       python-xml
20 23
 Requires:       python-pyasn1
21 24
 Requires:       openssh
22 25
 Requires:       openssl
... ...
@@ -36,18 +39,16 @@ VMs in the Windows Azure cloud. This package should be installed on Linux disk
36 36
 images that are built to run in the Windows Azure environment.
37 37
 
38 38
 %prep
39
-%setup -q
40
-find . -type f -exec sed -i 's/\r//' {} +
41
-find . -type f -exec chmod 0644 {} +
42
-%patch -P 0 -p1
39
+%setup -q -n WALinuxAgent-2.2.14
40
+%patch0 -p1
43 41
 
44 42
 %pre -p /bin/sh
45 43
 
46 44
 %build
47
-python2 setup.py build
45
+python2 setup.py build -b py2
48 46
 
49 47
 %install
50
-python2 setup.py install --prefix=%{_prefix} --lnx-distro='photon' --init-system='systemd' --root=%{buildroot}
48
+python2 -tt setup.py build -b py2 install --prefix=%{_prefix} --lnx-distro='photonos' --root=%{buildroot} --force
51 49
 mkdir -p  %{buildroot}/%{_localstatedir}/log
52 50
 mkdir -p -m 0700 %{buildroot}/%{_sharedstatedir}/waagent
53 51
 touch %{buildroot}/%{_localstatedir}/log/waagent.log
... ...
@@ -67,17 +68,18 @@ python2 setup.py check && python2 setup.py test
67 67
 
68 68
 %files
69 69
 /usr/lib/systemd/system/*
70
-%attr(0755,root,root) %{_sysconfdir}/udev/rules.d/99-azure-product-uuid.rules
71 70
 %defattr(0644,root,root,0755)
72
-%doc Changelog LICENSE-2.0.txt NOTICE README
73
-%attr(0755,root,root) %{_sbindir}/waagent
74
-%config(noreplace) %{_sysconfdir}/logrotate.d/waagent
71
+%doc Changelog
72
+%attr(0755,root,root) %{_bindir}/waagent
73
+%attr(0755,root,root) %{_bindir}/waagent2.0
75 74
 %config %{_sysconfdir}/waagent.conf
76 75
 %ghost %{_localstatedir}/log/waagent.log
77 76
 %dir %attr(0700, root, root) %{_sharedstatedir}/waagent
78
-
77
+/usr/lib/python2.7/site-packages/*
79 78
 
80 79
 %changelog
80
+* Thu Jul 13 2017 Anish Swaminathan <anishs@vmware.com> 2.2.14-1
81
+- Update to 2.2.14
81 82
 * Thu Jun 01 2017 Dheeraj Shetty <dheerajs@vmware.com> 2.0.18-4
82 83
 - Use python2 explicitly to build
83 84
 * Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.0.18-3
... ...
@@ -91,4 +93,4 @@ python2 setup.py check && python2 setup.py test
91 91
 * Thu Aug 6 2015 Anish Swaminathan <anishs@vmware.com>
92 92
 - Added sha1sum
93 93
 * Fri Mar 13 2015 - mbassiouny@vmware.com
94
-- Initial pacaking for Discus
94
+- Initial packaging
... ...
@@ -1,151 +1,247 @@
1
-diff -ru WALinuxAgent-2.0.18/waagent WALinuxAgent-2.0.18-new/waagent
2
-+++ WALinuxAgent-2.0.18-new/waagent	2016-04-29 01:03:04.294204270 -0700
3
-@@ -2403,6 +2403,139 @@
4
-         Run('/sbin/usermod ' + user + ' -G ""')
5
-         super(fedoraDistro, self).DeleteAccount(user)
6
- 
7
-+
8
-+############################################################    
9
-+# photonDistro
10
-+############################################################    
11
-+
12
-+class photonDistro(AbstractDistro):
13
-+    """
14
-+    photon Distro concrete class
15
-+    Put photon specific behavior here...
16
-+    """
17
-+    CORE_UID = 500
18
-+
1
+diff -rupN WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/factory.py WALinuxAgent-2.2.14/azurelinuxagent/common/osutil/factory.py
2
+--- WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/factory.py	2017-06-22 16:00:39.000000000 -0700
3
+@@ -21,6 +21,7 @@ from azurelinuxagent.common.version impo
4
+ from .default import DefaultOSUtil
5
+ from .arch import ArchUtil
6
+ from .clearlinux import ClearLinuxUtil
7
++from .photonos import PhotonOSUtil
8
+ from .coreos import CoreOSUtil
9
+ from .debian import DebianOSUtil
10
+ from .freebsd import FreeBSDOSUtil
11
+@@ -44,6 +45,9 @@ def get_osutil(distro_name=DISTRO_NAME,
12
+     if distro_name == "clear linux software for intel architecture":
13
+         return ClearLinuxUtil()
14
+
15
++    if distro_name == "photonos":
16
++        return PhotonOSUtil()
17
++
18
+     if distro_name == "ubuntu":
19
+         if Version(distro_version) == Version("12.04") or Version(distro_version) == Version("12.10"):
20
+             return Ubuntu12OSUtil()
21
+diff -rupN WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/photonos.py WALinuxAgent-2.2.14/azurelinuxagent/common/osutil/photonos.py
22
+--- WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/photonos.py	1969-12-31 16:00:00.000000000 -0800
23
+@@ -0,0 +1,88 @@
24
++#
25
++# Copyright 2017 Microsoft Corporation
26
++#
27
++# Licensed under the Apache License, Version 2.0 (the "License");
28
++# you may not use this file except in compliance with the License.
29
++# You may obtain a copy of the License at
30
++#
31
++#     http://www.apache.org/licenses/LICENSE-2.0
32
++#
33
++# Unless required by applicable law or agreed to in writing, software
34
++# distributed under the License is distributed on an "AS IS" BASIS,
35
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36
++# See the License for the specific language governing permissions and
37
++# limitations under the License.
38
++#
39
++# Requires Python 2.4+ and Openssl 1.0+
40
++#
41
++
42
++import os
43
++import re
44
++import pwd
45
++import shutil
46
++import socket
47
++import array
48
++import struct
49
++import fcntl
50
++import time
51
++import base64
52
++import azurelinuxagent.common.conf as conf
53
++import azurelinuxagent.common.logger as logger
54
++import azurelinuxagent.common.utils.fileutil as fileutil
55
++import azurelinuxagent.common.utils.shellutil as shellutil
56
++import azurelinuxagent.common.utils.textutil as textutil
57
++from azurelinuxagent.common.osutil.default import DefaultOSUtil
58
++
59
++class PhotonOSUtil(DefaultOSUtil):
19 60
 +    def __init__(self):
20
-+        super(photonDistro,self).__init__()
21
-+        self.requiredDeps += [ "/bin/systemctl" ]
22
-+        self.agent_service_name = 'waagent'
23
-+        self.init_script_file='/usr/lib/systemd/system/waagent.service'
24
-+        self.dhcp_client_name='systemd-networkd'
25
-+        self.getpidcmd='pidof '
26
-+        self.shadow_file_mode=0640
27
-+        self.dhcp_enabled=True
28
-+
29
-+    def checkPackageInstalled(self,p):
30
-+        """
31
-+        There is no package manager in Photon.  Return 1 since it must be preinstalled.
32
-+        """
33
-+        return 1
34
-+
35
-+    def checkDependencies(self):
36
-+        for a in self.requiredDeps:
37
-+            if Run("which " + a + " > /dev/null 2>&1",chk_err=False):
38
-+                Error("Missing required dependency: " + a)
39
-+                return 1
40
-+        return 0
41
-+
42
-+
43
-+    def checkPackageUpdateable(self,p):
44
-+        """
45
-+        There is no package manager in Photon.  Return 0 since it can't be updated via package.
46
-+        """
47
-+        return 0
48
-+
49
-+    def startAgentService(self):
50
-+        return Run('systemctl start ' + self.agent_service_name)
51
-+
52
-+    def stopAgentService(self):
53
-+        return Run('systemctl stop ' + self.agent_service_name)
54
-+
55
-+    def restartSshService(self):
56
-+        return Run('systemctl restart sshd')
57
-+
58
-+    def sshDeployPublicKey(self,fprint,path):
59
-+        """
60
-+        We support PKCS8.
61
-+        """
62
-+        if Run("ssh-keygen -i -m PKCS8 -f " + fprint + " >> " + path):
63
-+            return 1
64
-+        else :
65
-+            return 0
66
-+
67
-+    def RestartInterface(self, iface):
68
-+        Run("systemctl restart systemd-networkd")
69
-+
70
-+    def CreateAccount(self, user, password, expiration, thumbprint):
71
-+        """
72
-+        Create a user account, with 'user', 'password', 'expiration', ssh keys
73
-+        and sudo permissions.
74
-+        Returns None if successful, error string on failure.
75
-+        """
76
-+        userentry = None
77
-+        try:
78
-+            userentry = pwd.getpwnam(user)
79
-+        except:
80
-+            pass
81
-+        uidmin = None
82
-+        try:
83
-+            uidmin = int(GetLineStartingWith("UID_MIN", "/etc/login.defs").split()[1])
84
-+        except:
85
-+            pass
86
-+        if uidmin == None:
87
-+            uidmin = 100
88
-+        if userentry != None and userentry[2] < uidmin and userentry[2] != self.CORE_UID:
89
-+            Error("CreateAccount: " + user + " is a system user. Will not set password.")
90
-+            return "Failed to set password for system user: " + user + " (0x06)."
91
-+        if userentry == None:
92
-+            command = "useradd --create-home --password '*' " + user
93
-+            if expiration != None:
94
-+                command += " --expiredate " + expiration.split('.')[0]
95
-+            if Run(command):
96
-+                Error("Failed to create user account: " + user)
97
-+                return "Failed to create user account: " + user + " (0x07)."
98
-+        else:
99
-+            Log("CreateAccount: " + user + " already exists. Will update password.")
100
-+        if password != None:
101
-+            RunSendStdin("chpasswd", user + ":" + password + "\n")
61
++        super(PhotonOSUtil, self).__init__()
62
++        self.agent_conf_file_path = '/etc/waagent.conf'
63
++
64
++    def is_dhcp_enabled(self):
65
++        return True
66
++
67
++    def start_network(self) :
68
++        return shellutil.run("systemctl start systemd-networkd", chk_err=False)
69
++
70
++    def restart_if(self, iface):
71
++        shellutil.run("systemctl restart systemd-networkd")
72
++
73
++    def restart_ssh_service(self):
74
++        shellutil.run("systemctl restart sshd")
75
++
76
++    def stop_dhcp_service(self):
77
++        return shellutil.run("systemctl stop systemd-networkd", chk_err=False)
78
++
79
++    def start_dhcp_service(self):
80
++        return shellutil.run("systemctl start systemd-networkd", chk_err=False)
81
++
82
++    def start_agent_service(self):
83
++        return shellutil.run("systemctl start waagent", chk_err=False)
84
++
85
++    def stop_agent_service(self):
86
++        return shellutil.run("systemctl stop waagent", chk_err=False)
87
++
88
++    def get_dhcp_pid(self):
89
++        ret= shellutil.run_get_output("pidof systemd-networkd")
90
++        return ret[1] if ret[0] == 0 else None
91
++
92
++    def conf_sshd(self, disable_password):
93
++        pass
94
++
95
++    def del_root_password(self):
102 96
 +        try:
103
-+            if password == None:
104
-+                SetFileContents("/etc/sudoers.d/waagent", user + " ALL = (ALL) NOPASSWD: ALL\n")
97
++            passwd_file_path = conf.get_passwd_file_path()
98
++            try:
99
++                passwd_content = fileutil.read_file(passwd_file_path)
100
++                if not passwd_content:
101
++                    raise FileNotFoundError
102
++            except FileNotFoundError:
103
++                new_passwd = ["root:*LOCK*:14600::::::"]
105 104
 +            else:
106
-+                SetFileContents("/etc/sudoers.d/waagent", user + " ALL = (ALL) ALL\n")
107
-+            os.chmod("/etc/sudoers.d/waagent", 0440)
108
-+        except:
109
-+            Error("CreateAccount: Failed to configure sudo access for user.")
110
-+            return "Failed to configure sudo privileges (0x08)."
111
-+        home = MyDistro.GetHome()
112
-+        if thumbprint != None:
113
-+            dir = home + "/" + user + "/.ssh"
114
-+            CreateDir(dir, user, 0700)
115
-+            pub = dir + "/id_rsa.pub"
116
-+            prv = dir + "/id_rsa"
117
-+            Run("ssh-keygen -y -f " + thumbprint + ".prv > " + pub)
118
-+            SetFileContents(prv, GetFileContents(thumbprint + ".prv"))
119
-+            for f in [pub, prv]:
120
-+                os.chmod(f, 0600)
121
-+                ChangeOwner(f, user)
122
-+            SetFileContents(dir + "/authorized_keys", GetFileContents(pub))
123
-+            ChangeOwner(dir + "/authorized_keys", user)
124
-+        Log("Created user account: " + user)
125
-+        return None
126
-+
127
-+    def startDHCP(self):
128
-+        Run("systemctl start " + self.dhcp_client_name, chk_err=False)
129
-+
130
-+    def stopDHCP(self):
131
-+        Run("systemctl stop " + self.dhcp_client_name, chk_err=False)
132
-+
133
-+    def translateCustomData(self, data):
134
-+        return base64.b64decode(data)
135
-+
136
-+    def getConfigurationPath(self):
137
-+        return "/etc/waagent.conf"
138
-+
139
-+
140
- ############################################################    
141
- #	FreeBSD
142
- ############################################################    
143
-@@ -6934,6 +7067,7 @@
144
-     Return MyDistro object.
145
-     NOTE: Logging is not initialized at this point.
146
-     """
147
-+    dist_class_name = 'photonDistro'
148
-     if dist_class_name == '':
149
-         if 'Linux' in platform.system():
150
-             Distro=DistInfo()[0]
105
++                passwd = passwd_content.split('\n')
106
++                new_passwd = [x for x in passwd if not x.startswith("root:")]
107
++                new_passwd.insert(0, "root:*LOCK*:14600::::::")
108
++            fileutil.write_file(passwd_file_path, "\n".join(new_passwd))
109
++        except IOError as e:
110
++            raise OSUtilError("Failed to delete root password:{0}".format(e))
111
++        pass
112
+diff -rupN WALinuxAgent-2.2.14-old/azurelinuxagent/common/version.py WALinuxAgent-2.2.14/azurelinuxagent/common/version.py
113
+--- WALinuxAgent-2.2.14-old/azurelinuxagent/common/version.py	2017-06-22 16:00:39.000000000 -0700
114
+@@ -98,6 +98,9 @@ def get_distro():
115
+     if os.path.exists("/etc/euleros-release"):
116
+         osinfo[0] = "euleros"
117
+
118
++    if os.path.exists("/etc/photon-release"):
119
++        osinfo[0] = "photonos"
120
++
121
+     # The platform.py lib has issue with detecting BIG-IP linux distribution.
122
+     # Merge the following patch provided by F5.
123
+     if os.path.exists("/shared/vadc"):
124
+diff -rupN WALinuxAgent-2.2.14-old/config/photonos/waagent.conf WALinuxAgent-2.2.14/config/photonos/waagent.conf
125
+--- WALinuxAgent-2.2.14-old/config/photonos/waagent.conf	1969-12-31 16:00:00.000000000 -0800
126
+@@ -0,0 +1,81 @@
127
++#
128
++# Microsoft Azure Linux Agent Configuration
129
++#
130
++
131
++# Specified program is invoked with the argument "Ready" when we report ready status
132
++# to the endpoint server.
133
++Role.StateConsumer=None
134
++
135
++# Specified program is invoked with XML file argument specifying role
136
++#  configuration.
137
++Role.ConfigurationConsumer=None
138
++
139
++# Specified program is invoked with XML file argument specifying role topology.
140
++Role.TopologyConsumer=None
141
++
142
++# Enable instance creation
143
++Provisioning.Enabled=y
144
++
145
++# Rely on cloud-init to provision
146
++Provisioning.UseCloudInit=n
147
++
148
++# Password authentication for root account will be unavailable.
149
++Provisioning.DeleteRootPassword=y
150
++
151
++# Generate fresh host key pair.
152
++Provisioning.RegenerateSshHostKeyPair=y
153
++
154
++# Supported values are "rsa", "dsa" and "ecdsa".
155
++Provisioning.SshHostKeyPairType=rsa
156
++
157
++# Monitor host name changes and publish changes via DHCP requests.
158
++Provisioning.MonitorHostName=y
159
++
160
++# Decode CustomData from Base64.
161
++Provisioning.DecodeCustomData=y
162
++
163
++# Execute CustomData after provisioning.
164
++Provisioning.ExecuteCustomData=n
165
++
166
++# Allow reset password of sys user
167
++Provisioning.AllowResetSysUser=n
168
++
169
++# Format if unformatted. If 'n', resource disk will not be mounted.
170
++ResourceDisk.Format=y
171
++
172
++# File system on the resource disk
173
++# Typically ext3 or ext4. FreeBSD images should use 'ufs2' here.
174
++ResourceDisk.Filesystem=ext4
175
++
176
++# Mount point for the resource disk
177
++ResourceDisk.MountPoint=/mnt/resource
178
++
179
++# Create and use swapfile on resource disk.
180
++ResourceDisk.EnableSwap=n
181
++
182
++# Size of the swapfile.
183
++ResourceDisk.SwapSizeMB=0
184
++
185
++# Enable verbose logging (y|n)
186
++Logs.Verbose=n
187
++
188
++# Is FIPS enabled
189
++OS.EnableFIPS=n
190
++
191
++# Root device timeout in seconds.
192
++OS.RootDeviceScsiTimeout=300
193
++
194
++# If "None", the system default version is used.
195
++OS.OpensslPath=None
196
++
197
++# Set the path to SSH keys and configuration files
198
++OS.SshDir=/etc/ssh
199
++
200
++# Enable or disable self-update, default is enabled
201
++AutoUpdate.Enabled=y
202
++AutoUpdate.GAFamily=Prod
203
++
204
++# Determine if the overprovisioning feature is enabled. If yes, hold extension
205
++# handling until inVMArtifactsProfile.OnHold is false.
206
++# Default is disabled
207
++# EnableOverProvisioning=n
208
+diff -rupN WALinuxAgent-2.2.14-old/init/photonos/waagent.service WALinuxAgent-2.2.14/init/photonos/waagent.service
209
+--- WALinuxAgent-2.2.14-old/init/photonos/waagent.service	1969-12-31 16:00:00.000000000 -0800
210
+@@ -0,0 +1,16 @@
211
++[Unit]
212
++Description=Azure Linux Agent
213
++Wants=network-online.target sshd.service sshd-keygen.service
214
++After=network-online.target
215
++
216
++ConditionFileIsExecutable=/usr/bin/waagent
217
++ConditionPathExists=/etc/waagent.conf
218
++
219
++[Service]
220
++Type=simple
221
++ExecStart=/usr/bin/python -u /usr/bin/waagent -daemon
222
++Restart=always
223
++RestartSec=5
224
++
225
++[Install]
226
++WantedBy=multi-user.target
227
+diff -rupN WALinuxAgent-2.2.14-old/setup.py WALinuxAgent-2.2.14/setup.py
228
+--- WALinuxAgent-2.2.14-old/setup.py	2017-06-22 16:00:39.000000000 -0700
229
+@@ -112,6 +112,12 @@ def get_data_files(name, version, fullna
230
+                        src=["config/clearlinux/waagent.conf"])
231
+         set_systemd_files(data_files, dest='/usr/lib/systemd/system',
232
+                           src=["init/clearlinux/waagent.service"])
233
++    elif name == 'photonos':
234
++        set_bin_files(data_files, dest="/usr/bin")
235
++        set_conf_files(data_files, dest="/etc",
236
++                       src=["config/photonos/waagent.conf"])
237
++        set_systemd_files(data_files, dest='/usr/lib/systemd/system',
238
++                          src=["init/photonos/waagent.service"])
239
+     elif name == 'ubuntu':
240
+         set_bin_files(data_files)
241
+         set_conf_files(data_files, src=["config/ubuntu/waagent.conf"])
... ...
@@ -8,6 +8,9 @@ ln -s ../docker.service docker.service
8 8
 ln -s ../waagent.service waagent.service
9 9
 ln -s ../sshd-keygen.service sshd-keygen.service
10 10
 
11
+#Disable cloud-init
12
+rm -rf /etc/systemd/system/cloud-init.target.wants
13
+
11 14
 # Remove ssh host keys and add script to regenerate them at boot time.
12 15
 
13 16
 rm -f /etc/ssh/ssh_host_*
... ...
@@ -15,7 +18,7 @@ rm -f /etc/ssh/ssh_host_*
15 15
 sudo groupadd docker
16 16
 sudo groupadd sudo
17 17
 
18
-rm /root/.ssh/authorized_keys   
18
+rm /root/.ssh/authorized_keys
19 19
 
20 20
 # ssh server config
21 21
 # Override old values
... ...
@@ -48,15 +51,11 @@ echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,
48 48
 echo "Tunnel no" >> /etc/ssh/ssh_config
49 49
 echo "ServerAliveInterval 180" >> /etc/ssh/ssh_config
50 50
 
51
-sed -i 's/net.ifnames=0//' /boot/grub/grub.cfg
52
-sed -i 's/$photon_cmdline/init=\/lib\/systemd\/systemd loglevel=3 ro console=ttyS0 earlyprintk=ttyS0 rootdelay=30/' /boot/grub/grub.cfg
51
+sed -i 's/$photon_cmdline $systemd_cmdline/init=\/lib\/systemd\/systemd loglevel=3 ro console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 fsck.repair=yes rootdelay=300/' /boot/grub/grub.cfg
53 52
 
54
-# Disable loading/unloading of modules
55
-echo 1 > /proc/sys/kernel/modules_disabled
56 53
 
57 54
 # Remove kernel symbols
58 55
 rm /boot/system.map*
59 56
 
60
-sudo waagent -force -deprovision
61
-export HISTSIZE=0
62
-systemctl enable waagent.service
57
+waagent -force -deprovision+user
58
+export HISTSIZE=0
63 59
\ No newline at end of file