blob: 3d57892884c57a3ad21dd15156821d1b39e8389a [file] [log] [blame]
Don Newton2bdfd3f2019-04-08 17:06:33 -04001/*
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 mainmenu
18
19import (
20 "fmt"
21
22 "github.com/bclicn/color"
23 "github.com/opencord/voltha-go/cli/util"
24 "google.golang.org/grpc"
25)
26
27/*
28Conn - the grpc connection to use for making calls to voltha core
29*/
30var Conn *grpc.ClientConn
31
32/*
33MainLoop - the loop which processes commands at the main level
34*/
35func MainLoop(conn *grpc.ClientConn) {
36
37 inputPrompt := fmt.Sprint("(" + color.LightBlue("voltha") + ") ")
38 // inputPromptSize := len(inputPrompt)
39 Conn = conn
40 mainFuncTable := make(map[string]func(bool))
41 mainFuncTable["quit"] = util.Exit
42 mainFuncTable["exit"] = nil
43 mainFuncTable["cmdenvironment"] = doCmdEnvironment
44 mainFuncTable["load"] = doLoad
45 mainFuncTable["relative_load"] = doRelativeLoad
46 mainFuncTable["reset_history"] = doResetHistory
47 mainFuncTable["log"] = doLog
48 mainFuncTable["launch"] = doLaunch
49 mainFuncTable["restart"] = doRestart
50 mainFuncTable["devices"] = doDevices
51 mainFuncTable["device"] = doDevice
52 mainFuncTable["logical_devices"] = doLogicalDevices
53 mainFuncTable["logical_device"] = doLogicalDevice
54 mainFuncTable["omci"] = doOmci
55 mainFuncTable["pdb"] = doPdb
56 mainFuncTable["version"] = doVersion
57 mainFuncTable["health"] = doHealth
58 mainFuncTable["preprovison_olt"] = doPreprovisionOlt
59 mainFuncTable["enable"] = doEnable
60 mainFuncTable["reboot"] = doReboot
61 mainFuncTable["self_test"] = doSelfTest
62 mainFuncTable["delete"] = doDelete
63 mainFuncTable["disable"] = doDisable
64 mainFuncTable["test"] = doTest
65 mainFuncTable["alarm_filters"] = doAlarmFilters
66 mainFuncTable["arrive_onus"] = doArriveOnus
67 mainFuncTable["install_eapol_flow"] = doInstallEapolFlow
68 mainFuncTable["install_all_controller_bound_flows"] = doInstallAllControllerBoundFlows
69 mainFuncTable["install_all_sample_flows"] = doInstallAllSampleFlows
70 mainFuncTable["install_dhcp_flows"] = doInstallDhcpFlows
71 mainFuncTable["delete_all_flows"] = doDeleteAllFlows
72 mainFuncTable["send_simulated_upstream_eapol"] = doSendSimulatedUpstreamEapol
73 mainFuncTable["inject_eapol_start"] = doInjectEapolStart
74 util.ProcessTable(mainFuncTable, inputPrompt)
75}