-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute v2: Add Live Migration Action #728
Changes from 4 commits
6490524
8e53312
36c6c90
4f5656e
1d12f0d
729daa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,43 @@ func Migrate(client *gophercloud.ServiceClient, id string) (r MigrateResult) { | |
_, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"migrate": nil}, nil, nil) | ||
return | ||
} | ||
|
||
// LiveMigrateOptsBuilder allows extensions to add additional parameters to the | ||
// LiveMigrate request. | ||
type LiveMigrateOptsBuilder interface { | ||
ToLiveMigrateMap() (map[string]interface{}, error) | ||
} | ||
|
||
// LiveMigrateOpts specifies parameters of live migrate action. | ||
type LiveMigrateOpts struct { | ||
|
||
// The host to which to migrate the server. | ||
// If this parameter is None, the scheduler chooses a host. | ||
Host *string `json:"host"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this so you can specify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jtopjian It will be "valid", but I reckon that "host" has to be always in the request body according to this line.
I might be wrong please correct me. |
||
|
||
// Set to True to migrate local disks by using block migration. | ||
// If the source or destination host uses shared storage and you set | ||
// this value to True, the live migration fails. | ||
BlockMigration *bool `json:"block_migration,omitempty"` | ||
|
||
// Set to True to enable over commit when the destination host is checked | ||
// for available disk space. Set to False to disable over commit. This setting | ||
// affects only the libvirt virt driver. | ||
DiskOverCommit *bool `json:"disk_over_commit,omitempty"` | ||
} | ||
|
||
// ToLiveMigrateMap constructs a request body from LiveMigrateOpts. | ||
func (opts LiveMigrateOpts) ToLiveMigrateMap() (map[string]interface{}, error) { | ||
return gophercloud.BuildRequestBody(opts, "os-migrateLive") | ||
} | ||
|
||
// LiveMigrate will initiate a live-migration (without rebooting) of the instance to another host. | ||
func LiveMigrate(client *gophercloud.ServiceClient, id string, opts LiveMigrateOptsBuilder) (r MigrateResult) { | ||
b, err := opts.ToLiveMigrateMap() | ||
if err != nil { | ||
r.Err = err | ||
return | ||
} | ||
_, r.Err = client.Post(actionURL(client, id), b, nil, nil) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can you remove this line?