Addition of (nova ssh) key_pair_fixture with cmdline,heat template,
and a stacks fixture class to be used in test_floating_ip scenarios. Change-Id: I87c61e16b97527688e8a02277a7c6693e887692e
This commit is contained in:
parent
f301597e87
commit
579b0beb83
@ -10,6 +10,11 @@ function install_tobiko {
|
||||
|
||||
|
||||
function configure_tobiko {
|
||||
#Setup an ssh key
|
||||
local nova_key_file=${TOBIKO_NOVA_KEY_FILE:-~/.ssh/id_rsa}
|
||||
if ! [ -r "${nova_key_file}" ]; then
|
||||
ssh-keygen -t rsa -q -P "" -f "${nova_key_file}"
|
||||
fi
|
||||
# Write configuration to a new temporary file
|
||||
local tobiko_conf=$(mktemp)
|
||||
if [ -f "${TOBIKO_CONF}" ]; then
|
||||
@ -23,6 +28,7 @@ function configure_tobiko {
|
||||
echo_summary "Write compute service options to ${TOBIKO_CONF}"
|
||||
iniset "${tobiko_conf}" nova image "$(get_image)"
|
||||
iniset "${tobiko_conf}" nova flavor "$(get_flavor)"
|
||||
iniset "${tobiko_conf}" nova key_file "${nova_key_file}"
|
||||
|
||||
echo_summary "Write networking options to ${TOBIKO_CONF}"
|
||||
iniset "${tobiko_conf}" neutron floating_network \
|
||||
|
@ -20,6 +20,10 @@ def register_tobiko_options(conf):
|
||||
conf.register_opts(
|
||||
group=cfg.OptGroup('nova'),
|
||||
opts=[cfg.StrOpt('image',
|
||||
help="Default image for new server instances"),
|
||||
cfg.StrOpt('flavor',
|
||||
help="Default flavor for new server instances")])
|
||||
help="Default image for new server instances"),
|
||||
cfg.StrOpt('flavor',
|
||||
help="Default flavor for new server instances"),
|
||||
cfg.StrOpt('key_file', default='~/.ssh/id_rsa',
|
||||
help="ssh key file for new server instances"),
|
||||
cfg.StrOpt('key_name', default='nova_ssh_key',
|
||||
help="ssh key name for new server instances")])
|
||||
|
@ -16,6 +16,8 @@ from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
from tobiko import config
|
||||
from tobiko.openstack import heat
|
||||
from tobiko.openstack import neutron
|
||||
@ -110,3 +112,18 @@ class SecurityGroupsFixture(heat.HeatStackFixture):
|
||||
"""
|
||||
#: Heat template file
|
||||
template = heat_template_file('security_groups.yaml')
|
||||
|
||||
|
||||
class KeyPairFixture(heat.HeatStackFixture):
|
||||
template = heat_template_file('key_pair.yaml')
|
||||
key_file = os.path.expanduser(CONF.tobiko.nova.key_file)
|
||||
key_name = CONF.tobiko.nova.key_name
|
||||
|
||||
@property
|
||||
def public_key(self):
|
||||
with open(self.key_file + '.pub', 'r') as fd:
|
||||
key = fd.read()
|
||||
if not isinstance(key, six.string_types):
|
||||
# on Python 3 must convert key to string
|
||||
key = key.decode()
|
||||
return key
|
||||
|
@ -1,11 +1,13 @@
|
||||
heat_template_version: newton
|
||||
|
||||
|
||||
description: |
|
||||
Stack of resources used to test floating IP
|
||||
|
||||
|
||||
parameters:
|
||||
key_name:
|
||||
type: string
|
||||
|
||||
flavor:
|
||||
type: string
|
||||
|
||||
@ -39,6 +41,7 @@ resources:
|
||||
server:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
key_name: {get_param: key_name}
|
||||
image: {get_param: image}
|
||||
flavor: {get_param: flavor}
|
||||
networks:
|
||||
|
18
tobiko/tests/scenario/neutron/templates/key_pair.yaml
Normal file
18
tobiko/tests/scenario/neutron/templates/key_pair.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
heat_template_version: 2015-04-30
|
||||
|
||||
description: |
|
||||
Creates a nova ssh keypair
|
||||
|
||||
parameters:
|
||||
public_key:
|
||||
type: string
|
||||
key_name:
|
||||
type: string
|
||||
default: 'nova_ssh_key'
|
||||
|
||||
resources:
|
||||
nova_ssh_key_pair:
|
||||
type: OS::Nova::KeyPair
|
||||
properties:
|
||||
name: {get_param: key_name}
|
||||
public_key: {get_param: public_key}
|
@ -57,8 +57,9 @@ class FloatingIPFixture(heat.HeatStackFixture):
|
||||
stacks.InternalNetworkFixture)
|
||||
|
||||
# --- class parameters ---
|
||||
|
||||
#: Whenever port security on internal network is enable
|
||||
key_pair_stack = tobiko.required_setup_fixture(stacks.KeyPairFixture)
|
||||
key_name = CONF.tobiko.nova.key_name
|
||||
port_security_enabled = False
|
||||
|
||||
#: Security groups to be associated to network ports
|
||||
@ -81,6 +82,10 @@ class FloatingIPFixture(heat.HeatStackFixture):
|
||||
port_security_enabled=self.port_security_enabled,
|
||||
security_groups=self.security_groups or [])
|
||||
|
||||
def setup_stack(self):
|
||||
self.key_pair_stack.wait_for_create_complete()
|
||||
super(FloatingIPFixture, self).setup_stack()
|
||||
|
||||
|
||||
class FloatingIPTest(base.TobikoTest):
|
||||
"""Tests connectivity to Nova instances via floating IPs"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user