Add Clear Linux distro support

This commit is contained in:
William Douglas
2016-10-26 21:12:05 +00:00
parent b3bfdac934
commit d4a3226142
7 changed files with 217 additions and 0 deletions
@@ -0,0 +1,91 @@
#
# Copyright 2014 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 ClearLinuxUtil(DefaultOSUtil):
def __init__(self):
super(ClearLinuxUtil, self).__init__()
self.agent_conf_file_path = '/usr/share/defaults/waagent/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):
# SSH is socket activated. No need to restart it.
pass
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):
# Don't whack the system default sshd conf
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:
# Empty file is no better than no file
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
+3
View File
@@ -21,6 +21,7 @@ from azurelinuxagent.common.version import DISTRO_NAME, DISTRO_VERSION, \
DISTRO_FULL_NAME
from .default import DefaultOSUtil
from .clearlinux import ClearLinuxUtil
from .coreos import CoreOSUtil
from .debian import DebianOSUtil
from .freebsd import FreeBSDOSUtil
@@ -32,6 +33,8 @@ from .alpine import AlpineOSUtil
def get_osutil(distro_name=DISTRO_NAME, distro_version=DISTRO_VERSION,
distro_full_name=DISTRO_FULL_NAME):
if distro_name == "clear linux software for intel architecture":
return ClearLinuxUtil()
if distro_name == "ubuntu":
if Version(distro_version) == Version("12.04") or \
Version(distro_version) == Version("12.10"):
@@ -0,0 +1,31 @@
# Microsoft Azure Linux Agent
#
# Copyright 2014 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 azurelinuxagent.common.utils.fileutil as fileutil
from azurelinuxagent.pa.deprovision.default import DeprovisionHandler, \
DeprovisionAction
class ClearLinuxDeprovisionHandler(DeprovisionHandler):
def __init__(self, distro):
self.distro = distro
def setup(self, deluser):
warnings, actions = super(ClearLinuxDeprovisionHandler, self).setup(deluser)
# Probably should just wipe /etc and /var here
return warnings, actions
@@ -21,6 +21,7 @@ from azurelinuxagent.common.version import DISTRO_NAME, DISTRO_VERSION, \
DISTRO_FULL_NAME
from .default import DeprovisionHandler
from .clearlinux import ClearLinuxDeprovisionHandler
from .coreos import CoreOSDeprovisionHandler
from .ubuntu import UbuntuDeprovisionHandler
@@ -31,6 +32,8 @@ def get_deprovision_handler(distro_name=DISTRO_NAME,
return UbuntuDeprovisionHandler()
if distro_name == "coreos":
return CoreOSDeprovisionHandler()
if distro_name == "clear linux":
return ClearLinuxDeprovisionHandler()
return DeprovisionHandler()
+67
View File
@@ -0,0 +1,67 @@
#
# 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
# 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
# Root device timeout in seconds.
OS.RootDeviceScsiTimeout=300
# If "None", the system default version is used.
OS.OpensslPath=None
# Enable or disable self-update, default is enabled
AutoUpdate.Enabled=y
AutoUpdate.GAFamily=Prod
+16
View File
@@ -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=/usr/share/defaults/waagent/waagent.conf
[Service]
Type=simple
ExecStart=/usr/bin/python -u /usr/bin/waagent -daemon
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
+6
View File
@@ -96,6 +96,12 @@ def get_data_files(name, version, fullname):
set_udev_files(data_files)
set_files(data_files, dest="/usr/share/oem",
src=["init/coreos/cloud-config.yml"])
elif name == 'clear linux software for intel architecture':
set_bin_files(data_files, dest="/usr/bin")
set_conf_files(data_files, dest="/usr/share/defaults/waagent",
src=["config/clearlinux/waagent.conf"])
set_systemd_files(data_files, dest='/usr/lib/systemd/system',
src=["init/clearlinux/waagent.service"])
elif name == 'ubuntu':
set_bin_files(data_files)
set_conf_files(data_files, src=["config/ubuntu/waagent.conf"])