Skip to content

Commit

Permalink
vpcagent: apihelper: use IModelSet.IncludeEmulated()
Browse files Browse the repository at this point in the history
  • Loading branch information
yousong committed May 21, 2020
1 parent 5bf45ad commit e0349f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 9 additions & 6 deletions pkg/vpcagent/apihelper/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type IModelSet interface {
Copy() IModelSet

IncludeDetails() bool
IncludeEmulated() bool
}

func SyncModelSets(mssOld IModelSets, s *mcclient.ClientSession, batchSize int) (r ModelSetsUpdateResult, err error) {
Expand All @@ -47,12 +48,14 @@ func SyncModelSets(mssOld IModelSets, s *mcclient.ClientSession, batchSize int)
for i, msNew := range mssNews.ModelSetList() {
minUpdatedAt := ModelSetMaxUpdatedAt(mss[i])
err = GetModels(&GetModelsOptions{
ClientSession: s,
ModelManager: msNew.ModelManager(),
MinUpdatedAt: minUpdatedAt,
ModelSet: msNew,
BatchListSize: batchSize,
IncludeDetails: msNew.IncludeDetails(),
ClientSession: s,
ModelManager: msNew.ModelManager(),
MinUpdatedAt: minUpdatedAt,
ModelSet: msNew,
BatchListSize: batchSize,

IncludeDetails: msNew.IncludeDetails(),
IncludeEmulated: msNew.IncludeEmulated(),
})
if err != nil {
return
Expand Down
12 changes: 7 additions & 5 deletions pkg/vpcagent/apihelper/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ type GetModelsOptions struct {
ModelManager mcclient_modulebase.IBaseManager
ModelSet IModelSet

BatchListSize int
MinUpdatedAt time.Time
IncludeDetails bool
BatchListSize int
MinUpdatedAt time.Time
IncludeDetails bool
IncludeEmulated bool
}

func GetModels(opts *GetModelsOptions) error {
Expand Down Expand Up @@ -100,8 +101,9 @@ func GetModels(opts *GetModelsOptions) error {
}

listOptions := options.BaseListOptions{
Admin: options.Bool(true),
Details: options.Bool(opts.IncludeDetails),
Admin: options.Bool(true),
Details: options.Bool(opts.IncludeDetails),
ShowEmulated: options.Bool(opts.IncludeEmulated),
Filter: []string{
minUpdatedAtFilter(minUpdatedAt), // order matters, filter.0
"manager_id.isnullorempty()", // len(manager_id) > 0 is for pubcloud objects
Expand Down

0 comments on commit e0349f9

Please sign in to comment.