OpenStack is an open source project that is in use by a number a cloud providers, each of which have their own ways of using it.
This OpenStack driver uses a the shade python module which is managed by the OpenStack Infra team. This module is written to handle all the different versions of different OpenStack tools for salt, so most commands are just passed over to the module to handle everything.
There are two ways to configure providers for this driver. The first one is to just let shade handle everything, and configure using os-client-config and setting up /etc/openstack/clouds.yml.
clouds:
democloud:
region_name: RegionOne
auth:
username: 'demo'
password: secret
project_name: 'demo'
auth_url: 'http://openstack/identity'
And then this can be referenced in the salt provider based on the democloud name.
myopenstack:
driver: openstack
cloud: democloud
region_name: RegionOne
This allows for just using one configuration for salt-cloud and for any other openstack tools which are all using /etc/openstack/clouds.yml
The other method allows for specifying everything in the provider config, instead of using the extra configuration file. This will allow for passing salt-cloud configs only through pillars for minions without having to write a clouds.yml file on each minion.abs
myopenstack:
driver: openstack
region_name: RegionOne
auth:
username: 'demo'
password: secret
project_name: 'demo'
user_domain_name: default,
project_domain_name: default,
auth_url: 'http://openstack/identity'
Or if you need to use a profile to setup some extra stuff, it can be passed as a profile to use any of the vendor config options.
myrackspace:
driver: openstack
profile: rackspace
auth:
username: rackusername
api_key: myapikey
region_name: ORD
auth_type: rackspace_apikey
And this will pull in the profile for rackspace and setup all the correct options for the auth_url and different api versions for services.
Most of the options for building servers are just passed on to the create_server function from shade.
The salt specific ones are:
ssh_key_file: The path to the ssh key that should be used to login to the machine to bootstrap it
ssh_key_file: The name of the keypair in openstack
userdata_template: The renderer to use if the userdata is a file that is templated. Default: False
ssh_interface: The interface to use to login for bootstrapping: public_ips, private_ips, floating_ips, fixed_ips
centos:
provider: myopenstack
image: CentOS 7
size: ds1G
ssh_key_name: mykey
ssh_key_file: /root/.ssh/id_rsa
This is the minimum setup required.
If metadata is set to make sure that the host has finished setting up the wait_for_metadata can be set.
centos:
provider: myopenstack
image: CentOS 7
size: ds1G
ssh_key_name: mykey
ssh_key_file: /root/.ssh/id_rsa
meta:
build_config: rack_user_only
wait_for_metadata:
rax_service_level_automation: Complete
rackconnect_automation_status: DEPLOYED
Anything else from the create_server docs can be passed through here.
unless boot_volume is given.
flavor: Flavor dict, name or ID to boot onto.
the server. (defaults to True)
ips: List of IPs to attach to the server (defaults to None)
address from. (defaults to None)
(defaults to None - deprecated, use boot_volume)
(defaults to None)
be deleted when the server is destroyed. (defaults to False)
volumes: (optional) A list of volumes to attach to the server
store for this server. Both keys and values must be <=255 characters.
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.
reservation_id: a UUID for the set of servers being requested.
servers to launch.
servers to launch.
security_groups: A list of security group names
server this can be a file type object as well or a string.
keypair to inject into the instance.
placement.
device mappings for this server.
device mappings for this server.
added to this server, with information about connected networks, fixed IPs, port etc.
specified by the client to help boot an instance
either boolean, or volume-id
partitioned when the server is created. possible values are 'AUTO' or 'MANUAL'.
password.
See the wait
parameter.
floating ips should a floating IP be needed (defaults to True)
server to. Mutually exclusive with the nics parameter. Can also be be a list of network names or IDs or network dicts.
implies True, but boot_from_volume=True with no boot_volume is valid and will create a volume from the image and use that.
the created volume be? Defaults to 50.
be attached to, if it's not possible to infer from the cloud's configuration. (Optional, defaults to None)
If a group is provided in both scheduler_hints and in the group param, the group param will win. (Optional, defaults to None)
Note
If there is anything added, that is not in this list, it can be added to an extras dictionary for the profile, and that will be to the create_server function.
salt.cloud.clouds.openstack.
avail_images
(conn=None, call=None)¶List available images for OpenStack
CLI Example
salt-cloud -f avail_images myopenstack
salt-cloud --list-images myopenstack
salt.cloud.clouds.openstack.
avail_sizes
(conn=None, call=None)¶List available sizes for OpenStack
CLI Example
salt-cloud -f avail_sizes myopenstack
salt-cloud --list-sizes myopenstack
salt.cloud.clouds.openstack.
call
(conn=None, call=None, kwargs=None)¶Call function from shade.
func
function to call from shade.openstackcloud library
CLI Example
salt-cloud -f call myopenstack func=list_images
t sujksalt-cloud -f call myopenstack func=create_network name=mysubnet
salt.cloud.clouds.openstack.
create
(vm_)¶Create a single VM from a data dict
salt.cloud.clouds.openstack.
destroy
(name, conn=None, call=None)¶Delete a single VM
salt.cloud.clouds.openstack.
get_configured_provider
()¶Return the first configured instance.
salt.cloud.clouds.openstack.
get_conn
()¶Return a conn object for the passed VM data
salt.cloud.clouds.openstack.
get_dependencies
()¶Warn if dependencies aren't met.
salt.cloud.clouds.openstack.
list_networks
(conn=None, call=None)¶List networks for OpenStack
CLI Example
salt-cloud -f list_networks myopenstack
salt.cloud.clouds.openstack.
list_nodes
(conn=None, call=None)¶Return a list of VMs
CLI Example
salt-cloud -f list_nodes myopenstack
salt.cloud.clouds.openstack.
list_nodes_full
(conn=None, call=None)¶Return a list of VMs with all the information about them
CLI Example
salt-cloud -f list_nodes_full myopenstack
salt.cloud.clouds.openstack.
list_nodes_min
(conn=None, call=None)¶Return a list of VMs with minimal information
CLI Example
salt-cloud -f list_nodes_min myopenstack
salt.cloud.clouds.openstack.
list_nodes_select
(conn=None, call=None)¶Return a list of VMs with the fields from query.selection
CLI Example
salt-cloud -f list_nodes_full myopenstack
salt.cloud.clouds.openstack.
list_subnets
(conn=None, call=None, kwargs=None)¶List subnets in a virtual network
network to list subnets of
salt-cloud -f list_subnets myopenstack network=salt-net
salt.cloud.clouds.openstack.
preferred_ip
(vm_, ips)¶Return the preferred Internet protocol. Either 'ipv4' (default) or 'ipv6'.
salt.cloud.clouds.openstack.
request_instance
(vm_, conn=None, call=None)¶Request an instance to be built
salt.cloud.clouds.openstack.
show_instance
(name, conn=None, call=None)¶Get VM on this OpenStack account
name
name of the instance
CLI Example
salt-cloud -a show_instance myserver
salt.cloud.clouds.openstack.
ssh_interface
(vm_)¶Return the ssh_interface type to connect to. Either 'public_ips' (default) or 'private_ips'.