blob: 28c8820803bd9abc59cc1a6329809d59ed22bd66 [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*/
Don Newton5154fff2018-11-06 17:40:58 -050031func CreateOLTChassis(clli string, oltType string, driver string, address net.TCPAddr, hostname string) (string, error) {
Don Newtone973d342018-10-26 16:44:12 -040032 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
Don Newton5154fff2018-11-06 17:40:58 -050042 sOlt := physical.SimpleOLT{CLLI: clli, Hostname: hostname, Driver: driver, Address: address, Parent: physicalChassis}
Don Newtone973d342018-10-26 16:44:12 -040043 switch oltType {
44 case "edgecore":
45 sOlt.CreateEdgecore()
46 case "adtran":
47 case "tibit":
48 }
Don Newtone973d342018-10-26 16:44:12 -040049 ports := sOlt.GetPorts()
50 for i := 0; i < len(ports); i++ {
Don Newton5154fff2018-11-06 17:40:58 -050051 absPort, err := chassisHolder.AbstractChassis.NextPort()
52 if err != nil {
53 fmt.Println(err)
54 return "", err
55 }
Don Newtone973d342018-10-26 16:44:12 -040056 absPort.PhysPort = &ports[i]
57 //AssignTraits(&ports[i], absPort)
58 }
Don Newton5154fff2018-11-06 17:40:58 -050059 physicalChassis.AddOLTChassis(sOlt)
Don Newtone973d342018-10-26 16:44:12 -040060 isDirty = true
61 return clli, nil
62
63}