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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue May 22 14:05:11 CDT 2012


branch "master" has been updated
       via  417bdb90608d23abf4ea95df9b0a8bfeb274191a (commit)
       via  5285399e65bd42f7c21abc9d5af245fe4fd15acb (commit)
       via  b2fdce28d1062db22737204d3ea06b607f48e034 (commit)
       via  091ee01a138c66a7c7820bf40719be66b2b5f631 (commit)
       via  0e620d5dc7bb7b75f1a705f7401b9dac5a221657 (commit)
      from  b23f14ff56b442abcdfd66fefa7e292f0f66cc54 (commit)

Summary of changes:
 configs/remote/remoteAgent.yaml     |    2 +-
 lib/python/SubProcess.py            |    9 +-
 plugins/asteriskscf_configurator.py |  514 +++--------------------------------
 plugins/sipp.py                     |    2 +-
 plugins/testsuite_remotes.py        |    8 +-
 5 files changed, 46 insertions(+), 489 deletions(-)


- Log -----------------------------------------------------------------
commit 417bdb90608d23abf4ea95df9b0a8bfeb274191a
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue May 22 14:04:51 2012 -0500

    Updated the SIPp executable path as it has changed with the latest version of SIPp trunk.

diff --git a/plugins/sipp.py b/plugins/sipp.py
index d034344..312d792 100644
--- a/plugins/sipp.py
+++ b/plugins/sipp.py
@@ -102,7 +102,7 @@ class plugin(Plugin.BaseClass):
         return list
 
     def _componentConfig(self, mode, config, remote_agent):
-        execCmd = ['!!TMP!!/sipp/sipp/trunk/sipp']
+        execCmd = ['!!TMP!!/sipp/trunk/sipp']
 
         if 'scenario_file' in config:
             res = self.readFile('%s/tests/asteriskscf/%s/scenarios/%s' % (globalVars.cwd, globalVars.testInfo['testPath'], config['scenario_file']))

commit 5285399e65bd42f7c21abc9d5af245fe4fd15acb
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue May 22 14:03:55 2012 -0500

    Updated the remote agent interface defs to use vlan interfaces for complex testcases.

diff --git a/configs/remote/remoteAgent.yaml b/configs/remote/remoteAgent.yaml
index a3df298..b18b1ec 100644
--- a/configs/remote/remoteAgent.yaml
+++ b/configs/remote/remoteAgent.yaml
@@ -1 +1 @@
-ifaces: {private: eth0, public1: eth0, public2: eth0, rpc: eth0}
+ifaces: {private: vlan1000, public1: vlan1001, public2: vlan1002, rpc: eth0}

commit b2fdce28d1062db22737204d3ea06b607f48e034
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue May 22 11:42:39 2012 -0500

    Updated the 'run' remote rpc function call so that an optional argument can be passed that will allow a system call that returns 1 to not cause a failure. This is especially usefull for cleanup when pkill is utilized as pkill returns a 1 if it can't locate whatever name was specified during execution.

diff --git a/plugins/testsuite_remotes.py b/plugins/testsuite_remotes.py
index a0ea4b0..9eab02b 100644
--- a/plugins/testsuite_remotes.py
+++ b/plugins/testsuite_remotes.py
@@ -34,15 +34,15 @@ class plugin(Plugin.BaseClass):
                 return res
 
             for process in globalVars.cleanup['process']:
-                res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'pkill', ['pkill', '-9', process], True))
+                res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'pkill', ['pkill', '-9', process], True, False))
                 if res['success'] == False:
                     return res
 
-            res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'sharedip', ['ifconfig', 'eth0:0', 'down'], True))
+            res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'sharedip', ['ifconfig', 'eth0:0', 'down'], True, False))
             if res['success'] == False:
                 return res
 
-            res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'arpcache', ['arp', '-i', 'eth0', '-d', '10.19.136.15'], True))
+            res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'arpcache', ['arp', '-i', 'eth0', '-d', '10.19.136.15'], True, False))
             if res['success'] == False:
                 return res
 
@@ -75,7 +75,7 @@ class plugin(Plugin.BaseClass):
                 res = self.rpcBatchCmd(globalVars.remoteAgents, ('removeFile', '!!TMP!!/%s' % files))
 
             for process in globalVars.cleanup['process']:
