blob: 173868edf1b61dac32484ec152f9938ff7b13493 [file] [log] [blame]
Ash Wilson92457e92014-10-20 15:18:23 -04001package servers
Ash Wilsone5963982014-10-21 10:04:01 -04002
3import (
4 "github.com/rackspace/gophercloud"
5 os "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
6 "github.com/rackspace/gophercloud/pagination"
7)
8
9// List makes a request against the API to list servers accessible to you.
10func List(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
11 return os.List(client, opts)
12}
13
14// Create requests a server to be provisioned to the user in the current tenant.
15func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
16 return os.Create(client, opts)
17}
18
Jon Perritt723a24b2015-02-02 10:06:42 -070019// Update requests an existing server to be updated with the supplied options.
Jon Perritte5940aa2015-02-01 22:08:23 -070020func Update(client *gophercloud.ServiceClient, id string, opts os.UpdateOptsBuilder) os.UpdateResult {
21 return os.Update(client, id, opts)
22}
23
Ash Wilsone5963982014-10-21 10:04:01 -040024// Delete requests that a server previously provisioned be removed from your account.
Jamie Hannaford7bc317d2014-10-27 11:41:52 +010025func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult {
Ash Wilsone5963982014-10-21 10:04:01 -040026 return os.Delete(client, id)
27}
28
29// Get requests details on a single server, by ID.
30func Get(client *gophercloud.ServiceClient, id string) os.GetResult {
31 return os.Get(client, id)
32}
33
34// ChangeAdminPassword alters the administrator or root password for a specified server.
35func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) os.ActionResult {
36 return os.ChangeAdminPassword(client, id, newPassword)
37}
38
39// Reboot requests that a given server reboot. Two methods exist for rebooting a server:
40//
41// os.HardReboot (aka PowerCycle) restarts the server instance by physically cutting power to the
42// machine, or if a VM, terminating it at the hypervisor level. It's done. Caput. Full stop. Then,
43// after a brief wait, power is restored or the VM instance restarted.
44//
45// os.SoftReboot (aka OSReboot) simply tells the OS to restart under its own procedures. E.g., in
46// Linux, asking it to enter runlevel 6, or executing "sudo shutdown -r now", or by asking Windows to restart the machine.
47func Reboot(client *gophercloud.ServiceClient, id string, how os.RebootMethod) os.ActionResult {
48 return os.Reboot(client, id, how)
49}
50
51// Rebuild will reprovision the server according to the configuration options provided in the
52// RebuildOpts struct.
53func Rebuild(client *gophercloud.ServiceClient, id string, opts os.RebuildOptsBuilder) os.RebuildResult {
54 return os.Rebuild(client, id, opts)
55}
56
Ash Wilsone5963982014-10-21 10:04:01 -040057// WaitForStatus will continually poll a server until it successfully transitions to a specified
58// status. It will do this for at most the number of seconds specified.
59func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error {
60 return os.WaitForStatus(c, id, status, secs)
61}
Ash Wilsonbee34e22014-10-21 14:04:27 -040062
63// ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities.
64func ExtractServers(page pagination.Page) ([]os.Server, error) {
65 return os.ExtractServers(page)
66}