diff --git a/cmd/generate.go b/cmd/generate.go index 17dbd1594..dc4d5bb30 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -28,10 +28,11 @@ var interfaceFormat = map[string]string{ "bridge": "veth%d", "vr-sros": "eth%d", "vr-vmx": "eth%d", + "vr-vqfx": "eth%d", "vr-xrv9k": "eth%d", "vr-veos": "eth%d", } -var supportedKinds = []string{"srl", "ceos", "linux", "bridge", "sonic-vs", "crpd", "vr-sros", "vr-vmx", "vr-xrv9k"} +var supportedKinds = []string{"srl", "ceos", "linux", "bridge", "sonic-vs", "crpd", "vr-sros", "vr-vmx", "vr-vqfx", "vr-xrv9k"} const ( defaultSRLType = "ixrd2" @@ -257,35 +258,31 @@ func parseNodesFlag(kind string, nodes ...string) ([]nodesDef, error) { } def.numNodes = uint(i) switch len(items) { + // num_nodes notation + // kind is assumed to be `srl` or set with --kind case 1: if kind == "" { log.Errorf("no kind specified for nodes '%s'", n) return nil, errSyntax } def.kind = kind - if kind == "srl" { - def.typ = defaultSRLType - } + // num_nodes:kind notation case 2: - switch items[1] { - case "ceos", "linux", "bridge", "sonic", "crpd": - def.kind = items[1] - case "srl": - def.kind = items[1] - def.typ = defaultSRLType - default: - // assume second item is a type if kind set using --kind - if kind == "" { - log.Errorf("no kind specified for nodes '%s'", n) - return nil, errSyntax - } - def.kind = kind - def.typ = items[1] + if kind == "" { + log.Errorf("no kind specified for nodes '%s'", n) + return nil, errSyntax } + def.kind = items[1] + + // num_nodes:kind:type notation case 3: - // srl with #nodes, kind and type def.numNodes = uint(i) - def.kind = items[1] + def.kind = kind + + if items[1] != "" { + def.kind = items[1] + } + def.typ = items[2] } result[idx] = def diff --git a/cmd/generate_test.go b/cmd/generate_test.go index 711dfdf58..fb34651e1 100644 --- a/cmd/generate_test.go +++ b/cmd/generate_test.go @@ -127,9 +127,9 @@ var nodesTestSet = map[string]struct { }, out: nodesOutput{ out: []nodesDef{ - {numNodes: 1, kind: "srl", typ: "ixrd2"}, - {numNodes: 2, kind: "srl", typ: "ixrd2"}, - {numNodes: 3, kind: "srl", typ: "ixrd2"}, + {numNodes: 1, kind: "srl", typ: ""}, + {numNodes: 2, kind: "srl", typ: ""}, + {numNodes: 3, kind: "srl", typ: ""}, }, err: nil, }, @@ -142,7 +142,7 @@ var nodesTestSet = map[string]struct { out: nodesOutput{ out: []nodesDef{ {numNodes: 1, kind: "linux", typ: ""}, - {numNodes: 2, kind: "srl", typ: "ixrd2"}, + {numNodes: 2, kind: "srl", typ: ""}, {numNodes: 3, kind: "ceos", typ: ""}, }, err: nil, @@ -151,12 +151,12 @@ var nodesTestSet = map[string]struct { "kind_nodes_with_kind_and_type": { in: nodesInput{ kind: "srl", - nodes: []string{"1:ixrd", "2", "3:ceos"}, + nodes: []string{"1::ixrd", "2", "3:ceos"}, }, out: nodesOutput{ out: []nodesDef{ {numNodes: 1, kind: "srl", typ: "ixrd"}, - {numNodes: 2, kind: "srl", typ: "ixrd2"}, + {numNodes: 2, kind: "srl"}, {numNodes: 3, kind: "ceos", typ: ""}, }, err: nil, @@ -169,7 +169,7 @@ var nodesTestSet = map[string]struct { }, out: nodesOutput{ out: []nodesDef{ - {numNodes: 2, kind: "srl", typ: "ixrd2"}, + {numNodes: 2, kind: "srl", typ: ""}, }, err: nil, },