var CONSTRAINT_RESERVABLE_LEASE_MSG = "Configuration required: this resource needs to be scheduled";
+var CONSTRAINT_SLA = 1;
+
+var CONSTRAINT_SLA_MSG = "SLA acceptance required: testbed offers SLA for its resources"
+
// A structure for storing queries
function QueryExt(query, parent_query_ext, main_query_ext, update_query_ext, disabled, domain_query_ext) {
switch(query.object) {
case 'resource':
+
+ var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS);
// CONSTRAINT_RESERVABLE_LEASE
//
// +) If a reservable node is added to the slice, then it should have a corresponding lease
// XXX Not always a resource
var is_reservable = (record.exclusive == true);
if (is_reservable) {
- var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS);
+ // var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS);
if (event_type == STATE_SET_ADD) {
// We should have a lease_query associated
var warn = CONSTRAINT_RESERVABLE_LEASE_MSG;
warnings[CONSTRAINT_RESERVABLE_LEASE] = warn;
- manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_WARNINGS, warnings);
+ /*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)
data = {
state: STATE_WARNINGS,
op : null,
value : warnings
}
- manifold.raise_record_event(query.query_uuid, FIELD_STATE_CHANGED, data);
+ manifold.raise_record_event(query.query_uuid, FIELD_STATE_CHANGED, data);*/
} else {
// Lease are defined, delete the warning in case it was set previously
}
}
+ /*var urn_regexp = /\+(.*?)\+/;
+ var testbed_urn = urn_regexp.exec(record.urn)[1];
+ var has_sla = $.inArray(testbed_urn, localStorage.getItem("sla_testbeds").split(",")) != -1;
+
+ if (has_sla) {
+ // var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS);
+
+ if (event_type == STATE_SET_ADD) {
+ var warn = CONSTRAINT_SLA_MSG;
+ warnings[CONSTRAINT_SLA] = warn;
+ } 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)
+ data = {
+ state: STATE_WARNINGS,
+ key : record_key,
+ op : null,
+ value : warnings
+ }
+ manifold.raise_record_event(query.query_uuid, FIELD_STATE_CHANGED, data);
+
+ // JGLL: SLA code
+ /*get_testbeds_with_sla()
+ .done( function(testbeds) {
+ var urn_regexp = /\+(.*?)\+/;
+ var testbed_urn = urn_regexp.exec(record.urn)[1];
+
+ var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS);
+
+ if ($.inArray(testbed_urn, testbeds) != -1) {
+ // JGLL: Set a warning on resources covered by testbeds offering SLAs
+ // CONSTRAINT_SLA
+
+ if (event_type == STATE_SET_ADD) {
+ var warn = CONSTRAINT_SLA_MSG;
+ warnings[CONSTRAINT_SLA] = warn;
+ } 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)
+ data = {
+ state: STATE_WARNINGS,
+ key : record_key,
+ op : null,
+ value : warnings
+ }
+
+ manifold.raise_record_event(query.query_uuid, FIELD_STATE_CHANGED, data);
+ })
+ .fail( function(err) {
+ console.log("SLA - Error retrieving testbeds that support SLAs");
+ });*/
+
/* This was redundant */
- // manifold.query_store.recount(query.query_uuid);
+ // manifold.query_store.recount(query.query_uuid);
break;
switch(event_type) {
case STATUS_REMOVE_WARNING:
record = manifold.query_store.get_record(query_uuid, data.value);
- this._enforce_constraints(query_ext, record, data.value, STATE_SET_ADD);
+ this._enforce_constraints(query_ext, record, data.value, STATE_SET_REMOVE);
+ break;
// XXX At some point, should be renamed to RECORD_STATE_CHANGED
case FIELD_STATE_CHANGED: