Beispiel #1
0
    def configure(self, config):
        self.setattr('pw_not_username', as_boolean(config.get('pw_not_username', _manager.password_config.getboolean('Prohibited', 'username_as_password'))))
        self.setattr('pw_min_len_root', int(config.get('pw_min_len_root', _manager.password_config.getint('Length', 'minadmin'))))
        self.setattr('pw_no_repeat', as_boolean(config.get('pw_no_repeat', _manager.password_config.getboolean('Complexity', 'no_repeats'))))
        self.setattr('pw_complexity', as_boolean(config.get('pw_complexity', _manager.password_config.getboolean('Complexity', 'character_sets'))))
        self.setattr('pw_min_len', int(config.get('pw_min_len', _manager.password_config.getint('Length', 'min'))))
        self.setattr('pw_max_len', int(config.get('pw_max_len', _manager.password_config.getint('Length', 'max'))))
        self.setattr('pw_not_cisco', as_boolean(config.get('pw_not_cisco', _manager.password_config.getboolean('Prohibited', 'cisco'))))
        self.setattr('pw_not_mpxadmin', as_boolean(config.get('pw_not_mpxadmin', _manager.password_config.getboolean('Prohibited', 'mpxadmin'))))
        super(SecurityManager, self).configure(config)

        if not self.has_child('Roles'):
            from mpx.service.security.role import RoleManager
            manager = self.nodespace.create_node(RoleManager)
            manager.configure({'name': 'Roles',
                               'parent': self,
                               'debug': self.debug})
            self.message('Created Role Manager.')
        if not self.has_child('Users'):
            from mpx.service.security.user import UserManager
            manager = self.nodespace.create_node(UserManager)
            manager.configure({'name': 'Users',
                               'parent': self,
                               'debug': self.debug})
            self.message('Created User Manager.')
        if not self.has_child('Policies'):
            from mpx.service.security.policy import PolicyManager
            manager = self.nodespace.create_node(PolicyManager)
            manager.configure({'name': 'Policies',
                               'parent': self,
                               'debug': self.debug})
            self.message('Created Policy Manager.')
        return
Beispiel #2
0
 def configure(self, config):
     self.__nodespace = config.get('nodespace', self.nodespace)
     if not self.nodespace:
         self.__nodespace = rootspace
     self.enabled = as_boolean(config.get('enabled', self.enabled))
     self.debug = as_boolean(config.get('debug', self.debug))
     self.name = config.get('name', self.name)
     parent = config.get('parent')
     if parent is not None:
         parent = self.nodespace.as_node(parent)
         self.parent = parent
     return self.is_configured()
Beispiel #3
0
 def configure(self, config):
     self.__nodespace = config.get('nodespace', self.nodespace)
     if not self.nodespace:
         self.__nodespace = rootspace
     self.enabled = as_boolean(config.get('enabled', self.enabled))
     self.debug = as_boolean(config.get('debug', self.debug))
     self.name = config.get('name', self.name)
     parent = config.get('parent')
     if parent is not None:
         parent = self.nodespace.as_node(parent)
         self.parent = parent
     return self.is_configured()
Beispiel #4
0
 def configure(self, config):
     if "path" in config:
         self.path = config["path"]
     if "secured" in config:
         self.secured = as_boolean(config["secured"])
     if "provides_security" in config:
         self.provides_security = as_boolean(config["provides_security"])
     if "cloud_manager" in config:
         self.cloud_manager = config["cloud_manager"]
     if "subject" in config:
         self.subject = config["subject"]
     if "default" in config:
         self.default = config["default"]
     return super(SyndicationViewer, self).configure(config)
Beispiel #5
0
 def configure(self, config):
     if "path" in config:
         self.path = config["path"]
     if "secured" in config:
         self.secured = as_boolean(config["secured"])
     if "provides_security" in config:
         self.provides_security = as_boolean(config["provides_security"])
     if "cloud_manager" in config:
         self.cloud_manager = config["cloud_manager"]
     if "subject" in config:
         self.subject = config["subject"]
     if "default" in config:
         self.default = config["default"]
     return super(SyndicationViewer, self).configure(config)
