Module for handling OpenStack Nova calls
novaclient Python module
This module is not usable until the user, password, tenant, and auth URL are specified either in a pillar or in the minion's config file. For example:
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
# Optional
keystone.region_name: 'RegionOne'
If configuration for multiple OpenStack accounts is required, they can be set up as different configuration profiles: For example:
openstack1:
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
openstack2:
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.2:5000/v2.0/'
With this configuration in place, any of the nova functions can make use of a configuration profile by declaring it explicitly. For example:
salt '*' nova.flavor_list profile=openstack1
To use keystoneauth1 instead of keystoneclient, include the use_keystoneauth option in the pillar or minion config.
Note
This is required to use keystone v3 as for authentication.
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v3/'
keystone.use_keystoneauth: true
keystone.verify: '/path/to/custom/certs/ca-bundle.crt'
Note
By default the nova module will attempt to verify its connection utilizing the system certificates. If you need to verify against another bundle of CA certificates or want to skip verification altogether you will need to specify the verify option. You can specify True or False to verify (or not) against system certificates, a path to a bundle or CA certs to check against, or None to allow keystoneauth to search for the certificates on its own. (defaults to True)
Boot (create) a new instance
Name of the new instance (must be first)
Unique integer ID for the flavor
Unique integer ID for the image
How long to wait, after creating the instance, for the provider to return information about it (default 300 seconds).
New in version 2014.1.0.
CLI Example:
salt '*' nova.boot myinstance flavor_id=4596 image_id=2
The flavor_id and image_id are obtained from nova.flavor_list and nova.image_list
salt '*' nova.flavor_list
salt '*' nova.image_list
Delete an instance
ID of the instance to be deleted
CLI Example:
salt '*' nova.delete 1138
Add a flavor to nova (nova flavor-create). The following parameters are required:
Name of the new flavor (must be first)
Unique integer ID for the new flavor
Memory size in MB
Disk size in GB
Number of vcpus
CLI Example:
salt '*' nova.flavor_create myflavor flavor_id=6 ram=4096 disk=10 vcpus=1
Delete a flavor from nova by id (nova flavor-delete)
CLI Example:
salt '*' nova.flavor_delete 7
Return a list of available flavors (nova flavor-list)
CLI Example:
salt '*' nova.flavor_list
Return a list of available images (nova images-list + nova image-show) If a name is provided, only that image will be displayed.
CLI Examples:
salt '*' nova.image_list
salt '*' nova.image_list myimage
Delete a key=value pair from the metadata for an image (nova image-meta set)
CLI Examples:
salt '*' nova.image_meta_delete 6f52b2ff-0b31-4d84-8fd1-af45b84824f6 keys=cheese
salt '*' nova.image_meta_delete name=myimage keys=salad,beans
Sets a key=value pair in the metadata for an image (nova image-meta set)
CLI Examples:
salt '*' nova.image_meta_set 6f52b2ff-0b31-4d84-8fd1-af45b84824f6 cheese=gruyere
salt '*' nova.image_meta_set name=myimage salad=pasta beans=baked
Add a keypair to nova (nova keypair-add)
CLI Examples:
salt '*' nova.keypair_add mykey pubfile=/home/myuser/.ssh/id_rsa.pub
salt '*' nova.keypair_add mykey pubkey='ssh-rsa <key> myuser@mybox'
Add a keypair to nova (nova keypair-delete)
CLI Example:
salt '*' nova.keypair_delete mykey
Return a list of available keypairs (nova keypair-list)
CLI Example:
salt '*' nova.keypair_list
To maintain the feel of the nova command line, this function simply calls the server_list function.
CLI Example:
salt '*' nova.list
Lock an instance
ID of the instance to be locked
CLI Example:
salt '*' nova.lock 1138
Resume an instance
ID of the instance to be resumed
CLI Example:
salt '*' nova.resume 1138
Add a secgroup to nova (nova secgroup-create)
CLI Example:
salt '*' nova.secgroup_create mygroup 'This is my security group'
Delete a secgroup to nova (nova secgroup-delete)
CLI Example:
salt '*' nova.secgroup_delete mygroup
Return a list of available security groups (nova items-list)
CLI Example:
salt '*' nova.secgroup_list
Return information about a server
Server Name
CLI Example:
salt '*' nova.server_by_name myserver profile=openstack
Return list of active servers
CLI Example:
salt '*' nova.server_list
Return detailed list of active servers
CLI Example:
salt '*' nova.server_list_detailed
Return detailed information for an active server
CLI Example:
salt '*' nova.server_show <server_id>
To maintain the feel of the nova command line, this function simply calls the server_show function.
CLI Example:
salt '*' nova.show
Suspend an instance
ID of the instance to be suspended
CLI Example:
salt '*' nova.suspend 1138
Attach a block storage volume
Name of the new volume to attach
Name of the server to attach to
Name of the device on the server
Profile to build on
CLI Example:
salt '*' nova.volume_attach myblock slice.example.com profile=openstack
salt '*' nova.volume_attach myblock server.example.com device='/dev/xvdb' profile=openstack
Create a block storage volume
Name of the new volume (must be first)
Volume size
Block storage snapshot id
Type of storage
Profile to build on
CLI Example:
salt '*' nova.volume_create myblock size=300 profile=openstack
Destroy the volume
Name of the volume
Profile to build on
CLI Example:
salt '*' nova.volume_delete myblock profile=openstack
Attach a block storage volume
Name of the new volume to attach
Name of the server to detach from
Profile to build on
CLI Example:
salt '*' nova.volume_detach myblock profile=openstack
List storage volumes
Dictionary of search options
Profile to use
CLI Example:
salt '*' nova.volume_list search_opts='{"display_name": "myblock"}' profile=openstack
Create a block storage volume
Name of the volume
Profile to use
CLI Example:
salt '*' nova.volume_show myblock profile=openstack