// serviced snapshot remove [SNAPSHOTID | SERVICED TAG-NAME]
422999
func (c *ServicedCli) cmdSnapshotRemove(ctx *cli.Context) {

	args := ctx.Args()
	force := ctx.Bool("force")

	snapshotsToDelete := []string{}

	if len(args) > 2 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "remove")
		return
	}

	if len(args) == 0 {
		// user wants to delete all snapshots, but check for -f first
		if !force {
			fmt.Printf("Incorrect Usage.\nUse\n   serviced snapshot remove -f\nto delete all snapshots, or\n   serviced snapshot remove -h\nfor help with this command.\n")
			return
		} else {
			//delete all snapshots
			snapshots, err := c.driver.GetSnapshots()
			if err != nil {
				fmt.Fprintln(os.Stderr, err)
				return
			}
			for _, snapshot := range snapshots {
				snapshotsToDelete = append(snapshotsToDelete, snapshot.SnapshotID)
			}
		}
	} else if len(args) == 1 {
		//Delete the snapshot specified in the argument
		snapshotsToDelete = []string{args[0]}
	} else {
		//Find the snapshot with the given tag and service
		if snapshot, err := c.driver.GetSnapshotByServiceIDAndTag(args[0], args[1]); err != nil {
			fmt.Fprintln(os.Stderr, err)
			return
		} else if snapshot != "" {
			snapshotsToDelete = []string{snapshot}
		}
	}

	if len(snapshotsToDelete) == 0 {
		fmt.Println("No matching snapshots found.")
		return
	}

	//Delete the chosen snapshots
	for _, id := range snapshotsToDelete {
		if err := c.driver.RemoveSnapshot(id); err != nil {
			fmt.Fprintln(os.Stderr, err)
		} else {
			fmt.Println(id)
		}
	}
}
707444
func (a *api) TagSnapshot(snapshotID string, tagName string) error {
	client, err := a.connectDAO()
	if err != nil {
		return err
	}
	if err := client.TagSnapshot(dao.TagSnapshotRequest{snapshotID, tagName}, &unusedInt); err != nil {
		return err
	}
	return nil
}
67168
func (p *AuroraAdminClient) Snapshot(ctx context.Context) (r *Response, err error) {
  var _args344 AuroraAdminSnapshotArgs
  var _result345 AuroraAdminSnapshotResult
  if err = p.Client_().Call(ctx, "snapshot", &_args344, &_result345); err != nil {
    return
  }
  return _result345.GetSuccess(), nil
}
912508
func (c *ServicedCli) serviceActions(id string) (data []string) {
	svc, err := c.driver.GetService(id)
	if err != nil || svc == nil {
		c.exit(1)
		return
	}

	data = make([]string, len(svc.Actions))
	i := 0
	for a := range svc.Actions {
		data[i] = a
		i++
	}

	return
}
761028
func (db *TransactionDB) ReleaseSnapshot(snapshot *Snapshot) {
	C.rocksdb_transactiondb_release_snapshot(db.c, snapshot.c)
	snapshot.c = nil
}
453762
func (c *ServicedCli) initService() {

	c.app.Commands = append(c.app.Commands, cli.Command{
		Name:        "service",
		Usage:       "Administers services",
		Description: "",
		Subcommands: []cli.Command{
			{
				Name:         "list",
				Usage:        "Lists all services",
				Description:  "serviced service list [SERVICEID]",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceList,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "verbose, v",
						Usage: "Show JSON format",
					},
					cli.BoolFlag{
						Name:  "ascii, a",
						Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
					},
					cli.StringFlag{
						Name:  "format",
						Value: "",
						Usage: "format the output using the given go template",
					},
					cli.StringFlag{
						Name:  "show-fields",
						Value: "Name,ServiceID,Inst,ImageID,Pool,DState,Launch,DepID",
						Usage: "Comma-delimited list describing which fields to display",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:        "status",
				Usage:       "Displays the status of deployed services",
				Description: "serviced service status { SERVICEID | SERVICENAME | [POOL/]...PARENTNAME.../SERVICENAME }",
				Action:      c.cmdServiceStatus,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "ascii, a",
						Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
					},
					cli.StringFlag{
						Name:  "show-fields",
						Value: "Name,ServiceID,Status,HC Fail,Healthcheck,Healthcheck Status,Uptime,RAM,Cur/Max/Avg,Hostname,InSync,DockerID",
						Usage: "Comma-delimited list describing which fields to display",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:        "add",
				Usage:       "Adds a new service",
				Description: "serviced service add NAME IMAGEID COMMAND",
				Action:      c.cmdServiceAdd,
				Flags: []cli.Flag{
					cli.GenericFlag{
						Name:  "p",
						Value: &api.PortMap{},
						Usage: "Expose a port for this service (e.g. -p tcp:3306:mysql)",
					},
					cli.GenericFlag{
						Name:  "q",
						Value: &api.PortMap{},
						Usage: "Map a remote service port (e.g. -q tcp:3306:mysql)",
					},
					cli.StringFlag{
						Name:  "parent-id",
						Value: "",
						Usage: "Parent service ID for which this service relates",
					},
				},
			}, {
				Name:        "clone",
				Usage:       "Clones a new service",
				Description: "serviced service clone { SERVICEID | SERVICENAME | [DEPLOYMENTID/]...PARENTNAME.../SERVICENAME }",
				Action:      c.cmdServiceClone,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "suffix",
						Value: "",
						Usage: "name to append to service name, volumes, endpoints",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "remove",
				ShortName:    "rm",
				Usage:        "Removes an existing service",
				Description:  "serviced service remove SERVICEID",
				BashComplete: c.printServicesAll,
				Action:       c.cmdServiceRemove,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "edit",
				Usage:        "Edits an existing service in a text editor",
				Description:  "serviced service edit SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceEdit,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "editor, e",
						Value: os.Getenv("EDITOR"),
						Usage: "Editor used to update the service definition",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "assign-ip",
				Usage:        "Assigns an IP address to a service's endpoints requiring an explicit IP address",
				Description:  "serviced service assign-ip SERVICEID [IPADDRESS]",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceAssignIP,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "start",
				Usage:        "Starts one or more services",
				Description:  "serviced service start SERVICEID ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceStart,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "restart",
				Usage:        "Restarts one or more services",
				Description:  "serviced service restart { SERVICEID | INSTANCEID } ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceRestart,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "rebalance",
						Usage: "Stops all instances before restarting them, instead of performing a rolling restart",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "stop",
				Usage:        "Stops one or more services",
				Description:  "serviced service stop SERVICEID ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceStop,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "pause",
				Usage:        "Pauses one or more services",
				Description:  "serviced service pause SERVICEID ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServicePause,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "shell",
				Usage:        "Starts a service instance",
				Description:  "serviced service shell SERVICEID [COMMAND]",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceShell,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "saveas, s",
						Value: "",
						Usage: "saves the service instance with the given name",
					},
					cli.BoolFlag{
						Name:  "interactive, i",
						Usage: "runs the service instance as a tty",
					},
					cli.StringSliceFlag{
						Name:  "mount",
						Value: &cli.StringSlice{},
						Usage: "bind mount: HOST_PATH[,CONTAINER_PATH]",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "run",
				Usage:        "Runs a service command in a service instance",
				Description:  "serviced service run SERVICEID COMMAND [ARGS]",
				BashComplete: c.printServiceRun,
				Before:       c.cmdServiceRun,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "interactive, i",
						Usage: "runs the service instance as a tty",
					},
					cli.BoolFlag{
						Name:  "logtostderr",
						Usage: "enable/disable detailed serviced run logging (false by default)",
					},
					cli.BoolTFlag{
						Name:  "logstash",
						Usage: "enable/disable log stash (true by default)",
					},
					cli.StringFlag{
						Name:  "logstash-settle-time",
						Value: "5s",
						Usage: "time duration to wait for logstash to flush log messages before closing",
					},
					cli.StringSliceFlag{
						Name:  "mount",
						Value: &cli.StringSlice{},
						Usage: "bind mount: HOST_PATH[,CONTAINER_PATH]",
					},
					cli.StringFlag{
						Name:  "user",
						Value: "",
						Usage: "container username used to run command",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "attach",
				Usage:        "Run an arbitrary command in a running service container",
				Description:  "serviced service attach { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME/INSTANCE } [COMMAND]",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceAttach,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "action",
				Usage:        "Run a predefined action in a running service container",
				Description:  "serviced service action { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME/INSTANCE } ACTION",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceAction,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "logs",
				Usage:        "Output the logs of a running service container - calls docker logs",
				Description:  "serviced service logs { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME/INSTANCE }",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceLogs,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "list-snapshots",
				Usage:        "Lists the snapshots for a service",
				Description:  "serviced service list-snapshots SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceListSnapshots,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "show-tags, t",
						Usage: "shows the tags associated with each snapshot",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "snapshot",
				Usage:        "Takes a snapshot of the service",
				Description:  "serviced service snapshot SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceSnapshot,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "description, d",
						Value: "",
						Usage: "a description of the snapshot",
					},
					cli.StringFlag{
						Name:  "tag, t",
						Value: "",
						Usage: "a unique tag for the snapshot",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "endpoints",
				Usage:        "List the endpoints defined for the service",
				Description:  "serviced service endpoints SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceEndpoints,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "imports, i",
						Usage: "include only imported endpoints",
					},
					cli.BoolFlag{
						Name:  "all, a",
						Usage: "include all endpoints (imports and exports)",
					},
					cli.BoolFlag{
						Name:  "verify, v",
						Usage: "verify endpoints",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:        "public-endpoints",
				Usage:       "Manage public endpoints for a service",
				Description: "serviced service public-endpoints",
				Subcommands: []cli.Command{
					{
						Name:        "list",
						Usage:       "Lists public endpoints for a service",
						Description: "serviced service public-endpoints list [SERVICEID] [ENDPOINTNAME]",
						Action:      c.cmdPublicEndpointsListAll,
						Flags: []cli.Flag{
							cli.BoolFlag{
								Name:  "ascii, a",
								Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
							},
							cli.BoolFlag{
								Name:  "ports",
								Usage: "Show port public endpoints",
							},
							cli.BoolFlag{
								Name:  "vhosts",
								Usage: "Show vhost public endpoints",
							},
							cli.StringFlag{
								Name:  "show-fields",
								Value: "Service,ServiceID,Endpoint,Type,Protocol,Name,Enabled",
								Usage: "Comma-delimited list describing which fields to display",
							},
							cli.BoolFlag{
								Name:  "verbose, v",
								Usage: "Show JSON format",
							},
							cli.BoolFlag{
								Name:  "no-prefix-match, np",
								Usage: "Make SERVICEID matches on name strict 'ends with' matches",
							},
						},
					},
					{
						Name:        "port",
						Usage:       "Manages port public endpoints for a service",
						Description: "serviced service public-endpoints port",
						Subcommands: []cli.Command{
							{
								Name:        "list",
								Usage:       "List port public endpoints for a service",
								Description: "serviced service public-endpoints port list [SERVICEID] [ENDPOINTNAME]",
								Action:      c.cmdPublicEndpointsPortList,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "ascii, a",
										Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
									},
									cli.StringFlag{
										Name:  "show-fields",
										Value: "Service,ServiceID,Endpoint,Type,Protocol,Name,Enabled",
										Usage: "Comma-delimited list describing which fields to display",
									},
									cli.BoolFlag{
										Name:  "verbose, v",
										Usage: "Show JSON format",
									},
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "add",
								Usage:       "Add a port public endpoint to a service",
								Description: "serviced service public-endpoints port add <SERVICEID> <ENDPOINTNAME> <PORTADDR> <PROTOCOL> <ENABLED>",
								Action:      c.cmdPublicEndpointsPortAdd,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "restart, r",
										Usage: "Restart the service after adding the port if the service is currently running",
									},
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "remove",
								ShortName:   "rm",
								Usage:       "Remove a port public endpoint from a service",
								Description: "serviced service public-endpoints port remove <SERVICEID> <ENDPOINTNAME> <PORTADDR>",
								Action:      c.cmdPublicEndpointsPortRemove,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "enable",
								Usage:       "Enable/Disable a port public endpoint for a service",
								Description: "serviced service public-endpoints port enable <SERVICEID> <ENDPOINTNAME> <PORTADDR> true|false",
								Action:      c.cmdPublicEndpointsPortEnable,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
						},
					},
					{
						Name:        "vhost",
						Usage:       "Manages vhost public endpoints for a service",
						Description: "serviced service public-endpoints vhost",
						Subcommands: []cli.Command{
							{
								Name:        "list",
								Usage:       "List vhost public endpoints for a service",
								Description: "serviced service public-endpoints vhost list [SERVICEID] [ENDPOINTNAME]",
								Action:      c.cmdPublicEndpointsVHostList,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "ascii, a",
										Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
									},
									cli.StringFlag{
										Name:  "show-fields",
										Value: "Service,ServiceID,Endpoint,Type,Protocol,Name,Enabled",
										Usage: "Comma-delimited list describing which fields to display",
									},
									cli.BoolFlag{
										Name:  "verbose, v",
										Usage: "Show JSON format",
									},
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "add",
								Usage:       "Add a vhost public endpoint to a service",
								Description: "serviced service public-endpoints vhost add <SERVICEID> <ENDPOINTNAME> <VHOST> <ENABLED>",
								Action:      c.cmdPublicEndpointsVHostAdd,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "remove",
								ShortName:   "rm",
								Usage:       "Remove a vhost public endpoint from a service",
								Description: "serviced service public-endpoints vhost remove <SERVICEID> <ENDPOINTNAME> <VHOST>",
								Action:      c.cmdPublicEndpointsVHostRemove,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "enable",
								Usage:       "Enable/Disable a vhost public endpoint for a service",
								Description: "serviced service public-endpoints vhost enable <SERVICEID> <ENDPOINTNAME> <VHOST> true|false",
								Action:      c.cmdPublicEndpointsVHostEnable,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
						},
					},
				},
			},
			{
				Name:         "clear-emergency",
				Usage:        "Clears the 'emergency shutdown' state for a service and all child services",
				Description:  "serviced service clear-emergency { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME }",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceClearEmergency,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:         "remove-ip",
				Usage:        "Remove the IP assignment of a service's endpoints",
				Description:  "serviced service remove-ip <SERVICEID> <ENDPOINTNAME>",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceRemoveIP,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:         "set-ip",
				Usage:        "Setting an IP address to a service's endpoints requiring an explicit IP address. If ip is not provided it does an automatic assignment",
				Description:  "serviced service set-ip <SERVICEID> <ENDPOINTNAME> [ADDRESS] [--port=PORT] [--proto=PROTOCOL]",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceSetIP,
				Flags: []cli.Flag{
					cli.IntFlag{
						Name:  "port",
						Usage: "determine the port your service will use",
					},
					cli.StringFlag{
						Name:  "proto",
						Usage: "determine the port protocol your service will use",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:        "tune",
				Usage:       "Adjust instance count, RAM commitment, or RAM threshold for a service",
				Description: "serviced service tune SERVICEID",
				Action:      c.cmdServiceTune,
				Flags: []cli.Flag{
					cli.IntFlag{
						Name:  "instances",
						Usage: "Instance count for this service",
					},
					cli.StringFlag{
						Name:  "ramCommitment",
						Usage: "RAM Commitment for this service",
					},
					cli.StringFlag{
						Name:  "ramThreshold",
						Usage: "RAM Threshold for this service",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:        "config",
				Usage:       "Manage config files for services",
				Description: "serviced service config",
				Subcommands: []cli.Command{
					{
						Name:        "list",
						Usage:       "List all config files for a given service, or the contents of one named file",
						Description: "serviced service config list SERVICEID [FILENAME]",
						Action:      c.cmdServiceConfigList,
						Flags: []cli.Flag{
							cli.BoolFlag{
								Name:  "no-prefix-match, np",
								Usage: "Make SERVICEID matches on name strict 'ends with' matches",
							},
						},
					},
					{
						Name:        "edit",
						Usage:       "Edit one config file for a given service",
						Description: "serviced service config edit SERVICEID FILENAME",
						Action:      c.cmdServiceConfigEdit,
						Flags: []cli.Flag{
							cli.StringFlag{
								Name:  "editor, e",
								Value: os.Getenv("EDITOR"),
								Usage: "Editor used to update the config file",
							},
							cli.BoolFlag{
								Name:  "no-prefix-match, np",
								Usage: "Make SERVICEID matches on name strict 'ends with' matches",
							},
						},
					},
				},
			},
			{
				Name:        "variable",
				Usage:       "Manage service config variables",
				Description: "serviced service variable",
				Subcommands: []cli.Command{
					{
						Name:        "list",
						Usage:       "List one or all config variables and their values for a given service",
						Description: "serviced service variable list SERVICEID",
						Action:      c.cmdServiceVariableList,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
					{
						Name:        "get",
						Usage:       "Find the value of a config variable for a service",
						Description: "serviced service variable get SERVICEID VARIABLE",
						Action:      c.cmdServiceVariableGet,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
					{
						Name:        "set",
						Usage:       "Add or update one variable's value for a given service",
						Description: "serviced service variable set SERVICEID VARIABLE VALUE",
						Action:      c.cmdServiceVariableSet,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
					{
						Name:        "unset",
						Usage:       "Remove a variable from a given service",
						Description: "serviced service variable unset SERVICEID VARIABLE",
						Action:      c.cmdServiceVariableUnset,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
				},
			},
		},
	})
}
1110692
func (c *ServicedCli) cmdSnapshotRollback(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 1 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "rollback")
		return
	}

	if err := c.driver.Rollback(args[0], ctx.Bool("force-restart")); err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
	} else {
		fmt.Println(args[0])
	}
}
282650
func (s *SnapshotCreateService) Snapshot(snapshot string) *SnapshotCreateService {
	s.snapshot = snapshot
	return s
}
618878
func (c *ServicedCli) printSnapshotsAll(ctx *cli.Context) {
	args := ctx.Args()

	for _, s := range c.snapshots("") {
		for _, a := range args {
			if s.SnapshotID == a {
				goto next
			}
			fmt.Println(s)
		next:
		}
	}
}
743962
func (c *ServicedCli) cmdPoolRemove(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 1 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "remove")
	}

	for _, id := range args {
		if p, err := c.driver.GetResourcePool(id); err != nil {
			fmt.Fprintf(os.Stderr, "%s: %s\n", id, err)
		} else if p == nil {
			fmt.Fprintf(os.Stderr, "%s: pool not found", id)
		} else if err := c.driver.RemoveResourcePool(id); err != nil {
			fmt.Fprintf(os.Stderr, "%s: %s\n", id, err)
		} else {
			fmt.Println(id)
		}
	}
}
1038896
func (c *Client) RestoreSnapshot(id, snapshotID string) error {
	values := url.Values{
		"SUBID":      {id},
		"SNAPSHOTID": {snapshotID},
	}

	if err := c.post(`server/restore_snapshot`, values, nil); err != nil {
		return err
	}
	return nil
}
224039
func (c *ServicedCli) cmdSnapshotRemoveTag(ctx *cli.Context) {
	args := ctx.Args()

	var (
		snapshotID string
		err        error
	)

	if len(args) != 2 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "untag")
		return
	}

	//remove specified tag
	if snapshotID, err = c.driver.RemoveSnapshotTag(args[0], args[1]); err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	fmt.Printf("%s\n", snapshotID)
}
969769
func (c *ServicedCli) cmdRestore(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 1 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "restore")
		return
	}

	err := c.driver.Restore(args[0])
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
}
1073463
func (v *BtrfsVolume) Snapshot(label, message string, tags []string) error {
	// make sure the label doesn't already exist
	path := v.snapshotPath(label)
	if ok, err := volume.IsDir(path); err != nil {
		return err
	} else if ok {
		return volume.ErrSnapshotExists
	}
	// check the tags for duplicates
	for _, tagName := range tags {
		if tagInfo, err := v.GetSnapshotWithTag(tagName); err != volume.ErrSnapshotDoesNotExist {
			if err != nil {
				glog.Errorf("Could not look up snapshot with tag %s: %s", tagName, err)
				return err
			} else {
				glog.Errorf("Tag '%s' is already in use by snapshot %s", tagName, tagInfo.Name)
				return volume.ErrTagAlreadyExists
			}
		}
	}
	v.Lock()
	defer v.Unlock()
	info := volume.SnapshotInfo{
		Name:     v.rawSnapshotLabel(label),
		TenantID: v.Tenant(),
		Label:    v.prettySnapshotLabel(label),
		Tags:     tags,
		Message:  message,
		Created:  time.Now(),
	}
	if err := v.writeSnapshotInfo(label, &info); err != nil {
		return err
	}
	_, err := volume.RunBtrFSCmd(v.sudoer, "subvolume", "snapshot", "-r", v.Path(), path)
	return err
}
1231734
func (c *ServicedCli) initDocker() {
	c.app.Commands = append(c.app.Commands, cli.Command{
		Name:        "docker",
		Usage:       "Docker administration commands",
		Description: "",
		Subcommands: []cli.Command{
			{
				Name:        "sync",
				Usage:       "serviced docker sync",
				Description: "sync pushes all images to local registry - allows single host to easily be made master for multi-host",
				Action:      c.cmdRegistrySync,
			}, {
				Name:        "reset-registry",
				Usage:       "serviced docker reset-registry",
				Description: "Pulls images from the docker registry and updates the index",
				Action:      c.cmdResetRegistry,
			}, {
				Name:        "migrate-registry",
				Usage:       "serviced docker migrate-registry",
				Description: "Upgrades the docker registry from an older or remote registry",
				Action:      c.cmdMigrateRegistry,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "registry",
						Value: "",
						Usage: "host:port where the registry is running",
					},
					cli.BoolFlag{
						Name:  "override, f",
						Usage: "overrides all existing image records",
					},
				},
			}, {
				Name:        "override",
				Usage:       "Replace an image in the registry with a new image",
				Description: "serviced docker override OLDIMAGE NEWIMAGE",
				Action:      c.cmdDockerOverride,
			},
		},
	})
}
685637
func (c *ServicedCli) cmdServiceEdit(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 1 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "edit")
		c.exit(1)
		return
	}

	svcDetails, _, err := c.searchForService(args[0], ctx.Bool("no-prefix-match"))
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
		return
	}

	service, err := c.driver.GetService(svcDetails.ID)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
		return
	}

	jsonService, err := json.MarshalIndent(service, " ", "  ")
	if err != nil {
		fmt.Fprintf(os.Stderr, "error marshalling service: %s\n", err)
		c.exit(1)
		return
	}

	name := fmt.Sprintf("serviced_service_edit_%s", service.ID)
	reader, err := openEditor(jsonService, name, ctx.String("editor"))
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
		return
	}

	if service, err := c.driver.UpdateService(reader); err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
	} else if service == nil {
		fmt.Fprintln(os.Stderr, "received nil service")
		c.exit(1)
	} else {
		fmt.Println(service.ID)
	}
	return
}
203571
func (c *ServicedCli) initServer() {
	c.app.Commands = append(c.app.Commands, cli.Command{
		Name:        "server",
		Usage:       "Starts serviced",
		Description: "serviced server",
		Action:      c.cmdServer,
	})
}