Beispiel #6
0
 def configure_context(self, config):
     context = config.get('context', self.context)
     if not context:
         raise TypeError("Policy must have non-empty context")
     if config.has_key("uses_expression"):
         self.uses_expression = as_boolean(config["uses_expression"])
     else:
         self.uses_expression = False
     if self.uses_expression:
         self.context = context
         if config.has_key("filter"):
             self.filter = config["filter"]
         self.configured_expression = True
     else:
         self.configured_expression = False
         if isinstance(context, str) and context.startswith("REGEX:"):
             self.uses_expression = True
             # Regular expression encoded into context
             # as "REGEX: '<expr>', FILTER: '<expr>'.
             REGEX, FILTER = "REGEX", "FILTER"
             expressions = eval("{%s}" % context)
             self.context = expressions.get(REGEX, "")
             self.filter = expressions.get(FILTER, "")
         elif context != self.context:
             if not isinstance(context, str):
                 if ISecurityContext.providedBy(context):
                     context = context.url
                 else:
                     raise TypeError("Context must be string or object"
                                     " providing ISecurityContext.")
             self.filter = ""
             self.context = context
     return self.context, self.filter
Beispiel #7
0
 def configure(self, config):
     self.setattr('path', config.get('path','/scheduleconfig'))
     self.secured = as_boolean(as_internal_node("/services").secured)
     security_manager = config.get('security_manager',
                                   '/services/Security Manager')
     self.setattr('security_manager', security_manager)
     super(ScheduleConfigurator, self).configure(config)
Beispiel #8
0
 def configure(self, config):
     self.setattr('path', config.get('path','/postwriter'))
     self.delay = int(config.get('delay', self.delay))
     requires_authorization = config.get('requires_authorization', False)
     self.setattr('requires_authorization', 
                  as_boolean(requires_authorization))
     super(POSTWriter, self).configure(config)
 def configure(self, config):
     self.setattr('path', config.get('path', '/scheduleconfig'))
     self.secured = as_boolean(as_internal_node("/services").secured)
     security_manager = config.get('security_manager',
                                   '/services/Security Manager')
     self.setattr('security_manager', security_manager)
     super(ScheduleConfigurator, self).configure(config)
Beispiel #10
0
 def configure_context(self, config):
     context = config.get('context', self.context)
     if not context:
         raise TypeError("Policy must have non-empty context")
     if config.has_key("uses_expression"):
         self.uses_expression = as_boolean(config["uses_expression"])
     else:
         self.uses_expression = False
     if self.uses_expression:
         self.context = context
         if config.has_key("filter"):
             self.filter = config["filter"]
         self.configured_expression = True
     else:
         self.configured_expression = False
         if isinstance(context, str) and context.startswith("REGEX:"):
             self.uses_expression = True
             # Regular expression encoded into context 
             # as "REGEX: '<expr>', FILTER: '<expr>'.
             REGEX,FILTER = "REGEX","FILTER"
             expressions = eval("{%s}" % context)
             self.context = expressions.get(REGEX, "")
             self.filter = expressions.get(FILTER, "")
         elif context != self.context:
             if not isinstance(context, str):
                 if ISecurityContext.providedBy(context):
                     context = context.url
                 else:
                     raise TypeError("Context must be string or object"
                                     " providing ISecurityContext.")
             self.filter = ""
             self.context = context
     return self.context,self.filter
Beispiel #11
0
 def configure(self, config):
     self.setattr('path', config.get('path', '/postwriter'))
     self.delay = int(config.get('delay', self.delay))
     requires_authorization = config.get('requires_authorization', False)
     self.setattr('requires_authorization',
                  as_boolean(requires_authorization))
     super(POSTWriter, self).configure(config)
