"""\r
\r
from sla.slaclient import wsag_model\r
-import pdb\r
+import json\r
\r
from sla.slaclient.templates.fed4fire.django.factory import Factory\r
factory = Factory()\r
\r
class GuaranteeTerm(object):\r
\r
+ class GuaranteeScope(object):\r
+\r
+ def __init__(self,\r
+ servicename="",\r
+ scope=""):\r
+\r
+ self.servicename = servicename\r
+ self.scope = scope\r
+\r
+ def __repr__(self):\r
+ s = "<GuaranteeScope(servicename={}, scope={})>"\r
+ return s.format(\r
+ self.servicename,\r
+ self.scope\r
+ )\r
+\r
def __init__(self,\r
metric_name="",\r
- bounds=(0, 0)):\r
+ bounds=(0, 0),\r
+ guarantee_scopes=()):\r
"""Creates a GuaranteeTerm.\r
\r
Take into account that the GT's name is based on the metric_name.\r
- :param str metric_name: name of the service property being enforced.\r
- :param bounds: (lower, upper) bounds of the metric values.\r
+ :param str metric_name: name of the service property being enforced\r
+ :param bounds: (lower, upper) bounds of the metric values\r
:type bounds: (float, float)\r
"""\r
self.name = "GT_{}".format(metric_name)\r
self.metric_name = metric_name\r
self.kpiname = metric_name\r
self.bounds = bounds\r
+ self.guarantee_scopes = guarantee_scopes\r
+\r
+ def __repr__(self):\r
+ s = "<GuaranteeTerm(name={}, metric_name={}, " \\r
+ "kpiname={}, bounds={}, guarantee_scopes={})>"\r
+ return s.format(\r
+ self.name,\r
+ self.metric_name,\r
+ self.kpiname,\r
+ self.bounds,\r
+ repr(self.guarantee_scopes)\r
+ )\r
\r
def __init__(self,\r
agreement_id="",\r
:param str agreement_name: optional agreement name\r
:param str service_id: Domain id/name of the service.\r
:param str consumer: Id of the consumer party in the agreement.\r
- :param str provider: Resource Id of the provider party in the agreement.\r
+ :param str provider: Resource Id of the provider party in the agreement\r
The provider must exist previously in the SlaManager.\r
:param str template_id: TemplateId of the template this agreement is\r
based on.\r
#\r
# NOTE: templateinput does not address guaranteeterms (yet)\r
#\r
+\r
+ for _, gt in slatemplate.guaranteeterms.items():\r
+ gt.scopes[0].scope = self.guarantee_terms[0].guarantee_scopes.scope\r
+ gt.scopes[0].scope = [x.encode('utf-8') for x in gt.scopes[0].scope]\r
+\r
result = AgreementInput(\r
agreement_id=self.agreement_id,\r
agreement_name=self.agreement_name,\r
template_id=slatemplate.template_id,\r
expiration_time=self.expiration_time,\r
service_properties=slatemplate.variables.values(),\r
+ #guarantee_terms=self.guarantee_terms\r
guarantee_terms=slatemplate.guaranteeterms.values()\r
)\r
- print result.guarantee_terms[0]\r
+\r
+ #print self.guarantee_terms[0], "\nVVVVVVVVVVVVVVVVV"\r
+ #print slatemplate.guaranteeterms['GT_CPULoad'], "\nVVVVVVVVVVVVVVVVV"\r
+ #print self.guarantee_terms[0].guarantee_scopes.scope, "\nVVVVVVVVVVVVVVVVV"\r
+ #print "TIPO: ", type(self.guarantee_terms[0])\r
+ #print "TIPO 2", type(slatemplate.guaranteeterms['GT_CPULoad']), "\nVVVVVVVVVVVVVVVVV"\r
+ #print slatemplate.guaranteeterms['GT_CPULoad'].scopes, "\nVVVVVVVVVVVVVVVVV"\r
+ #print result.guarantee_terms[0], "\nVVVVVVVVVVVVVVVVV"\r
return result\r