|
| 1 | +# |
| 2 | +# Copyright 2018 Microsoft Corporation |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +# Requires Python 2.6+ and Openssl 1.0+ |
| 17 | +# |
| 18 | +# Azure Container Linux (ACL) is an immutable, sysext-based distro derived |
| 19 | +# from Flatcar. This osutil is a standalone copy of MarinerOSUtil with |
| 20 | +# ACL-specific overrides so that future Azure-Linux changes do not |
| 21 | +# inadvertently affect the immutable ACL image. |
| 22 | +# |
| 23 | + |
| 24 | +from azurelinuxagent.common.osutil.default import DefaultOSUtil |
| 25 | + |
| 26 | + |
| 27 | +class AclOSUtil(DefaultOSUtil): |
| 28 | + def __init__(self): |
| 29 | + super(AclOSUtil, self).__init__() |
| 30 | + self.jit_enabled = True |
| 31 | + |
| 32 | + @staticmethod |
| 33 | + def get_systemd_unit_file_install_path(): |
| 34 | + # ACL delivers waagent as a sysext; /usr is read-only. |
| 35 | + # Writable systemd units must go to /etc/systemd/system. |
| 36 | + return "/etc/systemd/system" |
| 37 | + |
| 38 | + @staticmethod |
| 39 | + def get_agent_bin_path(): |
| 40 | + return "/usr/bin" |
| 41 | + |
| 42 | + def is_dhcp_enabled(self): |
| 43 | + return True |
| 44 | + |
| 45 | + def start_network(self): |
| 46 | + self._run_command_without_raising(["systemctl", "start", "systemd-networkd"], log_error=False) |
| 47 | + |
| 48 | + def restart_if(self, ifname=None, retries=None, wait=None): |
| 49 | + self._run_command_without_raising(["systemctl", "restart", "systemd-networkd"]) |
| 50 | + |
| 51 | + def restart_ssh_service(self): |
| 52 | + # ACL uses sshd.socket for socket-activated SSH (similar to |
| 53 | + # Flatcar/CoreOS). Restarting sshd.service would conflict with |
| 54 | + # the active sshd.socket. |
| 55 | + pass |
| 56 | + |
| 57 | + def stop_dhcp_service(self): |
| 58 | + self._run_command_without_raising(["systemctl", "stop", "systemd-networkd"], log_error=False) |
| 59 | + |
| 60 | + def start_dhcp_service(self): |
| 61 | + self._run_command_without_raising(["systemctl", "start", "systemd-networkd"], log_error=False) |
| 62 | + |
| 63 | + def start_agent_service(self): |
| 64 | + self._run_command_without_raising(["systemctl", "start", "{0}".format(self.service_name)], log_error=False) |
| 65 | + |
| 66 | + def stop_agent_service(self): |
| 67 | + self._run_command_without_raising(["systemctl", "stop", "{0}".format(self.service_name)], log_error=False) |
| 68 | + |
| 69 | + def register_agent_service(self): |
| 70 | + self._run_command_without_raising(["systemctl", "enable", "{0}".format(self.service_name)], log_error=False) |
| 71 | + |
| 72 | + def unregister_agent_service(self): |
| 73 | + self._run_command_without_raising(["systemctl", "disable", "{0}".format(self.service_name)], log_error=False) |
| 74 | + |
| 75 | + def get_dhcp_pid(self): |
| 76 | + return self._get_dhcp_pid(["pidof", "systemd-networkd"]) |
| 77 | + |
| 78 | + def conf_sshd(self, disable_password): |
| 79 | + pass |
0 commit comments