blob: cc1798198395c81a8df706a974ae20460960cd38 [file] [log] [blame]
khenaidoobf6e7bb2018-08-14 22:27:29 -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 */
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040016package model
17
18import (
19 "crypto/md5"
20 "fmt"
21 "github.com/golang/protobuf/ptypes/any"
22 "github.com/opencord/voltha/protos/go/bbf_fiber"
23 "github.com/opencord/voltha/protos/go/common"
24 "github.com/opencord/voltha/protos/go/openflow_13"
25 "github.com/opencord/voltha/protos/go/voltha"
26 "testing"
27)
28
29func Test_Node_01_New(t *testing.T) {
30 ports := []*voltha.Port{
31 {
32 PortNo: 123,
33 Label: "test-etcd_port-0",
34 Type: voltha.Port_PON_OLT,
35 AdminState: common.AdminState_ENABLED,
36 OperStatus: common.OperStatus_ACTIVE,
37 DeviceId: "etcd_port-0-device-id",
38 Peers: []*voltha.Port_PeerPort{},
39 },
40 }
41 data := &voltha.Device{
42 Id: "Config-SomeNode-01-new-test",
43 Type: "simulated_olt",
44 Root: true,
45 ParentId: "",
46 ParentPortNo: 0,
47 Vendor: "voltha-test",
48 Model: "GetLatest-voltha-simulated-olt",
49 HardwareVersion: "1.0.0",
50 FirmwareVersion: "1.0.0",
51 Images: &voltha.Images{},
52 SerialNumber: "abcdef-123456",
53 VendorId: "DEADBEEF-INC",
54 Adapter: "simulated_olt",
55 Vlan: 1234,
56 Address: &voltha.Device_HostAndPort{HostAndPort: "1.2.3.4:5555"},
57 ExtraArgs: "",
58 ProxyAddress: &voltha.Device_ProxyAddress{},
59 AdminState: voltha.AdminState_PREPROVISIONED,
60 OperStatus: common.OperStatus_ACTIVE,
61 Reason: "",
62 ConnectStatus: common.ConnectStatus_REACHABLE,
63 Custom: &any.Any{},
64 Ports: ports,
65 Flows: &openflow_13.Flows{},
66 FlowGroups: &openflow_13.FlowGroups{},
67 PmConfigs: &voltha.PmConfigs{},
68 ChannelTerminations: []*bbf_fiber.ChannelterminationConfig{},
69 ImageDownloads: []*voltha.ImageDownload{},
70 }
71 root := &Root{}
72 txid := fmt.Sprintf("%x", md5.Sum([]byte("node_transaction_id")))
73
74 node := NewNode(root, data, true, txid)
75
76 t.Logf("new SomeNode created : %+v\n", node)
77}