-                res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'pkill', ['pkill', '-9', process], True))
+                res = self.rpcBatchCmd(globalVars.remoteAgents, ('run', 'startup', 'pkill', ['pkill', '-9', process], True, False))
                 if res['success'] == False:
                     return res
 

commit 091ee01a138c66a7c7820bf40719be66b2b5f631
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue May 22 11:38:45 2012 -0500

    Refactored the Asterisk SCF configurator plugin to exercise the configurator and component visitor scripts in the various component repos directly instead of duplicating all that code and making the configurator calls directly from the test-suite.

diff --git a/plugins/asteriskscf_configurator.py b/plugins/asteriskscf_configurator.py
index 179b6b1..5f857ad 100644
--- a/plugins/asteriskscf_configurator.py
+++ b/plugins/asteriskscf_configurator.py
@@ -2,9 +2,9 @@
 
  Asterisk SCF Configurator Plugin
 
- Test-Suite - Copyright (C) 2011, Digium, Inc.
+ Test-Suite - Copyright (C) 2012, Digium, Inc.
 
- Written by Josh Colp and Darren Sessions 
+ Written by Darren Sessions 
 
  See http://wiki.asterisk.org for more information.
 
@@ -15,494 +15,46 @@
 
 from GlobalVars import globalVars
 
-import os
-import sys
 import time
-import uuid
-
-import Misc
 import Plugin
 
-sys.path.append('/opt/Ice-3.4/python')
-
-import Ice
-
 class plugin(Plugin.BaseClass):
     def main(self, testData):
-        time.sleep(1)
-        if globalVars.mode == 'docs':
-            #rpc = self.manualRPC('testsuite-remote-1.digium.internal')
-            for cmd in testData['cmd']:
-                if cmd == 'sip':
-                    execCmd = ['./SIPConfigurator.py', '--config=<path to sip config>', '--locator="LocatorService:tcp -p 4411 -h <service locator host"']
-                elif cmd == 'rtp':
-                    execCmd = ['./RTPConfigurator.py', '--config=<path to rtp config>', '--locator="LocatorService:tcp -p 4411 -h <service locator host"']
-                res = rpc['rpc']('run', 'random host', globalVars, 'asteriskscf_configurator', testData['cmd'], execCmd)
-            return res
-
-        if not 'configuration_wipe' in testData:
-            testData['configuration_wipe'] = None
-
-        try:
-            gitall = "%s/tmp/gitall/" % os.getcwd()
-            slice = gitall + "slice/slice"
-            AstSCFslice = slice + "/AsteriskSCF/"
-
-            Ice.loadSlice("-I\"" + gitall + "\" -I\"" + Ice.getSliceDir() + "\" --all \"" + AstSCFslice + "System/OperationsIf.ice\"")
-            Ice.loadSlice("-I\"" + gitall + "\" -I\"" + Ice.getSliceDir() + "\" -I\"" + slice + "\" --all \"" + AstSCFslice + "System/Component/ConfigurationIf.ice\"")
-            Ice.loadSlice("-I\"" + slice + "\" -I\"" + Ice.getSliceDir() + "\" --all \"" + AstSCFslice + "Core/Discovery/ServiceLocatorIf.ice\"")
-            Ice.loadSlice("-I\"" + slice + "\" -I\"" + Ice.getSliceDir() + "\" --all \"" + gitall + "sip/slice/AsteriskSCF/Configuration/SIPSessionGateway/SIPConfigurationIf.ice\"")
-            Ice.loadSlice("-I\"" + slice + "\" -I\"" + Ice.getSliceDir() + "\" --all \"" + gitall + "media_rtp_pjmedia/slice/AsteriskSCF/Configuration/MediaRTPPJMEDIA/RTPConfigurationIf.ice\"")
-
-        except:
-            return {'success':False,'shutdownExempt':'True','msg':'Slice preprocessing failed. Unable to locate slice files.'}
-
-        try:
-            import AsteriskSCF.System.V1
-            import AsteriskSCF.System.Configuration.V1
-            import AsteriskSCF.Core.Discovery.V1
-            import AsteriskSCF.Configuration.SIPSessionGateway.V1
-            import AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1
-        except:
-            return {'success':False,'shutdownExempt':'True','msg':'Unable to import required Asterisk SCF python modules.'}
-
         ''' The configurator doesn't implement a start or stop function as it's just pushing config '''
         for cmd in testData['cmd']:
             if cmd == 'sip':