Beispiel #12
0
 def configure(self, config):
     """
         Configure node with from configuration dictionary.
         
         The policy may be configured to use regular expressions 
         instead of simple node-URL contexts in two different ways.
         
         The configuration dictionary may include a True/False 
         value "uses_expression", in which case the context 
         regular expression is taken verbatim from the "context" 
         parameter, and an optional filter expression from the 
         "filter" parameter.
         
         Or the expression(s) may be encoded directly into the 
         "context" value using the following format:
         
         REGEX: '<context regex>', FILTER: '<filter regex>'
         
         Note that the ", FILTER: [...]" part is completely 
         optional and will default to no filter. 
     """
     for attrname in self.readonly:
         current = getattr(self, attrname, None)
         incoming = config.get(attrname)
         if None not in (current, incoming) and (current != incoming):
             message = 'Attribute "%s" is readonly for Policy "%s".  '
             message += 'Overriding new value %s with current value %s.'
             message = message % (attrname, self.name, incoming, current)
             msglog.log('broadway', msglog.types.WARN, message)
             config[attrname] = current
     self.acquires = as_boolean(config.get('acquires', self.acquires))
     if not self.is_default:
         self.is_default = as_boolean(config.get('is_default', False))
     self.configure_context(config)
     super(Policy, self).configure(config)
     # Getting set of mappings whose value is a callback function.
     #   The assumption is being made here that such mappings are
     #   those considered 'read-only.'
     self.__lock.acquire()
     try:
         inherent = self.rolemap.callable_subset()
         self.rolemap = _RoleMap(config.get('rolemap', self.rolemap))
         self.rolemap.update(inherent)
     finally: 
         self.__lock.release()
     self.__verify_setup()
Beispiel #13
0
 def configure(self, config):
     """
         Configure node with from configuration dictionary.
         
         The policy may be configured to use regular expressions 
         instead of simple node-URL contexts in two different ways.
         
         The configuration dictionary may include a True/False 
         value "uses_expression", in which case the context 
         regular expression is taken verbatim from the "context" 
         parameter, and an optional filter expression from the 
         "filter" parameter.
         
         Or the expression(s) may be encoded directly into the 
         "context" value using the following format:
         
         REGEX: '<context regex>', FILTER: '<filter regex>'
         
         Note that the ", FILTER: [...]" part is completely 
         optional and will default to no filter. 
     """
     for attrname in self.readonly:
         current = getattr(self, attrname, None)
         incoming = config.get(attrname)
         if None not in (current, incoming) and (current != incoming):
             message = 'Attribute "%s" is readonly for Policy "%s".  '
             message += 'Overriding new value %s with current value %s.'
             message = message % (attrname, self.name, incoming, current)
             msglog.log('broadway', msglog.types.WARN, message)
             config[attrname] = current
     self.acquires = as_boolean(config.get('acquires', self.acquires))
     if not self.is_default:
         self.is_default = as_boolean(config.get('is_default', False))
     self.configure_context(config)
     super(Policy, self).configure(config)
     # Getting set of mappings whose value is a callback function.
     #   The assumption is being made here that such mappings are
     #   those considered 'read-only.'
     self.__lock.acquire()
     try:
         inherent = self.rolemap.callable_subset()
         self.rolemap = _RoleMap(config.get('rolemap', self.rolemap))
         self.rolemap.update(inherent)
     finally:
         self.__lock.release()
     self.__verify_setup()
Beispiel #14
0
 def configuration(self):
     config = super(Policy, self).configuration()
     config['acquires'] = str(self.acquires)
     config['is_default'] = as_boolean(self.is_default)
     self.context_configuration(config)
     self.__lock.acquire()
     try:
         config['rolemap'] = self.rolemap.copy()
     finally: 
         self.__lock.release()
     return config
Beispiel #15
0
 def configuration(self):
     config = super(Policy, self).configuration()
     config['acquires'] = str(self.acquires)
     config['is_default'] = as_boolean(self.is_default)
     self.context_configuration(config)
     self.__lock.acquire()
     try:
         config['rolemap'] = self.rolemap.copy()
     finally:
         self.__lock.release()
     return config
Beispiel #16
0
 def set(self, value):
     try:
         value = as_boolean(value)
     except EInvalidValue:
         raise
     if value:
         value = 0x07
     value = value + 0x33
     #someone has to take responsibility of adding 0x33.
     #Putting it on point, as I couldn't find any other person to do it
     self.parent.set_cr_value(value)
     self._set_dirty_flag()
