Skip to content

Fix listing virtual machines with vnfnics - #161

Draft
weizhouapache wants to merge 1 commit into
mainfrom
fix-vnfnics
Draft

Fix listing virtual machines with vnfnics#161
weizhouapache wants to merge 1 commit into
mainfrom
fix-vnfnics

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

This fixes #159

Copilot AI lite review requested due to automatic review settings August 5, 2026 08:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes CloudStack response decoding for the vnfnics field by introducing a structured VnfNic type and updating generated response structs to use it, addressing #159.

Changes:

  • Add a hand-maintained VnfNic struct to match the (undocumented) API response shape.
  • Update vnfnics fields from []string to []*VnfNic across multiple response/resource types.
  • Update generator mapping so vnfnics is emitted as []*VnfNic.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
generate/generate.go Generates VnfNic and maps vnfnics to []*VnfNic.
cloudstack/VirtualNetworkFunctionsService.go Adds VnfNic type and updates VNF appliance responses to use it.
cloudstack/VirtualMachineService.go Updates many VM-related responses/resources to use []*VnfNic for vnfnics.
cloudstack/SnapshotService.go Updates snapshot response to use []*VnfNic for vnfnics.
cloudstack/SSHService.go Updates SSH reset response to use []*VnfNic for vnfnics.
cloudstack/NicService.go Updates NIC update response to use []*VnfNic for vnfnics.
cloudstack/ISOService.go Updates ISO attach/detach responses to use []*VnfNic for vnfnics.
cloudstack/BackupService.go Updates VM-from-backup response to use []*VnfNic for vnfnics.
cloudstack/AffinityGroupService.go Updates VM affinity group response to use []*VnfNic for vnfnics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread generate/generate.go
Comment on lines +2012 to +2025
if a.Name == "listVnfAppliances" {
// The API docs do not describe the shape of the "vnfnics" field, so this
// type is hand maintained to mirror org.apache.cloudstack.api.response.VnfNicResponse.
pn("type VnfNic struct {")
pn(" Deviceid int64 `json:\"deviceid\"`")
pn(" Description string `json:\"description\"`")
pn(" Management bool `json:\"management\"`")
pn(" Name string `json:\"name\"`")
pn(" Networkid string `json:\"networkid\"`")
pn(" Networkname string `json:\"networkname\"`")
pn(" Required bool `json:\"required\"`")
pn("}")
pn("")
}
Comment thread generate/generate.go
Comment on lines +2420 to +2422
if pName == "vnfnics" {
return "[]*VnfNic"
}
Vmtype string `json:"vmtype"`
Vnfdetails map[string]string `json:"vnfdetails"`
Vnfnics []string `json:"vnfnics"`
Vnfnics []*VnfNic `json:"vnfnics"`
Comment on lines +3012 to +3020
type VnfNic struct {
Deviceid int64 `json:"deviceid"`
Description string `json:"description"`
Management bool `json:"management"`
Name string `json:"name"`
Networkid string `json:"networkid"`
Networkname string `json:"networkname"`
Required bool `json:"required"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot unmarshal object into Go struct field ListVirtualMachinesResponse.virtualmachine.vnfnics of type string

2 participants