[asterisk-scf-commits] asterisk-scf/integration/configurator.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 2 14:32:14 CDT 2012


branch "retry_deux" has been updated
       via  9054045f97e5a614221631be335719bcf50586d2 (commit)
      from  d7e61b03d974083ba546172435c1e7029cda8a95 (commit)

Summary of changes:
 ActivateServiceLocator.py |   76 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 ActivateServiceLocator.py


- Log -----------------------------------------------------------------
commit 9054045f97e5a614221631be335719bcf50586d2
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Wed May 2 14:24:42 2012 -0500

    Added Activator for just the ServiceLocator.

diff --git a/ActivateServiceLocator.py b/ActivateServiceLocator.py
new file mode 100644
index 0000000..0298aa8
--- /dev/null
+++ b/ActivateServiceLocator.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import argparse
+
+sys.path.append('/opt/Ice-3.4.2/python')
+
+import Ice, AsteriskSCF
+
+slice = os.environ["ASTSCF_HOME"] + "/slice/slice"
+AstSCFslice = slice + "/AsteriskSCF/"
+
+Ice.loadSlice("-I\"" + slice + "\" -I\"" + Ice.getSliceDir() + "\" --all \"" + AstSCFslice + "System/Component/ReplicaIf.ice\"")
+Ice.loadSlice("-I\"" + slice + "\" -I\"" + Ice.getSliceDir() + "\" --all \"" + AstSCFslice + "Core/Discovery/ServiceLocatorIf.ice\"")
+
+import AsteriskSCF.Core.Discovery.V1
+import AsteriskSCF.System.Component.V1 
+
+# This is a utiltity for activating the ServiceLocator. Components are typically activated by accessing their 
+# Replica interface from the ServiceLocator and calling the activate() operation. But for the ServiceLocator
+# itself, we use a direct proxy as sort of boot-strap. 
+#
+# Note that the Activator.py script will activate the ServiceLocator (if needed) if you use it to activate some other
+# component, using a similar technique as that below. But if you are running the ServiceLocator in a replica group, and
+# all the other components are in stand-alone mode, you need a way to activate just a ServiceLocator. This is it. 
+#
+class ComponentActivator(Ice.Application):
+    def run(self, args):
+        serviceLocatorReplicaString = 'ServiceLocatorReplica:tcp '
+       
+        argParser = argparse.ArgumentParser(description = 'Place a Service Locator in the \'active\' state.')
+        argParser.add_argument('-sh', '--service_locator_host', 
+            help='(OPTIONAL) Hostname or IP address of the Service Locator. If not specified, localhost is assumed.')
+	argParser.add_argument('-p', '--port', help='(OPTIONAL) Port number to access the Replica interface. (Default=4410)')
+
+        try:
+            args = argParser.parse_args()
+        except:
+            print ''
+            return 2
+
+        # Get a reference to the Service Locator's Replica interface. 
+        if not args.service_locator_host == None:
+            serviceLocatorReplicaString = serviceLocatorReplicaString + ' -h ' + args.service_locator_host
+
+	if not args.port == None:
+            serviceLocatorReplicaString = serviceLocatorReplicaString + ' -p ' + args.port
+        else:
+	    serviceLocatorReplicaString = serviceLocatorReplicaString + ' -p 4410'
+
+        try:
+            serviceLocatorReplica = AsteriskSCF.System.Component.V1.ReplicaPrx.checkedCast(self.communicator().stringToProxy(serviceLocatorReplicaString))
+	except Ice.ObjectNotExistException as e:
+            print >> sys.stderr, "No Replica interface found using: " + serviceLocatorReplicaString
+	    return -1
+
+        if serviceLocatorReplica == None:
+	    print >> sys.stderr, "Invalid Replica proxy using: " + serviceLocatorReplicaString
+	    print >> sys.stderr, "For usage details please run " + sys.argv[0] + " --help"
+            return -1
+
+	# Now make sure the Service Locator is active. 
+        try:
+	    print "Activating Service Locator using proxy: " + serviceLocatorReplicaString
+            result =  serviceLocatorReplica.activate(AsteriskSCF.createContext())
+	    
+        except Ice.Exception as ex:
+            print >> sys.stderr, "Exception trying to activate a Service Locator component: " + ex.what()
+            return -1
+
+
+if __name__ == '__main__':
+    print '' 
+    sys.exit(ComponentActivator().main(sys.argv))
+

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


-- 
asterisk-scf/integration/configurator.git



More information about the asterisk-scf-commits mailing list