Beispiel #17
0
 def set(self, value):
     try:
         value = as_boolean(value)
     except EInvalidValue:
         raise
     if value:
         value = 0x07
     value = value + 0x33
     #someone has to take responsibility of adding 0x33.
     #Putting it on point, as I couldn't find any other person to do it
     self.parent.set_cr_value(value)
     self._set_dirty_flag()
Beispiel #18
0
 def configure(self, config):
     super(AlarmExporter, self).configure(config)
     if not self.formatter:
         self.format = config.get("format", self.format).lower()
     if not self.transporter:
         self.transport = config.get("transport", self.transport).lower()
     if "formatter" in config:
         self.format_config.update(config["formatter"])
         if self.formatter:
             self.configure_formatter(self.format_config)
     if "transporter" in config:
         self.transport_config.update(config["transporter"])
         if self.transporter:
             self.configure_transporter(self.transport_config)
     if "connection" in config:
         self.connection = as_node(config["connection"])
     self.setattr('timeout', int(config.get('timeout', 30)))
     self.setattr('retries', int(config.get('retries', 1)))
     self.setattr('gm_time', as_boolean(config.get('gm_time', 1)))
     self.setattr('description', config.get('description', ''))
Beispiel #19
0
 def configure(self,config):
     super(AlarmExporter, self).configure(config)
     if not self.formatter:
         self.format = config.get("format", self.format).lower()
     if not self.transporter:
         self.transport = config.get("transport", self.transport).lower()
     if "formatter" in config:            
         self.format_config.update(config["formatter"])
         if self.formatter:
             self.configure_formatter(self.format_config)
     if "transporter" in config:            
         self.transport_config.update(config["transporter"])
         if self.transporter:
             self.configure_transporter(self.transport_config)
     if "connection" in config:
         self.connection = as_node(config["connection"])
     self.setattr('timeout', int(config.get('timeout', 30)))
     self.setattr('retries', int(config.get('retries', 1)))
     self.setattr('gm_time', as_boolean(config.get('gm_time', 1)))
     self.setattr('description', config.get('description', ''))
Beispiel #20
0
def isfile_upgradeable(filename):
    upgradeable = 1
    if os.path.exists(filename):
        # See if the file's been acquired by another package, or
        # replaced by the end user.
        upgradeable = get_upgradeable_property(filename)
        if upgradeable is not None:
            upgradeable = upgradeable.lower()
            try:
                upgradeable = as_boolean(upgradeable)
            except:
                upgradeable = 0
        else:
            # Typically, this indicates that a user has overwritten
            # the file.  But we need to survive the 1.2 to 1.3
            # transition...
            upgradeable = 1
            version = get_version_property(filename)
            if version is not None:
                major, minor, revision, build = (0, 0, 0, 0)
                version = version.split('.')
                if len(version) > 2:
                    if version[-2] == 'build':
                        build = version.pop()  # Get build number.
                        version.pop()  # Remove 'build'
                if len(version):
                    major = int(version.pop(0))
                    if len(version):
                        minor = int(version.pop(0))
                        if len(version):
                            revision = int(version.pop(0))
                if (major > 1) or (major == 1 and minor > 2):
                    # The file should have had the upgradeable property,
                    # assume that the file has been changed.
                    upgradeable = 0
            else:
                # No version information, this file's been overwritten
                # by the user.
                upgradeable = 0
    return upgradeable
Beispiel #21
0
def isfile_upgradeable(filename):
    upgradeable = 1
    if os.path.exists(filename):
        # See if the file's been acquired by another package, or
        # replaced by the end user.
        upgradeable = get_upgradeable_property(filename)
        if upgradeable is not None:
            upgradeable = upgradeable.lower()
            try:
                upgradeable = as_boolean(upgradeable)
            except:
                upgradeable = 0
        else:
            # Typically, this indicates that a user has overwritten
            # the file.  But we need to survive the 1.2 to 1.3
            # transition...
            upgradeable = 1
            version = get_version_property(filename)
            if version is not None:
                major, minor, revision, build = (0,0,0,0)
                version = version.split('.')
                if len(version) > 2:
                    if version[-2] == 'build':
                        build = version.pop() # Get build number.
                        version.pop()         # Remove 'build'
                if len(version):
                    major = int(version.pop(0))
                    if len(version):
                        minor = int(version.pop(0))
                        if len(version):
                            revision = int(version.pop(0))
                if (major > 1) or (major == 1 and minor > 2):
                    # The file should have had the upgradeable property,
                    # assume that the file has been changed.
                    upgradeable = 0
            else:
                # No version information, this file's been overwritten
                # by the user.
                upgradeable = 0
    return upgradeable
