blob: 4c7b24909aaf4dc3502d062d72b6502e9feb2fa7 [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
19// Delete requests that a server previously provisioned be removed from your account.
Jamie Hannaford7bc317d2014-10-27 11:41:52 +010020func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult {
Ash Wilsone5963982014-10-21 10:04:01 -040021 return os.Delete(client, id)
22}
23
24// Get requests details on a single server, by ID.
25func Get(client *gophercloud.ServiceClient, id string) os.GetResult {
26 return os.Get(client, id)
27}
28
29// ChangeAdminPassword alters the administrator or root password for a specified server.
30func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) os.ActionResult {
31 return os.ChangeAdminPassword(client, id, newPassword)
32}
33
34// Reboot requests that a given server reboot. Two methods exist for rebooting a server:
35//
36// os.HardReboot (aka PowerCycle) restarts the server instance by physically cutting power to the
37// machine, or if a VM, terminating it at the hypervisor level. It's done. Caput. Full stop. Then,
38// after a brief wait, power is restored or the VM instance restarted.
39//
40// os.SoftReboot (aka OSReboot) simply tells the OS to restart under its own procedures. E.g., in
41// Linux, asking it to enter runlevel 6, or executing "sudo shutdown -r now", or by asking Windows to restart the machine.
42func Reboot(client *gophercloud.ServiceClient, id string, how os.RebootMethod) os.ActionResult {
43 return os.Reboot(client, id, how)
44}
45
46// Rebuild will reprovision the server according to the configuration options provided in the
47// RebuildOpts struct.
48func Rebuild(client *gophercloud.ServiceClient, id string, opts os.RebuildOptsBuilder) os.RebuildResult {
49 return os.Rebuild(client, id, opts)
50}
51
Ash Wilsone5963982014-10-21 10:04:01 -040052// WaitForStatus will continually poll a server until it successfully transitions to a specified
53// status. It will do this for at most the number of seconds specified.
54func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error {
55 return os.WaitForStatus(c, id, status, secs)
56}
Ash Wilsonbee34e22014-10-21 14:04:27 -040057
58// ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities.
59func ExtractServers(page pagination.Page) ([]os.Server, error) {
60 return os.ExtractServers(page)
61}