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 {
|
if i == 0 {
|
||||||
fmt.Printf("|")
|
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++ {
|
for i := len(f.Value)+1 ; i < f.MaxLen+1 ; i++ {
|
||||||
fmt.Printf(" ")
|
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 */
|
/* Get Jails from datastores. Store config and running metadata into gJails global var */
|
||||||
func listJails(args []string, display bool) {
|
func ListJails(args []string, display bool) {
|
||||||
fields := []string{"JID", "Name", "Config.Release", "Config.Ip4_addr", "RootPath", "Running", "Config.Jail_zfs", "Config.Jail_zfs_dataset"}
|
//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") {
|
for _, d := range viper.GetStringSlice("datastore") {
|
||||||
listJailsFromDatastore(d)
|
listJailsFromDatastore(d)
|
||||||
@ -250,9 +259,18 @@ func listJailsFromDirectory(dir string) ([]Jail) {
|
|||||||
j.JID = rj.Jid
|
j.JID = rj.Jid
|
||||||
j.Running = true
|
j.Running = true
|
||||||
j.InternalName = rj.Name
|
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)
|
gJails = append(gJails, j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ type Jail struct {
|
|||||||
Running bool
|
Running bool
|
||||||
// No need, Config.Release always represent what is running (plus it know release for non-running jails)
|
// No need, Config.Release always represent what is running (plus it know release for non-running jails)
|
||||||
//Release string
|
//Release string
|
||||||
|
Zpool string
|
||||||
}
|
}
|
||||||
|
|
||||||
// iocage struct as stored in config.json
|
// iocage struct as stored in config.json
|
||||||
|
Loading…
Reference in New Issue
Block a user