Fix listing virtual machines with vnfnics - #161
Draft
weizhouapache wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
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
VnfNicstruct to match the (undocumented) API response shape. - Update
vnfnicsfields from[]stringto[]*VnfNicacross multiple response/resource types. - Update generator mapping so
vnfnicsis 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 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 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"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #159