Add connection-type to provider diskimage

The connection type should be included in the provider diskimage. This
makes it possible to define images using other connection methods than
ssh like winrm for Windows.

Change-Id: Ica0b9afe39d347028eb66c069b8dbd56a8c0ec8c
This commit is contained in:
Tobias Henkel 2017-09-12 21:28:19 +02:00
parent 9065905296
commit b707e7218e
7 changed files with 30 additions and 0 deletions

View File

@ -469,6 +469,8 @@ Example configuration::
meta:
key: value
key2: value
- name: windows
connection-type: winrm
**required**
@ -491,6 +493,11 @@ Example configuration::
metadata service. A maximum of five entries is allowed, and both keys and
values must be 255 characters or less.
``connection-type`` (string)
The connection type that a consumer should use when connecting onto the
node. For most diskimages this is not necessary. However when creating
Windows images this could be 'winrm' to enable access via ansible.
.. _provider_cloud_images:
@ -506,6 +513,8 @@ Example configuration::
cloud-images:
- name: trusty-external
config-drive: False
- name: windows-external
connection-type: winrm
**required**
@ -536,6 +545,11 @@ Example configuration::
``username`` (str)
The username that a consumer should use when connecting onto the node.
``connection-type`` (str)
The connection type that a consumer should use when connecting onto the
node. For most diskimages this is not necessary. However when creating
Windows images this could be 'winrm' to enable access via ansible.
.. _pool_labels:
labels

View File

@ -126,6 +126,7 @@ class OpenStackProviderConfig(ProviderConfig):
diskimage.image_types.add(self.image_type)
i.pause = bool(image.get('pause', False))
i.config_drive = image.get('config-drive', None)
i.connection_type = image.get('connection-type', 'ssh')
# This dict is expanded and used as custom properties when
# the image is uploaded.
@ -149,6 +150,7 @@ class OpenStackProviderConfig(ProviderConfig):
i.image_id = image.get('image-id', None)
i.image_name = image.get('image-name', None)
i.username = image.get('username', None)
i.connection_type = image.get('connection-type', 'ssh')
self.cloud_images[i.name] = i
self.pools = {}
@ -201,11 +203,13 @@ class OpenStackProviderConfig(ProviderConfig):
'pause': bool,
'meta': dict,
'config-drive': bool,
'connection-type': str,
}
provider_cloud_images = {
'name': str,
'config-drive': bool,
'connection-type': str,
v.Exclusive('image-id', 'cloud-image-name-or-id'): str,
v.Exclusive('image-name', 'cloud-image-name-or-id'): str,
'username': str,

View File

@ -93,6 +93,7 @@ class NodeLauncher(threading.Thread, stats.StatsReporter):
upload_id=cloud_image.id)
image_name = self._diskimage.name
username = cloud_image.username
connection_type = self._diskimage.connection_type
else:
# launch using unmanaged cloud image
@ -102,6 +103,7 @@ class NodeLauncher(threading.Thread, stats.StatsReporter):
image_id = self._label.cloud_image.name
image_name = self._label.cloud_image.name
username = self._label.cloud_image.username
connection_type = self._label.cloud_image.connection_type
hostname = self._provider.hostname_format.format(
label=self._label, provider=self._provider, node=self._node
@ -137,6 +139,7 @@ class NodeLauncher(threading.Thread, stats.StatsReporter):
self._node.image_id = image_id
if username:
self._node.username = username
self._node.connection_type = connection_type
# Checkpoint save the updated node info
self._zk.storeNode(self._node)

View File

@ -54,11 +54,13 @@ providers:
diskimages:
- name: trusty
pause: False
connection-type: ssh
cloud-images:
- name: trusty-unmanaged
config-drive: true
- name: windows-unmanaged
username: winzuul
connection-type: winrm
pools:
- name: main
max-servers: 184

View File

@ -22,6 +22,7 @@ providers:
- name: fake-image
- name: fake-image-windows
username: zuul
connection-type: winrm
pools:
- name: main
max-servers: 96

View File

@ -57,6 +57,7 @@ class TestLauncher(tests.DBTestCase):
self.assertEqual(node.region, 'fake-region')
self.assertEqual(node.az, "az1")
self.assertEqual(node.username, "zuul")
self.assertEqual(node.connection_type, 'ssh')
p = "{path}/{id}".format(
path=self.zk._imageUploadPath(image.image_name,
image.build_id,
@ -659,6 +660,7 @@ class TestLauncher(tests.DBTestCase):
nodes = self.waitForNodes('fake-label-windows')
self.assertEqual(len(nodes), 1)
self.assertEqual('zuul', nodes[0].username)
self.assertEqual('winrm', nodes[0].connection_type)
def test_unmanaged_image_provider_name(self):
"""

View File

@ -445,6 +445,7 @@ class Node(BaseModel):
self.comment = None
self.hold_job = None
self.username = None
self.connection_type = None
self.host_keys = []
def __repr__(self):
@ -477,6 +478,7 @@ class Node(BaseModel):
self.comment == other.comment and
self.hold_job == other.hold_job and
self.username == other.username and
self.connection_type == other.connection_type and
self.host_keys == other.host_keys)
else:
return False
@ -510,6 +512,7 @@ class Node(BaseModel):
d['hold_job'] = self.hold_job
d['host_keys'] = self.host_keys
d['username'] = self.username
d['connection_type'] = self.connection_type
return d
@staticmethod
@ -544,6 +547,7 @@ class Node(BaseModel):
o.comment = d.get('comment')
o.hold_job = d.get('hold_job')
o.username = d.get('username', 'zuul')
o.connection_type = d.get('connection_type')
o.host_keys = d.get('host_keys', [])
return o