blob: 4c2c1d057580dae1aa61fdbd326be022d2ca433c [file] [log] [blame]
Jamie Hannaford583e23d2014-11-13 13:22:29 +01001package startstop
2
Krzysztof Szukiełojć3f41d082017-05-07 14:43:06 +02003import "gerrit.mcp.mirantis.net/debian/gophercloud.git"
Jamie Hannaford583e23d2014-11-13 13:22:29 +01004
5func actionURL(client *gophercloud.ServiceClient, id string) string {
6 return client.ServiceURL("servers", id, "action")
7}
8
Jamie Hannaford1c015e12014-11-13 13:23:14 +01009// Start is the operation responsible for starting a Compute server.
Jon Perritt3860b512016-03-29 12:01:48 -050010func Start(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060011 _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-start": nil}, nil, nil)
jrperritt29ae6b32016-04-13 12:59:37 -050012 return
Jamie Hannaford583e23d2014-11-13 13:22:29 +010013}
14
Jamie Hannaford1c015e12014-11-13 13:23:14 +010015// Stop is the operation responsible for stopping a Compute server.
Jon Perritt3860b512016-03-29 12:01:48 -050016func Stop(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060017 _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-stop": nil}, nil, nil)
jrperritt29ae6b32016-04-13 12:59:37 -050018 return
Jamie Hannaford583e23d2014-11-13 13:22:29 +010019}