fix(region): vendor update (#25203)

This commit is contained in:
屈轩
2026-07-22 11:19:05 +08:00
committed by GitHub
parent 07b718eeb2
commit 8d0ee46764
7 changed files with 55 additions and 9 deletions

2
go.mod
View File

@@ -113,7 +113,7 @@ require (
k8s.io/cri-api v0.28.15
k8s.io/klog/v2 v2.90.1
moul.io/http2curl/v2 v2.3.0
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260721151521-534cae0bb436
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260722023537-f41e01f2eee3
yunion.io/x/executor v0.0.0-20260312022053-f538abd2b005
yunion.io/x/jsonutils v1.0.1-0.20260715075349-615cfb44ff7c
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91

4
go.sum
View File

@@ -1754,8 +1754,8 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260721151521-534cae0bb436 h1:iCppAxvih2qIve2V49RPPCHYcuDlkBVWwZZs2mmSVZw=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260721151521-534cae0bb436/go.mod h1:QgrcekfkD3fELNYipZnlUfhR8dPI8CCUsuzC2SkP3YE=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260722023537-f41e01f2eee3 h1:QBX44ByHjCYbstpxDejNPI+GqJmcsJIE8nTQCGfxUsw=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260722023537-f41e01f2eee3/go.mod h1:QgrcekfkD3fELNYipZnlUfhR8dPI8CCUsuzC2SkP3YE=
yunion.io/x/executor v0.0.0-20260312022053-f538abd2b005 h1:3sWwcjGXGjG9mLBWa7AyLq+QSi0udTAx21pfVQRFMBE=
yunion.io/x/executor v0.0.0-20260312022053-f538abd2b005/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=

View File

@@ -238,7 +238,13 @@ func (ps *SProxmoxStorage) agentCreateGuest(ctx context.Context, data jsonutils.
PublicKey: desc.Pubkey,
}
if len(desc.Nics) > 0 {
createParam.IpAddr = desc.Nics[0].Ip
nic := desc.Nics[0]
createParam.IpAddr = nic.Ip
createParam.MacAddr = nic.Mac
createParam.Bridge = nic.Bridge
createParam.Gateway = nic.Gateway
createParam.Masklen = nic.Masklen
createParam.Dns = nic.Dns
}
for i := range desc.Disks {
if i == 0 {

2
vendor/modules.txt vendored
View File

@@ -2547,7 +2547,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
# sigs.k8s.io/yaml v1.3.0
## explicit; go 1.12
sigs.k8s.io/yaml
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260721151521-534cae0bb436
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20260722023537-f41e01f2eee3
## explicit; go 1.24
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing

View File

@@ -151,6 +151,11 @@ type SManagedVMCreateConfig struct {
ExternalNetworkId string
ExternalVpcId string
IpAddr string
MacAddr string
Bridge string
Gateway string
Masklen int8
Dns string
Description string
SysDisk SDiskInfo
DataDisks []SDiskInfo

View File

@@ -212,10 +212,18 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
return nil, errors.Wrapf(err, "GetStorage")
}
bridge := opts.Bridge
if len(bridge) == 0 {
bridge = "vmbr0"
}
net0 := fmt.Sprintf("virtio,bridge=%s,firewall=1", bridge)
if len(opts.MacAddr) > 0 {
net0 = fmt.Sprintf("virtio=%s,bridge=%s,firewall=1", strings.ToUpper(opts.MacAddr), bridge)
}
body := map[string]interface{}{
"vmid": vmId,
"name": opts.Name,
//"ide2": fmt.Sprintf("%s,media=cdrom", opts.ExternalImageId),
"vmid": vmId,
"name": opts.Name,
"ostype": "other",
"sockets": 1,
"cores": opts.Cpu,
@@ -225,7 +233,8 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
"memory": opts.MemoryMB,
"description": opts.OsDistribution,
"scsihw": "virtio-scsi-pci",
"net0": "virtio,bridge=vmbr0,firewall=1",
"net0": net0,
"agent": "1",
}
sysIndex := 0
if strings.HasSuffix(opts.ExternalImageId, ".iso") { // iso image
@@ -236,6 +245,8 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
//body["ide2"] = fmt.Sprintf("%s,media=disk", opts.ExternalImageId)
} else {
body["scsi0"] = fmt.Sprintf("%s:0,import-from=%s,iothread=on", storage.Storage, opts.ExternalImageId)
// cloud-init drive for network/user injection on non-ISO images
body["ide2"] = fmt.Sprintf("%s:cloudinit", storage.Storage)
}
for i, disk := range opts.DataDisks {
storage, err := self.cli.GetStorage(disk.StorageExternalId)
@@ -245,6 +256,21 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
body[fmt.Sprintf("scsi%d", i+sysIndex)] = fmt.Sprintf("%s:%d", storage.Storage, opts.SysDisk.SizeGB)
}
if len(opts.IpAddr) > 0 && !strings.HasSuffix(opts.ExternalImageId, ".iso") {
masklen := opts.Masklen
if masklen <= 0 {
masklen = 24
}
ipconfig := fmt.Sprintf("ip=%s/%d", opts.IpAddr, masklen)
if len(opts.Gateway) > 0 {
ipconfig = fmt.Sprintf("%s,gw=%s", ipconfig, opts.Gateway)
}
body["ipconfig0"] = ipconfig
if len(opts.Dns) > 0 {
body["nameserver"] = opts.Dns
}
}
log.Debugf("opts: %s params: %s", jsonutils.Marshal(opts), jsonutils.Marshal(body))
res := fmt.Sprintf("/nodes/%s/qemu", self.Node)

View File

@@ -320,6 +320,10 @@ func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
if strings.HasSuffix(disks[i].DiskId, ".iso") {
continue
}
// skip cloud-init drive
if strings.HasSuffix(disks[i].DiskId, ":cloudinit") || strings.Contains(disks[i].DiskId, "cloudinit") {
continue
}
diskIds = append(diskIds, disks[i].DiskId)
}
disks, err := self.host.cli.GetDisks(self.host.Node, storageName)
@@ -769,6 +773,11 @@ func (self *SProxmoxClient) GetQemuConfig(node string, VmId int) (*SInstance, er
if diskConfMap["volume"].(string) == "none" {
continue
}
// skip cloud-init drive, e.g. local-lvm:cloudinit
volume := diskConfMap["volume"].(string)
if strings.HasSuffix(volume, ":cloudinit") || strings.Contains(volume, "cloudinit") {
continue
}
size := int(0)
if sizeStr, ok := diskConfMap["size"].(string); ok {