API documentation¶
Client¶
-
class
pylxd.client.
Client
(endpoint=None, version='1.0', cert=None, verify=True)¶ Client class for LXD REST API.
This client wraps all the functionality required to interact with LXD, and is meant to be the sole entry point.
-
containers
¶ Instance of
Client.Containers
:
-
images
¶ Instance of
Client.Images
.
-
operations
¶ Instance of
Client.Operations
.
-
profiles
¶ Instance of
Client.Profiles
.
-
api
¶ This attribute provides tree traversal syntax to LXD’s REST API for lower-level interaction.
Use the name of the url part as attribute or item of an api object to create another api object appended with the new url part name, ie:
>>> api = Client().api # / >>> response = api.get() # Check status code and response >>> print response.status_code, response.json() # /containers/test/ >>> print api.containers['test'].get().json()
-
events
(websocket_client=None)¶ Get a websocket client for getting events.
/events is a websocket url, and so must be handled differently than most other LXD API endpoints. This method returns a client that can be interacted with like any regular python socket.
An optional websocket_client parameter can be specified for implementation-specific handling of events as they occur.
-
Container¶
-
class
pylxd.container.
Container
(**kwargs)¶ An LXD Container.
This class is not intended to be used directly, but rather to be used via Client.containers.create.
-
class
FilesManager
(client, container)¶ A pseudo-manager for namespacing file operations.
-
classmethod
Container.
all
(client)¶ Get all containers.
Containers returned from this method will only have the name set, as that is the only property returned from LXD. If more information is needed, Container.fetch is the method call that should be used.
-
classmethod
Container.
create
(client, config, wait=False)¶ Create a new container config.
-
Container.
delete
(wait=False)¶ Delete the container.
-
Container.
execute
(commands, environment={})¶ Execute a command on the container.
-
Container.
fetch
()¶ Reload the container information.
-
Container.
freeze
(timeout=30, force=True, wait=False)¶ Freeze the container.
-
classmethod
Container.
get
(client, name)¶ Get a container by name.
-
Container.
rename
(name, wait=False)¶ Rename a container.
-
Container.
restart
(timeout=30, force=True, wait=False)¶ Restart the container.
-
Container.
start
(timeout=30, force=True, wait=False)¶ Start the container.
-
Container.
stop
(timeout=30, force=True, wait=False)¶ Stop the container.
-
Container.
unfreeze
(timeout=30, force=True, wait=False)¶ Unfreeze the container.
-
Container.
update
(wait=False)¶ Update the container in lxd from local changes.
-
class
Image¶
-
class
pylxd.image.
Image
(**kwargs)¶ A LXD Image.
-
classmethod
all
(client)¶ Get all images.
-
classmethod
create
(client, image_data, public=False, wait=False)¶ Create an image.
-
delete
(wait=False)¶ Delete the image.
-
export
()¶ Export the image.
-
fetch
()¶ Fetch the object from LXD, populating attributes.
-
classmethod
get
(client, fingerprint)¶ Get an image.
-
update
()¶ Update LXD based on changes to this image.
-
classmethod
Operation¶
Profile¶
-
class
pylxd.profile.
Profile
(**kwargs)¶ A LXD profile.
-
classmethod
all
(client)¶ Get all profiles.
-
classmethod
create
(client, name, config=None, devices=None)¶ Create a profile.
-
delete
()¶ Delete a profile.
-
fetch
()¶ Fetch the object from LXD, populating attributes.
-
classmethod
get
(client, name)¶ Get a profile.
-
rename
(new)¶ Rename the profile.
-
update
()¶ Update the profile in LXD based on local changes.
-
classmethod