Skip to content

Commit 1210d55

Browse files
author
Vipin Jain
committed
supply local host as defult
1 parent 0e50f4b commit 1210d55

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

netdcli/netdcli.go

+13
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type cliOpts struct {
121121
idStr string
122122
vlans string
123123
vxlans string
124+
homingHost string
124125
}
125126

126127
var opts cliOpts
@@ -174,6 +175,10 @@ func init() {
174175
"alloc-subnet-len",
175176
24,
176177
"Subnet length of auto allocated subnets from the subnet pool")
178+
flagSet.StringVar(&opts.homingHost,
179+
"host",
180+
"",
181+
"Host name/label on which an ep needs to be created. Default is the local host ")
177182
flagSet.StringVar(&opts.vxlans,
178183
"vxlans",
179184
"",
@@ -249,6 +254,13 @@ func validateOpts() error {
249254
opts.construct.Get() == CLI_CONSTRUCT_NW {
250255
}
251256

257+
if opts.homingHost == "" {
258+
opts.homingHost, err = os.Hostname()
259+
if err != nil {
260+
log.Fatalf("error obtaining the hostname, error %s \n", err)
261+
}
262+
}
263+
252264
// default gw and mask parsing
253265
if opts.subnetCidr == "" {
254266
opts.subnetLen = 0
@@ -349,6 +361,7 @@ func main() {
349361
epCfg.NetId = opts.netId
350362
epCfg.IpAddress = opts.ipAddr
351363
epCfg.ContName = opts.contName
364+
epCfg.HomingHost = opts.homingHost
352365
state = epCfg
353366
}
354367
case CLI_CONSTRUCT_NW:

0 commit comments

Comments
 (0)