Create and delete snapshot OK + version bump to 0.25
This commit is contained in:
41
cmd/root.go
41
cmd/root.go
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
gVersion = "0.24"
|
||||
gVersion = "0.25"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -30,7 +30,7 @@ var (
|
||||
gHostVersion float64
|
||||
|
||||
gTimeZone string
|
||||
|
||||
gSnapshotName string
|
||||
|
||||
rootCmd = & cobra.Command {
|
||||
Use: "gocage",
|
||||
@ -144,7 +144,30 @@ You can specify multiple jails.`,
|
||||
// Load inventory
|
||||
ListJails(args, false)
|
||||
ListJailsSnapshots(args)
|
||||
cleanAfterRun()
|
||||
},
|
||||
}
|
||||
|
||||
snapshotCreateCmd = &cobra.Command {
|
||||
Use: "create",
|
||||
Short: "create snapshots",
|
||||
Long: `Create snapshot of a jail by specifying snapshot name and jail name.`,
|
||||
// You can specify multiple jails.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Load inventory
|
||||
ListJails(args, false)
|
||||
CreateJailSnapshot(args)
|
||||
},
|
||||
}
|
||||
|
||||
snapshotDeleteCmd = &cobra.Command {
|
||||
Use: "destroy",
|
||||
Short: "destroy snapshots",
|
||||
Long: `Destroy snapshot of a jail by specifying snapshot name and jail name.`,
|
||||
// You can specify multiple jails.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Load inventory
|
||||
ListJails(args, false)
|
||||
DeleteJailSnapshot(args)
|
||||
},
|
||||
}
|
||||
)
|
||||
@ -160,10 +183,18 @@ func init() {
|
||||
rootCmd.PersistentFlags().StringVarP(&gTimeZone, "timezone", "t", "", "Specify timezone. Will get from /var/db/zoneinfo if not set.")
|
||||
|
||||
// Command dependant switches
|
||||
|
||||
// These are persistent so we can reuse them in "gocage list snapshot myjail" command (TODO)
|
||||
listCmd.PersistentFlags().StringVarP(&gDisplayColumns, "outcol", "o", "JID,Name,Config.Release,Config.Ip4_addr,Running", "Show these columns in output")
|
||||
listCmd.PersistentFlags().BoolVarP(&gNoLineSep, "nolinesep", "l", false, "Do not display line separator between jails")
|
||||
listCmd.PersistentFlags().StringVarP(&gFilterJails, "filter", "f", "none", "Only display jails with these values. Ex: \"gocage list -f Config.Boot=1\" will only list started on boot jails")
|
||||
listCmd.PersistentFlags().StringVarP(&gSortFields, "sort", "s", "none", "Display jails sorted by field values. Ex: \"gocage list -s +Name,-Config.Priority\" will sort jails by their decreasing name, then increasing start priority. 3 critera max supported.")
|
||||
|
||||
// This is local flag : Only available to gocage snapshot create command
|
||||
snapshotCreateCmd.Flags().StringVarP(&gSnapshotName, "snapname", "n", "", "Name of the snapshot to create")
|
||||
snapshotCreateCmd.MarkFlagRequired("snapname")
|
||||
snapshotDeleteCmd.Flags().StringVarP(&gSnapshotName, "snapname", "n", "", "Name of the snapshot to destroy")
|
||||
snapshotDeleteCmd.MarkFlagRequired("snapname")
|
||||
|
||||
// Now declare commands
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
@ -175,7 +206,9 @@ func init() {
|
||||
rootCmd.AddCommand(setCmd)
|
||||
rootCmd.AddCommand(snapshotCmd)
|
||||
snapshotCmd.AddCommand(snapshotListCmd)
|
||||
|
||||
snapshotCmd.AddCommand(snapshotCreateCmd)
|
||||
snapshotCmd.AddCommand(snapshotDeleteCmd)
|
||||
|
||||
// Get FreeBSD version
|
||||
out, err := executeCommand("freebsd-version")
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user