lbagents: deploy: check existence of pbId before create/update

This commit is contained in:
Yousong Zhou
2019-09-16 13:33:03 +00:00
parent 5ce5e36298
commit 54937ea7ce
@@ -313,6 +313,17 @@ func (lbagent *SLoadbalancerAgent) updateOrCreatePbModel(ctx context.Context,
pb *ansible.Playbook,
) (*mcclient_models.AnsiblePlaybook, error) {
cliSess := auth.GetSession(ctx, userCred, "", "")
if pbId == "" {
pbJson, err := mcclient_modules.AnsiblePlaybooks.Get(cliSess, pbName, nil)
if err == nil {
pbModel := &mcclient_models.AnsiblePlaybook{}
if err := pbJson.Unmarshal(pbModel); err == nil {
pbId = pbModel.Id
}
}
}
var pbJson jsonutils.JSONObject
if pbId != "" {
var err error