Beispiel #22
0
 def set(self, value, asyncOK=1):
     global DOs
     channel = self.id
     if channel < 1 or channel > 2:
         raise Exception('channel must be between 1 and 2')
     # regardless of the name, the next line
     # converts various words and values to int 0,1
     value = as_boolean(value)
     bit = 1 << (channel - 1)
     if value:
         DOs |= bit
     else:
         DOs &= ~bit
     command = 'do %d\r' % (DOs)
     dict = self.read_response(command)
     if dict is None:
         raise Exception('no response')
     error = dict.get('error')
     if error:
         raise Exception(str(dict['error']))
     if dict['command'] != 'do':
         raise Exception('command mismatch: %s' % (dict['command'], ))
     if dict['outputs'] != DOs:
         raise Exception('outputs do not match')
Beispiel #23
0
 def set(self, value, asyncOK=1):
     global DOs
     channel = self.id
     if channel < 1 or channel > 2:
         raise Exception('channel must be between 1 and 2')
     # regardless of the name, the next line
     # converts various words and values to int 0,1
     value = as_boolean(value) 
     bit = 1 << (channel - 1)
     if value:
         DOs |= bit
     else:
         DOs &= ~bit
     command = 'do %d\r' % (DOs)
     dict = self.read_response(command)
     if dict is None:
         raise Exception('no response')
     error = dict.get('error')
     if error:
         raise Exception(str(dict['error']))
     if dict['command'] != 'do':
         raise Exception('command mismatch: %s' % (dict['command'],))
     if dict['outputs'] != DOs:
         raise Exception('outputs do not match')
Beispiel #24
0
 def configure(self, config):
     self.secured = as_boolean(as_internal_node("/services").secured)
     self.setattr('path', config.get('path',self.path))
     self.setattr('manager', config.get('manager','/services/Cloud Manager'))
     super(CloudConfigurator, self).configure(config)
