blob: 0a961ab32d987856adcda5a6b45d6883229a1c37 [file] [log] [blame]
Girish Gowdra64503432020-01-07 10:59:10 +05301/*
2 * Copyright 2018-present Open Networking Foundation
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 core
18
19import (
20 "errors"
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030021
Girish Gowdra64503432020-01-07 10:59:10 +053022 "github.com/opencord/openolt-scale-tester/config"
Girish Gowdra390f12f2021-07-01 15:53:49 -070023 "github.com/opencord/voltha-lib-go/v7/pkg/log"
24 oop "github.com/opencord/voltha-protos/v5/go/openolt"
Girish Gowdra64503432020-01-07 10:59:10 +053025)
26
Girish Gowdra64503432020-01-07 10:59:10 +053027type WorkFlow interface {
28 ProvisionScheds(subs *Subscriber) error
29 ProvisionQueues(subs *Subscriber) error
30 ProvisionEapFlow(subs *Subscriber) error
Girish Gowdraef1b7c42020-01-23 16:27:48 +053031 ProvisionDhcpIPV4Flow(subs *Subscriber) error
32 ProvisionDhcpIPV6Flow(subs *Subscriber) error
Girish Gowdra64503432020-01-07 10:59:10 +053033 ProvisionIgmpFlow(subs *Subscriber) error
34 ProvisionHsiaFlow(subs *Subscriber) error
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030035 ProvisionVoipFlow(subs *Subscriber) error
36 ProvisionVodFlow(subs *Subscriber) error
37 ProvisionMgmtFlow(subs *Subscriber) error
38 ProvisionMulticastFlow(subs *Subscriber) error
Girish Gowdra64503432020-01-07 10:59:10 +053039 // TODO: Add new items here as needed.
40}
41
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030042func DeployWorkflow(subs *Subscriber, isGroup bool) {
Girish Gowdraaeceb842020-08-21 12:10:39 -070043
44 defer subs.subWg.Done()
45
Girish Gowdra64503432020-01-07 10:59:10 +053046 var wf = getWorkFlow(subs)
47
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030048 if isGroup {
49 if err := wf.ProvisionMulticastFlow(subs); err != nil {
50 subs.Reason = err.Error()
51 return
52 }
53 } else {
54 // TODO: Catch and log errors for below items if needed.
55 if err := wf.ProvisionScheds(subs); err != nil {
56 subs.Reason = err.Error()
57 return
58 }
Girish Gowdra64503432020-01-07 10:59:10 +053059
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030060 if err := wf.ProvisionQueues(subs); err != nil {
61 subs.Reason = err.Error()
62 return
63 }
Girish Gowdra64503432020-01-07 10:59:10 +053064
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030065 if err := wf.ProvisionEapFlow(subs); err != nil {
66 subs.Reason = err.Error()
67 return
68 }
Girish Gowdra64503432020-01-07 10:59:10 +053069
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030070 if err := wf.ProvisionDhcpIPV4Flow(subs); err != nil {
71 subs.Reason = err.Error()
72 return
73 }
Girish Gowdraef1b7c42020-01-23 16:27:48 +053074
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030075 if err := wf.ProvisionDhcpIPV6Flow(subs); err != nil {
76 subs.Reason = err.Error()
77 return
78 }
Girish Gowdra64503432020-01-07 10:59:10 +053079
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030080 if err := wf.ProvisionIgmpFlow(subs); err != nil {
81 subs.Reason = err.Error()
82 return
83 }
Girish Gowdra64503432020-01-07 10:59:10 +053084
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030085 if err := wf.ProvisionHsiaFlow(subs); err != nil {
86 subs.Reason = err.Error()
87 return
88 }
89
90 if err := wf.ProvisionVoipFlow(subs); err != nil {
91 subs.Reason = err.Error()
92 return
93 }
94
95 if err := wf.ProvisionVodFlow(subs); err != nil {
96 subs.Reason = err.Error()
97 return
98 }
99
100 if err := wf.ProvisionMgmtFlow(subs); err != nil {
101 subs.Reason = err.Error()
102 return
103 }
Girish Gowdra64503432020-01-07 10:59:10 +0530104 }
105
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700106 logger.Infow(nil, "subscriber-provision-completed-from-onu-manager", log.Fields{"subsName": subs.SubscriberName})
Girish Gowdra64503432020-01-07 10:59:10 +0530107 subs.Reason = ReasonCodeToReasonString(SUBSCRIBER_PROVISION_SUCCESS)
108}
109
110func getWorkFlow(subs *Subscriber) WorkFlow {
111 switch subs.TestConfig.WorkflowName {
112 case "ATT":
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700113 logger.Info(nil, "chosen-att-workflow")
Girish Gowdra64503432020-01-07 10:59:10 +0530114 return AttWorkFlow{}
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +0530115 case "DT":
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700116 logger.Info(nil, "chosen-dt-workflow")
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +0530117 return DtWorkFlow{}
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +0300118 case "TT":
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700119 logger.Info(nil, "chosen-tt-workflow")
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +0300120 return TtWorkFlow{}
Girish Gowdra64503432020-01-07 10:59:10 +0530121 // TODO: Add new workflow here
122 default:
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700123 logger.Errorw(nil, "operator-workflow-not-supported-yet", log.Fields{"workflowName": subs.TestConfig.WorkflowName})
Girish Gowdra64503432020-01-07 10:59:10 +0530124 }
125 return nil
126}
127
128// This function should get called even before provisioning an ONUs to install trap-from-nni flows.
129// The flows installed here are not related to any subscribers.
130func ProvisionNniTrapFlow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error {
131 switch config.WorkflowName {
132 case "ATT":
133 if err := ProvisionAttNniTrapFlow(oo, config, rsrMgr); err != nil {
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700134 logger.Error(nil, "error-installing-flow", log.Fields{"err": err})
Girish Gowdra64503432020-01-07 10:59:10 +0530135 return err
136 }
Thiyagarajan Subramanic4f8da82020-02-05 16:08:26 +0530137 case "DT":
138 if err := ProvisionDtNniTrapFlow(oo, config, rsrMgr); err != nil {
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700139 logger.Error(nil, "error-installing-flow", log.Fields{"err": err})
Thiyagarajan Subramanic4f8da82020-02-05 16:08:26 +0530140 return err
141 }
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +0300142 case "TT":
143 if err := ProvisionTtNniTrapFlow(oo, config, rsrMgr); err != nil {
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700144 logger.Error(nil, "error-installing-flow", log.Fields{"err": err})
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +0300145 return err
146 }
Girish Gowdra64503432020-01-07 10:59:10 +0530147 // TODO: Add new items here
148 default:
Girish Gowdra5d7d6442020-09-08 17:03:11 -0700149 logger.Errorw(nil, "operator-workflow-not-supported-yet", log.Fields{"workflowName": config.WorkflowName})
Girish Gowdra64503432020-01-07 10:59:10 +0530150 return errors.New("workflow-not-supported")
151 }
152 return nil
153}