-                serviceLocatorParams = AsteriskSCF.Core.Discovery.V1.ServiceLocatorParams()
-                serviceLocatorParams.category = AsteriskSCF.Configuration.SIPSessionGateway.V1.ConfigurationDiscoveryCategory
-                serviceLocatorParams.service = 'default'
+                configurator = "!!TMP!!/gitall/sip/config/SIPConfigurator.py"
+                configFile = "SIP.configurator.config"
             elif cmd == 'rtp':
-                serviceLocatorParams = AsteriskSCF.Core.Discovery.V1.ServiceLocatorParams()
-                serviceLocatorParams.category = AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.ConfigurationDiscoveryCategory
+                configurator = "!!TMP!!/gitall/media_rtp_pjmedia/config/RTPConfigurator.py" 
+                configFile = "RTP.configurator.config"
             else:
-                return {'success':False,'shutdownExempt':'True','msg':'The %s command is invalid.' % cmd}
-
-            res = self.hostLabelResolver(testData['service_locator_host'])
-            if res['success'] == False:
-                return res
-
-            res = ConfiguratorApp(globalVars, cmd, res['ip'], testData['cmd'][cmd], AsteriskSCF, testData['configuration_wipe'], serviceLocatorParams).main([''])
-            if 'msg' in res:
-                res['msg'] = "Error detected while configuring the \'%s\' component. %s" % (cmd, res['msg'])
-
-            if res['success'] == False:
-                return {'success':False, 'shutdownExempt':'True', 'msg':res['msg']}
+                return {'success':False, 'msg':'The %s command is invalid.' % cmd}
+
+            config = ""
+            for entry in testData['cmd'][cmd]:
+                for sectionName, sectionConfig in entry.iteritems():
+                    config += "[%s]\n" % sectionName
+                    for param, val in sectionConfig.iteritems():
+                        if param == 'ipv4oripv6': continue
+                        if type(val).__name__ == 'list':
+                             try:
+                                 val = self.hostLabelResolver(val)['ip']
+                             except:
+                                 return {'success':False, 'msg':'Unregistered remote agent specified: %s' % val}
+                        config += "%s = %s\n" % (param, val)
+                    config += "\n"
+
+            results = globalVars.rpc.cmd[testData['remote_agent'][0]]("writeFile", "!!TMP!!/%s" % configFile, config)
+            if results['success'] == False: return results
+
+            results = self.hostLabelResolver(testData['service_locator_host'])
+            if results['success'] == False: return results
+
+            locator = "LocatorService:tcp -p 4411 -h %s" % results['ip']
+            cmdList = [configurator, "-l", "%s" % locator, "-c", "!!TMP!!/%s" % configFile]
+
+            results = globalVars.rpc.cmd[testData['remote_agent'][0]]('run', 'configurator', cmd, cmdList, True, True) 
+            if results['success'] == False: return results
 
         return {'success':True, 'shutdownExempt':'True'}
