Skip to content

Commit

Permalink
vcsim: Fix keys in DistributedVirtualPorts
Browse files Browse the repository at this point in the history
Closes: #2726
Signed-off-by: syuparn <s.hello.spagetti@gmail.com>
  • Loading branch information
Syuparn committed Feb 1, 2022
1 parent c9ab1c7 commit 451ec35
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
12 changes: 3 additions & 9 deletions simulator/dvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,12 @@ func (s *DistributedVirtualSwitch) dvPortgroups(_ *types.DistributedVirtualSwitc

for _, ref := range s.Portgroup {
pg := Map.Get(ref).(*DistributedVirtualPortgroup)
res = append(res, types.DistributedVirtualPort{
DvsUuid: s.Uuid,
Key: pg.Key,
Config: types.DVPortConfigInfo{
Setting: pg.Config.DefaultPortConfig,
},
})

for _, key := range pg.PortKeys {
res = append(res, types.DistributedVirtualPort{
DvsUuid: s.Uuid,
Key: key,
DvsUuid: s.Uuid,
Key: key,
PortgroupKey: pg.Key,
Config: types.DVPortConfigInfo{
Setting: pg.Config.DefaultPortConfig,
},
Expand Down
4 changes: 3 additions & 1 deletion simulator/dvs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func TestDVS(t *testing.T) {
} else {
switch test.op {
case types.ConfigSpecOperationAdd:
dtask, err = dswitch.AddPortgroup(ctx, []types.DVPortgroupConfigSpec{{Name: test.pg}})
dtask, err = dswitch.AddPortgroup(ctx, []types.DVPortgroupConfigSpec{
{Name: test.pg, NumPorts: 1},
})
}
}

Expand Down
5 changes: 3 additions & 2 deletions simulator/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,9 @@ func (f *Folder) CreateDVSTask(ctx *Context, req *types.CreateDVS_Task) soap.Has

dvs.AddDVPortgroupTask(ctx, &types.AddDVPortgroup_Task{
Spec: []types.DVPortgroupConfigSpec{{
Name: dvs.Name + "-DVUplinks" + strings.TrimPrefix(dvs.Self.Value, "dvs"),
Type: string(types.DistributedVirtualPortgroupPortgroupTypeEarlyBinding),
Name: dvs.Name + "-DVUplinks" + strings.TrimPrefix(dvs.Self.Value, "dvs"),
Type: string(types.DistributedVirtualPortgroupPortgroupTypeEarlyBinding),
NumPorts: 1,
DefaultPortConfig: &types.VMwareDVSPortSetting{
Vlan: &types.VmwareDistributedVirtualSwitchTrunkVlanSpec{
VlanId: []types.NumericRange{{Start: 0, End: 4094}},
Expand Down
5 changes: 3 additions & 2 deletions simulator/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,9 @@ func (m *Model) Create() error {
for npg := 0; npg < m.Portgroup; npg++ {
name := m.fmtName(dcName+"_DVPG", npg)
spec := types.DVPortgroupConfigSpec{
Name: name,
Type: string(types.DistributedVirtualPortgroupPortgroupTypeEarlyBinding),
Name: name,
Type: string(types.DistributedVirtualPortgroupPortgroupTypeEarlyBinding),
NumPorts: 1,
}

task, err := dvs.AddPortgroup(ctx, []types.DVPortgroupConfigSpec{spec})
Expand Down

0 comments on commit 451ec35

Please sign in to comment.