[−][src]Crate openstack
OpenStack SDK in Rust.
The goal of this project is to provide a simple API for working with OpenStack clouds.
Usage
Start with authentication, then create a Cloud object and use it for OpenStack API calls.
Examples
List servers
Get authentication parameters from the environment and get UUIDs of all servers.
extern crate openstack; fn get_server_uuids() -> openstack::Result<Vec<String>> { let os = openstack::Cloud::from_env()?; let server_names = os .list_servers()? .into_iter() .map(|server| server.id().clone()) .collect(); Ok(server_names) }
Find images
Find public images using Identity password authentication with the default region:
extern crate fallible_iterator; extern crate openstack; use fallible_iterator::FallibleIterator; fn get_public_image_names() -> openstack::Result<Vec<String>> { let auth = openstack::auth::Password::new( "https://cloud.local/identity", "admin", "pa$$w0rd", "Default" ) .expect("Invalid auth_url") .with_project_scope("project1", "Default"); let os = openstack::Cloud::new(auth); let image_names = os .find_images() .with_visibility(openstack::image::ImageVisibility::Public) .into_iter() // This `map` comes from fallible-iterator, thus the closure returns a `Result`. .map(|image| Ok(image.name().clone())) .collect()?; Ok(image_names) }
Notice the difference between list_*
methods (return a result with a vector) and find_*
methods (return a query builder that can be used to create a fallible iterator).
Create server
Create a server with authentication from a clouds.yaml
file:
extern crate openstack; extern crate waiter; // Required for the `wait` call. use waiter::Waiter; fn create_server() -> openstack::Result<openstack::compute::Server> { openstack::Cloud::from_config("my-cloud-1")? .new_server("test-server-1", "x-large") .with_image("centos-7") .with_network("private") .with_keypair("default") .create()? .wait() }
Modules
auth | Reimports of authentication bits from |
common | Types and traits shared by all API parts. |
compute | Compute API implementation bits. |
image | Image API implementation bits. |
network | Network API implementation bits. |
session | Reimport of the synchronous session from |
Structs
Cloud | OpenStack cloud API. |
Error | Error from an OpenStack call. |
Enums
ErrorKind | Kind of an error. |
Sort | Sorting request. |
Traits
Refresh | Trait representing something that can be refreshed. |
Type Definitions
Result | A result of an OpenStack operation. |