VOLTHA/VOL-3478 : FlowId are logged as decimals and reported by voltctl as hex.
By Default flow-id would be in int format .
hex-id option is supported to display flow id in hex format.
Change-Id: I8b715613a6800b89a5dcedb8b90dc289b336bf24
diff --git a/VERSION b/VERSION
index b6bb93f..f0bb29e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.3.0-dev
+1.3.0
diff --git a/internal/pkg/commands/command.go b/internal/pkg/commands/command.go
index d5a2785..d2951a3 100644
--- a/internal/pkg/commands/command.go
+++ b/internal/pkg/commands/command.go
@@ -157,6 +157,10 @@
NameLimit int `short:"l" long:"namelimit" default:"-1" value-name:"LIMIT" description:"Limit the depth (length) in the table column name"`
}
+type FlowIdOptions struct {
+ HexId bool `short:"x" long:"hex-id" description:"Output Ids in hex format"`
+}
+
type ListOutputOptions struct {
OutputOptions
Filter string `short:"f" long:"filter" default:"" value-name:"FILTER" description:"Only display results that match filter"`
diff --git a/internal/pkg/commands/devices.go b/internal/pkg/commands/devices.go
index dd0bfc8..2f0d8a8 100644
--- a/internal/pkg/commands/devices.go
+++ b/internal/pkg/commands/devices.go
@@ -91,6 +91,7 @@
type DeviceFlowList struct {
ListOutputOptions
+ FlowIdOptions
Args struct {
Id DeviceId `positional-arg-name:"DEVICE_ID" required:"yes"`
} `positional-args:"yes"`
@@ -698,6 +699,7 @@
func (options *DeviceFlowList) Execute(args []string) error {
fl := &FlowList{}
fl.ListOutputOptions = options.ListOutputOptions
+ fl.FlowIdOptions = options.FlowIdOptions
fl.Args.Id = string(options.Args.Id)
fl.Method = "device-flows"
return fl.Execute(args)
diff --git a/internal/pkg/commands/flows.go b/internal/pkg/commands/flows.go
index efe09f2..1e8ec62 100644
--- a/internal/pkg/commands/flows.go
+++ b/internal/pkg/commands/flows.go
@@ -28,6 +28,7 @@
type FlowList struct {
ListOutputOptions
+ FlowIdOptions
Args struct {
Id string `positional-arg-name:"DEVICE_ID" required:"yes"`
} `positional-args:"yes"`
@@ -143,7 +144,7 @@
data := make([]model.Flow, len(flows.Items))
var fieldset model.FlowFieldFlag
for i, item := range flows.Items {
- data[i].PopulateFromProto(item)
+ data[i].PopulateFromProto(item, options.HexId)
fieldset |= data[i].Populated()
}
diff --git a/internal/pkg/commands/logicaldevices.go b/internal/pkg/commands/logicaldevices.go
index 3a5dd66..bef1de3 100644
--- a/internal/pkg/commands/logicaldevices.go
+++ b/internal/pkg/commands/logicaldevices.go
@@ -43,6 +43,7 @@
type LogicalDeviceFlowList struct {
ListOutputOptions
+ FlowIdOptions
Args struct {
Id LogicalDeviceId `positional-arg-name:"DEVICE_ID" required:"yes"`
} `positional-args:"yes"`
@@ -212,6 +213,7 @@
func (options *LogicalDeviceFlowList) Execute(args []string) error {
fl := &FlowList{}
fl.ListOutputOptions = options.ListOutputOptions
+ fl.FlowIdOptions = options.FlowIdOptions
fl.Args.Id = string(options.Args.Id)
fl.Method = "logical-device-flows"
return fl.Execute(args)
diff --git a/pkg/model/flow.go b/pkg/model/flow.go
index 1a5f88b..928339c 100644
--- a/pkg/model/flow.go
+++ b/pkg/model/flow.go
@@ -294,10 +294,15 @@
return fmt.Sprintf("%d", val)
}
-func (f *Flow) PopulateFromProto(flow *openflow_13.OfpFlowStats) {
+func (f *Flow) PopulateFromProto(flow *openflow_13.OfpFlowStats, hexId bool) {
f.Reset()
- f.Id = fmt.Sprintf("%016x", flow.Id)
+ if hexId {
+ f.Id = fmt.Sprintf("%016x", flow.Id)
+ } else {
+ f.Id = fmt.Sprintf("%v", flow.Id)
+ }
+
f.TableId = flow.TableId
f.Priority = flow.Priority
// mask the lower 8 for the cookie, why?