forked from terra-farm/go-virtualbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
25 lines (22 loc) · 773 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package virtualbox
import (
"context"
"net"
)
// ParseIPv4Mask parses IPv4 netmask written in IP form (e.g. 255.255.255.0).
// This function should really belong to the net package.
func ParseIPv4Mask(s string) net.IPMask {
mask := net.ParseIP(s)
if mask == nil {
return nil
}
return net.IPv4Mask(mask[12], mask[13], mask[14], mask[15])
}
// Run is a helper method used to execute the commands using the configured
// VBoxManage path. The command should be omitted and only the arguments
// should be passed. It will return the stdout, stderr and error if one
// occured during command execution.
func Run(_ context.Context, args ...string) (string, string, error) {
// TODO: Convert the function so you can pass in the context.
return Manage().run(args...)
}