aboutsummaryrefslogtreecommitdiffstats
path: root/sos/policies/ubuntu.py
blob: c841b22bfa8f84ea6acd4ee4f90a14b0720914e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from sos import _sos as _
from sos.plugins import UbuntuPlugin, IndependentPlugin
from sos.policies.debian import DebianPolicy, DebianPackageManager
from sos.utilities import shell_out

import os
        
class UbuntuPolicy(DebianPolicy):
    def __init__(self):
        super(UbuntuPolicy, self).__init__()

    def validatePlugin(self, plugin_class):
        "Checks that the plugin will execute given the environment"
        return issubclass(plugin_class, UbuntuPlugin) or issubclass(plugin_class, IndependentPlugin)

    @classmethod
    def check(self):
        """This method checks to see if we are running on Ubuntu.
           It returns True or False."""
        if os.path.isfile('/etc/lsb-release'):
            try:
                fp = open('/etc/lsb-release', 'r')
                if "Ubuntu" in fp.read():
                    fp.close()
                    return True
            except:
                return False
        return False

    def get_msg(self):
        msg_dict = {"distro": "Ubuntu"}
        return self.msg % msg_dict