Beispiel #25
0
    def render(self):
        """
            Configuration should be broken into three main topics.
            Edit, associated with an 'edit' button on the manager 
            page, exposes name and other standard node configuration 
            options.
            
            Export, associated with an 'export' button on the manager 
            page, exposes two panels.  One panel is identified with a 
            title of "transport", and configures the transporter; the 
            other is identified with a title of "format", and configures 
            the formatter.
            
            Trigger, associated with a "triggers" button on the manager 
            page, allows the user to select available event generators 
            and configure specific events for each using check boxes.
        """
        attrs = KeyWordAssist()
        document = self.base_doc.copy()
        request_path = '/exportconfig'
        exportname = cgi.escape(self.exporter.name)
        editorinput = HTMLgen.Input(name='edit',
                                    type='hidden',
                                    value=exportname)
        targetinput = HTMLgen.Input(name="target",
                                    type='hidden',
                                    value=exportname)
        classes = itertools.cycle(['light', 'dark'])

        ###
        # Sources part of page.
        section = HTMLgen.Div(id="triggers", **attrs('class', 'section'))
        triggernames = ['raised', 'accepted', 'cleared', 'closed']
        actioninput = HTMLgen.Input(name="actionName",
                                    type="hidden",
                                    value="add_source")
        sources = self.exporter.get_sources()
        for source in sources:
            form = HTMLgen.Form(request_path)
            sourcename = cgi.escape(source.name)
            sourcepath = cgi.escape(source.as_node_url())
            table = HTMLgen.TableLite(**attrs('class', 'configuration-table'))
            title = HTMLgen.Input(name="title",
                                  type="hidden",
                                  value=sourcename)
            form.append(editorinput)
            form.append(actioninput)
            form.append(targetinput)
            form.append(title)
            sourceinput = HTMLgen.Input(name="params",
                                        type='hidden',
                                        value=sourcepath)
            form.append(sourceinput)
            selected = self.exporter.get_event_names(source)
            if 'all' in selected:
                selected = triggernames[:]
            items = []
            for name in triggernames:
                triggername = cgi.escape(name)
                row = HTMLgen.TR(**attrs('class', classes.next()))
                row.append(HTMLgen.TH(triggername))
                field = HTMLgen.Input(type='checkbox',
                                      checked=(name in selected),
                                      name='params',
                                      value=triggername)
                row.append(HTMLgen.TD(field, **attrs('class', 'control')))
                table.append(row)
            form.submit.value = 'commit'
            form.append(table)
            section.append(form)

            ## Not integrated yet.
            remove_source_form = HTMLgen.Form(request_path)
            actioninput = HTMLgen.Input(name="actionName",
                                        type='hidden',
                                        value='remove_source')
            remove_source_form.append(editorinput)
            remove_source_form.append(actioninput)
            remove_source_form.append(sourceinput)
            remove_source_form.append(targetinput)
            remove_source_form.submit.value = 'remove'
        document.append(section)

        manager = self.exporter.nodespace.as_node('/services/Alarm Manager')
        nodes = [manager] + manager.get_alarms()
        triggers = []
        for node in nodes:
            if node in sources:
                continue
            triggers.append((node.name, cgi.escape(node.url)))
        if triggers:
            triggers.sort()
            select = HTMLgen.Select(triggers, name='params')
            add_form = HTMLgen.Form(request_path)
            add_form.append(editorinput)
            add_form.append(actioninput)
            add_form.append(targetinput)
            add_form.append(select)
            add_form.submit.value = 'add'


#            sources_section.append(add_form)
#        document.append(sources_section)
### End Sources ###

##
# Configuration part of page.
        config_section = HTMLgen.Div(id="main", **attrs('class', 'section'))
        configure = HTMLgen.Input(name="configure",
                                  type='hidden',
                                  value=exportname)
        exportconfig = self.exporter.configuration()
        if exportconfig.has_key('formatter'):
            formatconfig = exportconfig['formatter']
            del (exportconfig['formatter'])
        else:
            formatconfig = {}
        if exportconfig.has_key('transporter'):
            transportconfig = exportconfig['transporter']
            del (exportconfig['transporter'])
        else:
            transportconfig = {}
        hidden = ['parent', 'connection', 'debug', 'enabled']
        boolean = ['gm_time', 'authenticate', 'as_attachment']
        password = ['password']
        for name, config in [('Exporter', exportconfig),
                             ('Formatter', formatconfig),
                             ('Transporter', transportconfig)]:
            form = HTMLgen.Form(request_path)
            title = HTMLgen.Input(type="hidden", name="title", value=name)
            form.append(title)
            form.append(editorinput)
            table = HTMLgen.TableLite(**attrs('class', 'configuration-table'))

            config_header = HTMLgen.TR(**attrs('class', 'table-header'))
            for header in ['Attribute', 'Value']:
                headcell = HTMLgen.TH(header,
                                      scope="col",
                                      abbr=header,
                                      id="%sheader" % header)
                if header == "Value":
                    setattr(headcell, "class", "control")
                config_header.append(headcell)
            table.append(config_header)

            classes = itertools.cycle(['light', 'dark'])
            for aname, avalue in config.items():
                fieldname = '%s.%s' % (name, aname)
                if aname in boolean:
                    if as_boolean(avalue):
                        options = ['true', 'false']
                    else:
                        options = ['false', 'true']
                    field = HTMLgen.Select(options, name=fieldname)
                else:
                    field = HTMLgen.Input(value=avalue, name=fieldname)
                if aname in hidden:
                    field.type = 'hidden'
                    form.append(field)
                    continue
                elif aname in password:
                    field.type = 'password'
                row = HTMLgen.TR(**attrs('class', classes.next()))
                headercell = HTMLgen.TH(aname)
                datacell = HTMLgen.TD(field, **attrs('class', 'control'))
                row.append(headercell)
                row.append(datacell)
                table.append(row)
            form.append(table)
            config_section.append(form)
        document.append(config_section)
        return str(document)
