Skip to content

Commit

Permalink
Merge pull request #2547 from yuyin002/issue-2545
Browse files Browse the repository at this point in the history
fix: Regenerated interface and type to include BaseAgencyConfigInfo. …
  • Loading branch information
zach96guan committed Aug 12, 2021
2 parents 4a7de71 + a366e35 commit ec5a4a7
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion eam/object/agency.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (m Agency) Config(ctx context.Context) (*types.AgencyConfigInfo, error) {
if err != nil {
return nil, err
}
return &resp.Returnval, nil
return resp.Returnval.GetAgencyConfigInfo(), nil
}

func (m Agency) Runtime(ctx context.Context) (*types.EamObjectRuntimeInfo, error) {
Expand Down
2 changes: 1 addition & 1 deletion eam/object/esx_agent_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (m EsxAgentManager) CreateAgency(
var agency Agency
resp, err := methods.CreateAgency(ctx, m.c, &types.CreateAgency{
This: m.r,
AgencyConfigInfo: config,
AgencyConfigInfo: config.GetAgencyConfigInfo(),
InitialGoalState: initialGoalState,
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions eam/simulator/agency.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (m *Agency) QueryConfig(

return &methods.QueryConfigBody{
Res: &types.QueryConfigResponse{
Returnval: m.Config,
Returnval: &m.Config,
},
}
}
Expand Down Expand Up @@ -237,7 +237,7 @@ func (m *Agency) Update(
ctx *simulator.Context,
req *types.Update) soap.HasFault {

m.Config = req.Config
m.Config = *req.Config.GetAgencyConfigInfo()

return &methods.UpdateBody{
Res: &types.UpdateResponse{},
Expand Down
2 changes: 1 addition & 1 deletion eam/simulator/esx_agent_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (m *EsxAgentManager) CreateAgency(

if agency, err := NewAgency(
ctx,
req.AgencyConfigInfo,
*req.AgencyConfigInfo.GetAgencyConfigInfo(),
req.InitialGoalState); err != nil {

res.Fault_ = simulator.Fault("", err)
Expand Down
10 changes: 10 additions & 0 deletions eam/types/if.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ import (
"github.com/vmware/govmomi/vim25/types"
)

func (b *AgencyConfigInfo) GetAgencyConfigInfo() *AgencyConfigInfo { return b }

type BaseAgencyConfigInfo interface {
GetAgencyConfigInfo() *AgencyConfigInfo
}

func init() {
types.Add("BaseAgencyConfigInfo", reflect.TypeOf((*AgencyConfigInfo)(nil)).Elem())
}

func (b *AgencyIssue) GetAgencyIssue() *AgencyIssue { return b }

type BaseAgencyIssue interface {
Expand Down
6 changes: 3 additions & 3 deletions eam/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func init() {

type CreateAgencyRequestType struct {
This types.ManagedObjectReference `xml:"_this"`
AgencyConfigInfo AgencyConfigInfo `xml:"agencyConfigInfo"`
AgencyConfigInfo BaseAgencyConfigInfo `xml:"agencyConfigInfo,typeattr"`
InitialGoalState string `xml:"initialGoalState"`
}

Expand Down Expand Up @@ -1201,7 +1201,7 @@ func init() {
}

type QueryConfigResponse struct {
Returnval AgencyConfigInfo `xml:"returnval"`
Returnval BaseAgencyConfigInfo `xml:"returnval,typeattr"`
}

type QueryIssue QueryIssueRequestType
Expand Down Expand Up @@ -1375,7 +1375,7 @@ func init() {

type UpdateRequestType struct {
This types.ManagedObjectReference `xml:"_this"`
Config AgencyConfigInfo `xml:"config"`
Config BaseAgencyConfigInfo `xml:"config,typeattr"`
}

func init() {
Expand Down
9 changes: 8 additions & 1 deletion gen/gen.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (c) 2014 VMware, Inc. All Rights Reserved.
# Copyright (c) 2014-2021 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,6 +52,13 @@ generate() {
#
export COPYRIGHT_DATE_RANGE="2014-2021"

#
# FORCE_BASE_INTERFACE_FOR_TYPES defines the types that we want to
# generate base interfaces for. The type names should be comma seperated -
# e.g. "TypeA,TypeB,TypeC"
#
export FORCE_BASE_INTERFACE_FOR_TYPES="AgencyConfigInfo"

# ./sdk/ contains the contents of wsdl.zip from vimbase build 17354719
generate "../vim25" "vim" "./rbvmomi/vmodl.db" # from github.com/vmware/rbvmomi@v3.0.0
generate "../pbm" "pbm"
Expand Down
7 changes: 4 additions & 3 deletions gen/vim_wsdl.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2014-2018 VMware, Inc. All Rights Reserved.
# Copyright (c) 2014-2021 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@
require "test/unit"

$namespaces = %w(vim25)
$force_base_interface_for_types = ENV['FORCE_BASE_INTERFACE_FOR_TYPES']

def valid_ns?(t)
$namespaces.include?(t)
Expand Down Expand Up @@ -62,7 +63,7 @@ def base?
# VrpResourceAllocationInfo is removed in 6.7, so base will no longer generated
return false if ["ResourceAllocationInfo", "FaultDomainId"].include?(@name)

return !children.empty?
return !children.empty? || $force_base_interface_for_types.split(",").include?(@name)
end
end

Expand Down Expand Up @@ -193,7 +194,7 @@ def vim_type(t = self.type)
end

def base_type?
vim_type? && Peek.base?(vim_type)
vim_type? && (Peek.base?(vim_type) || $force_base_interface_for_types.split(",").include?(vim_type))
end

def enum_type?
Expand Down

0 comments on commit ec5a4a7

Please sign in to comment.