You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This makes it possible to add DHCP hosts entries directly to a new
network. At least in an Ubuntu Focal server environment, this performs
much better than adding a network and then adding hosts entries.
Copy file name to clipboardexpand all lines: cmd/network_add.go
+43-9
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,29 @@
1
1
package cmd
2
2
3
3
import (
4
+
"fmt"
5
+
"net"
6
+
4
7
libvirtxml "github.com/libvirt/libvirt-go-xml"
5
8
log "github.com/sirupsen/logrus"
6
9
"github.com/spf13/cobra"
7
-
"net"
10
+
11
+
"github.com/LINBIT/virter/internal/virter"
8
12
)
9
13
10
14
funcnetworkAddCommand() *cobra.Command {
11
15
varforwardstring
12
16
vardhcpbool
17
+
vardhcpMACstring
18
+
vardhcpIDuint
19
+
vardhcpCountuint
13
20
varnetworkstring
14
21
vardomainstring
15
22
16
23
addCmd:=&cobra.Command{
17
24
Use: "add <name>",
18
25
Short: "Add a new network",
19
-
Long: `Add a new network. VMs can be attached to such a network in addition to the default network used by virter.`,
26
+
Long: `Add a new network. VMs can be attached to such a network in addition to the default network used by virter. DHCP entries can be added directly to the new network.`,
addCmd.Flags().StringVarP(&forward, "forward-mode", "m", "", "Set the forward mode, for example 'nat'")
83
84
addCmd.Flags().StringVarP(&network, "network-cidr", "n", "", "Configure the network range (IPv4) in CIDR notation. The IP will be assigned to the host device.")
84
85
addCmd.Flags().BoolVarP(&dhcp, "dhcp", "p", false, "Configure DHCP. Use together with '--network-cidr'. DHCP range is configured starting from --network-cidr+1 until the broadcast address")
86
+
addCmd.Flags().StringVarP(&dhcpMAC, "dhcp-mac", "", virter.QemuBaseMAC().String(), "Base MAC address to which ID is added. The default can be used to populate a virter access network")
87
+
addCmd.Flags().UintVarP(&dhcpID, "dhcp-id", "", 0, "ID which determines the MAC and IP addresses to associate")
88
+
addCmd.Flags().UintVar(&dhcpCount, "dhcp-count", 0, "Number of host entries to add")
85
89
addCmd.Flags().StringVarP(&domain, "domain", "d", "", "Configure DNS names for the network")
0 commit comments