[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue May 24 09:49:26 CDT 2011


branch "master" has been updated
       via  eac4258e1eae1ddb66c102438c6e4336f773e04e (commit)
      from  366a988285e61b635662501351607e8f45659c16 (commit)

Summary of changes:
 config/Configurator.py    |  179 ---------------------------------------------
 config/SipConfigurator.py |    4 +-
 2 files changed, 2 insertions(+), 181 deletions(-)
 delete mode 100755 config/Configurator.py


- Log -----------------------------------------------------------------
commit eac4258e1eae1ddb66c102438c6e4336f773e04e
Author: Brent Eagles <beagles at digium.com>
Date:   Tue May 24 12:13:53 2011 -0230

    This typo wasn't the bug, the bug lies elsewhere.
    
    Revert "Fixed a configuration item name typo and a number of arguments error."
    
    This reverts commit 366a988285e61b635662501351607e8f45659c16.
    
    Also removed obsolete file.

diff --git a/config/Configurator.py b/config/Configurator.py
deleted file mode 100755
index 6e20173..0000000
--- a/config/Configurator.py
+++ /dev/null
@@ -1,179 +0,0 @@
-#!/usr/bin/env python
-
-# Asterisk SCF Configurator Module
-
-import ConfigParser, os, Ice, getopt
-
-# Load and make the configuration interface available, we require it
-Ice.loadSlice('-I. --all ../../slice/AsteriskSCF/System/Component/ConfigurationIf.ice')
-import AsteriskSCF.System.Configuration.V1
-
-# Exception class used within the configurator application
-class ConfiguratorError(Exception):
-    def __init__(self, value):
-        self.value = value
-
-    def __str__(self):
-        return repr(self.value)
-
-# Common section visitor pattern implementation
-class SectionVisitors():
-    def __init__(self):
-        """Generic class meant to be inherited from for section visitors"""
-        self.groups = []
-
-    def visit(self, config, section):
-        """Execute the visit_ function corresponding to the section name"""
-        try:
-            method = getattr(self, 'visit_' + section)
-        except AttributeError:
-            self.visit_unsupported(config, section)
-        else:
-            method(config, section);
-
-    def visit_unsupported(self, config, section):
-        """Handle an unsupported configuration section"""
-        print "Unsupported configuration section " + section
-
-# Common option to item mapper implementation
-class OptionMapper():
-    options = { }
-
-    def __init(self):
-        """Generic class meant to perform option to item mapping"""
-        self.options = { }
-
-    def map(self, option, object, item, item_name, method, default = None):
-        setattr(object, item, default)
-        self.options[option] = [ object, item, item_name, method, default ]
-
-    def execute(self, group, section, option):
-        """Map options to configuration items based on options set"""
-        try:
-            object = self.options[option][0]
-        except:
-            return
-        item = self.options[option][1]
-        item_name = self.options[option][2]
-        method = self.options[option][3]
-        default = self.options[option][4]
-
-        try:
-            setattr(object, item, method(section, option))
-
-        except ValueError:
-            # This is not a fatal error since we just use the default value.
-            if default == None:
-                print "The specified value for option '" + option + "' is not valid and no default value exists."
-            else:
-                print "The specified value for option '" + option + "' is not valid. Using default value."
-                setattr(object, item, default)
-
-        # This has the potential to overwrite an existing item but this is done on purpose so that
-        # configuration options that all map to a single item can happily exist
-        if item != None:
-            group.configurationItems[item_name] = object
-
-    def finish(self, group):
-        """Finish mapping options by finding ones that should have a value but do not"""
-        for option in self.options:
-            item = self.options[option][1]
-            default = self.options[option][4]
-            if default == None:
-                if item == None:
-                    print "Option '" + option + "' requires a value to be set and no default value exists."
-
-# Common configurator application logic
-class ConfiguratorApp(Ice.Application):
-    def __init__(self, defaultConfigFile, visitor, configurationService = None):
-        """Common configuration utility class"""
-
-        if defaultConfigFile == '':
-            raise ConfiguratorError('Configuration utility implementation issue - No default configuration filename specified.')
-
-        self.defaultConfigFile = defaultConfigFile
-        self.visitor = visitor
-        self.configurationService = configurationService
-
-    def usage(self):
-        """Print usage information for the configuration utility"""
-
-        print "Usage: " + self.appName() + " [--config=filename] [--proxy=stringified configuration service proxy] [--wipe]"
-        print "Push a configuration to a component."
-        print ""
-        print "Mandatory arguments to long options are mandatory for short options too."
-        print "-h, --help              display help information"
-        print "-c, --config=FILENAME   use specified configuration file instead of " + self.defaultConfigFile
-        print "-p, --proxy=PROXY       use specified proxy instead of locating component"
-        print "-w, --wipe              remove existing configuration before applying new one"
-
-    def run(self, args):
-        """Parse options, read configuration file, produce configuration data, and submit it"""
-
-        try:
-            opts, arguments = getopt.getopt(args[1:], "hc:p:w", ["help", "config=", "proxy=", "wipe"])
-        except getopt.GetoptError, err:
-            print str(err)
-            self.usage()
-            return 1
-
-        configFile = self.defaultConfigFile
-        configurationService = self.configurationService
-        configurationWipe = False
-
-        for o, a in opts:
-            if o in ("-h", "--help"):
-                self.usage()
-                return 1
-
-            elif o in ("-c", "--config"):
-                configFile = a
-
-            elif o in ("-p", "--proxy"):
-                configurationService = AsteriskSCF.System.Configuration.V1.ConfigurationServicePrx.checkedCast(self.communicator().stringToProxy(a))
-
-            elif o in ("-w", "--wipe"):
-                configurationWipe = True
-
-        if configurationService == None:
-            print "No configuration service to configure."
-            return 0
-
-        print "Reading configuration from file " + configFile
-        config = ConfigParser.ConfigParser()
-
-        # This purposely uses open and readfp so that the file is required to be present
-        try:
-            config.readfp(open(configFile))
-        except IOError:
-            print "Specified configuration file " + configFile + " could not be loaded."
-            return 0
-
-        print "Building configuration changes to send to component"
-        for section in config.sections():
-            self.visitor.visit(config, section)
-
-        if self.visitor.groups:
-            if configurationWipe == True:
-                print "Wiping existing configuration before applying changes"
-                # There is a race condition here where another component could modify the groups present, but if two
-                # components are altering the configuration we are best effort to begin with
-                try:
-                    groups = configurationService.getConfigurationGroups()
-                    configurationService.removeConfigurationGroups(groups)
-                except:
-                    print "Configuration could not be wiped - Failed to contact component"
-                    return 0
-
-            print "Applying configuration"
-
-            try:
-                configurationService.setConfiguration(self.visitor.groups)
-                print "Configuration applied"
-            except:
-                print "Configuration could not be applied - Failed to contact component"
-
-        else:
-            print "No configuration to apply"
-
-        return 0
diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index 4d66a18..1a63436 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -116,7 +116,7 @@ class SipSectionVisitors(Configurator.SectionVisitors):
 
         mapper.map('securetransport', AsteriskSCF.SIP.V1.SipEndpointTransportItem(), 'secureTransport', 'transport', transformer.get, None)
 
-        item = AsteriskSCF.SIP.V1.SipRTPMediaServiceItem()
+        item = AsteriskSCF.SIP.V1.RTPMediaServiceItem()
         mapper.map('rtpoveripv6', item, 'requireIPv6', 'mediaservice', config.getboolean, None)
 
         item = AsteriskSCF.SIP.V1.SipCryptoCertificateItem()
@@ -174,5 +174,5 @@ serviceLocatorParams = AsteriskSCF.SIP.V1.SipConfigurationParams()
 serviceLocatorParams.category = AsteriskSCF.SIP.V1.ConfigurationDiscoveryCategory
 
 # Make a configurator application and let it run
-app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors(), None)
+app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors(), None, serviceLocatorParams)
 sys.exit(app.main(sys.argv))

-----------------------------------------------------------------------


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list