salt.cloud.clouds.nova

OpenStack Nova Cloud Module

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.

The OpenStack Nova module for Salt Cloud was bootstrapped from the OpenStack module for Salt Cloud, which uses a libcloud-based connection. The Nova module is designed to use the nova and glance modules already built into Salt.

These modules use the Python novaclient and glanceclient libraries, respectively. In order to use this module, the proper salt configuration must also be in place. This can be specified in the master config, the minion config, a set of grains or a set of pillars.

my_openstack_profile:
  keystone.user: admin
  keystone.password: verybadpass
  keystone.tenant: admin
  keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'

Note that there is currently a dependency upon netaddr. This can be installed on Debian-based systems by means of the python-netaddr package.

This module currently requires the latest develop branch of Salt to be installed.

This module has been tested to work with HP Cloud and Rackspace. See the documentation for specific options for either of these providers. These examples could be set up in the cloud configuration at /etc/salt/cloud.providers or /etc/salt/cloud.providers.d/openstack.conf:

my-openstack-config:
  # The ID of the minion that will execute the salt nova functions
  auth_minion: myminion
  # The name of the configuration profile to use on said minion
  config_profile: my_openstack_profile

  ssh_key_name: mykey

  driver: nova
  userdata_file: /tmp/userdata.txt

For local installations that only use private IP address ranges, the following option may be useful. Using the old syntax:

Note: For api use, you will need an auth plugin. The base novaclient does not support apikeys, but some providers such as rackspace have extended keystone to accept them

my-openstack-config:
  # Ignore IP addresses on this network for bootstrap
  ignore_cidr: 192.168.50.0/24

my-nova:
  identity_url: 'https://identity.api.rackspacecloud.com/v2.0/'
  compute_region: IAD
  user: myusername
  password: mypassword
  tenant: <userid>
  driver: nova

my-api:
  identity_url: 'https://identity.api.rackspacecloud.com/v2.0/'
  compute_region: IAD
  user: myusername
  api_key: <api_key>
  os_auth_plugin: rackspace
  tenant: <userid>
  driver: nova
  networks:
    - net-id: 47a38ff2-fe21-4800-8604-42bd1848e743
    - net-id: 00000000-0000-0000-0000-000000000000
    - net-id: 11111111-1111-1111-1111-111111111111

This is an example profile.

debian8-2-iad-cloudqe4:
  provider: cloudqe4-iad
  size: performance1-2
  image: Debian 8 (Jessie) (PVHVM)
  script_args: -UP -p python-zmq git 2015.8

and one using cinder volumes already attached

# create the block storage device
centos7-2-iad-rackspace:
  provider: rackspace-iad
  size: general1-2
  block_device:
    - source: image
      id: <image_id>
      dest: volume
      size: 100
      shutdown: <preserve/remove>
      bootindex: 0

# with the volume already created
centos7-2-iad-rackspace:
  provider: rackspace-iad
  size: general1-2
  boot_volume: <volume id>

# create the volume from a snapshot
centos7-2-iad-rackspace:
  provider: rackspace-iad
  size: general1-2
  snapshot: <cinder snapshot id>

# create the create an extra ephemeral disk
centos7-2-iad-rackspace:
  provider: rackspace-iad
  size: general1-2
  ephemeral:
    - size: 100
      format: <swap/ext4>

# create the create an extra ephemeral disk
centos7-2-iad-rackspace:
  provider: rackspace-iad
  size: general1-2
  swap: <size>

Block Device can also be used for having more than one block storage device attached

centos7-2-iad-rackspace:
  provider: rackspace-iad
  size: general1-2
  block_device:
    - source: image
      id: <image_id>
      dest: volume
      size: 100
      shutdown: <preserve/remove>
      bootindex: 0
    - source: blank
      dest: volume
      device: xvdc
      size: 100
      shutdown: <preserve/remove>

Floating IPs can be auto assigned and ssh_interface can be set to fixed_ips, floating_ips, public_ips or private_ips

centos7-2-iad-rackspace:
  provider: rackspace-iad
  size: general1-2
  ssh_interface: floating_ips
  floating_ip:
    auto_assign: True
    pool: public

Note: You must include the default net-ids when setting networks or the server will be created without the rest of the interfaces

Note: For rackconnect v3, rackconnectv3 needs to be specified with the rackconnect v3 cloud network as its variable.

salt.cloud.clouds.nova.attach_volume(name, server_name, device='/dev/xvdb', **kwargs)

Attach block volume

salt.cloud.clouds.nova.avail_images()

Return a dict of all available VM images on the cloud provider.

salt.cloud.clouds.nova.avail_locations(conn=None, call=None)

Return a list of locations

salt.cloud.clouds.nova.avail_sizes()

