fix(region): esxi vm create with tags (#19262)

This commit is contained in:
屈轩
2024-01-16 14:25:50 +08:00
committed by GitHub
parent 39690fabed
commit 4a7692b8d0
2 changed files with 10 additions and 0 deletions
+2
View File
@@ -467,6 +467,8 @@ func (self *SESXiGuestDriver) RequestDeployGuestOnHost(ctx context.Context, gues
extId = guest.ExternalId
}
config.Add(jsonutils.NewString(extId), "guest_ext_id")
tags, _ := guest.GetAllUserMetadata()
config.Set("tags", jsonutils.Marshal(tags))
account := host.GetCloudaccount()
accessInfo, err := account.GetVCenterAccessInfo(storage.ExternalId)
+8
View File
@@ -170,6 +170,14 @@ func (as *SAgentStorage) agentCreateGuest(ctx context.Context, data *jsonutils.J
if err != nil {
return false, errors.Wrap(err, "SHost.CreateVM2")
}
tags := map[string]string{}
data.Unmarshal(&tags, "tags")
if len(tags) > 0 {
err = vm.SetTags(tags, true)
if err != nil {
log.Warningf("set tags for vm %s error: %v", createParam.Name, err)
}
}
name, _ := descDict.GetString("name")
err = as.tryRenameVm(ctx, vm, name)
if err != nil {