Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.142.124.139
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/sosreport/sos/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/sosreport/sos/plugins/maas.py
# Copyright (C) 2013 Adam Stokes <adam.stokes@ubuntu.com>
#
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.

from sos.plugins import Plugin, UbuntuPlugin


class Maas(Plugin, UbuntuPlugin):
    """Ubuntu Metal-As-A-Service
    """

    plugin_name = 'maas'
    profiles = ('sysmgmt',)
    packages = ('maas', 'maas-common')

    services = (
        # For the deb:
        'maas-dhcpd',
        'maas-dhcpd6',
        'maas-http',
        'maas-proxy',
        'maas-rackd',
        'maas-regiond',
        'maas-syslog',
        # For the snap:
        'snap.maas.supervisor',
    )

    option_list = [
        ('profile-name',
         'The name with which you will later refer to this remote', '', ''),
        ('url', 'The URL of the remote API', '', ''),
        ('credentials',
         'The credentials, also known as the API key', '', '')
    ]

    def _has_login_options(self):
        return self.get_option("url") and self.get_option("credentials") \
            and self.get_option("profile-name")

    def _remote_api_login(self):
        ret = self.exec_cmd(
            "maas login %s %s %s" % (
                self.get_option("profile-name"),
                self.get_option("url"),
                self.get_option("credentials")
            )
        )

        return ret['status'] == 0

    def _is_snap_installed(self):
        return self.exec_cmd('snap list maas')["status"] == 0

    def check_enabled(self):
        if super().check_enabled():
            # deb-based MAAS and existing triggers
            return True
        # Do we have the snap installed?
        return self._is_snap_installed()

    def setup(self):
        self._is_snap = self._is_snap_installed()
        if self._is_snap:
            self.add_cmd_output([
                'snap info maas',
                'maas status'
            ])
            # Don't send secrets
            self.add_forbidden_path("/var/snap/maas/current/bind/session.key")
            self.add_copy_spec([
                "/var/snap/maas/common/log",
                "/var/snap/maas/common/snap_mode",
                "/var/snap/maas/current/*.conf",
                "/var/snap/maas/current/bind",
                "/var/snap/maas/current/http",
                "/var/snap/maas/current/supervisord",
                "/var/snap/maas/current/preseeds",
                "/var/snap/maas/current/proxy",
                "/var/snap/maas/current/rsyslog",
            ])
        else:
            self.add_copy_spec([
                "/etc/squid-deb-proxy",
                "/etc/maas",
                "/var/lib/maas/dhcp*",
                "/var/log/apache2*",
                "/var/log/maas*",
                "/var/log/upstart/maas-*",
            ])
            self.add_cmd_output([
                "apt-cache policy maas-*",
                "apt-cache policy python-django-*",
            ])

        for service in self.services:
            self.add_journal(units=service)

        if self.is_installed("maas-region-controller"):
            self.add_cmd_output([
                "maas-region-admin dumpdata",
            ])

        if self._has_login_options():
            if self._remote_api_login():
                self.add_cmd_output("maas %s commissioning-results list" %
                                    self.get_option("profile-name"))
            else:
                self._log_error(
                    "Cannot login into MAAS remote API with provided creds.")

    def postproc(self):
        if self._is_snap:
            regiond_path = "/var/snap/maas/current/maas/regiond.conf"
        else:
            regiond_path = "/etc/maas/regiond.conf"
        self.do_file_sub(regiond_path,
                         r"(database_pass\s*:\s*)(.*)",
                         r"\1********")

# vim: set et ts=4 sw=4 :

Anon7 - 2022
AnonSec Team