can select an alternate config. directory on the command-line
[sface.git] / sface / sfiprocess.py
index 6f2140b..f794c63 100644 (file)
@@ -41,6 +41,9 @@ class SfiProcess(QObject):
 
     def __init_command(self, args):
         self.args = QStringList()
+        self.args << "-d"
+        self.args << config.get_dirname()
+
         if config.debug:
             # this shows xmlrpc conversation, see sfi.py docs.
             self.args << QString('-D')
@@ -105,6 +108,27 @@ class SfiProcess(QObject):
 #    def getRSpecFromAM(self):
 #        return self.__getRSpec(config.getAggmgr())
 
+    def listRecords(self, hrn, rectype=None, filename=None):
+        args = ["-u", config.getUser(), "-a", config.getAuthority(),
+                "-r", config.getRegistry(), "-s", config.getSlicemgr(), "list", hrn]
+
+        if filename:
+            # we can't tell whether SFI will create one file or many, so delete
+            # leftovers from last time, then we'll know what we got, after we get it.
+            if os.path.exists(filename):
+                os.remove(filename)
+            if os.path.exists(filename + ".1"):
+                os.remove(filename + ".1")
+            args.append("-o")
+            args.append(filename)
+
+        if rectype:
+            args.append("-t")
+            args.append(rectype)
+
+        self.__init_command(args)
+        self.start()
+
     def getRecord(self, hrn, filename=None):
         args = ["-u", config.getUser(), "-a", config.getAuthority(),
                 "-r", config.getRegistry(), "-s", config.getSlicemgr(), "show", hrn]
@@ -114,6 +138,12 @@ class SfiProcess(QObject):
         self.__init_command(args)
         self.start()
 
+    def getSliceRecord(self):
+        self.getRecord(config.getSlice(), config.getSliceRecordFile())
+
+    def getAuthorityRecord(self):
+        self.getRecord(config.getAuthority(), config.getAuthorityRecordFile())
+
     def applyRSpec(self, rspec):
         filename = config.getSliceRSpecFile() + "_new"
         rspec.save(filename)
@@ -130,6 +160,12 @@ class SfiProcess(QObject):
         self.__init_command(args)
         self.start()
 
+    def addRecord(self, filename):
+        args = ["-u", config.getUser(), "-a", config.getAuthority(),
+                "-r", config.getRegistry(), "-s", config.getSlicemgr(), "add", filename]
+        self.__init_command(args)
+        self.start()
+
     def renewSlivers(self, expiration):
         args = ["-u", config.getUser(), "-a", config.getAuthority(),
                 "-r", config.getRegistry(), "-s", config.getSlicemgr(), "renew",