blob: b9e22bd2ad799a1ebb715e0e429037c4c8b1e2d6 [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 devicemenu
18
19import (
20 "context"
21 "fmt"
22 "strconv"
23
24 "github.com/opencord/voltha-go/cli/util"
25 "github.com/opencord/voltha-protos/go/common"
26 "github.com/opencord/voltha-protos/go/voltha"
27)
28
29func doShow(enterPressed bool) {
30 client := voltha.NewVolthaServiceClient(Conn)
31 fmt.Println(*DeviceId)
32 device, err := client.GetDevice(context.Background(), &common.ID{Id: *DeviceId})
33 if err != nil {
34 fmt.Println(err)
35 }
36 fields := []string{"field", "value"}
37 var rows []map[string]string
38
39 id := make(map[string]string)
40 id["field"] = "id"
41 id["value"] = device.Id
42 rows = append(rows, id)
43
44 Type := make(map[string]string)
45 Type["field"] = "type"
46 Type["value"] = device.Type
47 rows = append(rows, Type)
48
49 parentId := make(map[string]string)
50 parentId["field"] = "parent_id"
51 parentId["value"] = device.ParentId
52 rows = append(rows, parentId)
53
54 vlan := make(map[string]string)
55 vlan["field"] = "vlan"
56 vlan["value"] = strconv.FormatUint(uint64(device.Vlan), 10)
57 rows = append(rows, vlan)
58
59 adminState := make(map[string]string)
60 adminState["field"] = "admin_state"
61 adminState["value"] = strconv.FormatUint(uint64(device.AdminState), 10)
62 rows = append(rows, adminState)
63
64 proxyAddress := device.GetProxyAddress()
65 proxyDeviceId := make(map[string]string)
66 proxyDeviceId["field"] = "proxy_address.device_id"
67 proxyDeviceId["value"] = proxyAddress.DeviceId
68 rows = append(rows, proxyDeviceId)
69
70 proxyDeviceType := make(map[string]string)
71 proxyDeviceType["field"] = "proxy_address.device_type"
72 proxyDeviceType["value"] = proxyAddress.DeviceType
73 rows = append(rows, proxyDeviceType)
74
75 proxyChannelId := make(map[string]string)
76 proxyChannelId["field"] = "proxy_address.channel_id"
77 proxyChannelId["value"] = strconv.FormatUint(uint64(proxyAddress.ChannelId), 10)
78 rows = append(rows, proxyChannelId)
79
80 parentPortNumber := make(map[string]string)
81 parentPortNumber["field"] = "parent_port_no"
82 parentPortNumber["value"] = strconv.FormatUint(uint64(device.GetParentPortNo()), 10)
83 rows = append(rows, parentPortNumber)
84
85 output, _ := util.BuildTable(fields, rows)
86
87 fmt.Println(output)
88}