-
-# 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 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, value, default = None):
-        setattr(object, item, default)
-        self.options[option] = [ object, item, item_name, value, 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]
-        value = self.options[option][3]
-        default = self.options[option][4]
-
-        try:
-            setattr(object, item, value)
-
-        except ValueError:
-            # This is not a fatal error since we just use the default value.
-            if default == None:
-                print >> sys.stderr, "WARNING! The specified value for option '" + option + "' is not valid and no default value exists."
-            else:
-                print >> sys.stderr, "WARNING! 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 >> sys.stderr, "WARNING! Option '" + option + "' requires a value to be set and no default value exists."
-
-# Common configurator application logic
-class ConfiguratorApp(Ice.Application, Misc.Utils):
-    '''
-    As the configurator app uses a base class from the Ice module, 
-    we don't want to pass the main function (which then executes 'run')
-    any arguments as it will expect a file path and we're using a dict
-    type instead.
-    '''
-    def __init__(self, globalVars, cmd, host, config, AsteriskSCF, configWipe=False, serviceLocatorParams=None):
-        self.cmd = cmd
-        self.host = host
-        self.config = config
-        self.configWipe = configWipe
-        self.AsteriskSCF = AsteriskSCF
-        self.serviceLocatorParams = serviceLocatorParams
-
-    def createContext(self):
-        newContext = self.AsteriskSCF.System.V1.OperationContext()
-        newContext.id = str(uuid.uuid4()) # Random UUID
-        newContext.transactionId = newContext.id
-        return newContext
-
-    def run(self, args):
-        if self.cmd == 'sip':
-            visitor = SIPSectionVisitors()
-        if self.cmd == 'rtp':
-            visitor = RTPSectionVisitors()
-
-        visitor.AsteriskSCF = self.AsteriskSCF
-      
-        locator = 'LocatorService:tcp -p 4411 -h %s' % self.host
-        configurationServiceName = ""
-
-        try:
-            serviceLocator = self.AsteriskSCF.Core.Discovery.V1.ServiceLocatorPrx.checkedCast(self.communicator().stringToProxy(locator))
-        except:
-            return self.resFailure('Locator endpoint is invalid: %s. %s' % (locator, sys.exc_info()[1]))
-
-        if serviceLocator:
-            # Populate params with the name
-            setattr(self.serviceLocatorParams, "name", configurationServiceName)
-
-            try:
-                service = serviceLocator.locate(self.serviceLocatorParams)
-            except self.AsteriskSCF.Core.Discovery.V1.ServiceNotFound:
-                return {'success':False,'msg':"Configuration service could not be found in service locator. %s" % sys.exc_info()[1]}
-
-            configurationService = self.AsteriskSCF.System.Configuration.V1.ConfigurationServicePrx.uncheckedCast(service)
-
-        if configurationService == None:
-            return {'success':False,'msg':"No configuration service to configure."}
-
-        for config in self.config:
-            for section in config:
-                res = visitor.visit(config[section], section)
-                if res['success'] == False:
-                    return res
-
-        if visitor.groups:
-            if self.configWipe == True:
-                # 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(self.createContext(), groups)
-                except:
-                    return {'success':False,'msg':'Configuration could not be wiped - Failed to contact component'}
-
-            configurationService.setConfiguration(self.createContext(), visitor.groups)
-
-            try:
-                configurationService.setConfiguration(self.createContext(), visitor.groups)
-            except:
-                print "here"
-                return {'success':False,'msg':'Configuration could not be applied - Failed to contact component. %s' % sys.exc_info()[0]}
-        else:
-            return {'success':False,'msg':'No configuration to apply.'}
-
-        return {'success':True}
-
-# Common section visitor pattern implementation
-class SectionVisitors(Misc.Utils):
-    def __init__(self):
-        """Generic class meant to be inherited from for section visitors"""
-        self.groups = []
-        self.hosts = {}
-
-    def visit(self, config, section):
-        """Execute the visit_ function corresponding to the section name"""
-        try:
-            method = getattr(self, 'visit_%s' % section)
-        except AttributeError:
-            return self.visit_unsupported(config, section)
-        else:
-            return method(config, section);
-
-    def visit_unsupported(self, config, section):
-        """Handle an unsupported configuration section"""
-        print >> sys.stderr, "Unsupported configuration section " + section
-
-    def chkOption(self, config, option):
-        try:
-            return config[option]
-        except:
-            return None
-
-    def getRemoteHost(self, section, config, hostLabel, portLabel):
-        try:
-            config[hostLabel]
-        except:
-            if skipIfNoValue == False:
-                return self.resFailure('The required option, \'%s\', is not set in \'%s\'.' % (hostLabel, section))
-            else:
-                return {'success':True, hostLabel:None, portLabel:None}
-
-        try:
-            config[hostLabel][0]
-            config[hostLabel][1]
-            config[hostLabel][2]
-        except:
-            return self.resFailure('The testcase host is invalid in the %s section. Must be a list containing hostname, iface label, and ip version. ' % section)
-
-        res = self.hostLabelResolver(config[hostLabel])
-        if res['success'] == False:
-            return res
-            
-        return {'success':True, hostLabel:res['ip'], portLabel:config[portLabel]}
-
-class SIPSectionVisitors(SectionVisitors):
-    def visit_general(self, config, section):
-        group = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPGeneralGroup()
-        group.configurationItems = {}
-        self.groups.append(group)
-        return {'success':True}
-
-    def visit_transport_udp(self, config, section):
-        remote = self.getRemoteHost(section, config, hostLabel='host', portLabel='port')
-        if remote['success'] == False:
-            return remote
-
-        group = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPUDPTransportGroup()
-        group.name = section
-        group.configurationItems = {}
-
-        mapper = OptionMapper()
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPHostItem()
-        mapper.map('host', item, 'host', 'address', remote['host'], None)
-        mapper.map('port', item, 'port', 'address', remote['port'], 5060)
-        for option in config:
-            mapper.execute(group, section, option)
-
-        mapper.finish(group)
-
-        self.groups.append(group)
-
-        return {'success':True}
-
-    def visit_transport_tcp(self, config, section):
-        remote = self.getRemoteHost(section, config, hostLabel='host', portLabel='port')
-        if remote['success'] == False:
-            return remote
-
-        group = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPTCPTransportGroup()
-        group.name = section
-        group.configurationItems = {}
-
-        mapper = OptionMapper()
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPHostItem()
-        mapper.map('host', item, 'host', 'address', remote['host'], None)
-        mapper.map('port', item, 'port', 'address', remote['port'], 5060)
-        for option in config.options(section):
-            if option == 'ipv4oripv6':
-                pass
-            mapper.execute(group, section, option)
-
-        mapper.finish(group)
-
-        self.groups.append(group)
-
-        return {'success':True}
-
-    def visit_transport_tls(self, config, section):
-        remote = self.getRemoteHost(section, config, hostLabel='host', portLabel='port')
-        if remote['success'] == False:
-            return remote
-
-        group = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPTLSTransportGroup()
-        group.name = section
-        group.configurationItems = {}
-
-        mapper = OptionMapper()
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPHostItem()
-        mapper.map('host', item, 'host', 'address', remote['host'], None)
-        mapper.map('port', item, 'port', 'address', remote['port'], 5060)
-        for option in config.options(section):
-            if option == 'ipv4oripv6':
-                pass
-            mapper.execute(group, section, option)
-
-        mapper.finish(group)
-
-        self.groups.append(group)
-
-        return {'success':True}
-
-    def visit_endpoint(self, config, section):
-        group = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPEndpointGroup()
-        group.name = section
-        group.configurationItems = {}
-
-        mapper = OptionMapper()
-
-        mapper.map('routing', self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPRoutingItem(), 'routingServiceName', 'routingService', config.get, None)
-
-        remote = self.getRemoteHost(section, config, hostLabel='sourcehost', portLabel='sourceport')
-        if remote['success'] == False:
-            return remote
-
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPSourceTransportAddressItem()
-        mapper.map('sourcehost', item, 'host', 'sourceaddress', remote['sourcehost'], None)
-        mapper.map('sourceport', item, 'port', 'sourceaddress', remote['sourceport'], 5060)
-
-        remote = self.getRemoteHost(section, config, hostLabel='targethost', portLabel='targetport')
-        if remote['success'] == False:
-            return remote
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPTargetDestinationAddressItem()
-        mapper.map('targethost', item, 'host', 'targetaddress', remote['targethost'], None)
-        mapper.map('targetport', item, 'port', 'targetaddress', remote['targetport'], 5060)
-
-        class AllowableCallDirectionTransformer():
-            def get(self, option, AsteriskSCF):
-                if option:
-                    if option == 'inbound':
-                        return AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPAllowableCallDirection.Inbound
-                    elif option == 'outbound':
-                        return AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPAllowableCallDirection.Outbound
-                    elif option == 'both':
-                        return AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPAllowableCallDirection.Both
-                    elif option == 'none':
-                        return AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPAllowableCallDirection.Disabled
-                return AsteriskSCF.SIP.V1.SIPAllowableCallDirection.Both
-
-        transformer = AllowableCallDirectionTransformer()
-
-        mapper.map('direction', self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPAllowableCallDirectionItem(), 'callDirection', 'callDirection', transformer.get(self.chkOption(config, 'direction'), self.AsteriskSCF), None)
-        mapper.map('securetransport', self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPEndpointTransportItem(), 'secureTransport', 'transport', transformer.get(self.chkOption(config, 'securetransport'), self.AsteriskSCF), None)
-
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPRTPMediaServiceItem()
-        mapper.map('rtpoveripv6', item, 'requireIPv6', 'mediaservice', self.chkOption(config, 'rtpoveripv6'), None)
-
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPCryptoCertificateItem()
-        mapper.map('certificateauthorityfile', item, 'certificateAuthority', 'cryptocert', self.chkOption(config, 'certificateauthorityfile'), None)
-        mapper.map('certificatefile', item, 'certificate', 'cryptocert', self.chkOption(config, 'certificatefile'), None)
-        mapper.map('privatekeyfile', item, 'privateKey', 'cryptocert', self.chkOption(config, 'privatekeyfile'), None)
-        mapper.map('privatekeypassword', item, 'privateKeyPassword', 'cryptocert', self.chkOption(config, 'privatekeypassword'), None)
-
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPCryptoRequirementsItem()
-        mapper.map('requireverifiedserver', item, 'requireVerifiedServer', 'cryptorequirements', self.chkOption(config, 'requireverifiedserver'), None)
-        mapper.map('requireverifiedclient', item, 'requireVerifiedClient', 'cryptorequirements', self.chkOption(config, 'requireverifiedclient'), None)
-        mapper.map('requireclientcertificate', item, 'requireClientCertificate', 'cryptorequirements', self.chkOption(config, 'requireclientcertificate'), None)
-
-        item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPCryptoItem()
-        mapper.map('supportedciphers', item, 'supportedCiphers', 'crypto', self.chkOption(config, 'supportedciphers'), None)
-        mapper.map('tlsservername', item, 'serverName', 'crypto', self.chkOption(config, 'tlsservername'), None)
-        mapper.map('tlstimeout', item, 'timeout', 'crypto', self.chkOption(config, 'tlstimeout'), None)
-
-        if self.chkOption(config, 'tlsprotocolmethod') == 'tlsv1':
-            tlsprotocolmethod = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.TLSProtocolMethod.PROTOCOLMETHODTLSV1
-        elif self.chkOption(config, 'tlsprotocolmethod') == 'sslv2':
-            tlsprotocolmethod = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.TLSProtocolMethod.PROTOCOLMETHODTSSLV2
-        elif self.chkOption(config, 'tlsprotocolmethod') == 'sslv3':
-            tlsprotocolmethod =  self.AsteriskSCF.Configuration.SIPSessionGateway.V1.TLSProtocolMethod.PROTOCOLMETHODSSLV3
-        elif self.chkOption(config, 'tlsprotocolmethod') == 'sslv23':
-            tlsprotocolmethod = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.TLSProtocolMethod.PROTOCOLMETHODSSLV23
-        else:
-            tlsprotocolmethod = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.TLSProtocolMethod.PROTOCOLMETHODUNSPECIFIED
-
-        mapper.map('tlsprotocolmethod', item, 'protocolMethod', 'crypto', tlsprotocolmethod, None)
-
-        for option in config:
-            if option == 'ipv4oripv6':
-                pass
-            mapper.execute(group, section, option)
-
-        mapper.finish(group)
-
-        if 'formats' in config:
-            try:
-                for format in config['formats'].split(','):
-                    name, found, rest = format.partition('/')
-                    sampleRate, found, rest = rest.partition('@')
-                    frameSize, found, formatSpecific = rest.partition(';')
- 
-                    item = self.AsteriskSCF.Configuration.SIPSessionGateway.V1.SIPMediaFormatItem()
-                    item.name = name
-                    if sampleRate:
-                        item.sampleRate = sampleRate
-                    if frameSize:
-                        item.frameSize = frameSize
-                    item.formatSpecific = []
-                    if formatSpecific:
-                        item.formatSpecific.append(formatSpecific)
-
-                    group.configurationItems[format] = item
-            except:
-                pass
-
-        self.groups.append(group)
-
-        return {'success':True}
-
-    def visit_unsupported(self, config, section):
-        if config['type'] == 'transport_udp':
-            return self.visit_transport_udp(config, section)
-        elif config['type'] == 'transport_tcp':
-            return self.visit_transport_tcp(config, section)
-        elif config['type'] == 'transport_tls':
-            return self.visit_transport_tls(config, section)
-        elif config['type'] == 'endpoint':
-            return self.visit_endpoint(config, section)
-
-class RTPSectionVisitors(SectionVisitors):
-    def visit_general(self, config, section):
-        group = self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.RTPGeneralGroup()
-        group.configurationItems = {}
-
-        mapper = OptionMapper()
-
-        portsItem = self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.PortRangesItem()
-        mapper.map('startport', portsItem, 'startPort', self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.PortRangesItemName, self.chkOption(config, 'startport'), 10000)
-        mapper.map('endport', portsItem, 'endPort', self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.PortRangesItemName, self.chkOption(config, 'endport'), 20000)
-
-        workerItem = self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.WorkerThreadCountItem()
-        mapper.map('workerthreadcount', workerItem, 'count', self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.WorkerThreadCountItemName, self.chkOption(config, 'workerthreadcount'), 4)
-
-        ipv4bind = ipv6bind = None
-        if not self.chkOption(config, 'ipv4bind') == None:
-            res = self.hostLabelResolver(config['ipv4bind'])
-            if res['success'] == True:
-                ipv4bind = res['ip']
-        if not self.chkOption(config, 'ipv6bind') == None:
-            res = self.hostLabelResolver(config['ipv6bind'])
-            if res['success'] == True:
-                ipv6bind = res['ip']
-                
-        ipv4BindingItem = self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.BindingIPv4Item()
-        mapper.map('ipv4bind', ipv4BindingItem, 'address', self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.BindingIPv4AddressItemName, ipv4bind, None)
-
-        ipv6BindingItem = self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.BindingIPv6Item()
-        mapper.map('ipv6bind', ipv6BindingItem, 'address', self.AsteriskSCF.Configuration.MediaRTPPJMEDIA.V1.BindingIPv6AddressItemName, ipv6bind, None)
- 
-        for option in config:
-            mapper.execute(group, section, option)
-
-        mapper.finish(group)
-        self.groups.append(group)
-    
-        return {'success':True}

