github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/api/migrationtarget/client.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package migrationtarget 5 6 import ( 7 "gopkg.in/juju/names.v2" 8 9 "github.com/juju/juju/api/base" 10 "github.com/juju/juju/apiserver/params" 11 coremigration "github.com/juju/juju/core/migration" 12 ) 13 14 // NewClient returns a new Client based on an existing API connection. 15 func NewClient(caller base.APICaller) *Client { 16 return &Client{base.NewFacadeCaller(caller, "MigrationTarget")} 17 } 18 19 // Client is the client-side API for the MigrationTarget facade. It is 20 // used by the migrationmaster worker when talking to the target 21 // controller during a migration. 22 type Client struct { 23 caller base.FacadeCaller 24 } 25 26 func (c *Client) Prechecks(model coremigration.ModelInfo) error { 27 args := params.MigrationModelInfo{ 28 UUID: model.UUID, 29 Name: model.Name, 30 OwnerTag: model.Owner.String(), 31 AgentVersion: model.AgentVersion, 32 } 33 return c.caller.FacadeCall("Prechecks", args, nil) 34 } 35 36 // Import takes a serialized model and imports it into the target 37 // controller. 38 func (c *Client) Import(bytes []byte) error { 39 serialized := params.SerializedModel{Bytes: bytes} 40 return c.caller.FacadeCall("Import", serialized, nil) 41 } 42 43 // Abort removes all data relating to a previously imported model. 44 func (c *Client) Abort(modelUUID string) error { 45 args := params.ModelArgs{ModelTag: names.NewModelTag(modelUUID).String()} 46 return c.caller.FacadeCall("Abort", args, nil) 47 } 48 49 // Activate marks a migrated model as being ready to use. 50 func (c *Client) Activate(modelUUID string) error { 51 args := params.ModelArgs{ModelTag: names.NewModelTag(modelUUID).String()} 52 return c.caller.FacadeCall("Activate", args, nil) 53 }