blob: 932ee5e1e861cef5c0e455cfa5ba4aabd2c67dea [file] [log] [blame]
Don Newtone973d342018-10-26 16:44:12 -04001/*
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
17package impl
18
19import (
20 "errors"
21 "fmt"
22
23 "gerrit.opencord.org/abstract-olt/models"
24)
25
26/*
27ProvsionOnt - provisions ont using sTag,cTag,NasPortID, and CircuitID generated internally
28*/
29func 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/*
45ProvsionOntFull - provisions ont using sTag,cTag,NasPortID, and CircuitID passed in
46*/
47func 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/*
63DeleteOnt - deletes a previously provision ont
64*/
65func 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}