Beispiel #26
0
    def render(self):
        """
            Configuration should be broken into three main topics.
            Edit, associated with an 'edit' button on the manager 
            page, exposes name and other standard node configuration 
            options.
            
            Export, associated with an 'export' button on the manager 
            page, exposes two panels.  One panel is identified with a 
            title of "transport", and configures the transporter; the 
            other is identified with a title of "format", and configures 
            the formatter.
            
            Trigger, associated with a "triggers" button on the manager 
            page, allows the user to select available event generators 
            and configure specific events for each using check boxes.
        """
        attrs = KeyWordAssist()
        document = self.base_doc.copy()
        request_path = '/exportconfig'
        exportname = cgi.escape(self.exporter.name)
        editorinput = HTMLgen.Input(
            name='edit', type='hidden', value=exportname)
        targetinput = HTMLgen.Input(
            name="target", type='hidden', value=exportname)
        classes = itertools.cycle(['light', 'dark'])

        ###
        # Sources part of page.
        section = HTMLgen.Div(id="triggers",**attrs('class','section'))
        triggernames = ['raised', 'accepted', 'cleared', 'closed']
        actioninput = HTMLgen.Input(
            name="actionName", type="hidden", value="add_source")
        sources = self.exporter.get_sources()
        for source in sources:
            form = HTMLgen.Form(request_path)
            sourcename = cgi.escape(source.name)
            sourcepath = cgi.escape(source.as_node_url())            
            table = HTMLgen.TableLite(**attrs('class','configuration-table'))
            title = HTMLgen.Input(name="title",type="hidden",value=sourcename)
            form.append(editorinput)
            form.append(actioninput)
            form.append(targetinput)
            form.append(title)
            sourceinput = HTMLgen.Input(
                name="params", type='hidden', value=sourcepath)
            form.append(sourceinput)
            selected = self.exporter.get_event_names(source)
            if 'all' in selected: 
                selected = triggernames[:]
            items = []
            for name in triggernames:
                triggername = cgi.escape(name)
                row = HTMLgen.TR(**attrs('class', classes.next()))
                row.append(HTMLgen.TH(triggername))                
                field = HTMLgen.Input(type='checkbox', 
                                      checked=(name in selected), 
                                      name='params', value=triggername)
                row.append(HTMLgen.TD(field, **attrs('class', 'control')))
                table.append(row)
            form.submit.value = 'commit'
            form.append(table)
            section.append(form)

            ## Not integrated yet.
            remove_source_form = HTMLgen.Form(request_path)
            actioninput = HTMLgen.Input(
                name="actionName", type='hidden', value='remove_source')
            remove_source_form.append(editorinput)
            remove_source_form.append(actioninput)
            remove_source_form.append(sourceinput)
            remove_source_form.append(targetinput)
            remove_source_form.submit.value = 'remove'
        document.append(section)

        manager = self.exporter.nodespace.as_node('/services/Alarm Manager')
        nodes = [manager] + manager.get_alarms()
        triggers = []
        for node in nodes:
            if node in sources: 
                continue
            triggers.append((node.name, cgi.escape(node.url)))
        if triggers:
            triggers.sort()
            select = HTMLgen.Select(triggers, name='params')
            add_form = HTMLgen.Form(request_path)
            add_form.append(editorinput)
            add_form.append(actioninput)
            add_form.append(targetinput)
            add_form.append(select)
            add_form.submit.value = 'add'
