From: Costas Yiotis Date: Tue, 18 Nov 2014 12:25:16 +0000 (+0200) Subject: Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab X-Git-Tag: myslice-1.1~13^2~9 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=558fe659b62f98ccc7f4e64cab68dee712a9be30;hp=90c5da3ffa580fa4514579e405eb130adabe2ad5;p=unfold.git Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab --- diff --git a/README b/README index 4e0b4716..b1f201da 100644 --- a/README +++ b/README @@ -11,7 +11,7 @@ See the devel/ subdir for more devel-oriented doc. ** see devel/django-install.txt in case of trouble $ apt-get install python-django $ apt-get install python-django-south -$ apt-get install python-pip +$ apt-get install python-pip or sudo easy_install pip==1.4.1 $ pip install requests $ pip install djangorestframework * git clone git://git.onelab.eu/myslice.git diff --git a/activity/__init__.py b/activity/__init__.py index ab2cd0d3..4719a61c 100644 --- a/activity/__init__.py +++ b/activity/__init__.py @@ -34,7 +34,7 @@ else : # default log server server = "http://athos.ipv6.lip6.fr/activity/push/log" -def logWrite(request, action, message): +def logWrite(request, action, message, objects = None): if not apikey : print "===============>> activity: no apikey" @@ -54,17 +54,31 @@ def logWrite(request, action, message): "action" : action, "message" : message, "apikey" : apikey, - "signature" : sign(secret, "%s%s%s%s" % (timestamp, ip, request.user, action)) + "signature" : sign(secret, "%s%s%s%s" % (timestamp, ip, request.user, action)), + "slice" : None, + "resource" : None, + "resource_type" : None, + "facility" : None, + "testbed" : None, } + + if objects is not None: + for o in objects : + if (o in log) : + log[o] = objects[o] + try : result = urllib2.urlopen(server, urllib.urlencode(log)) + print "===============>> activity: %s <%s> %s" % (action, request.user,message) content = result.read() except urllib2.URLError as e: print "===============>> activity: connection to " + server + " impossible, could not log action" + print e.strerror + print "" -def log(request, action, message): +def log(request, action, message, objects = None): # Create a new thread in Daemon mode to send the log entry - t = threading.Thread(target=logWrite, args=(request, action, message)) + t = threading.Thread(target=logWrite, args=(request, action, message, objects)) t.setDaemon(True) t.start() diff --git a/activity/slice.py b/activity/slice.py new file mode 100644 index 00000000..f7f1eff4 --- /dev/null +++ b/activity/slice.py @@ -0,0 +1,11 @@ +# +# log functions for slice +# + +import activity + +def validate(request, o): + activity.log(request, "slice.validate", "Slice validation", o) + +def resource(request, o): + activity.log(request, "slice.resource", "Resource reservation", o) \ No newline at end of file diff --git a/manifoldapi/manifoldproxy.py b/manifoldapi/manifoldproxy.py index 433a854b..9897b506 100644 --- a/manifoldapi/manifoldproxy.py +++ b/manifoldapi/manifoldproxy.py @@ -13,6 +13,9 @@ from manifoldresult import ManifoldException from manifold.util.log import Log from myslice.configengine import ConfigEngine +# register activity +import activity.slice + debug=False #debug=True @@ -78,7 +81,26 @@ with the query passed using POST""" if 'description' in result and result['description'] \ and isinstance(result['description'], (tuple, list, set, frozenset)): result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ] - + + print "=> MANIFOLD PROXY executing: " + manifold_query.action.lower() + # + # register activity + # + # resource reservation + if (manifold_query.action.lower() == 'update') : + print result['value'][0] + if 'resource' in result['value'][0] : + for resource in result['value'][0]['resource'] : + activity.slice.resource(request, + { + 'slice' : result['value'][0]['slice_hrn'], + 'resource' : resource['hostname'], + 'resource_type' : resource['type'], + 'facility' : resource['facility_name'], + 'testbed' : resource['testbed_name'] + } + ) + json_answer=json.dumps(result) return HttpResponse (json_answer, mimetype="application/json") diff --git a/manifoldapi/static/js/manifold.js b/manifoldapi/static/js/manifold.js index 74fb5d9d..ca111de7 100644 --- a/manifoldapi/static/js/manifold.js +++ b/manifoldapi/static/js/manifold.js @@ -785,6 +785,7 @@ var manifold = { switch (this_type) { case TYPE_VALUE: case TYPE_LIST_OF_VALUES: + case TYPE_LIST_OF_RECORDS: if (this_value != other_value) return false; break; @@ -792,6 +793,9 @@ var manifold = { if (!(_record_equals(this_value, other_value, key_fields))) return false; break; + /* + XXX WARNING = disabled for OpenFlow plugin !!! + case TYPE_LIST_OF_RECORDS: if (this_value.length != other_value.length) return false; @@ -799,6 +803,7 @@ var manifold = { if (!(_record_equals(this_value[j], other_value[j], key_fields))) return false; break; + */ } } return true; @@ -1223,6 +1228,11 @@ var manifold = { } key = manifold.metadata.get_key(new_object); + if (!key){ + console.log("object type: " + new_object + " has no key"); + console.log(record); + return; + } record.hashCode = manifold.record_hashcode(key.sort()); record.equals = manifold.record_equals(key); diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index 7ddf300d..3c1aab2a 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -163,6 +163,62 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; }); $(".dataTables_filter").append("
"); $(".dataTables_filter input").css("width","100%"); + + // resource info + var sTable = this.table; + $('table.dataTable').delegate('a.resource-info','click',function() { + var aPos = sTable.fnGetPosition( this.parentNode ); + var aData = sTable.fnGetData( aPos[0] ); + //console.log(aData); + + var network_hrn = aData[18]; + var resourceData = { + 'hostname' : strip(aData[2]), + 'urn' : aData[6], + 'type' : aData[3], + 'status' : aData[10], + 'testbed' : aData[4], + 'facility' : aData[5], + }; + + + console.log(network_hrn); + //Greece: 37.6687092,22.2282404 + if (network_hrn == 'omf.nitos') { + var logo = 'nitos'; + var resourceLocation = { + 'longitude' : '22.2282404', + 'latitude' : '37.6687092', + }; + var coordinates = resourceLocation['latitude']+','+resourceLocation['longitude']; + } else if (network_hrn == 'iotlab') { + var logo = network_hrn; + var s = resourceData['hostname'].split("."); + var n = s[0].split("-"); + resourceData['type'] = 'node ( Hardware: '+n[0]+' )'; + var coordinates = resourceData['testbed']; + } else { + var logo = network_hrn; + var resourceLocation = { + 'longitude' : aData[13], + 'latitude' : aData[23], + }; + var coordinates = resourceLocation['latitude']+','+resourceLocation['longitude']; + } + + var modal = $('#resource-info-modal'); + modal.find('.modal-title').text(resourceData['testbed'] + ': ' +resourceData['hostname']); + table = modal.find('.modal-resource-info'); + table.html(''+resourceData['facility']+' - '+resourceData['testbed']+''); + for (var j in resourceData) { + table.append('' + j + '' + resourceData[j] + ''); + } + if (coordinates != '') { + table.append(''); + } + modal.modal(); + }); + }, // initialize_table /** @@ -232,7 +288,8 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; //TODO: we need to add source/destination for links line.push(''); else - line.push(record['hostname']); + //line.push(record['hostname']); + line.push('' + record['hostname'] + ''); } else if (colnames[j] == this.init_key && typeof(record) != 'undefined') { obj = this.object @@ -337,7 +394,7 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; } } else { msg = '