~ubuntu-branches/debian/stretch/waagent/stretch

« back to all changes in this revision

Viewing changes to azurelinuxagent/distro/ubuntu/osutil.py

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2016-08-24 16:48:22 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20160824164822-vdf8m5xy5gycm1cz
Tags: 2.1.6-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Copyright 2014 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.4+ and Openssl 1.0+
17
 
#
18
 
 
19
 
import os
20
 
import re
21
 
import pwd
22
 
import shutil
23
 
import socket
24
 
import array
25
 
import struct
26
 
import fcntl
27
 
import time
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
33
 
 
34
 
class Ubuntu14OSUtil(DefaultOSUtil):
35
 
    def __init__(self):
36
 
        super(Ubuntu14OSUtil, self).__init__()
37
 
 
38
 
    def start_network(self):
39
 
        return shellutil.run("service networking start", chk_err=False)
40
 
 
41
 
    def stop_agent_service(self):
42
 
        return shellutil.run("service walinuxagent stop", chk_err=False)
43
 
 
44
 
    def start_agent_service(self):
45
 
        return shellutil.run("service walinuxagent start", chk_err=False)
46
 
 
47
 
class Ubuntu12OSUtil(Ubuntu14OSUtil):
48
 
    def __init__(self):
49
 
        super(Ubuntu12OSUtil, self).__init__()
50
 
 
51
 
    #Override
52
 
    def get_dhcp_pid(self):
53
 
        ret= shellutil.run_get_output("pidof dhclient3")
54
 
        return ret[1] if ret[0] == 0 else None
55
 
 
56
 
class UbuntuOSUtil(Ubuntu14OSUtil):
57
 
    def __init__(self):
58
 
        super(UbuntuOSUtil, self).__init__()
59
 
 
60
 
    def register_agent_service(self):
61
 
        return shellutil.run("systemctl unmask walinuxagent", chk_err=False)
62
 
 
63
 
    def unregister_agent_service(self):
64
 
        return shellutil.run("systemctl mask walinuxagent", chk_err=False)
65
 
 
66
 
class UbuntuSnappyOSUtil(Ubuntu14OSUtil):
67
 
    def __init__(self):
68
 
        super(UbuntuSnappyOSUtil, self).__init__()
69
 
        self.conf_file_path = '/apps/walinuxagent/current/waagent.conf'
70
 
 
71
 
    def remove_rules_files(self, rules_files=""):
72
 
        pass
73
 
 
74
 
    def restore_rules_files(self, rules_files=""):
75
 
        pass