David K. Bainbridge | bd6b288 | 2021-08-26 13:31:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-present Ciena Corporation |
| 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 | package model |
| 17 | |
| 18 | import ( |
| 19 | "time" |
| 20 | |
| 21 | "github.com/opencord/voltha-protos/v5/go/voltha" |
| 22 | ) |
| 23 | |
| 24 | type AdapterInstance struct { |
| 25 | Id string `json:"id"` |
| 26 | Vendor string `json:"vendor"` |
| 27 | Type string `json:"type"` |
| 28 | Version string `json:"version"` |
| 29 | Endpoint string `json:"endpoint"` |
| 30 | CurrentReplica int32 `json:"currentreplica"` |
| 31 | TotalReplicas int32 `json:"totalreplicas"` |
| 32 | LastCommunication time.Time `json:"lastcommunication"` |
| 33 | } |
| 34 | |
| 35 | func (a *AdapterInstance) PopulateFrom(val *voltha.Adapter) { |
| 36 | a.Id = val.Id |
| 37 | a.Vendor = val.Vendor |
| 38 | a.Type = val.Type |
| 39 | a.Version = val.Version |
| 40 | a.Endpoint = val.Endpoint |
| 41 | a.CurrentReplica = val.CurrentReplica |
| 42 | a.TotalReplicas = val.TotalReplicas |
| 43 | a.LastCommunication = time.Unix(val.LastCommunication, 0) |
| 44 | } |