gRPC migration update
Change-Id: Icdd1a824948fa994cd36bd121c962f5ecf74e3cf
diff --git a/pkg/format/formatter.go b/pkg/format/formatter.go
index 2b744d1..4adedb1 100644
--- a/pkg/format/formatter.go
+++ b/pkg/format/formatter.go
@@ -94,7 +94,8 @@
funcmap := template.FuncMap{
"timestamp": formatTimestamp,
- "since": formatSince}
+ "since": formatSince,
+ "gosince": formatGoSince}
tmpl, err := template.New("output").Funcs(funcmap).Parse(string(format))
if err != nil {
diff --git a/pkg/format/formatter_funcs.go b/pkg/format/formatter_funcs.go
index 6d10514..41be2f4 100644
--- a/pkg/format/formatter_funcs.go
+++ b/pkg/format/formatter_funcs.go
@@ -16,9 +16,9 @@
package format
import (
- "github.com/golang/protobuf/ptypes"
- timestamppb "github.com/golang/protobuf/ptypes/timestamp"
"time"
+
+ timestamppb "github.com/golang/protobuf/ptypes/timestamp"
)
// formats a Timestamp proto as a RFC3339 date string
@@ -26,11 +26,12 @@
if tsproto == nil {
return "", nil
}
- ts, err := ptypes.Timestamp(tsproto)
- if err != nil {
- return "", err
- }
- return ts.Truncate(time.Second).Format(time.RFC3339), nil
+ return tsproto.AsTime().Truncate(time.Second).Format(time.RFC3339), nil
+}
+
+// Computes the age of a timestamp and returns it in HMS format
+func formatGoSince(ts time.Time) (string, error) {
+ return time.Since(ts).Truncate(time.Second).String(), nil
}
// Computes the age of a timestamp and returns it in HMS format
@@ -38,9 +39,5 @@
if tsproto == nil {
return "", nil
}
- ts, err := ptypes.Timestamp(tsproto)
- if err != nil {
- return "", err
- }
- return time.Since(ts).Truncate(time.Second).String(), nil
+ return time.Since(tsproto.AsTime()).Truncate(time.Second).String(), nil
}
diff --git a/pkg/model/adapter.go b/pkg/model/adapter.go
new file mode 100644
index 0000000..89ede0a
--- /dev/null
+++ b/pkg/model/adapter.go
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2019-present Ciena Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package model
+
+import (
+ "time"
+
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+type AdapterInstance struct {
+ Id string `json:"id"`
+ Vendor string `json:"vendor"`
+ Type string `json:"type"`
+ Version string `json:"version"`
+ Endpoint string `json:"endpoint"`
+ CurrentReplica int32 `json:"currentreplica"`
+ TotalReplicas int32 `json:"totalreplicas"`
+ LastCommunication time.Time `json:"lastcommunication"`
+}
+
+func (a *AdapterInstance) PopulateFrom(val *voltha.Adapter) {
+ a.Id = val.Id
+ a.Vendor = val.Vendor
+ a.Type = val.Type
+ a.Version = val.Version
+ a.Endpoint = val.Endpoint
+ a.CurrentReplica = val.CurrentReplica
+ a.TotalReplicas = val.TotalReplicas
+ a.LastCommunication = time.Unix(val.LastCommunication, 0)
+}
diff --git a/pkg/model/flow.go b/pkg/model/flow.go
index 39bb81b..8869c05 100644
--- a/pkg/model/flow.go
+++ b/pkg/model/flow.go
@@ -17,7 +17,7 @@
import (
"fmt"
- "github.com/opencord/voltha-protos/v4/go/openflow_13"
+ "github.com/opencord/voltha-protos/v5/go/openflow_13"
)
type FlowFieldFlag uint64