fix some issues
This commit is contained in:
17
cmd/cmd.go
17
cmd/cmd.go
@@ -30,23 +30,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewCommand() *cobra.Command {
|
func NewCommand() *cobra.Command {
|
||||||
var cli *client.Client
|
var cli client.Client
|
||||||
var host string = "tcp://127.0.0.1:23457"
|
var host string = "tcp://127.0.0.1:23457"
|
||||||
var cmd = &cobra.Command{
|
var cmd = &cobra.Command{
|
||||||
Use: "gotgt",
|
Use: "gotgt",
|
||||||
Short: "Gotgt is a very fast and stable SCSI target framework",
|
Short: "Gotgt is a very fast and stable SCSI target framework",
|
||||||
Long: ``,
|
Long: ``,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
httpClient, err := newHTTPClient(host)
|
httpClient, err := newHTTPClient(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%v", err)
|
fmt.Fprintf(os.Stderr, "%v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cli, err = client.NewClient(host, version.Version, httpClient, nil)
|
if _cli, err := client.NewClient(host, version.Version, httpClient, nil); err != nil {
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "%v", err)
|
fmt.Fprintf(os.Stderr, "%v", err)
|
||||||
return err
|
return err
|
||||||
|
} else {
|
||||||
|
cli = *_cli
|
||||||
}
|
}
|
||||||
// Do Stuff Here
|
// Do Stuff Here
|
||||||
return nil
|
return nil
|
||||||
@@ -56,10 +57,10 @@ func NewCommand() *cobra.Command {
|
|||||||
cmd.PersistentFlags().StringVar(&host, "host", host, "Endpoint for SCSI target daemon")
|
cmd.PersistentFlags().StringVar(&host, "host", host, "Endpoint for SCSI target daemon")
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
newDaemonCommand(),
|
newDaemonCommand(),
|
||||||
newCreateCommand(cli),
|
newCreateCommand(&cli),
|
||||||
newRemoveCommand(cli),
|
newRemoveCommand(&cli),
|
||||||
newListCommand(cli),
|
newListCommand(&cli),
|
||||||
newVersionCommand(cli),
|
newVersionCommand(&cli),
|
||||||
)
|
)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,29 @@
|
|||||||
{
|
{
|
||||||
"storages":[
|
"storages": [
|
||||||
{
|
{
|
||||||
"deviceID":1000,
|
"deviceID": 1000,
|
||||||
"path":"file:/var/tmp/disk.img",
|
"path": "file:/var/tmp/disk.img",
|
||||||
"online":true,
|
"online": true,
|
||||||
"thinProvisioning":false,
|
"thinProvisioning": false,
|
||||||
"blockShift": 9,
|
"blockShift": 9
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"iscsiportals":[
|
"iscsiportals": [
|
||||||
{
|
{
|
||||||
"id":0,
|
"id": 0,
|
||||||
"portal":"127.0.0.1:3260"
|
"portal": "127.0.0.1:3260"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"iscsitargets":{
|
"iscsitargets": {
|
||||||
"iqn.2016-09.com.gotgt.gostor:02:example-tgt-0":{
|
"iqn.2016-09.com.gotgt.gostor:02:example-tgt-0": {
|
||||||
"tpgts":{
|
"tpgts": {
|
||||||
"1":[0]
|
"1": [
|
||||||
|
0
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"luns":{
|
"luns": {
|
||||||
"0":1000
|
"0": 1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
|
|||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import (
|
|||||||
|
|
||||||
// versionMatcher defines a variable matcher to be parsed by the router
|
// versionMatcher defines a variable matcher to be parsed by the router
|
||||||
// when a request is about to be served.
|
// when a request is about to be served.
|
||||||
const versionMatcher = "/v{version:[0-9.]+}"
|
const versionMatcher = "/v{version:[0-9.]+(?:-dirty)}"
|
||||||
|
|
||||||
// Config provides the configuration for the API server
|
// Config provides the configuration for the API server
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var (
|
||||||
// Version shows the version of gotgt.
|
// Version shows the version of gotgt.
|
||||||
Version = "Not provided."
|
Version = "Not provided."
|
||||||
// SCSIVersion string MUST be shorter than 4 characters
|
// SCSIVersion string MUST be shorter than 4 characters
|
||||||
|
|||||||
Reference in New Issue
Block a user