@Test public void totalConversion() throws Exception { setupFakeProviderRegistry(); OvfDefinition ovfDefinition = OVFUtils.getOvfDefinition(ovfSelfAdaptationString); SLATemplate slaTemplate = SLATemplateCreator.generateSLATemplate(ovfDefinition, "http: SLASOITemplateRenderer slasoiTemplateRenderer = new SLASOITemplateRenderer(); SLATemplateDocument slaTemplateRendered = SLATemplateDocument.Factory.parse(slasoiTemplateRenderer.renderSLATemplate(slaTemplate)); String slaTemplateString = slaTemplateRendered.toString(); System.out.println("SLA rendered as XML: ############################## "); System.out.println(slaTemplateString); eu.ascetic.paas.applicationmanager.slam.sla.model.SLATemplate slat = null; try { JAXBContext jaxbContext = JAXBContext.newInstance(eu.ascetic.paas.applicationmanager.slam.sla.model.SLATemplate.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); slat = (eu.ascetic.paas.applicationmanager.slam.sla.model.SLATemplate) jaxbUnmarshaller.unmarshal(new StringReader(slaTemplateString)); } catch(JAXBException jaxbExpcetion) { jaxbExpcetion.printStackTrace(); } assertEquals("ASCETiC-SLaTemplate-Example-01", slat.getUUID()); assertEquals("sla_at_soi_sla_model_v1.0", slat.getModelVersion()); assertEquals(1, slat.getProperties().getEntries().size()); assertEquals(value, slat.getProperties().getEntries().get(0).getValue()); assertEquals(2, slat.getParties().size()); assertEquals("AsceticProvider", slat.getParties().get(0).getId()); assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("333", slat.getParties().get(1).getId()); assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("OVF_URL", slat.getInterfaceDeclrs().get(0).getProperties().getEntries().get(0).getKey()); assertEquals("http: assertEquals("OVF-Item-NA-HAProxy", slat.getInterfaceDeclrs().get(0).getId()); assertEquals("AsceticProvider", slat.getInterfaceDeclrs().get(0).getProviderRef()); assertEquals("OVF_VirtualSystem_ID", slat.getInterfaceDeclrs().get(0).getEndPoint().getProperties().getEntries().get(0).getKey()); assertEquals("NA-HAProxy", slat.getInterfaceDeclrs().get(0).getEndPoint().getProperties().getEntries().get(0).getValue()); assertEquals("NA-HAProxy-VM-Type", slat.getInterfaceDeclrs().get(0).getEndPoint().getId()); assertEquals("VM-Manager ID", slat.getInterfaceDeclrs().get(0).getEndPoint().getLocation()); assertEquals("http: assertEquals("OVFAppliance", slat.getInterfaceDeclrs().get(0).getIntf().getInterfaceResourceType().getName()); assertEquals(7, slat.getAgreemenTerms().size()); assertEquals("App Guarantees", slat.getAgreemenTerms().get(0).getId()); assertEquals(OVFToSLANames.APP_ENERGY_CONSUMPTION_SLA, slat.getAgreemenTerms().get(0).getGuaranteed().getState().getId()); assertEquals(OVFToSLANames.APP_ENERGY_CONSUMPTION_SLA_OPERATOR, slat.getAgreemenTerms().get(0).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr().getOperator()); assertEquals(OVFToSLANames.COMPARATORS.get("LT"), slat.getAgreemenTerms().get(0).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getComparisonOp()); assertEquals("2000", slat.getAgreemenTerms().get(0).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getValue()); assertEquals(OVFToSLANames.METRIC_UNITS.get("WattHour"), slat.getAgreemenTerms().get(0).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getDatatype()); assertEquals(OVFToSLANames.APP_POWER_CONSUMPTION_SLA, slat.getAgreemenTerms().get(1).getGuaranteed().getState().getId()); assertEquals(OVFToSLANames.APP_POWER_CONSUMPTION_SLA_OPERATOR, slat.getAgreemenTerms().get(1).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr().getOperator()); assertEquals(OVFToSLANames.COMPARATORS.get("LTE"), slat.getAgreemenTerms().get(1).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getComparisonOp()); assertEquals("2000", slat.getAgreemenTerms().get(1).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getValue()); assertEquals(OVFToSLANames.METRIC_UNITS.get("Watt"), slat.getAgreemenTerms().get(1).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getDatatype()); assertEquals(OVFToSLANames.APP_PRICE_PER_HOUR_SLA, slat.getAgreemenTerms().get(2).getGuaranteed().getState().getId()); assertEquals(OVFToSLANames.APP_PRICE_PER_HOUR_SLA_OPERATOR, slat.getAgreemenTerms().get(2).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr().getOperator()); assertEquals(OVFToSLANames.COMPARATORS.get("LTE"), slat.getAgreemenTerms().get(2).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getComparisonOp()); assertEquals("2000", slat.getAgreemenTerms().get(2).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getValue()); assertEquals(OVFToSLANames.METRIC_UNITS.get("EUR"), slat.getAgreemenTerms().get(2).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getDatatype()); assertEquals("NA-HAProxy_Guarantees", slat.getAgreemenTerms().get(3).getId()); assertEquals("VM_of_type_NA-HAProxy", slat.getAgreemenTerms().get(3).getVariableDeclr().getVar()); assertEquals("http: assertEquals("OVF-Item-NA-HAProxy", slat.getAgreemenTerms().get(3).getVariableDeclr().getExpr().getValueExpr().getFuncExpr().getParameters().get(0).getId()); assertEquals("Power_Usage_for_NA-HAProxy", slat.getAgreemenTerms().get(3).getGuaranteed().getState().getId()); assertEquals(OVFToSLANames.POWER_USAGE_PER_VM_SLA_OPERATOR, slat.getAgreemenTerms().get(3).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr().getOperator()); assertEquals("VM_of_type_NA-HAProxy", slat.getAgreemenTerms().get(3).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr().getParameters().get(0).getId()); assertEquals(OVFToSLANames.COMPARATORS.get("LT"), slat.getAgreemenTerms().get(3).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getComparisonOp()); assertEquals("50", slat.getAgreemenTerms().get(3).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getValue()); assertEquals(OVFToSLANames.METRIC_UNITS.get("Watt"), slat.getAgreemenTerms().get(3).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getDatatype()); assertEquals("NA-HAProxy_Guarantees", slat.getAgreemenTerms().get(4).getId()); assertEquals("VM_of_type_NA-HAProxy", slat.getAgreemenTerms().get(4).getVariableDeclr().getVar()); assertEquals("http: assertEquals("OVF-Item-NA-HAProxy", slat.getAgreemenTerms().get(4).getVariableDeclr().getExpr().getValueExpr().getFuncExpr().getParameters().get(0).getId()); assertEquals("Energy_Usage_for_NA-HAProxy", slat.getAgreemenTerms().get(4).getGuaranteed().getState().getId()); assertEquals(OVFToSLANames.ENERGY_USAGE_PER_VM_SLA_OPERATOR, slat.getAgreemenTerms().get(4).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr().getOperator()); assertEquals("VM_of_type_NA-HAProxy", slat.getAgreemenTerms().get(4).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr().getParameters().get(0).getId()); assertEquals(OVFToSLANames.COMPARATORS.get("LT"), slat.getAgreemenTerms().get(4).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getComparisonOp()); assertEquals("50", slat.getAgreemenTerms().get(4).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getValue()); assertEquals(OVFToSLANames.METRIC_UNITS.get("WattHour"), slat.getAgreemenTerms().get(4).getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr().getValue().getConstVariable().getDatatype()); AgreementTerm agreementTerm = slat.getAgreemenTerms().get(5); assertEquals("Aggregated Guarantees", agreementTerm.getId()); assertEquals("searchForNewsItems_for_NA-HAProxy", agreementTerm.getGuaranteed().getState().getId()); FuncExpr funcExpr = agreementTerm.getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr(); assertEquals(OVFToSLANames.AGGREGATED_METRIC_SLA_OPERATOR, funcExpr.getOperator()); List<Parameter> parameters = funcExpr.getParameters(); assertEquals(5, parameters.size()); Parameter parameter = parameters.get(0); assertEquals("searchForNewsItems", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_STRING, parameter.getcONST().getDatatype()); parameter = parameters.get(1); assertEquals("duration", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_STRING, parameter.getcONST().getDatatype()); parameter = parameters.get(2); assertEquals("15", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_INTEGER, parameter.getcONST().getDatatype()); parameter = parameters.get(3); assertEquals("percentile", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_STRING, parameter.getcONST().getDatatype()); parameter = parameters.get(4); assertEquals("90", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_INTEGER, parameter.getcONST().getDatatype()); SimpleDomainExpr simpleDomainExpr = agreementTerm.getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr(); assertEquals(OVFToSLANames.COMPARATORS.get("LTE"), simpleDomainExpr.getComparisonOp()); assertEquals(OVFToSLANames.DATATYPE_DECIMAL, simpleDomainExpr.getValue().getConstVariable().getDatatype()); assertEquals("0.7", simpleDomainExpr.getValue().getConstVariable().getValue()); agreementTerm = slat.getAgreemenTerms().get(6); assertEquals("Aggregated Guarantees", agreementTerm.getId()); assertEquals("anticipatedWorkload_for_NA-HAProxy", agreementTerm.getGuaranteed().getState().getId()); funcExpr = agreementTerm.getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getValue().getFuncExpr(); assertEquals(OVFToSLANames.AGGREGATED_METRIC_SLA_OPERATOR, funcExpr.getOperator()); parameters = funcExpr.getParameters(); assertEquals(5, parameters.size()); parameter = parameters.get(0); assertEquals("anticipatedWorkload", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_STRING, parameter.getcONST().getDatatype()); parameter = parameters.get(1); assertEquals("degree", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_STRING, parameter.getcONST().getDatatype()); parameter = parameters.get(2); assertEquals("NaN", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_INTEGER, parameter.getcONST().getDatatype()); parameter = parameters.get(3); assertEquals("last", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_STRING, parameter.getcONST().getDatatype()); parameter = parameters.get(4); assertEquals("NaN", parameter.getcONST().getValue()); assertEquals(OVFToSLANames.DATATYPE_INTEGER, parameter.getcONST().getDatatype()); simpleDomainExpr = agreementTerm.getGuaranteed().getState().getConstraint().getTypeConstraintExpr().getDomain().getSimpleDomainExpr(); assertEquals(OVFToSLANames.COMPARATORS.get("LTE"), simpleDomainExpr.getComparisonOp()); assertEquals(OVFToSLANames.DATATYPE_DECIMAL, simpleDomainExpr.getValue().getConstVariable().getDatatype()); assertEquals("0.0", simpleDomainExpr.getValue().getConstVariable().getValue()); }
public static SLATemplate generateSLATemplate(OvfDefinition ovf, String ovfURL, SLAApplicationTerms appTerms) { SLATemplate slaTemplate = new SLATemplate(); UUID uuid = new UUID("ASCETiC-SLaTemplate-Example-01"); slaTemplate.setUuid(uuid); addProperties(slaTemplate); addProviderEndPointToTemplate(slaTemplate); addUserEndPointToTemplate(slaTemplate); addInterfaceDclr(slaTemplate, ovf, ovfURL); addAppAgreementTerm(slaTemplate, ovf, APP_ENERGY_CONSUMPTION_OVF, APP_ENERGY_CONSUMPTION_SLA_OPERATOR, APP_ENERGY_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_POWER_CONSUMPTION_OVF, APP_POWER_CONSUMPTION_SLA_OPERATOR, APP_POWER_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_PRICE_PER_HOUR_OVF, APP_PRICE_PER_HOUR_SLA_OPERATOR, APP_PRICE_PER_HOUR_SLA, appTerms); addVMSpecificAgreementTerms(slaTemplate, ovf); AgreementTerm[] agreementTerms = slaTemplate.getAgreementTerms(); if(agreementTerms == null || agreementTerms.length == 0) { addSimpleAgreementTermForApp(slaTemplate, ovf); } return slaTemplate; }
SLATemplateCreator { public static SLATemplate generateSLATemplate(OvfDefinition ovf, String ovfURL, SLAApplicationTerms appTerms) { SLATemplate slaTemplate = new SLATemplate(); UUID uuid = new UUID("ASCETiC-SLaTemplate-Example-01"); slaTemplate.setUuid(uuid); addProperties(slaTemplate); addProviderEndPointToTemplate(slaTemplate); addUserEndPointToTemplate(slaTemplate); addInterfaceDclr(slaTemplate, ovf, ovfURL); addAppAgreementTerm(slaTemplate, ovf, APP_ENERGY_CONSUMPTION_OVF, APP_ENERGY_CONSUMPTION_SLA_OPERATOR, APP_ENERGY_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_POWER_CONSUMPTION_OVF, APP_POWER_CONSUMPTION_SLA_OPERATOR, APP_POWER_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_PRICE_PER_HOUR_OVF, APP_PRICE_PER_HOUR_SLA_OPERATOR, APP_PRICE_PER_HOUR_SLA, appTerms); addVMSpecificAgreementTerms(slaTemplate, ovf); AgreementTerm[] agreementTerms = slaTemplate.getAgreementTerms(); if(agreementTerms == null || agreementTerms.length == 0) { addSimpleAgreementTermForApp(slaTemplate, ovf); } return slaTemplate; } }
SLATemplateCreator { public static SLATemplate generateSLATemplate(OvfDefinition ovf, String ovfURL, SLAApplicationTerms appTerms) { SLATemplate slaTemplate = new SLATemplate(); UUID uuid = new UUID("ASCETiC-SLaTemplate-Example-01"); slaTemplate.setUuid(uuid); addProperties(slaTemplate); addProviderEndPointToTemplate(slaTemplate); addUserEndPointToTemplate(slaTemplate); addInterfaceDclr(slaTemplate, ovf, ovfURL); addAppAgreementTerm(slaTemplate, ovf, APP_ENERGY_CONSUMPTION_OVF, APP_ENERGY_CONSUMPTION_SLA_OPERATOR, APP_ENERGY_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_POWER_CONSUMPTION_OVF, APP_POWER_CONSUMPTION_SLA_OPERATOR, APP_POWER_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_PRICE_PER_HOUR_OVF, APP_PRICE_PER_HOUR_SLA_OPERATOR, APP_PRICE_PER_HOUR_SLA, appTerms); addVMSpecificAgreementTerms(slaTemplate, ovf); AgreementTerm[] agreementTerms = slaTemplate.getAgreementTerms(); if(agreementTerms == null || agreementTerms.length == 0) { addSimpleAgreementTermForApp(slaTemplate, ovf); } return slaTemplate; }  }
SLATemplateCreator { public static SLATemplate generateSLATemplate(OvfDefinition ovf, String ovfURL, SLAApplicationTerms appTerms) { SLATemplate slaTemplate = new SLATemplate(); UUID uuid = new UUID("ASCETiC-SLaTemplate-Example-01"); slaTemplate.setUuid(uuid); addProperties(slaTemplate); addProviderEndPointToTemplate(slaTemplate); addUserEndPointToTemplate(slaTemplate); addInterfaceDclr(slaTemplate, ovf, ovfURL); addAppAgreementTerm(slaTemplate, ovf, APP_ENERGY_CONSUMPTION_OVF, APP_ENERGY_CONSUMPTION_SLA_OPERATOR, APP_ENERGY_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_POWER_CONSUMPTION_OVF, APP_POWER_CONSUMPTION_SLA_OPERATOR, APP_POWER_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_PRICE_PER_HOUR_OVF, APP_PRICE_PER_HOUR_SLA_OPERATOR, APP_PRICE_PER_HOUR_SLA, appTerms); addVMSpecificAgreementTerms(slaTemplate, ovf); AgreementTerm[] agreementTerms = slaTemplate.getAgreementTerms(); if(agreementTerms == null || agreementTerms.length == 0) { addSimpleAgreementTermForApp(slaTemplate, ovf); } return slaTemplate; }  static SLATemplate generateSLATemplate(OvfDefinition ovf, String ovfURL, SLAApplicationTerms appTerms); }
SLATemplateCreator { public static SLATemplate generateSLATemplate(OvfDefinition ovf, String ovfURL, SLAApplicationTerms appTerms) { SLATemplate slaTemplate = new SLATemplate(); UUID uuid = new UUID("ASCETiC-SLaTemplate-Example-01"); slaTemplate.setUuid(uuid); addProperties(slaTemplate); addProviderEndPointToTemplate(slaTemplate); addUserEndPointToTemplate(slaTemplate); addInterfaceDclr(slaTemplate, ovf, ovfURL); addAppAgreementTerm(slaTemplate, ovf, APP_ENERGY_CONSUMPTION_OVF, APP_ENERGY_CONSUMPTION_SLA_OPERATOR, APP_ENERGY_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_POWER_CONSUMPTION_OVF, APP_POWER_CONSUMPTION_SLA_OPERATOR, APP_POWER_CONSUMPTION_SLA, appTerms); addAppAgreementTerm(slaTemplate, ovf, APP_PRICE_PER_HOUR_OVF, APP_PRICE_PER_HOUR_SLA_OPERATOR, APP_PRICE_PER_HOUR_SLA, appTerms); addVMSpecificAgreementTerms(slaTemplate, ovf); AgreementTerm[] agreementTerms = slaTemplate.getAgreementTerms(); if(agreementTerms == null || agreementTerms.length == 0) { addSimpleAgreementTermForApp(slaTemplate, ovf); } return slaTemplate; }  static SLATemplate generateSLATemplate(OvfDefinition ovf, String ovfURL, SLAApplicationTerms appTerms);  }