X-Git-Url: http://git.onelab.eu/?p=sface.git;a=blobdiff_plain;f=sface%2Fscreens%2Fmainscreen.py;h=3c1be13c6ea06a89d488ec2e363b073647dcf10b;hp=0452161a5ba1ff2e34834835f2a286f5a3e62ad8;hb=b4479edcd8022bc11805758a575f7ca96dcdfc04;hpb=a42adfb545b5810b301f43a6eede650c94ab5e9d
diff --git a/sface/screens/mainscreen.py b/sface/screens/mainscreen.py
index 0452161..3c1be13 100644
--- a/sface/screens/mainscreen.py
+++ b/sface/screens/mainscreen.py
@@ -1,11 +1,11 @@
import datetime
import os
+import urlparse
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#from sfa.util.rspecHelper import RSpec
-from sfa.rspecs.rspec_parser import parse_rspec
from sface.config import config
from sface.sfirenew import RenewWindow
from sface.sfiprocess import SfiProcess
@@ -338,7 +338,7 @@ class SliceWidget(QWidget):
self.connect(refresh, SIGNAL('clicked()'), self.refresh)
self.connect(renew, SIGNAL('clicked()'), self.renew)
- self.connect(submit, SIGNAL('clicked()'), self.submit)
+ self.connect(submit, SIGNAL('clicked()'), self.submit_pg_compat)
self.connect(searchbox, SIGNAL('textChanged(QString)'), self.search)
self.connect(filterbox, SIGNAL('currentIndexChanged(QString)'), self.filter)
self.connect(self.nodeView, SIGNAL('hostnameClicked(QString)'),
@@ -423,11 +423,11 @@ class SliceWidget(QWidget):
print "Error: Failed to find %s in resources rspec" % hostname
else:
rspec.merge_node(resource_node, testbed)
- rspec.add_slivers(str(hostname), testbed)
+ rspec.add_slivers([{"hostname": str(hostname)}], testbed)
change = True
elif status == node_status['remove']:
print "Remove hostname: %s" % hostname
- rspec.remove_slivers(str(hostname), testbed)
+ rspec.remove_slivers([{"hostname": str(hostname)}], testbed)
change = True
elif depth == 3: # Tag
tag, value = self.itemText(item).split(": ")
@@ -438,14 +438,14 @@ class SliceWidget(QWidget):
testbed = self.itemText(item.parent().parent())
if status == tag_status['add']:
print "Add tag to (%s, %s): %s/%s " % (testbed, node, tag, value)
- if node.startsWith(default_tags):
+ if node.startswith(default_tags):
rspec.add_default_sliver_attribute(tag, value, testbed)
else:
rspec.add_sliver_attribute(node, tag, value, testbed)
change = True
elif status == tag_status['remove']:
print "Remove tag from (%s, %s): %s/%s " % (testbed, node, tag, value)
- if node.startsWith(default_tags):
+ if node.startswith(default_tags):
rspec.remove_default_sliver_attribute(tag, value, testbed)
else:
rspec.remove_sliver_attribute(node, tag, value, testbed)
@@ -470,11 +470,120 @@ class SliceWidget(QWidget):
self.setStatus("No change in slice data. Not submitting!", timeout=3000)
return
- self.connect(self.process, SIGNAL('finished()'), self.submitFinished)
+ # Several aggregates have issues with the section in the
+ # rspec, so make sure it's not there.
+ stats_elems = rspec.xml.xpath("//statistics")
+ if len(stats_elems)>0:
+ stats_elem = stats_elems[0]
+ parent = stats_elem.xpath("..")[0]
+ parent.remove(stats_elem)
+ self.connect(self.process, SIGNAL('finished()'), self.submitFinished)
self.process.applyRSpec(rspec)
self.setStatus("Sending slice data (RSpec). This will take some time...")
+ # ProtoGENI-compatible submit. Contact each aggregate individually rather
+ # than using the slice manager.
+ # This code will be removed when ProtoGENI slicemanager is patched.
+ def submit_pg_compat(self):
+ if self.checkRunningProcess():
+ return
+
+ rspec = SfiData().getSliceRSpec()
+ resources = SfiData().getResourcesRSpec()
+ change = self.process_subtree(rspec, resources, self.nodeModel.invisibleRootItem())
+
+ if not change:
+ self.setStatus("No change in slice data. Not submitting!", timeout=3000)
+ return
+
+ # Several aggregates have issues with the section in the
+ # rspec, so make sure it's not there.
+ stats_elems = rspec.xml.xpath("//statistics")
+ if len(stats_elems)>0:
+ stats_elem = stats_elems[0]
+ parent = stats_elem.xpath("..")[0]
+ parent.remove(stats_elem)
+
+ self.submit_aggSuccessCount = 0
+ self.submit_aggFailCount = 0
+ self.submit_rspec = rspec
+ self.connect(self.process, SIGNAL('finished()'), self.getVersionFinished)
+ self.process.getSliceMgrVersion()
+ self.setStatus("Getting aggregate directory...")
+
+ def getVersionFinished(self):
+ self.disconnect(self.process, SIGNAL('finished()'), self.getVersionFinished)
+
+ faultString = self.process.getFaultString()
+ if not faultString:
+ peers = SfiData().getSliceMgrVersion()["peers"]
+ self.submit_aggs = [(key, peers[key]) for key in peers.keys()]
+ self.delete_aggs = [(key, peers[key]) for key in peers.keys() if key.startswith("emulab")]
+ str = "Successfully retrieved agg list. "
+ #self.submitNextAgg(str)
+ self.deleteNextAgg(str)
+ else:
+ self.setStatus("getSliceMgrVersion failed: %s" % (faultString))
+
+ def deleteNextAgg(self, statusStr=""):
+ if (self.delete_aggs == []):
+ self.submitNextAgg(statusStr)
+ return
+
+ self.delete_agg = self.delete_aggs.pop()
+
+ urlParts = urlparse.urlsplit(self.delete_agg[1])
+ amPort = urlParts.port
+ amAddr = urlParts.hostname+urlParts.path
+
+ self.setStatus(statusStr + "Deleting slivers on %s..." % (self.delete_agg[0]))
+
+ self.connect(self.process, SIGNAL('finished()'), self.deleteNextAggFinished)
+ self.process.deleteSlivers(aggAddr = amAddr, aggPort = amPort)
+
+ def submitNextAgg(self, statusStr=""):
+ if (self.submit_aggs == []):
+ self.setStatus(statusStr + "Finished submitting. %d/%d aggs succeeded." %
+ (self.submit_aggSuccessCount,self.submit_aggSuccessCount+self.submit_aggFailCount))
+ QTimer.singleShot(2500, self.refresh)
+ return
+
+ self.submit_agg = self.submit_aggs.pop()
+
+ urlParts = urlparse.urlsplit(self.submit_agg[1])
+ amPort = urlParts.port
+ amAddr = urlParts.hostname+urlParts.path
+
+ self.setStatus(statusStr + "Submitting to %s..." % (self.submit_agg[0]))
+
+ self.connect(self.process, SIGNAL('finished()'), self.submitNextAggFinished)
+ self.process.applyRSpec(self.submit_rspec, aggAddr = amAddr, aggPort = amPort, saveObtained=False)
+
+ def submitNextAggFinished(self):
+ self.disconnect(self.process, SIGNAL('finished()'), self.submitNextAggFinished)
+
+ faultString = self.process.getFaultString()
+ if not faultString:
+ self.submit_aggSuccessCount+=1
+ str = "Succeeded on %s. " % (self.submit_agg[0])
+ else:
+ self.submit_aggFailCount+=1
+ str = "Failed on %s. " % (self.submit_agg[0]) # , faultString)
+
+ self.submitNextAgg(str)
+
+ def deleteNextAggFinished(self):
+ self.disconnect(self.process, SIGNAL('finished()'), self.deleteNextAggFinished)
+
+ faultString = self.process.getFaultString()
+ if not faultString:
+ str = "Succeeded deleteslivers on %s. " % (self.delete_agg[0])
+ else:
+ str = "Failed deleteslivers on %s. " % (self.delete_agg[0]) # , faultString)
+
+ self.deleteNextAgg(str)
+
def renew(self):
dlg = RenewWindow(parent=self)
dlg.exec_()