Servers
A virtual machine instance.
Classes
-
class ukcloudservers.ServerManager(api)
-
get(server)
Get a server.
Parameters: |
- server – ID of the Server to get.
|
Return type: | Server
|
-
list()
Get a list of servers.
:rtype: list of Server
-
find(**kwargs)
Find a single item with attributes matching **kwargs.
This isn’t very efficient: it loads the entire list then filters on
the Python side.
-
findall(**kwargs)
Find all items with attributes matching **kwargs.
This isn’t very efficient: it loads the entire list then filters on
the Python side.
-
create(name, image, flavor, ipgroup=None, meta=None, files=None)
Create (boot) a new server.
Parameters: |
- name – Something to name the server.
- image – The Image to boot with.
- flavor – The Flavor to boot onto.
- ipgroup – An initial IPGroup for this server.
- meta – A dict of arbitrary key/value metadata to store for this
server. A maximum of five entries is allowed, and both
keys and values must be 255 characters or less.
- files – A dict of files to overrwrite on the server upon boot.
Keys are file names (i.e. /etc/passwd) and values
are the file contents (either as a string or as a
file-like object). A maximum of five entries is allowed,
and each file must be 10k or less.
|
There’s a bunch more info about how a server boots in Rackspace’s
official API docs, page 23.
-
update(server, name=None, password=None)
Update the name or the password for a server.
Parameters: |
- server – The Server (or its ID) to update.
- name – Update the server’s name.
- password – Update the root password.
|
-
delete(server)
Delete (i.e. shut down and delete the image) this server.
-
share_ip(server, ipgroup, address, configure=True)
Share an IP address from the given IP group onto a server.
Parameters: |
- server – The Server (or its ID) to share onto.
- ipgroup – The IPGroup that the given address belongs to.
- address – The IP address to share.
- configure – If True, the server will be automatically
configured to use this IP. I don’t know why you’d
want this to be False.
|
-
unshare_ip(server, address)
Stop sharing the given address.
Parameters: |
- server – The Server (or its ID) to share onto.
- address – The IP address to stop sharing.
|
-
reboot(server, type='SOFT')
Reboot a server.
Parameters: |
- server – The Server (or its ID) to share onto.
- type – either REBOOT_SOFT for a software-level reboot,
or REBOOT_HARD for a virtual power cycle hard reboot.
|
-
rebuild(server, image)
Rebuild – shut down and then re-image – a server.
Parameters: |
- server – The Server (or its ID) to share onto.
- image – the Image (or its ID) to re-image with.
|
-
resize(server, flavor)
Resize a server’s resources.
Parameters: |
- server – The Server (or its ID) to share onto.
- flavor – the Flavor (or its ID) to resize to.
|
Until a resize event is confirmed with confirm_resize(), the old
server will be kept around and you’ll be able to roll back to the old
flavor quickly with revert_resize(). All resizes are
automatically confirmed after 24 hours.
-
confirm_resize(server)
Confirm that the resize worked, thus removing the original server.
Parameters: |
- server – The Server (or its ID) to share onto.
|
-
revert_resize(server)
Revert a previous resize, switching back to the old server.
Parameters: |
- server – The Server (or its ID) to share onto.
|
-
class ukcloudservers.Server(manager, info)
-
id
This server’s ID.
-
name
The name you gave the server when you booted it.
-
imageId
The Image this server was booted with.
-
flavorId
This server’s current Flavor.
-
hostId
Rackspace doesn’t document this value. It appears to be SHA1 hash.
-
status
The server’s status (BOOTING, ACTIVE, etc).
-
progress
When booting, resizing, updating, etc., this will be set to a
value between 0 and 100 giving a rough estimate of the progress
of the current operation.
-
addresses
The public and private IP addresses of this server. This’ll be a dict
of the form:
{
"public" : ["67.23.10.138"],
"private" : ["10.176.42.19"]
}
You can get more than one public/private IP provisioned, but not
directly from the API; you’ll need to open a support ticket.
-
metadata
The metadata dict you gave when creating the server.
-
update(name=None, password=None)
Update the name or the password for this server.
Parameters: |
- name – Update the server’s name.
- password – Update the root password.
|
-
delete()
Delete (i.e. shut down and delete the image) this server.
-
share_ip(ipgroup, address, configure=True)
Share an IP address from the given IP group onto this server.
Parameters: |
- ipgroup – The IPGroup that the given address belongs to.
- address – The IP address to share.
- configure – If True, the server will be automatically
configured to use this IP. I don’t know why you’d
want this to be False.
|
-
unshare_ip(address)
Stop sharing the given address.
Parameters: |
- address – The IP address to stop sharing.
|
-
reboot(type='SOFT')
Reboot the server.
Parameters: |
- type – either REBOOT_SOFT for a software-level reboot,
or REBOOT_HARD for a virtual power cycle hard reboot.
|
-
rebuild(image)
Rebuild – shut down and then re-image – this server.
Parameters: |
- image – the Image (or its ID) to re-image with.
|
-
resize(flavor)
Resize the server’s resources.
Parameters: |
- flavor – the Flavor (or its ID) to resize to.
|
Until a resize event is confirmed with confirm_resize(), the old
server will be kept around and you’ll be able to roll back to the old
flavor quickly with revert_resize(). All resizes are
automatically confirmed after 24 hours.
-
confirm_resize()
Confirm that the resize worked, thus removing the original server.
-
revert_resize()
Revert a previous resize, switching back to the old server.
Constants
Reboot types:
-
ukcloudservers.REBOOT_SOFT
-
ukcloudservers.REBOOT_HARD