From: Javier Garcia Date: Thu, 17 Sep 2015 08:33:45 +0000 (+0200) Subject: SLA plugin: template integration with SLA Dashboard X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=26b2d32f6132a3e619f47411adeccfa693b71162 SLA plugin: template integration with SLA Dashboard --- diff --git a/manifoldapi/static/js/manifold.js b/manifoldapi/static/js/manifold.js index d6f09320..7b2d54c1 100644 --- a/manifoldapi/static/js/manifold.js +++ b/manifoldapi/static/js/manifold.js @@ -1690,6 +1690,8 @@ case TYPE_LIST_OF_VALUES: query = query_ext.query; + var testbeds_with_sla = localStorage.getItem("sla_testbeds").split(","); + switch(query.object) { case 'resource': @@ -1735,9 +1737,9 @@ case TYPE_LIST_OF_VALUES: } } - /*var urn_regexp = /\+(.*?)\+/; + var urn_regexp = /\+(.*?)\+/; var testbed_urn = urn_regexp.exec(record.urn)[1]; - var has_sla = $.inArray(testbed_urn, localStorage.getItem("sla_testbeds").split(",")) != -1; + var has_sla = $.inArray(testbed_urn, testbeds_with_sla) != -1; if (has_sla) { // var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS); @@ -1748,7 +1750,7 @@ case TYPE_LIST_OF_VALUES: } else { delete warnings[CONSTRAINT_SLA]; } - }*/ + } manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_WARNINGS, warnings); // Signal the change to plugins (even if the constraint does not apply, so that the plugin can display a checkmark) diff --git a/plugins/sladialog/static/js/sladialog.js b/plugins/sladialog/static/js/sladialog.js index 2773df09..8ea38dc5 100644 --- a/plugins/sladialog/static/js/sladialog.js +++ b/plugins/sladialog/static/js/sladialog.js @@ -1,13 +1,10 @@ /** - * MyPlugin: demonstration plugin - * Version: 0.1 - * Description: Template for writing new plugins and illustrating the different - * possibilities of the plugin API. - * This file is part of the Manifold project + * SlaDialog + * Description: Plugin to allow SLA acceptance and creation to MySlice portal + * in Fed4FIRE * Requires: js/plugin.js - * URL: http://www.myslice.info - * Author: Jordan Augé - * Copyright: Copyright 2012-2013 UPMC Sorbonne Universités + * Author: Javier García Lloreda + * Copyright: Copyright Atos Spain S.A. * License: GPLv3 */ @@ -18,17 +15,8 @@ accepted_slas: {}, queries: [], - /** XXX to check - * @brief Plugin constructor - * @param options : an associative array of setting values - * @param element : - * @return : a jQuery collection of objects on which the plugin is - * applied, which allows to maintain chainability of calls - */ init: function(options, element) { - // for debugging tools - this.classname="SlaDialog"; - // Call the parent constructor, see FAQ when forgotten + this.classname = "SlaDialog"; this._super(options, element); /* Member variables */ @@ -36,22 +24,19 @@ /* Plugin events */ /* Setup query and record handlers */ - - // Explain this will allow query events to be handled - // What happens when we don't define some events ? - // Some can be less efficient this.listen_query(options.query_uuid); /* GUI setup and event binding */ + // call function this.button_binding(); // Get testbeds with sla and store them in localStorage - //this.get_testbeds_with_sla(); - + this.get_testbeds_with_sla(); }, get_testbeds_with_sla: function () { + var self = this; return $.get('/sla/testbeds/', function(data) { if (typeof(Storage) !== "undefined") { if (!localStorage.getItem("sla_testbeds")) { @@ -59,24 +44,44 @@ localStorage.setItem("sla_testbeds", testbeds); } } + }).done(function(data) { + self.get_sla_templates(data); + alert("sla templates recovered: " + data); }); }, - find_row: function(key) - { - // key in third position, column id = 2 - var KEY_POS = 2; + get_sla_templates: function (testbeds) { - var cols = $.grep(this.table.fnSettings().aoData, function(col) { - return (col._aData[KEY_POS] == key); - } ); + testbeds.forEach(function(testbed, index, array) { - if (cols.length == 0) - return null; - if (cols.length > 1) - throw "Too many same-key rows in ResourceSelected plugin"; + if(testbed!="omf:netmode") { return } // TODO: remove - return cols[0]; + $.get('/sla/agreements/templates/' + testbed, function(slo) { + + $(".modal-body #sla_template").append(slo); + + var content = + " -
- - - - -
+
\ No newline at end of file diff --git a/sla/slaclient/restclient.py b/sla/slaclient/restclient.py index c3dc0134..4b8614be 100755 --- a/sla/slaclient/restclient.py +++ b/sla/slaclient/restclient.py @@ -343,12 +343,12 @@ class Templates(object): converter = xmlconverter.AgreementConverter() self.res = _Resource(resourceurl, converter) - def getall(self): + def getall(self, provider_id): """ Get all templates :rtype : list[wsag_model.Template] """ - return self.res.getall() + return self.res.get(path="", params={"testbed": provider_id}) def getbyid(self, provider_id): """Get a template diff --git a/sla/slicetabsla.py b/sla/slicetabsla.py index c9043f67..a5b56fd2 100755 Binary files a/sla/slicetabsla.py and b/sla/slicetabsla.py differ diff --git a/sla/urls.py b/sla/urls.py index 03ab14f9..87363ee1 100755 --- a/sla/urls.py +++ b/sla/urls.py @@ -13,6 +13,8 @@ urlpatterns = patterns('', slicetabsla.agreement_details, name='agreement_details'), url(r'^agreements/(?P[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/guarantees/(?P\w+)/violations$', slicetabsla.agreement_term_violations, name='agreement_term_violations'), + url(r'^agreements/templates/(?P[^/]+)', + slicetabsla.AgreementTemplates.as_view(), name='agreement_templates'), url(r'^agreements/create/$', slicetabsla.CreateAgreement.as_view(), name="agreement_create"), # url(r'^agreements/simplecreate/?$',