Merge "Make providing a keypair optional"

This commit is contained in:
Zuul 2018-11-23 15:00:53 +00:00 committed by Gerrit Code Review
commit ee44e6e9e1
10 changed files with 32 additions and 8 deletions

View File

@ -63,8 +63,12 @@ def validate_flavor(cli, flavor):
def validate_keypair(cli, keypair):
"""Validate keypair"""
"""Validate keypair
validate the keypair, if provided.
"""
if keypair is None:
return
try:
cli.nova().keypairs.get(keypair)
except nova_exception.NotFound:

View File

@ -210,8 +210,7 @@ class BaseTemplateDefinition(TemplateDefinition):
self._osc = None
self.add_parameter('ssh_key_name',
cluster_attr='keypair',
required=True)
cluster_attr='keypair')
self.add_parameter('server_image',
cluster_template_attr='image_id')
self.add_parameter('dns_nameserver',

View File

@ -14,6 +14,7 @@ parameters:
ssh_key_name:
type: string
description: name of ssh key to be provisioned on our server
default: ""
external_network:
type: string

View File

@ -10,6 +10,7 @@ parameters:
ssh_key_name:
type: string
description: name of ssh key to be provisioned on our server
default: ""
external_network:
type: string

View File

@ -10,6 +10,7 @@ parameters:
ssh_key_name:
type: string
description: name of ssh key to be provisioned on our server
default: ""
external_network:
type: string

View File

@ -11,6 +11,7 @@ parameters:
ssh_key_name:
type: string
description: name of ssh key to be provisioned on our server
default: ""
external_network:
type: string

View File

@ -16,6 +16,7 @@ parameters:
ssh_key_name:
type: string
description: name of ssh key to be provisioned on our server
default: ""
external_network:
type: string

View File

@ -16,6 +16,7 @@ parameters:
ssh_key_name:
type: string
description: name of ssh key to be provisioned on our server
default: ""
external_network:
type: string

View File

@ -94,6 +94,15 @@ class TestAttrValidator(base.BaseTestCase):
attr_validator.validate_external_network,
mock_os_cli, 'test_ext_net')
def test_validate_keypair_with_no_keypair(self):
mock_keypair = mock.MagicMock()
mock_keypair.id = None
mock_nova = mock.MagicMock()
mock_nova.keypairs.get.return_value = mock_keypair
mock_os_cli = mock.MagicMock()
mock_os_cli.nova.return_value = mock_nova
attr_validator.validate_keypair(mock_os_cli, None)
def test_validate_keypair_with_valid_keypair(self):
mock_keypair = mock.MagicMock()
mock_keypair.id = 'test-keypair'

View File

@ -0,0 +1,6 @@
---
features:
- |
This makes the keypair optional. The user should not have to include
the keypair because they may use some other method of security such
as using SSSD, preconfigured on the image.