X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=olm%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Folm%2FOlmPowerSetupImpl.java;h=9a82ad5efe47884eca550ab7038b44d0e4f006d8;hb=74d11927047a7b6ace072a208ee7b1d9a3769d9d;hp=ba2d07814d1f46630c154b7dff1720f284a96854;hpb=c28ecb3f1e25f12a69f0925d7682e0e6024381e2;p=transportpce.git diff --git a/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerSetupImpl.java b/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerSetupImpl.java index ba2d07814..9a82ad5ef 100644 --- a/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerSetupImpl.java +++ b/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerSetupImpl.java @@ -19,6 +19,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.MountPointService; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.transportpce.olm.power.PowerMgmt; import org.opendaylight.transportpce.olm.spanloss.RoadmLinks; import org.opendaylight.transportpce.olm.spanloss.SpanLoss; import org.opendaylight.transportpce.renderer.mapping.PortMapping; @@ -33,6 +34,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.get.pm.output.MeasurementsBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -218,16 +222,47 @@ public class OlmPowerSetupImpl implements OlmService { roadmLinks.add(rdmLink); } } - boolean successVal = new SpanLoss(db, mps).getLinkSpanloss(roadmLinks); + boolean successValSpanCalculation = new SpanLoss(db, mps).getLinkSpanloss(roadmLinks); + boolean successValPowerCalculation = new PowerMgmt(db,mps).setPower(input); - if (successVal) { + if (successValSpanCalculation && successValPowerCalculation) { output.setResult("Success"); } else { output.setResult("Failed"); } return RpcResultBuilder.success(output).buildFuture(); - } + + /** + * This method is the implementation of the 'service-power-trundown' RESTCONF service, which + * is one of the external APIs into the olm application. + * + *

+ * 1. service-power-turndown: This operation performs following steps: + * Step1: For each TP within Node sets interface outofservice . + * Step2: For each roam-connection sets power to -60dbm + * Step3: Turns power mode off + * + *

+ * The signature for this method was generated by yang tools from the + * renderer API model. + * + * @param input + * Input parameter from the olm yang model + * Input will contain nodeId and termination point + * + * @return Result of the request + */ + @Override + public Future> servicePowerTurndown(ServicePowerTurndownInput input) { + ServicePowerTurndownOutputBuilder output = new ServicePowerTurndownOutputBuilder(); + if (new PowerMgmt(db,mps).powerTurnDown(input)) { + output.setResult("Success"); + } else { + output.setResult("Failed"); + } + return RpcResultBuilder.success(output).buildFuture(); + } } \ No newline at end of file