Get zpool, dont display JID if jail is off
This commit is contained in:
parent
d8c78cfd34
commit
f90de63f87
24
cmd/list.go
24
cmd/list.go
@ -163,7 +163,15 @@ func displayStructFields(jails []Jail, valsToDisplay []string) {
|
||||
if i == 0 {
|
||||
fmt.Printf("|")
|
||||
}
|
||||
fmt.Printf(" %s", f.Value)
|
||||
// Special cases of value displaying
|
||||
if f.Name == "JID" && f.Value == "0" {
|
||||
fmt.Printf(" ")
|
||||
/* } else if f.Name == "Ip4_addr" {
|
||||
fmt.Printf(" %s", strings.Split(strings.Split(f.Value, "|")[1], "/")[0])
|
||||
*/
|
||||
} else {
|
||||
fmt.Printf(" %s", f.Value)
|
||||
}
|
||||
for i := len(f.Value)+1 ; i < f.MaxLen+1 ; i++ {
|
||||
fmt.Printf(" ")
|
||||
}
|
||||
@ -179,8 +187,9 @@ func displayStructFields(jails []Jail, valsToDisplay []string) {
|
||||
|
||||
|
||||
/* Get Jails from datastores. Store config and running metadata into gJails global var */
|
||||
func listJails(args []string, display bool) {
|
||||
fields := []string{"JID", "Name", "Config.Release", "Config.Ip4_addr", "RootPath", "Running", "Config.Jail_zfs", "Config.Jail_zfs_dataset"}
|
||||
func ListJails(args []string, display bool) {
|
||||
//fields := []string{"JID", "Name", "Config.Release", "Config.Ip4_addr", "RootPath", "Running", "Config.Jail_zfs", "Config.Jail_zfs_dataset", "Zpool"}
|
||||
fields := []string{"JID", "Name", "Config.Release", "Config.Ip4_addr", "Running", "Zpool"}
|
||||
|
||||
for _, d := range viper.GetStringSlice("datastore") {
|
||||
listJailsFromDatastore(d)
|
||||
@ -250,8 +259,17 @@ func listJailsFromDirectory(dir string) ([]Jail) {
|
||||
j.JID = rj.Jid
|
||||
j.Running = true
|
||||
j.InternalName = rj.Name
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/* This op take some 600ms for ~40 jails :^( */
|
||||
out, err := executeCommand(fmt.Sprintf("zfs list -H -o name %s", j.RootPath))
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR getting dataset from %s: %s\n", j.RootPath, err.Error())
|
||||
} else {
|
||||
j.Zpool = strings.Split(strings.TrimSuffix(out, "\n"), "/")[0]
|
||||
}
|
||||
|
||||
gJails = append(gJails, j)
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ type Jail struct {
|
||||
Running bool
|
||||
// No need, Config.Release always represent what is running (plus it know release for non-running jails)
|
||||
//Release string
|
||||
Zpool string
|
||||
}
|
||||
|
||||
// iocage struct as stored in config.json
|
||||
|
Loading…
Reference in New Issue
Block a user