Cosmetic rearrangement
This commit is contained in:
parent
29ce0d9b58
commit
1462c383d3
66
cmd/utils.go
66
cmd/utils.go
@ -435,29 +435,11 @@ func getJailFromArray(name string, jarray []Jail) (*Jail, error) {
|
|||||||
return &Jail{}, errors.New("Jail not found")
|
return &Jail{}, errors.New("Jail not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* Generic utilities
|
* devfs rules management
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
func isStringInArray(strarr []string, searched string) bool {
|
|
||||||
for _, s := range strarr {
|
|
||||||
if strings.EqualFold(s, searched) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func getDatastoreFromArray(name string, dsa []Datastore) (*Datastore, error) {
|
|
||||||
for _, d := range dsa {
|
|
||||||
if name == d.Name {
|
|
||||||
return &d, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &Datastore{}, errors.New("Datastore not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
func getDevfsRuleset(ruleset int) []string {
|
func getDevfsRuleset(ruleset int) []string {
|
||||||
cmd := fmt.Sprintf("/sbin/devfs rule -s %d show", ruleset)
|
cmd := fmt.Sprintf("/sbin/devfs rule -s %d show", ruleset)
|
||||||
out, err := executeCommand(cmd)
|
out, err := executeCommand(cmd)
|
||||||
@ -511,6 +493,47 @@ func addDevfsRuleToRuleset(rule string, ruleset int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Generic utilities
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
func isStringInArray(strarr []string, searched string) bool {
|
||||||
|
for _, s := range strarr {
|
||||||
|
if strings.EqualFold(s, searched) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDatastoreFromArray(name string, dsa []Datastore) (*Datastore, error) {
|
||||||
|
for _, d := range dsa {
|
||||||
|
if name == d.Name {
|
||||||
|
return &d, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &Datastore{}, errors.New("Datastore not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Flag a jail so config on disk will be updated when calling WriteConfigToDisk
|
||||||
|
*****************************************************************************/
|
||||||
|
func setJailConfigUpdated(jail *Jail) error {
|
||||||
|
if len(jail.ConfigPath) == 0 {
|
||||||
|
return errors.New(fmt.Sprintf("No config path for jail %s", jail.Name))
|
||||||
|
}
|
||||||
|
|
||||||
|
j, err := getJailFromArray(jail.Name, gJails)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
j.ConfigUpdated = true
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Return the quantity of jails with the name passed as parameter
|
* Return the quantity of jails with the name passed as parameter
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -1419,7 +1442,6 @@ func displayDatastoresFields(datastores []Datastore, valsToDisplay []string) {
|
|||||||
* Sorting jails
|
* Sorting jails
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
// This struct hold "sort by jail fields" functions
|
// This struct hold "sort by jail fields" functions
|
||||||
type jailLessFunc func(j1 *Jail, j2 *Jail) bool
|
type jailLessFunc func(j1 *Jail, j2 *Jail) bool
|
||||||
|
|
||||||
@ -2360,7 +2382,6 @@ func (js *jailSorter) Less(i, j int) bool {
|
|||||||
* Sorting snapshots
|
* Sorting snapshots
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
// This struct hold "sort by jail fields" functions
|
// This struct hold "sort by jail fields" functions
|
||||||
type snapshotLessFunc func(s1 *Snapshot, s2 *Snapshot) bool
|
type snapshotLessFunc func(s1 *Snapshot, s2 *Snapshot) bool
|
||||||
|
|
||||||
@ -2474,7 +2495,6 @@ func (ss *snapshotSorter) Less(i, j int) bool {
|
|||||||
* Sorting datastores
|
* Sorting datastores
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
// This struct hold "sort by datastores fields" functions
|
// This struct hold "sort by datastores fields" functions
|
||||||
type datastoreLessFunc func(s1 *Datastore, s2 *Datastore) bool
|
type datastoreLessFunc func(s1 *Datastore, s2 *Datastore) bool
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user