diff --git a/azurelinuxagent/pa/deprovision/factory.py b/azurelinuxagent/pa/deprovision/factory.py index 2caedc8da..80627a0e6 100644 --- a/azurelinuxagent/pa/deprovision/factory.py +++ b/azurelinuxagent/pa/deprovision/factory.py @@ -22,6 +22,7 @@ from .clearlinux import ClearLinuxDeprovisionHandler from .coreos import CoreOSDeprovisionHandler from .default import DeprovisionHandler +from .suse import SUSEDeprovisionHandler from .ubuntu import UbuntuDeprovisionHandler, Ubuntu1804DeprovisionHandler @@ -39,6 +40,8 @@ def get_deprovision_handler(distro_name=DISTRO_NAME, return CoreOSDeprovisionHandler() if "Clear Linux" in distro_full_name: return ClearLinuxDeprovisionHandler() # pylint: disable=E1120 + if distro_name in ("suse", "sle_hpc", "sles", "opensuse"): + return SUSEDeprovisionHandler() return DeprovisionHandler() diff --git a/azurelinuxagent/pa/deprovision/suse.py b/azurelinuxagent/pa/deprovision/suse.py new file mode 100644 index 000000000..3bac75867 --- /dev/null +++ b/azurelinuxagent/pa/deprovision/suse.py @@ -0,0 +1,32 @@ +# Microsoft Azure Linux Agent +# +# Copyright 2022 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.6+ and Openssl 1.0+ +# + +from azurelinuxagent.pa.deprovision.default import DeprovisionHandler, \ + DeprovisionAction + +class SUSEDeprovisionHandler(DeprovisionHandler): + def __init__(self): # pylint: disable=W0235 + super(SUSEDeprovisionHandler, self).__init__() + + def reset_hostname(self, warnings, actions): + localhost = ["AUTO"] + actions.append(DeprovisionAction(self.osutil.set_hostname, + localhost)) + actions.append(DeprovisionAction(self.osutil.set_dhcp_hostname, + localhost))