From 4d888f172542b5fe645e8cef36258150120d546e Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Thu, 14 Mar 2019 15:26:49 +0800 Subject: [PATCH] fix: support batch update joint module --- pkg/mcclient/modules/joint.go | 13 ++++++++++++- pkg/mcclient/modules/modules.go | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/mcclient/modules/joint.go b/pkg/mcclient/modules/joint.go index a45cf49a70..da032d7214 100644 --- a/pkg/mcclient/modules/joint.go +++ b/pkg/mcclient/modules/joint.go @@ -5,7 +5,6 @@ import ( "net/url" "yunion.io/x/jsonutils" - "yunion.io/x/onecloud/pkg/mcclient" ) @@ -175,3 +174,15 @@ func (this *JointResourceManager) Patch(s *mcclient.ClientSession, mid, sid stri } return this.filterSingleResult(s, result, nil) } + +func (this *JointResourceManager) BatchUpdate(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult { + return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { + return this.Update(s, mid, sid, query, params) + }) +} + +func (this *JointResourceManager) BatchPatch(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult { + return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { + return this.Patch(s, mid, sid, query, params) + }) +} diff --git a/pkg/mcclient/modules/modules.go b/pkg/mcclient/modules/modules.go index 726254069e..7bbb90ec95 100644 --- a/pkg/mcclient/modules/modules.go +++ b/pkg/mcclient/modules/modules.go @@ -6,7 +6,6 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" - "yunion.io/x/onecloud/pkg/mcclient" ) @@ -139,7 +138,9 @@ type JointManager interface { BatchDetach(s *mcclient.ClientSession, mid string, sids []string) []SubmitResult BatchDetach2(s *mcclient.ClientSession, mid string, sids []string) []SubmitResult Update(s *mcclient.ClientSession, mid, sid string, query jsonutils.JSONObject, params jsonutils.JSONObject) (jsonutils.JSONObject, error) + BatchUpdate(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult Patch(s *mcclient.ClientSession, mid, sid string, query jsonutils.JSONObject, params jsonutils.JSONObject) (jsonutils.JSONObject, error) + BatchPatch(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult } var (