####SLA#####
SLA_COLLECTOR_URL = "http://157.193.215.125:4001/sla-collector/sla"
+#SLA_COLLECTOR_URL = "http://172.24.76.19:8000/sla"
SLA_COLLECTOR_USER = "portal"
SLA_COLLECTOR_PASSWORD = "password"
var urns = [];
- record.resource.forEach(function(r) {
- if ($.inArray(r.component_id, record.resource) == -1) { // if not already selected
- urns.push(r.component_id);
- }
- });
+ if (record.resource.length != 0 && typeof record.resource[0] === "object") {
+
+ record.resource.forEach(function(r) {
+ if ($.inArray(r.component_id, record.resource) == -1) { // if not already selected
+ urns.push(r.component_id);
+ }
+ });
- if (record.resource.length != 0 && typeof record.resource[0] !== "undefined") {
var data = {
"SLIVER_INFO_AGGREGATE_URN": record.resource[0].component_manager_id,
"SLIVER_INFO_EXPIRATION": record.lease[0].end_time, // FIXME: only working with leases
# for key, values in kwargs.iteritems():
# print key, values
- logger.debug('SLA GET {}'.format(url))
result = requests.get(url, **kwargs)
logger.debug('SLA GET {} - result: {}'.format(result.url, result.status_code))
# print "GET {} {} {}".format(
result = requests.post(url, data, **kwargs)
location = result.headers["location"] \
if "location" in result.headers else "<null>"
- print "POST {} {} Location: {}".format(
+ print "POST {} {} - Location: {}".format(
result.url, result.status_code, location)
return result
:param Element xmlroot: root element of xml to convert.
:rtype: wsag_model.Agreement
"""
- for name, value in xmlroot.attrib.items():
- logger.debug('SLA xmlconverter: {} = {}'.format(name, value))
- # print '{0}="{1}"'.format(name, value)
+ # for name, value in xmlroot.attrib.items():
+ # logger.debug('SLA xmlconverter: {} = {}'.format(name, value))
if xmlroot.tag in self.agreement_tags:
result = Agreement()
# this somehow is not used anymore - should it not be ?
import ast
from datetime import datetime
+import json
import pytz
from django.template import RequestContext
from django.shortcuts import render_to_response
row.append(agreement.context.time_formatted()) # Date
enf = _get_enforcement(agreement.agreement_id, provider)
- logger.debug("SLA AAAAA: {}".format(agreement.guaranteestatus))
+ # logger.debug("SLA guarantee status {}: {}".format(agreement.agreement_id,
+ # agreement.guaranteestatus))
if enf.enabled == 'true':
row.append('Evaluating') # Status
pattern = re.compile(testbed_urn_regex)
testbed_urn = pattern.search(data["SLIVER_INFO_AGGREGATE_URN"]).group(1)
- tstmp = data["SLIVER_INFO_EXPIRATION"]
+ # Fix for django QueryDict list parameters
+ slivers = data.getlist("SLIVER_INFO_URN[]")
+ data["SLIVER_INFO_URN"] = slivers
+ del data["SLIVER_INFO_URN[]"]
+ # Timestamp to ISO date + timezone
+ tstmp = data["SLIVER_INFO_EXPIRATION"]
dt = datetime.fromtimestamp(float(tstmp))
- gmt_2 = pytz.timezone("Etc/GMT-2") # FIXME: hardcoded for demo purposes
- dlocal = gmt_2.localize(dt).isoformat()
-
+ # gmt_2 = pytz.timezone("Etc/GMT-2")
+ # dlocal = gmt_2.localize(dt).isoformat()
+ dlocal = dt.isoformat() + "CET" # FIXME: hardcoded for demo purposes
data["SLIVER_INFO_EXPIRATION"] = dlocal
- logger.debug("SLA Agreement parameters: {}".format(data))
+ # logger.debug("SLA Agreement parameters: {}".format(data.dict()))
+ # import pdb; pdb.set_trace()
try:
- response = c.post("agreementslist/", data=data, testbed=testbed_urn)
+ response = c.post("agreementslist/", data=json.dumps(data),
+ headers={"accept": "application/json",
+ "content-type": "application/json"})
except Exception as e:
- import traceback, sys
-
- traceback.print_exc(file=sys.stdout)
- logger.debug("SLA ERROR {}".format(e.message))
+ # import traceback, sys
+ #
+ # traceback.print_exc(file=sys.stdout)
+ logger.debug("SLA Error: CreateAgreement {}".format(e.message))
return HttpResponse(response.text, status=response.status_code)
<dt>Experimenter</dt>
<dd>{{ row.agreement.context.consumer|default:" " }}</dd>
<dt>Service</dt>
- <dd>Testbed guarantees 0.99 Uptime rate for 0.99 rate of the resources during the sliver lifetime</dd>
+ <dd>Testbed guarantees 0.99 Uptime rate for 0.99 rate of the selected resources</dd>
<dt>Testbed</dt>
<dd>{{ row.agreement.context.testbed_formatted }}</dd>
<dt>Expiration date:</dt>
<dd>{{ row.date|default:" " }}</dd>
- <dt>Covered slivers:</dt>
+ <dt>Covered resources:</dt>
{% for sliver in row.slivers %}
<dd>{{ sliver|default:" " }}</dd>
{% endfor %}
"""\r
a = agreement\r
\r
- logger.debug("SLA STATUS: {}".format(status))\r
-\r
if status is not None:\r
a.guaranteestatus = status.guaranteestatus\r
a.statusclass = self._get_statusclass(status.guaranteestatus)\r