#            sources_section.append(add_form)
#        document.append(sources_section)
        ### End Sources ###

        ##
        # Configuration part of page.
        config_section = HTMLgen.Div(id="main", **attrs('class','section'))
        configure = HTMLgen.Input(
            name="configure", type='hidden', value=exportname)
        exportconfig = self.exporter.configuration()
        if exportconfig.has_key('formatter'):
            formatconfig = exportconfig['formatter']
            del(exportconfig['formatter'])
        else: 
            formatconfig = {}
        if exportconfig.has_key('transporter'):
            transportconfig = exportconfig['transporter']
            del(exportconfig['transporter'])
        else: 
            transportconfig = {}
        hidden = ['parent', 'connection', 'debug', 'enabled']
        boolean = ['gm_time', 'authenticate', 'as_attachment']
        password = ['password']
        for name,config in [('Exporter', exportconfig), 
                            ('Formatter', formatconfig), 
                            ('Transporter', transportconfig)]:
            form = HTMLgen.Form(request_path)
            title = HTMLgen.Input(type="hidden", name="title", value=name)
            form.append(title)
            form.append(editorinput)
            table = HTMLgen.TableLite(**attrs('class','configuration-table'))

            config_header = HTMLgen.TR(**attrs('class', 'table-header'))
            for header in ['Attribute', 'Value']:
                headcell = HTMLgen.TH(header, scope="col", abbr=header,
                                      id="%sheader" % header)
                if header == "Value":
                    setattr(headcell, "class", "control")                
                config_header.append(headcell)
            table.append(config_header)

            classes = itertools.cycle(['light', 'dark'])
            for aname,avalue in config.items():
                fieldname = '%s.%s' % (name,aname)
                if aname in boolean:
                    if as_boolean(avalue):
                        options = ['true', 'false']
                    else: 
                        options = ['false', 'true']
                    field = HTMLgen.Select(options, name=fieldname)
                else: 
                    field = HTMLgen.Input(value=avalue, name=fieldname)
                if aname in hidden:
                    field.type = 'hidden'
                    form.append(field)
                    continue
                elif aname in password:
                    field.type = 'password'
                row = HTMLgen.TR(**attrs('class', classes.next()))
                headercell = HTMLgen.TH(aname)
                datacell = HTMLgen.TD(field,**attrs('class', 'control'))
                row.append(headercell)
                row.append(datacell)
                table.append(row)
            form.append(table)
            config_section.append(form)
        document.append(config_section)
        return str(document)
Beispiel #27
0
 def configure(self, config):
     RequestHandler.configure(self, config)
     set_attribute(self, 'request_path', '.*\.psp$', config)
     set_attribute(self, 'provides_security', 1, config, as_boolean)
     self.secured = as_boolean(as_internal_node("/services").secured)
     self.request_regex = re.compile(self.request_path)
Beispiel #28
0
 def configure(self, config):
     if not getattr(self, 'parent', None):
         config.setdefault('parent', '/')
     self.setattr('secured', as_boolean(config.get('secured', True)))
     ServiceNode.configure(self, config)
Beispiel #29
0
 def configure(self, config):
     set_attribute(self, 'node_browsable', True, config, as_boolean)
     self.secured = as_boolean(as_internal_node("/services").secured)
     super(FileSpace, self).configure(config)
Beispiel #30
0
 def configure(self, config):
     set_attribute(self, 'node_browsable', True, config, as_boolean)
     self.secured = as_boolean(as_internal_node("/services").secured)
     super(FileSpace, self).configure(config)
Beispiel #31
0
 def configure(self, config):
     if not getattr(self, 'parent', None):
         config.setdefault('parent', '/')
     self.setattr('secured', as_boolean(config.get('secured', True)))
     ServiceNode.configure(self, config)
Beispiel #32
0
 def set(self, value, asyncOK=1):
     value = as_boolean(value)
     self.avr.invoke_message(self.set_cmds[value])
Beispiel #33
0
 def set(self, value, asyncOK=1):
     value = as_boolean(value)
     self.avr.invoke_message(self.set_cmds[value])
Beispiel #34
0
 def configure(self,config):
     RequestHandler.configure(self,config)
     set_attribute(self,'request_path','.*\.psp$',config)
     set_attribute(self, 'provides_security', 1, config, as_boolean)
     self.secured = as_boolean(as_internal_node("/services").secured)
     self.request_regex = re.compile(self.request_path)