forked from vmware/photon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphotondistroadd.patch
247 lines (245 loc) · 9.06 KB
/
photondistroadd.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
diff -rupN WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/factory.py WALinuxAgent-2.2.14/azurelinuxagent/common/osutil/factory.py
--- WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/factory.py 2017-06-22 16:00:39.000000000 -0700
+++ WALinuxAgent-2.2.14/azurelinuxagent/common/osutil/factory.py 2017-07-18 13:22:05.614854350 -0700
@@ -21,6 +21,7 @@ from azurelinuxagent.common.version impo
from .default import DefaultOSUtil
from .arch import ArchUtil
from .clearlinux import ClearLinuxUtil
+from .photonos import PhotonOSUtil
from .coreos import CoreOSUtil
from .debian import DebianOSUtil
from .freebsd import FreeBSDOSUtil
@@ -44,6 +45,9 @@ def get_osutil(distro_name=DISTRO_NAME,
if distro_name == "clear linux software for intel architecture":
return ClearLinuxUtil()
+ if distro_name == "photonos":
+ return PhotonOSUtil()
+
if distro_name == "ubuntu":
if Version(distro_version) == Version("12.04") or Version(distro_version) == Version("12.10"):
return Ubuntu12OSUtil()
diff -rupN WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/photonos.py WALinuxAgent-2.2.14/azurelinuxagent/common/osutil/photonos.py
--- WALinuxAgent-2.2.14-old/azurelinuxagent/common/osutil/photonos.py 1969-12-31 16:00:00.000000000 -0800
+++ WALinuxAgent-2.2.14/azurelinuxagent/common/osutil/photonos.py 2017-07-18 12:29:32.146925587 -0700
@@ -0,0 +1,88 @@
+#
+# Copyright 2017 Microsoft Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Requires Python 2.4+ and Openssl 1.0+
+#
+
+import os
+import re
+import pwd
+import shutil
+import socket
+import array
+import struct
+import fcntl
+import time
+import base64
+import azurelinuxagent.common.conf as conf
+import azurelinuxagent.common.logger as logger
+import azurelinuxagent.common.utils.fileutil as fileutil
+import azurelinuxagent.common.utils.shellutil as shellutil
+import azurelinuxagent.common.utils.textutil as textutil
+from azurelinuxagent.common.osutil.default import DefaultOSUtil
+
+class PhotonOSUtil(DefaultOSUtil):
+ def __init__(self):
+ super(PhotonOSUtil, self).__init__()
+ self.agent_conf_file_path = '/etc/waagent.conf'
+
+ def is_dhcp_enabled(self):
+ return True
+
+ def start_network(self) :
+ return shellutil.run("systemctl start systemd-networkd", chk_err=False)
+
+ def restart_if(self, iface):
+ shellutil.run("systemctl restart systemd-networkd")
+
+ def restart_ssh_service(self):
+ shellutil.run("systemctl restart sshd")
+
+ def stop_dhcp_service(self):
+ return shellutil.run("systemctl stop systemd-networkd", chk_err=False)
+
+ def start_dhcp_service(self):
+ return shellutil.run("systemctl start systemd-networkd", chk_err=False)
+
+ def start_agent_service(self):
+ return shellutil.run("systemctl start waagent", chk_err=False)
+
+ def stop_agent_service(self):
+ return shellutil.run("systemctl stop waagent", chk_err=False)
+
+ def get_dhcp_pid(self):
+ ret= shellutil.run_get_output("pidof systemd-networkd")
+ return ret[1] if ret[0] == 0 else None
+
+ def conf_sshd(self, disable_password):
+ pass
+
+ def del_root_password(self):
+ try:
+ passwd_file_path = conf.get_passwd_file_path()
+ try:
+ passwd_content = fileutil.read_file(passwd_file_path)
+ if not passwd_content:
+ raise FileNotFoundError
+ except FileNotFoundError:
+ new_passwd = ["root:*LOCK*:14600::::::"]
+ else:
+ passwd = passwd_content.split('\n')
+ new_passwd = [x for x in passwd if not x.startswith("root:")]
+ new_passwd.insert(0, "root:*LOCK*:14600::::::")
+ fileutil.write_file(passwd_file_path, "\n".join(new_passwd))
+ except IOError as e:
+ raise OSUtilError("Failed to delete root password:{0}".format(e))
+ pass
diff -rupN WALinuxAgent-2.2.14-old/azurelinuxagent/common/version.py WALinuxAgent-2.2.14/azurelinuxagent/common/version.py
--- WALinuxAgent-2.2.14-old/azurelinuxagent/common/version.py 2017-06-22 16:00:39.000000000 -0700
+++ WALinuxAgent-2.2.14/azurelinuxagent/common/version.py 2017-07-21 17:42:54.424578877 -0700
@@ -98,6 +98,9 @@ def get_distro():
if os.path.exists("/etc/euleros-release"):
osinfo[0] = "euleros"
+ if os.path.exists("/etc/photon-release"):
+ osinfo[0] = "photonos"
+
# The platform.py lib has issue with detecting BIG-IP linux distribution.
# Merge the following patch provided by F5.
if os.path.exists("/shared/vadc"):
diff -rupN WALinuxAgent-2.2.14-old/config/photonos/waagent.conf WALinuxAgent-2.2.14/config/photonos/waagent.conf
--- WALinuxAgent-2.2.14-old/config/photonos/waagent.conf 1969-12-31 16:00:00.000000000 -0800
+++ WALinuxAgent-2.2.14/config/photonos/waagent.conf 2017-07-17 16:21:35.248562852 -0700
@@ -0,0 +1,81 @@
+#
+# Microsoft 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
+
+# Rely on cloud-init to provision
+Provisioning.UseCloudInit=n
+
+# Password authentication for root account will be unavailable.
+Provisioning.DeleteRootPassword=y
+
+# Generate fresh host key pair.
+Provisioning.RegenerateSshHostKeyPair=y
+
+# Supported values are "rsa", "dsa" and "ecdsa".
+Provisioning.SshHostKeyPairType=rsa
+
+# Monitor host name changes and publish changes via DHCP requests.
+Provisioning.MonitorHostName=y
+
+# Decode CustomData from Base64.
+Provisioning.DecodeCustomData=y
+
+# Execute CustomData after provisioning.
+Provisioning.ExecuteCustomData=n
+
+# Allow reset password of sys user
+Provisioning.AllowResetSysUser=n
+
+# 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
+
+# Enable verbose logging (y|n)
+Logs.Verbose=n
+
+# Is FIPS enabled
+OS.EnableFIPS=n
+
+# Root device timeout in seconds.
+OS.RootDeviceScsiTimeout=300
+
+# If "None", the system default version is used.
+OS.OpensslPath=None
+
+# Set the path to SSH keys and configuration files
+OS.SshDir=/etc/ssh
+
+# Enable or disable self-update, default is enabled
+AutoUpdate.Enabled=y
+AutoUpdate.GAFamily=Prod
+
+# Determine if the overprovisioning feature is enabled. If yes, hold extension
+# handling until inVMArtifactsProfile.OnHold is false.
+# Default is disabled
+# EnableOverProvisioning=n
diff -rupN WALinuxAgent-2.2.14-old/init/photonos/waagent.service WALinuxAgent-2.2.14/init/photonos/waagent.service
--- WALinuxAgent-2.2.14-old/init/photonos/waagent.service 1969-12-31 16:00:00.000000000 -0800
+++ WALinuxAgent-2.2.14/init/photonos/waagent.service 2017-07-21 17:44:11.849359536 -0700
@@ -0,0 +1,16 @@
+[Unit]
+Description=Azure Linux Agent
+Wants=network-online.target sshd.service sshd-keygen.service
+After=network-online.target
+
+ConditionFileIsExecutable=/usr/bin/waagent
+ConditionPathExists=/etc/waagent.conf
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/python -u /usr/bin/waagent -daemon
+Restart=always
+RestartSec=5
+
+[Install]
+WantedBy=multi-user.target
diff -rupN WALinuxAgent-2.2.14-old/setup.py WALinuxAgent-2.2.14/setup.py
--- WALinuxAgent-2.2.14-old/setup.py 2017-06-22 16:00:39.000000000 -0700
+++ WALinuxAgent-2.2.14/setup.py 2017-07-21 17:50:50.695661748 -0700
@@ -112,6 +112,12 @@ def get_data_files(name, version, fullna
src=["config/clearlinux/waagent.conf"])
set_systemd_files(data_files, dest='/usr/lib/systemd/system',
src=["init/clearlinux/waagent.service"])
+ elif name == 'photonos':
+ set_bin_files(data_files, dest="/usr/bin")
+ set_conf_files(data_files, dest="/etc",
+ src=["config/photonos/waagent.conf"])
+ set_systemd_files(data_files, dest='/usr/lib/systemd/system',
+ src=["init/photonos/waagent.service"])
elif name == 'ubuntu':
set_bin_files(data_files)
set_conf_files(data_files, src=["config/ubuntu/waagent.conf"])