Skip to content

Commit

Permalink
incus/network: Align attach-profile with attach
Browse files Browse the repository at this point in the history
Closes #870

Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed May 22, 2024
1 parent 65c93e3 commit 96dea80
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions cmd/incus/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,27 @@ func (c *cmdNetworkAttachProfile) Run(cmd *cobra.Command, args []string) error {
return err
}

// Prepare the profile's device entry
device := map[string]string{
"type": "nic",
"nictype": "macvlan",
"parent": resource.name,
}
// Prepare the instance's device entry
var device map[string]string
if network.Managed && resource.server.HasExtension("instance_nic_network") {
// If network is managed, use the network property rather than nictype, so that the network's
// inherited properties are loaded into the NIC when started.
device = map[string]string{
"type": "nic",
"network": network.Name,
}
} else {
// If network is unmanaged default to using a macvlan connected to the specified interface.
device = map[string]string{
"type": "nic",
"nictype": "macvlan",
"parent": resource.name,
}

if network.Type == "bridge" {
device["nictype"] = "bridged"
if network.Type == "bridge" {
// If the network type is an unmanaged bridge, use bridged NIC type.
device["nictype"] = "bridged"
}
}

if len(args) > 3 {
Expand Down

0 comments on commit 96dea80

Please sign in to comment.