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"])