Skip to content

Commit

Permalink
add flag to gotgt command
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <[email protected]>
  • Loading branch information
shubham14bajpai committed Jul 1, 2021
1 parent b278ab3 commit 1beca4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,24 @@ func newDaemonCommand(cli *client.Client) *cobra.Command {
var host string
var driver string
var logLevel string
var blockMultipleHosts bool
var cmd = &cobra.Command{
Use: "daemon",
Short: "Setup a daemon",
Long: `Setup the Gotgt's daemon`,
RunE: func(cmd *cobra.Command, args []string) error {
return createDaemon(host, driver, logLevel)
return createDaemon(host, driver, logLevel, blockMultipleHosts)
},
}
flags := cmd.Flags()
flags.StringVar(&logLevel, "log", "info", "Log level of SCSI target daemon")
flags.StringVar(&host, "host", "tcp://127.0.0.1:23457", "Host for SCSI target daemon")
flags.StringVar(&driver, "driver", "iscsi", "SCSI low level driver")
flags.BoolVar(&blockMultipleHosts, "block-multiple-hosts", false, "Disable login from multiple hosts")
return cmd
}

func createDaemon(host, driver, level string) error {
func createDaemon(host, driver, level string, blockMultipleHosts bool) error {
switch level {
case "info":
log.SetLevel(log.InfoLevel)
Expand Down Expand Up @@ -88,6 +90,10 @@ func createDaemon(host, driver, level string) error {
targetDriver.NewTarget(tgtname, config)
}

if blockMultipleHosts {
targetDriver.EnableBlockMultipleHostLogin()
}

// comment this to avoid concurrent issue
// runtime.GOMAXPROCS(runtime.NumCPU())
// run a service
Expand Down

0 comments on commit 1beca4d

Please sign in to comment.