Create Nova key pair with random name.

Change-Id: Ic9d107cc92592efd0bcd9c060c1a702a155f9dc4
This commit is contained in:
Federico Ressi 2019-05-07 15:02:30 +02:00
parent 579b0beb83
commit 850a791e5d
4 changed files with 23 additions and 17 deletions

View File

@ -20,10 +20,8 @@ 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"),
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")])
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")])

View File

@ -117,7 +117,6 @@ class SecurityGroupsFixture(heat.HeatStackFixture):
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):

View File

@ -3,16 +3,26 @@ 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:
key_name:
type: OS::Heat::RandomString
properties:
length: 32
key_pair:
type: OS::Nova::KeyPair
properties:
name: {get_param: key_name}
name: {get_attr: [key_name, value]}
public_key: {get_param: public_key}
outputs:
key_name:
value: {get_attr: [key_name, value]}

View File

@ -59,7 +59,6 @@ class FloatingIPFixture(heat.HeatStackFixture):
# --- 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
@ -82,9 +81,9 @@ 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()
@property
def key_name(self):
return self.key_pair_stack.outputs.key_name
class FloatingIPTest(base.TobikoTest):