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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu May 26 18:10:08 CDT 2011


branch "master" has been updated
       via  172c3c0e2ce2172208b4247f41cb6a7247cddd06 (commit)
      from  7f2109621858bd9d3988115e0301becd99c9c2ec (commit)

Summary of changes:
 replica_tool.py |   41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit 172c3c0e2ce2172208b4247f41cb6a7247cddd06
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Thu May 26 18:08:09 2011 -0500

     - Added "-a" param to allow setting path to Slice API files.
     - Allow specifying proxy string on command line without need for
     separate property file.
     - Added the AsteriskSCF root of the slice API directory for the path.

diff --git a/replica_tool.py b/replica_tool.py
index 105ab2a..d22283b 100644
--- a/replica_tool.py
+++ b/replica_tool.py
@@ -14,8 +14,8 @@ replica_tool.py is a command line python script for querying the
 status of replicas, making a standby replica active and putting an
 active replica on standby.
 
-Usage:
-   replica_tool.py [-f=proxy_list_file] command property_name [command property_anme ...]
+Usage:[-a=asterisk_scf_api_path]
+   replica_tool.py [-f=proxy_list_file] [-a=asterisk_scf_api_path] command property_or_proxy [command property_or_proxy ...] 
 
 The command line format is options followed by command/property name pairs.
 
@@ -24,10 +24,16 @@ Where command is one of:
    standby  - tell the replica to enter standby mode
    status   - query the status of the replica
 
+If -a option is omitted an Environment variable named ASTERISKSCF_SLICE will be checked to 
+locate the slice API of Asterisk SCF. If that Environment variable is unset, the 
+current directory will be checked.  
+
 Each command is followed by a string that specifies a property name
-contained in either the file specified by the proxy_list_file option
-or in the properties configured in the Ice communicator for this
-process via Ice configuration.
+or proxy specification. If a file is specified with the -f option, 
+the string is a assumed to be the name of a property from that file
+that defines a proxy to the Replica interface that is the target of
+the command. Otherwise, the string is interpreted to be an Ice 
+proxy string to the target Replica interface. 
 """
 
 if len(sys.argv) == 1:
@@ -40,19 +46,28 @@ global propertyFile
 propertyFile = ""
 
 try:
-    opts, args = getopt.getopt(sys.argv[1:], "-f:")
+    opts, args = getopt.getopt(sys.argv[1:], "f:a:")
 except getopt.GetoptError:
     usage()
 
+slicepath = ""
+
 for o, a in opts:
     if o == "-f":
         propertyFile = a
+    if o == "-a":
+        slicepath = a	
+
+print "Using slicepath=" + slicepath
 
 if len(propertyFile) > 0 and not os.path.exists(propertyFile):
     print "Property file provided through -f option does not exist"
     sys.exit(1)
 
-slicepath = os.environ["ASTERISKSCF_SLICE"]
+if len(slicepath) == 0:
+    if os.environ.has_key("ASTERISKSCF_SLICE"):
+        slicepath = os.environ["ASTERISKSCF_SLICE"]
+
 if len(slicepath) == 0:
     slicepath = "."
 
@@ -60,9 +75,11 @@ if not os.path.exists(slicepath):
     print "Slice path does not exist."
     sys.exit(1)
 
-replicaSlice = os.path.join(slicepath, "System", "Component", "ReplicaIf.ice")
+print "Using slicepath=" + slicepath
+
+replicaSlice = os.path.join(slicepath, "AsteriskSCF", "System", "Component", "ReplicaIf.ice")
 if not os.path.exists(replicaSlice):
-    print "Unable to locate replica slice."
+    print "Unable to locate replica slice: " + replicaSlice
     sys.exit(1)
 
 Ice.loadSlice("--all -I" + slicepath + " " + replicaSlice)
@@ -81,7 +98,11 @@ class ReplicaTool(Ice.Application):
             self.mProperties = self.communicator().getProperties()
         
         for cmd, prop in pairs:
-            objref = self.mProperties.getProperty(prop)
+	    if len(self.mPropertyFile) > 0:
+                objref = self.mProperties.getProperty(prop)
+            else:
+	        objref = prop
+
             if len(objref) == 0:
                 print "unknown object"
                 return 1

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


-- 
asterisk-scf/release/replica_tool.git



More information about the asterisk-scf-commits mailing list