示例#1
0
 def extract_environment_level(self, server):
     try:
         level = CONF.getint("webui", "environment.level")
     except ConfigParser.NoOptionError:
         logger.error("Cannot find environment.level variable. Environment information won't be shown in webui")
         return ""
     # You can change the environment level in your puppet classes hierarchy
     # In kermit configuration file
     for puppetclass in server.puppet_classes.values():
         if puppetclass["level"] == level:
             environment = puppetclass["name"]
             return environment
示例#2
0
def send_server_inventory_email():
    alert_db = Alert.objects.get(name='ServerListMailAlert')
    if alert_db.enabled:
        htmly = get_template('alerting/serveremail.html')
        #Extract first level puppet class for user.
        for user in alert_db.users.all():
            servers_for_mail = []
            first_level_classes = get_objects_for_user(
                user, 'access_puppet_class', PuppetClass).filter(enabled=True,
                                                                 level=0)
            second_level_classes = get_objects_for_user(
                user, 'access_puppet_class', PuppetClass).filter(enabled=True,
                                                                 level=1)
            for first_level_class in first_level_classes:
                for second_level_class in second_level_classes:
                    server_path = '/' + first_level_class.name + '/' + second_level_class.name
                    app_modules = platforms.extract(Application)
                    applications = []
                    if app_modules:
                        for current_module in app_modules:
                            applications_list = current_module.getApplicationsPath(
                                user, server_path)
                            if applications_list:
                                applications.extend(applications_list)
                    if len(applications) > 0:
                        servers_for_mail.append({
                            'first_level_class':
                            first_level_class.name,
                            'second_level_class':
                            second_level_class.name,
                            "applications":
                            applications
                        })
            if len(servers_for_mail) > 0:
                d = Context({'classed_servers': servers_for_mail})

                try:
                    from_email = CONF.get('webui', 'alerting.from_mail')
                except:
                    logger.warn(
                        "No from_mail configured in your webui config file. Using default"
                    )
                    from_email = '*****@*****.**'
                subject = alert_db.mail_subjet
                html_content = htmly.render(d)
                msg = EmailMultiAlternatives(subject, "Need HTML", from_email,
                                             [user.email])
                msg.attach_alternative(html_content, "text/html")
                msg.send()
            else:
                logger.info(
                    "Mail for user %s won't be send. No applications found!" %
                    user.username)
示例#3
0
 def extract_environment_level(self, server):
     try:
         level = CONF.getint("webui", "environment.level")
     except ConfigParser.NoOptionError:
         logger.error("Cannot find environment.level variable. Environment information won't be shown in webui")
         return ""
     #You can change the environment level in your puppet classes hierarchy 
     #In kermit configuration file
     for puppetclass in server.puppet_classes.values():
         if puppetclass["level"]==level:
             environment = puppetclass["name"]
             return environment
示例#4
0
def send_server_inventory_email():
    alert_db = Alert.objects.get(name="ServerListMailAlert")
    if alert_db.enabled:
        htmly = get_template("alerting/serveremail.html")
        # Extract first level puppet class for user.
        for user in alert_db.users.all():
            servers_for_mail = []
            first_level_classes = get_objects_for_user(user, "access_puppet_class", PuppetClass).filter(
                enabled=True, level=0
            )
            second_level_classes = get_objects_for_user(user, "access_puppet_class", PuppetClass).filter(
                enabled=True, level=1
            )
            for first_level_class in first_level_classes:
                for second_level_class in second_level_classes:
                    server_path = "/" + first_level_class.name + "/" + second_level_class.name
                    app_modules = platforms.extract(Application)
                    applications = []
                    if app_modules:
                        for current_module in app_modules:
                            applications_list = current_module.getApplicationsPath(user, server_path)
                            if applications_list:
                                applications.extend(applications_list)
                    if len(applications) > 0:
                        servers_for_mail.append(
                            {
                                "first_level_class": first_level_class.name,
                                "second_level_class": second_level_class.name,
                                "applications": applications,
                            }
                        )
            if len(servers_for_mail) > 0:
                d = Context({"classed_servers": servers_for_mail})

                try:
                    from_email = CONF.get("webui", "alerting.from_mail")
                except:
                    logger.warn("No from_mail configured in your webui config file. Using default")
                    from_email = "*****@*****.**"
                subject = alert_db.mail_subjet
                html_content = htmly.render(d)
                msg = EmailMultiAlternatives(subject, "Need HTML", from_email, [user.email])
                msg.attach_alternative(html_content, "text/html")
                msg.send()
            else:
                logger.info("Mail for user %s won't be send. No applications found!" % user.username)
示例#5
0
'''
Created on Sep 19, 2011

@author: mmornati
'''
import saml2
from os import path
import ConfigParser
from webui.utils import CONF

BASE_URL=CONF.get('webui', 'base_url')

LOGIN_URL=BASE_URL+"/auth/saml2/login/"
LOGIN_REDIRECT_URL = BASE_URL
LOGOUT_LINK = ""
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

BASEDIR = path.dirname(path.abspath(__file__))
SAML_CONFIG = {
    # full path to the xmlsec1 binary programm
    'xmlsec_binary': '/usr/bin/xmlsec1',

    # your entity id, usually your subdomain plus the url to the metadata view
    'entityid': 'KermitIDP',
    
    #Added to prevent time not synchro between webui-server and IDP server
    'timeslack': '5000' ,

    # directory with attribute mapping
    'attribute_map_dir': path.join(BASEDIR, 'attribute-maps'),