Validation Resources¶
The validation_resources module¶
- class ValidationResourcesFixture(clients, keypair=False, floating_ip=False, security_group=False, security_group_rules=False, ethertype='IPv4', use_neutron=True, floating_network_id=None, floating_network_name=None)[source]¶
Fixture to provision and cleanup validation resources
- clear_validation_resources(clients, keypair=None, floating_ip=None, security_group=None, use_neutron=True)[source]¶
Cleanup resources for VM ping/ssh testing
Cleanup a set of resources provisioned via create_validation_resources. In case of errors during cleanup, the exception is logged and the cleanup process is continued. The first exception that was raised is re-raised after the cleanup is complete.
- Parameters:
clients – Instance of tempest.lib.services.clients.ServiceClients or of a subclass of it. Resources are provisioned using clients from clients.
keypair – A dictionary with the keypair to be deleted. Defaults to None.
floating_ip – A dictionary with the floating_ip to be deleted. Defaults to None.
security_group – A dictionary with the security_group to be deleted. Defaults to None.
use_neutron – When True resources are provisioned via neutron, when False resources are provisioned via nova.
Examples:
from tempest.common import validation_resources as vr from tempest.lib import auth from tempest.lib.services import clients creds = auth.get_credentials('http://mycloud/identity/v3', username='me', project_name='me', password='secret', domain_name='Default') osclients = clients.ServiceClients(creds, 'http://mycloud/identity/v3') # Request keypair and floating IP resources = dict(keypair=True, security_group=False, security_group_rules=False, floating_ip=True) resources = vr.create_validation_resources( osclients, validation_resources=resources, use_neutron=True, floating_network_id='4240E68E-23DA-4C82-AC34-9FEFAA24521C') # Now cleanup the resources try: vr.clear_validation_resources(osclients, use_neutron=True, **resources) except Exception as e: LOG.exception('Something went wrong during cleanup, ignoring')
- create_ssh_security_group(clients, add_rule=False, ethertype='IPv4', use_neutron=True)[source]¶
Create a security group for ping/ssh testing
Create a security group to be attached to a VM using the nova or neutron clients. If rules are added, the group can be attached to a VM to enable connectivity validation over ICMP and further testing over SSH.
- Parameters:
clients – Instance of tempest.lib.services.clients.ServiceClients or of a subclass of it. Resources are provisioned using clients from clients.
add_rule – Whether security group rules are provisioned or not. Defaults to False.
ethertype – ‘IPv4’ or ‘IPv6’. Honoured only in case neutron is used.
use_neutron – When True resources are provisioned via neutron, when False resources are provisioned via nova.
- Returns:
A dictionary with the security group as returned by the API.
Examples:
from tempest.common import validation_resources as vr from tempest.lib import auth from tempest.lib.services import clients creds = auth.get_credentials('http://mycloud/identity/v3', username='me', project_name='me', password='secret', domain_name='Default') osclients = clients.ServiceClients(creds, 'http://mycloud/identity/v3') # Security group for IPv4 tests sg4 = vr.create_ssh_security_group(osclients, add_rule=True) # Security group for IPv6 tests sg6 = vr.create_ssh_security_group(osclients, ethertype='IPv6', add_rule=True)
- create_validation_resources(clients, keypair=False, floating_ip=False, security_group=False, security_group_rules=False, ethertype='IPv4', use_neutron=True, floating_network_id=None, floating_network_name=None)[source]¶
Provision resources for VM ping/ssh testing
Create resources required to be able to ping / ssh a virtual machine: keypair, security group, security group rules and a floating IP. Which of those resources are required may depend on the cloud setup and on the specific test and it can be controlled via the corresponding arguments.
Provisioned resources are returned in a dictionary.
- Parameters:
clients – Instance of tempest.lib.services.clients.ServiceClients or of a subclass of it. Resources are provisioned using clients from clients.
keypair – Whether to provision a keypair. Defaults to False.
floating_ip – Whether to provision a floating IP. Defaults to False.
security_group – Whether to provision a security group. Defaults to False.
security_group_rules – Whether to provision security group rules. Defaults to False.
ethertype – ‘IPv4’ or ‘IPv6’. Honoured only in case neutron is used.
use_neutron – When True resources are provisioned via neutron, when False resources are provisioned via nova.
floating_network_id – The id of the network used to provision a floating IP. Only used if a floating IP is requested and with neutron.
floating_network_name – The name of the floating IP pool used to provision the floating IP. Only used if a floating IP is requested and with nova-net.
- Returns:
A dictionary with the resources in the format they are returned by the API. Valid keys are ‘keypair’, ‘floating_ip’ and ‘security_group’.
Examples:
from tempest.common import validation_resources as vr from tempest.lib import auth from tempest.lib.services import clients creds = auth.get_credentials('http://mycloud/identity/v3', username='me', project_name='me', password='secret', domain_name='Default') osclients = clients.ServiceClients(creds, 'http://mycloud/identity/v3') # Request keypair and floating IP resources = dict(keypair=True, security_group=False, security_group_rules=False, floating_ip=True) resources = vr.create_validation_resources( osclients, use_neutron=True, floating_network_id='4240E68E-23DA-4C82-AC34-9FEFAA24521C', **resources) # The floating IP to be attached to the VM floating_ip = resources['floating_ip']['ip']