From: Javier GarcĂ­a Date: Mon, 1 Dec 2014 12:03:09 +0000 (+0100) Subject: Merge branch 'fed4fire' into onelab X-Git-Tag: myslice-1.1~27 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=3aae671a1ca0cef870a268b88ddcde8d520d7621;hp=d3828739b742f18881ce982179ea0f75b080ed71;p=myslice.git Merge branch 'fed4fire' into onelab Conflicts: plugins/queryupdater/static/js/queryupdater.js portal/templates/base.html --- diff --git a/myslice/settings.py b/myslice/settings.py index 235a18ca..fe71e108 100644 --- a/myslice/settings.py +++ b/myslice/settings.py @@ -278,7 +278,8 @@ LOGGING = { } } -AUTHENTICATION_BACKENDS = ( 'auth.manifoldbackend.ManifoldBackend','django.contrib.auth.backends.ModelBackend' ) +AUTHENTICATION_BACKENDS = ('auth.manifoldbackend.ManifoldBackend', + 'django.contrib.auth.backends.ModelBackend') ### the view to redirect malformed (i.e. with a wrong CSRF) incoming requests # without this setting django will return a 403 forbidden error, which is fine @@ -292,6 +293,7 @@ CSRF_FAILURE_VIEW = 'manifoldapi.manifoldproxy.csrf_failure' ####SLA##### -SLA_MANAGER_URL = "http://157.193.215.125:4000/sla-service" -SLA_MANAGER_USER = "normal_user" -SLA_MANAGER_PASSWORD = "password" \ No newline at end of file +SLA_MANAGER_URL = "http://157.193.215.125:4001/sla-collector/sla" +#SLA_MANAGER_URL = "http://172.24.76.28:8000/sla" +SLA_MANAGER_USER = "portal" +SLA_MANAGER_PASSWORD = "password" diff --git a/plugins/queryupdater/static/js/queryupdater.js b/plugins/queryupdater/static/js/queryupdater.js index f3ba672d..f1d6b322 100644 --- a/plugins/queryupdater/static/js/queryupdater.js +++ b/plugins/queryupdater/static/js/queryupdater.js @@ -56,7 +56,109 @@ /***************************** GUI EVENTS *****************************/ - /************************** GUI MANIPULATION **************************/ + do_checksla: function(e) { + var username = e.data.options.username; + var urn = data.value; + var arraySelectedResources = data.selected_resources; + + var accepted_sla = []; + var count = 0; + var self = e.data; + // var testbedsWithSLA = ["iminds", "fuseco", "netmode"]; + var testbedsWithSLA; + + var sliverPattern = /IDN\+(.+)\+(node|channel)\+/; + var list = []; + + var promt = $('#sla-table-body'); + + $.get("/sla/testbeds/", function(data) { + testbedsWithSLA = data; + + console.log("Testbeds with SLA: " + testbedsWithSLA); + + $(arraySelectedResources).each(function () { + var sliverMatch = sliverPattern.exec(this); + var sliverId = sliverMatch[1]; + for (var i = 0; i < testbedsWithSLA.length; i++) { + if(this.indexOf(testbedsWithSLA[i].toLowerCase()) >= 0){ // If it has SLA + if (list.indexOf(sliverId) == -1) { // If it is not in the list + list.push(sliverId); + } + } + } + }); + + if (list.length > 0) { + for (var i = 0; i < list.length; i++) { + var element = $(''); + element.append( + $('').append(list[i]), + $('').append('99% of Uptime for 99% of resources'), + $('').append('
') + ); + promt.append(element); + } + + $('#sla_dialog').show(); + $('#slamodal').modal('show'); + } else { + //manifold.raise_event(self.options.query_uuid, RUN_UPDATE); + } + + }); + + $("#submit_sla").unbind().click(function(){ + console.log("With username: " + username); + + var notChecked = $("input[name='slaaccept']:not(:checked)"); + + if (notChecked.length > 0) { + for (var i = 0; i < notChecked.length; i++) { + console.log("SLA not accepted: " + notChecked[i].value); + } + + alert("All SLAs have to be accepted to continue with the reservation"); + + } else { + // $(list).each(function () { + // var date = new Date(); + // date.setYear(date.getFullYear() + 1); + + // $.post("/sla/agreements/simplecreate", + // { "template_id": this.toString(), + // "user": username, + // "expiration_time": date.toISOString() + // }); + + + // }); + + $.ajax({ + url: "/sla/agreements/simplecreate", + data: { testbeds: list, + user: username, + resources: arraySelectedResources, + slice: main_query.filters.slice()[0][2] + }, + type: "post", + traditional: true + }); + + console.log(main_query.filters.slice()[0][2]); + + $('#slamodal').modal('hide'); + $('#sla-table-body').empty(); + //manifold.raise_event(self.options.query_uuid, RUN_UPDATE); + } + }); + + $("#cancel_sla").unbind().click(function(){ + $('#slamodal').modal('hide'); + $('#sla-table-body').empty(); + }); + }, + /************************** GUI MANIPULATION **************************/ populate_table: function() { diff --git a/plugins/sladialog/templates/sladialog.html b/plugins/sladialog/templates/sladialog.html index ce27c2e4..cb50c29b 100644 --- a/plugins/sladialog/templates/sladialog.html +++ b/plugins/sladialog/templates/sladialog.html @@ -1,18 +1,27 @@
-