Skip to content

Commit

Permalink
Network: add target parameter for GET 1.0/networks and network_get_ta…
Browse files Browse the repository at this point in the history
…rget api extension. fixes canonical#14406

Signed-off-by: David Edler <[email protected]>
  • Loading branch information
edlerd committed Nov 8, 2024
1 parent 5c0f573 commit 9d1604a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/api-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2520,3 +2520,7 @@ contains the total available logical CPUs available when LXD started.
## `vm_limits_cpu_pin_strategy`

Adds a new {config:option}`instance-resource-limits:limits.cpu.pin_strategy` configuration option for virtual machines. This option controls the CPU pinning strategy. When set to `none`, CPU auto pinning is disabled. When set to `auto`, CPU auto pinning is enabled.

## `network_get_target`

Adds optional `target` parameter to `GET /1.0/network`. When target is set, forward the request to the specified cluster member and return the non managed interfaces from that member.
11 changes: 11 additions & 0 deletions lxd/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ func networkAccessHandler(entitlement auth.Entitlement) func(d *Daemon, r *http.
// description: Project name
// type: string
// example: default
// - in: query
// name: target
// description: Cluster member name
// type: string
// example: lxd01
// responses:
// "200":
// description: API endpoints
Expand Down Expand Up @@ -231,6 +236,12 @@ func networkAccessHandler(entitlement auth.Entitlement) func(d *Daemon, r *http.
func networksGet(d *Daemon, r *http.Request) response.Response {
s := d.State()

// If a target was specified, forward the request to the relevant node.
resp := forwardedResponseIfTargetIsRemote(s, r)
if resp != nil {
return resp
}

requestProjectName := request.ProjectParam(r)
effectiveProjectName, reqProject, err := project.NetworkProject(s.DB.Cluster, requestProjectName)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions shared/version/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ var APIExtensions = []string{
"network_ovn_uplink_vlan",
"state_logical_cpus",
"vm_limits_cpu_pin_strategy",
"network_get_target",
}

// APIExtensionsCount returns the number of available API extensions.
Expand Down

0 comments on commit 9d1604a

Please sign in to comment.