Don Newton | e973d34 | 2018-10-26 16:44:12 -0400 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2017 the original author or authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package impl |
| 18 | |
| 19 | import ( |
| 20 | "errors" |
| 21 | "fmt" |
| 22 | |
| 23 | "gerrit.opencord.org/abstract-olt/models" |
| 24 | ) |
| 25 | |
| 26 | /* |
| 27 | ProvsionOnt - provisions ont using sTag,cTag,NasPortID, and CircuitID generated internally |
| 28 | */ |
| 29 | func ProvisionOnt(clli string, slotNumber int, portNumber int, ontNumber int, serialNumber string) (bool, error) { |
| 30 | myChan := getSyncChannel() |
| 31 | <-myChan |
| 32 | defer done(myChan, true) |
| 33 | chassisMap := models.GetChassisMap() |
| 34 | chassisHolder := (*chassisMap)[clli] |
| 35 | if chassisHolder == nil { |
| 36 | errString := fmt.Sprintf("There is no chassis with CLLI of %s", clli) |
| 37 | return false, errors.New(errString) |
| 38 | } |
| 39 | err := chassisHolder.AbstractChassis.ActivateONT(slotNumber, portNumber, ontNumber, serialNumber) |
| 40 | isDirty = true |
| 41 | return true, err |
| 42 | } |
| 43 | |
| 44 | /* |
| 45 | ProvsionOntFull - provisions ont using sTag,cTag,NasPortID, and CircuitID passed in |
| 46 | */ |
| 47 | func ProvisionOntFull(clli string, slotNumber int, portNumber int, ontNumber int, serialNumber string, cTag uint32, sTag uint32, nasPortID string, circuitID string) (bool, error) { |
| 48 | myChan := getSyncChannel() |
| 49 | <-myChan |
| 50 | defer done(myChan, true) |
| 51 | chassisMap := models.GetChassisMap() |
| 52 | chassisHolder := (*chassisMap)[clli] |
| 53 | if chassisHolder == nil { |
| 54 | errString := fmt.Sprintf("There is no chassis with CLLI of %s", clli) |
| 55 | return false, errors.New(errString) |
| 56 | } |
| 57 | err := chassisHolder.AbstractChassis.ActivateONTFull(slotNumber, portNumber, ontNumber, serialNumber, cTag, sTag, nasPortID, circuitID) |
| 58 | isDirty = true |
| 59 | return true, err |
| 60 | } |
| 61 | |
| 62 | /* |
| 63 | DeleteOnt - deletes a previously provision ont |
| 64 | */ |
| 65 | func DeleteOnt(clli string, slotNumber int, portNumber int, ontNumber int, serialNumber string) (bool, error) { |
| 66 | myChan := getSyncChannel() |
| 67 | <-myChan |
| 68 | defer done(myChan, true) |
| 69 | chassisMap := models.GetChassisMap() |
| 70 | chassisHolder := (*chassisMap)[clli] |
| 71 | err := chassisHolder.AbstractChassis.DeleteONT(slotNumber, portNumber, ontNumber, serialNumber) |
| 72 | isDirty = true |
| 73 | return true, err |
| 74 | } |