blob: b878a9b55f30ee1907b50ce0e39d44759814eef5 [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 "net"
23
24 "gerrit.opencord.org/abstract-olt/models"
25 "gerrit.opencord.org/abstract-olt/models/physical"
26)
27
28/*
29CreateOLTChassis adds an OLT chassis/line card to the Physical chassis
30*/
31func CreateOLTChassis(clli string, oltType string, address net.TCPAddr, hostname string) (string, error) {
32 myChan := getSyncChannel()
33 <-myChan
34 defer done(myChan, true)
35 chassisMap := models.GetChassisMap()
36 chassisHolder := (*chassisMap)[clli]
37 if chassisHolder == nil {
38 errString := fmt.Sprintf("There is no chassis with CLLI of %s", clli)
39 return "", errors.New(errString)
40 }
41 physicalChassis := &chassisHolder.PhysicalChassis
42 sOlt := physical.SimpleOLT{CLLI: clli, Hostname: hostname, Address: address, Parent: physicalChassis}
43 switch oltType {
44 case "edgecore":
45 sOlt.CreateEdgecore()
46 case "adtran":
47 case "tibit":
48 }
49 physicalChassis.AddOLTChassis(sOlt)
50 ports := sOlt.GetPorts()
51 for i := 0; i < len(ports); i++ {
52 absPort, _ := chassisHolder.AbstractChassis.NextPort()
53
54 absPort.PhysPort = &ports[i]
55 //AssignTraits(&ports[i], absPort)
56 }
57 isDirty = true
58 return clli, nil
59
60}