Zafer Kaban | b0a1668 | 2018-12-04 11:16:24 +0300 | [diff] [blame] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM Core
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 Netsia
|
| 6 | * ================================================================================
|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | * ============LICENSE_END=========================================================
|
| 19 | */
|
| 20 |
|
| 21 | package org.onap.osam.external.grpc;
|
| 22 |
|
| 23 | import lombok.extern.slf4j.Slf4j;
|
| 24 | import org.onap.osam.grpc.AddOntFullMessage;
|
| 25 | import org.onap.osam.grpc.AddOntMessage;
|
| 26 | import org.onap.osam.grpc.PreProvisionOntMessage;
|
| 27 | import org.onap.osam.model.dao.Chassis;
|
| 28 | import org.onap.osam.model.dao.OLTPort;
|
| 29 | import org.onap.osam.model.dao.OLTSlot;
|
| 30 | import org.onap.osam.model.dao.ONTDevice;
|
| 31 |
|
| 32 | @Slf4j
|
| 33 | public class OntMessageFactory {
|
| 34 |
|
| 35 | public static PreProvisionOntMessage getPreProvisionOntMessage (ONTDevice ontDevice) {
|
| 36 |
|
| 37 | OLTPort oltPort = ontDevice.getOLTPort();
|
| 38 | OLTSlot oltSlot = oltPort.getOltSlot();
|
| 39 | Chassis chassis = oltSlot.getChassis();
|
| 40 | String clli = chassis.getClli();
|
| 41 | String serialNumber = ontDevice.getSerialNumber();
|
| 42 | int slotNumber = oltSlot.getNumber();
|
| 43 | int portNumber = oltPort.getPortNumber();
|
| 44 | int ontNumber = ontDevice.getNumber();
|
| 45 | int stag = ontDevice.getSTag();
|
| 46 | int ctag = ontDevice.getCTag();
|
| 47 | String nasPortID = ontDevice.getNasPortId();
|
| 48 | String circuitId = ontDevice.getCircuitId();
|
| 49 | log.info("getPreProvisionOntMessage, clli: {}, serialNumber: {}, slotNumber: {}, portNumber:{}, ontNumber:{}, sTag:{}, cTag:{}, nasPortId:{}, circuitId:{}", clli, serialNumber, slotNumber, portNumber, ontNumber, stag, ctag,nasPortID, circuitId);
|
| 50 |
|
| 51 | PreProvisionOntMessage preProvisionOntMessage = PreProvisionOntMessage.newBuilder()
|
| 52 | .setCLLI(clli)
|
| 53 | .setSlotNumber(slotNumber)
|
| 54 | .setPortNumber(portNumber)
|
| 55 | .setOntNumber(ontNumber)
|
| 56 | .setSTag(stag)
|
| 57 | .setCTag(ctag)
|
| 58 | .setNasPortID(nasPortID)
|
| 59 | .setCircuitID(circuitId)
|
| 60 | .build();
|
| 61 | //TODO Handle technology and speed profiles later
|
| 62 | log.info("PreProvisionOntMessage is {}", preProvisionOntMessage);
|
| 63 | return preProvisionOntMessage;
|
| 64 |
|
| 65 | }
|
| 66 |
|
| 67 |
|
| 68 | public static AddOntFullMessage getOntFullMessage (ONTDevice ontDevice) {
|
| 69 |
|
| 70 | OLTPort oltPort = ontDevice.getOLTPort();
|
| 71 | OLTSlot oltSlot = oltPort.getOltSlot();
|
| 72 | Chassis chassis = oltSlot.getChassis();
|
| 73 | String clli = chassis.getClli();
|
| 74 | String serialNumber = ontDevice.getSerialNumber();
|
| 75 | int slotNumber = oltSlot.getNumber();
|
| 76 | int portNumber = oltPort.getPortNumber();
|
| 77 | int ontNumber = ontDevice.getNumber();
|
| 78 | int stag = ontDevice.getSTag();
|
| 79 | int ctag = ontDevice.getCTag();
|
| 80 | String nasPortID = ontDevice.getNasPortId();
|
| 81 | String circuitId = ontDevice.getCircuitId();
|
| 82 | log.info("getOntFullMessage, clli: {}, serialNumber: {}, slotNumber: {}, portNumber:{}, ontNumber:{}, sTag:{}, cTag:{}, nasPortId:{}, circuitId:{}", clli, serialNumber, slotNumber, portNumber, ontNumber, stag, ctag,nasPortID, circuitId);
|
| 83 |
|
| 84 | AddOntFullMessage addOntFullMessage = AddOntFullMessage.newBuilder()
|
| 85 | .setCLLI(clli)
|
| 86 | .setSerialNumber(serialNumber)
|
| 87 | .setSlotNumber(slotNumber)
|
| 88 | .setPortNumber(portNumber)
|
| 89 | .setOntNumber(ontNumber)
|
| 90 | .setSTag(stag)
|
| 91 | .setCTag(ctag)
|
| 92 | .setNasPortID(nasPortID)
|
| 93 | .setCircuitID(circuitId)
|
| 94 | .build();
|
| 95 | log.info("AddOntFullMessage is {}", addOntFullMessage);
|
| 96 | return addOntFullMessage;
|
| 97 |
|
| 98 | }
|
| 99 |
|
| 100 | public static AddOntMessage getOntMessage (ONTDevice ontDevice) {
|
| 101 |
|
| 102 | OLTPort oltPort = ontDevice.getOLTPort();
|
| 103 | OLTSlot oltSlot = oltPort.getOltSlot();
|
| 104 | Chassis chassis = oltSlot.getChassis();
|
| 105 | String clli = chassis.getClli();
|
| 106 | String serialNumber = ontDevice.getSerialNumber();
|
| 107 | int slotNumber = oltSlot.getNumber();
|
| 108 | int portNumber = oltPort.getPortNumber();
|
| 109 | int ontNumber = ontDevice.getNumber();
|
| 110 | log.info("getOntFullMessage, clli: {}, serialNumber: {}, slotNumber: {}, portNumber:{}, ontNumber:{}", clli, serialNumber, slotNumber, portNumber, ontNumber);
|
| 111 |
|
| 112 | AddOntMessage addOntMessage = AddOntMessage.newBuilder()
|
| 113 | .setCLLI(clli)
|
| 114 | .setSerialNumber(serialNumber)
|
| 115 | .setSlotNumber(slotNumber)
|
| 116 | .setPortNumber(portNumber)
|
| 117 | .setOntNumber(ontNumber)
|
| 118 | .build();
|
| 119 | log.info("AddOntMessage is {}", addOntMessage);
|
| 120 | return addOntMessage;
|
| 121 |
|
| 122 | }
|
| 123 | }
|