Skip to content

Commit b559a3d

Browse files
authored
Merge pull request #1426 from ioito/hotfix/qx-vmware-update-name
fix(esxi): allow update vmware account
2 parents 2a78d1b + 745cd34 commit b559a3d

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

pkg/multicloud/esxi/provider/provider.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,22 +154,21 @@ func (self *SESXiProviderFactory) GetClientRC(info cloudprovider.SProviderInfo)
154154
}, nil
155155
}
156156

157-
func (self *SESXiProviderFactory) GetAccountIdEqualizer() func(origin, now string) bool {
158-
return func(origin, now string) bool {
159-
if len(now) == 0 {
160-
return true
161-
}
162-
originUserName, nowUserName := origin, now
163-
index1 := strings.Index(origin, "@")
164-
index2 := strings.Index(now, "@")
165-
if index1 != -1 {
166-
originUserName = originUserName[:index1]
167-
}
168-
if index2 != -1 {
169-
nowUserName = nowUserName[:index2]
170-
}
171-
return originUserName == nowUserName
157+
// admin@vsphere.local@192.168.1.100:443 test@vsphere.local@192.168.1.100:443
158+
func isAccountEqual(origin, now string) bool {
159+
if len(now) == 0 {
160+
return true
172161
}
162+
host := origin
163+
hostIdx := strings.LastIndex(origin, "@")
164+
if hostIdx > 0 {
165+
host = origin[hostIdx+1:]
166+
}
167+
return strings.HasSuffix(now, host)
168+
}
169+
170+
func (self *SESXiProviderFactory) GetAccountIdEqualizer() func(origin, now string) bool {
171+
return isAccountEqual
173172
}
174173

175174
func init() {

0 commit comments

Comments
 (0)