commit 0e620d5dc7bb7b75f1a705f7401b9dac5a221657
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue May 22 11:36:03 2012 -0500

    Removed the hardcoded globalVars.env variable and added the ability to pass variables through the run function to subprocess for custom environments with system calls. This is good for setting variables used for things like ccache, astscf_home, and etc..

diff --git a/lib/python/SubProcess.py b/lib/python/SubProcess.py
index 5592889..a4b3227 100644
--- a/lib/python/SubProcess.py
+++ b/lib/python/SubProcess.py
@@ -36,11 +36,16 @@ class Exec(Misc.Utils, Logging.Artifacts):
         else:
             return res
 
-    def run(self, plugin, label, execCmd, wait=False, checkReturnCode=True):
+    def run(self, plugin, label, execCmd, wait=False, checkReturnCode=True, envAdd=None):
         if plugin in globalVars.processList:
             if label in globalVars.processList[plugin]:
                 return self.resFailure('%s executed by the %s plugin is already running.' % (label, plugin))
 
+        localEnv = os.environ
+
+        if not envAdd == None:
+            localEnv = self.dictMerge(envAdd, localEnv)
+
         for Cmd in execCmd:
                execCmd[execCmd.index(Cmd)] = self.replaceMarkers(Cmd)
 
@@ -55,7 +60,7 @@ class Exec(Misc.Utils, Logging.Artifacts):
         
         time.sleep(.5)
         if os.path.exists(execCmd[0]) and os.access(execCmd[0], os.X_OK):
-            p = subprocess.Popen(execCmd, bufsize=0, shell=False, stdout=logFileObject, stderr=logFileObject, env=globalVars.env)
+            p = subprocess.Popen(execCmd, bufsize=0, shell=False, stdout=logFileObject, stderr=logFileObject, env=localEnv)
             time.sleep(.5)
             p.poll()
 

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


-- 
asterisk-scf/release/testsuite.git



More information about the asterisk-scf-commits mailing list