~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/cmd/plugins/juju-restore/restore.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-03 09:22:46 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20140203092246-e03vg402vztzo4qa
Tags: 1.17.2-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        "os/signal"
13
13
        "text/template"
14
14
 
 
15
        "github.com/loggo/loggo"
15
16
        "launchpad.net/gnuflag"
16
 
        "launchpad.net/loggo"
17
17
 
18
18
        "launchpad.net/juju-core/cmd"
19
19
        "launchpad.net/juju-core/constraints"
56
56
 
57
57
type restoreCommand struct {
58
58
        cmd.EnvCommandBase
59
 
        Log         cmd.Log
60
 
        Constraints constraints.Value
61
 
        backupFile  string
 
59
        Log             cmd.Log
 
60
        Constraints     constraints.Value
 
61
        backupFile      string
 
62
        showDescription bool
62
63
}
63
64
 
64
65
func (c *restoreCommand) Info() *cmd.Info {
73
74
func (c *restoreCommand) SetFlags(f *gnuflag.FlagSet) {
74
75
        c.EnvCommandBase.SetFlags(f)
75
76
        f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set environment constraints")
 
77
        f.BoolVar(&c.showDescription, "description", false, "show the purpose of this plugin")
76
78
        c.Log.AddFlags(f)
77
79
}
78
80
 
79
81
func (c *restoreCommand) Init(args []string) error {
 
82
        if c.showDescription {
 
83
                return cmd.CheckEmpty(args)
 
84
        }
80
85
        if len(args) == 0 {
81
86
                return fmt.Errorf("no backup file specified")
82
87
        }
124
129
}
125
130
 
126
131
func (c *restoreCommand) Run(ctx *cmd.Context) error {
 
132
        if c.showDescription {
 
133
                fmt.Fprintf(ctx.Stdout, "%s\n", c.Info().Purpose)
 
134
                return nil
 
135
        }
127
136
        if err := c.Log.Start(ctx); err != nil {
128
137
                return err
129
138
        }
199
208
                return nil, fmt.Errorf("cannot retrieve environment storage; perhaps the environment was not bootstrapped: %v", err)
200
209
        }
201
210
        if len(state.StateInstances) == 0 {
202
 
                return nil, fmt.Errorf("no instances found on bootstrap state; perhaps the environment was not bootstrapped", err)
 
211
                return nil, fmt.Errorf("no instances found on bootstrap state; perhaps the environment was not bootstrapped")
203
212
        }
204
213
        if len(state.StateInstances) > 1 {
205
214
                return nil, fmt.Errorf("restore does not support HA juju configurations yet")