2
# Copyright 2014 Microsoft Corporation
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
8
# http://www.apache.org/licenses/LICENSE-2.0
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.
16
# Requires Python 2.4+ and Openssl 1.0+
28
import azurelinuxagent.logger as logger
29
import azurelinuxagent.utils.fileutil as fileutil
30
import azurelinuxagent.utils.shellutil as shellutil
31
import azurelinuxagent.utils.textutil as textutil
32
from azurelinuxagent.distro.default.osutil import DefaultOSUtil
34
class Ubuntu14OSUtil(DefaultOSUtil):
36
super(Ubuntu14OSUtil, self).__init__()
38
def start_network(self):
39
return shellutil.run("service networking start", chk_err=False)
41
def stop_agent_service(self):
42
return shellutil.run("service walinuxagent stop", chk_err=False)
44
def start_agent_service(self):
45
return shellutil.run("service walinuxagent start", chk_err=False)
47
class Ubuntu12OSUtil(Ubuntu14OSUtil):
49
super(Ubuntu12OSUtil, self).__init__()
52
def get_dhcp_pid(self):
53
ret= shellutil.run_get_output("pidof dhclient3")
54
return ret[1] if ret[0] == 0 else None
56
class UbuntuOSUtil(Ubuntu14OSUtil):
58
super(UbuntuOSUtil, self).__init__()
60
def register_agent_service(self):
61
return shellutil.run("systemctl unmask walinuxagent", chk_err=False)
63
def unregister_agent_service(self):
64
return shellutil.run("systemctl mask walinuxagent", chk_err=False)
66
class UbuntuSnappyOSUtil(Ubuntu14OSUtil):
68
super(UbuntuSnappyOSUtil, self).__init__()
69
self.conf_file_path = '/apps/walinuxagent/current/waagent.conf'
71
def remove_rules_files(self, rules_files=""):
74
def restore_rules_files(self, rules_files=""):