Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package core |
| 18 | |
| 19 | import ( |
| 20 | "errors" |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 21 | |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 22 | "github.com/opencord/openolt-scale-tester/config" |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 23 | "github.com/opencord/voltha-lib-go/v4/pkg/log" |
| 24 | oop "github.com/opencord/voltha-protos/v4/go/openolt" |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 25 | ) |
| 26 | |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 27 | type WorkFlow interface { |
| 28 | ProvisionScheds(subs *Subscriber) error |
| 29 | ProvisionQueues(subs *Subscriber) error |
| 30 | ProvisionEapFlow(subs *Subscriber) error |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 31 | ProvisionDhcpIPV4Flow(subs *Subscriber) error |
| 32 | ProvisionDhcpIPV6Flow(subs *Subscriber) error |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 33 | ProvisionIgmpFlow(subs *Subscriber) error |
| 34 | ProvisionHsiaFlow(subs *Subscriber) error |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 35 | ProvisionVoipFlow(subs *Subscriber) error |
| 36 | ProvisionVodFlow(subs *Subscriber) error |
| 37 | ProvisionMgmtFlow(subs *Subscriber) error |
| 38 | ProvisionMulticastFlow(subs *Subscriber) error |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 39 | // TODO: Add new items here as needed. |
| 40 | } |
| 41 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 42 | func DeployWorkflow(subs *Subscriber, isGroup bool) { |
Girish Gowdra | aeceb84 | 2020-08-21 12:10:39 -0700 | [diff] [blame] | 43 | |
| 44 | defer subs.subWg.Done() |
| 45 | |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 46 | var wf = getWorkFlow(subs) |
| 47 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 48 | 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 Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 59 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 60 | if err := wf.ProvisionQueues(subs); err != nil { |
| 61 | subs.Reason = err.Error() |
| 62 | return |
| 63 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 64 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 65 | if err := wf.ProvisionEapFlow(subs); err != nil { |
| 66 | subs.Reason = err.Error() |
| 67 | return |
| 68 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 69 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 70 | if err := wf.ProvisionDhcpIPV4Flow(subs); err != nil { |
| 71 | subs.Reason = err.Error() |
| 72 | return |
| 73 | } |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 74 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 75 | if err := wf.ProvisionDhcpIPV6Flow(subs); err != nil { |
| 76 | subs.Reason = err.Error() |
| 77 | return |
| 78 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 79 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 80 | if err := wf.ProvisionIgmpFlow(subs); err != nil { |
| 81 | subs.Reason = err.Error() |
| 82 | return |
| 83 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 84 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 85 | 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 Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 104 | } |
| 105 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 106 | logger.Infow(nil, "subscriber-provision-completed-from-onu-manager", log.Fields{"subsName": subs.SubscriberName}) |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 107 | subs.Reason = ReasonCodeToReasonString(SUBSCRIBER_PROVISION_SUCCESS) |
| 108 | } |
| 109 | |
| 110 | func getWorkFlow(subs *Subscriber) WorkFlow { |
| 111 | switch subs.TestConfig.WorkflowName { |
| 112 | case "ATT": |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 113 | logger.Info(nil, "chosen-att-workflow") |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 114 | return AttWorkFlow{} |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 115 | case "DT": |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 116 | logger.Info(nil, "chosen-dt-workflow") |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 117 | return DtWorkFlow{} |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 118 | case "TT": |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 119 | logger.Info(nil, "chosen-tt-workflow") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 120 | return TtWorkFlow{} |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 121 | // TODO: Add new workflow here |
| 122 | default: |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 123 | logger.Errorw(nil, "operator-workflow-not-supported-yet", log.Fields{"workflowName": subs.TestConfig.WorkflowName}) |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 124 | } |
| 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. |
| 130 | func 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 Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 134 | logger.Error(nil, "error-installing-flow", log.Fields{"err": err}) |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 135 | return err |
| 136 | } |
Thiyagarajan Subramani | c4f8da8 | 2020-02-05 16:08:26 +0530 | [diff] [blame] | 137 | case "DT": |
| 138 | if err := ProvisionDtNniTrapFlow(oo, config, rsrMgr); err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 139 | logger.Error(nil, "error-installing-flow", log.Fields{"err": err}) |
Thiyagarajan Subramani | c4f8da8 | 2020-02-05 16:08:26 +0530 | [diff] [blame] | 140 | return err |
| 141 | } |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 142 | case "TT": |
| 143 | if err := ProvisionTtNniTrapFlow(oo, config, rsrMgr); err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 144 | logger.Error(nil, "error-installing-flow", log.Fields{"err": err}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 145 | return err |
| 146 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 147 | // TODO: Add new items here |
| 148 | default: |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame^] | 149 | logger.Errorw(nil, "operator-workflow-not-supported-yet", log.Fields{"workflowName": config.WorkflowName}) |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 150 | return errors.New("workflow-not-supported") |
| 151 | } |
| 152 | return nil |
| 153 | } |