Return a dict of all available VM sizes on the cloud provider.

salt.cloud.clouds.nova.cloudnetwork(vm_)

Determine if we should use an extra network to bootstrap Either 'False' (default) or 'True'.

salt.cloud.clouds.nova.create(vm_)

从一个字典数据中创建单一的VM

salt.cloud.clouds.nova.create_attach_volumes(name, call=None, **kwargs)

Create and attach volumes to created node

salt.cloud.clouds.nova.create_volume(name, size=100, snapshot=None, voltype=None, **kwargs)

Create block storage device

salt.cloud.clouds.nova.destroy(name, conn=None, call=None)

Delete a single VM

salt.cloud.clouds.nova.floating_ip_associate(name, kwargs, call=None)

Associate a floating IP address to a server

2016.3.0 新版功能.

salt.cloud.clouds.nova.floating_ip_create(kwargs, call=None)

Allocate a floating IP

2016.3.0 新版功能.

salt.cloud.clouds.nova.floating_ip_delete(kwargs, call=None)

De-allocate floating IP

2016.3.0 新版功能.

salt.cloud.clouds.nova.floating_ip_disassociate(name, kwargs, call=None)

Disassociate a floating IP from a server

2016.3.0 新版功能.

salt.cloud.clouds.nova.floating_ip_list(call=None)

List floating IPs

2016.3.0 新版功能.

salt.cloud.clouds.nova.floating_ip_pool_list(call=None)

List all floating IP pools

2016.3.0 新版功能.

salt.cloud.clouds.nova.get_block_mapping_opts(vm_)
salt.cloud.clouds.nova.get_configured_provider()

Return the first configured instance.

salt.cloud.clouds.nova.get_conn()

Return a conn object for the passed VM data

salt.cloud.clouds.nova.get_dependencies()

Warn if dependencies aren't met.

salt.cloud.clouds.nova.get_image(conn, vm_)

Return the image object to use

salt.cloud.clouds.nova.get_size(conn, vm_)

Return the VM's size object

salt.cloud.clouds.nova.ignore_cidr(vm_, ip)

Return True if we are to ignore the specified IP. Compatible with IPv4.

salt.cloud.clouds.nova.list_nodes(call=None, **kwargs)

Return a list of the VMs that in this location

salt.cloud.clouds.nova.list_nodes_full(call=None, **kwargs)

Return a list of the VMs that in this location

salt.cloud.clouds.nova.list_nodes_select(call=None)

Return a list of the VMs that are on the provider, with select fields

salt.cloud.clouds.nova.managedcloud(vm_)

Determine if we should wait for the managed cloud automation before running. Either 'False' (default) or 'True'.

salt.cloud.clouds.nova.network_create(name, **kwargs)

Create private networks

salt.cloud.clouds.nova.network_list(call=None, **kwargs)

List private networks

salt.cloud.clouds.nova.preferred_ip(vm_, ips)

Return the preferred Internet protocol. Either 'ipv4' (default) or 'ipv6'.

salt.cloud.clouds.nova.rackconnect(vm_)

Determine if we should wait for rackconnect automation before running. Either 'False' (default) or 'True'.

salt.cloud.clouds.nova.rackconnectv3(vm_)

Determine if server is using rackconnectv3 or not Return the rackconnect network name or False

salt.cloud.clouds.nova.reboot(name, conn=None)

Reboot a single VM

salt.cloud.clouds.nova.request_instance(vm_=None, call=None)

Put together all of the information necessary to request an instance through Novaclient and then fire off the request the instance.

Returns data about the instance

salt.cloud.clouds.nova.script(vm_)

Return the script deployment object

salt.cloud.clouds.nova.show_instance(name, call=None)

Show the details from the provider concerning an instance

salt.cloud.clouds.nova.ssh_interface(vm_)

Return the ssh_interface type to connect to. Either 'public_ips' (default) or 'private_ips'.

salt.cloud.clouds.nova.virtual_interface_create(name, net_name, **kwargs)

Create private networks

salt.cloud.clouds.nova.virtual_interface_list(name, **kwargs)

Create private networks

salt.cloud.clouds.nova.volume_attach(name, server_name, device='/dev/xvdb', **kwargs)

Attach block volume

salt.cloud.clouds.nova.volume_create(name, size=100, snapshot=None, voltype=None, **kwargs)

Create block storage device

salt.cloud.clouds.nova.volume_create_attach(name, call=None, **kwargs)

Create and attach volumes to created node

salt.cloud.clouds.nova.volume_delete(name, **kwargs)

Delete block storage device

salt.cloud.clouds.nova.volume_detach(name, **kwargs)

Detach block volume

salt.cloud.clouds.nova.volume_list(**kwargs)

List block devices