Gather host keys for connection-type network_cli
The network_cli conneciton in ansible, is built a top of paramiko, which then uses SSH at the transport. This means hosts using this connection should also have their host keys collected. Change-Id: I0383227374bdc1a9b0cecc255eabcb8a8d097b09 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
77d31dc126
commit
3b893e3c28
@ -76,7 +76,8 @@ class AwsInstanceLauncher(NodeLauncher):
|
||||
self.node.connection_type = self.label.cloud_image.connection_type
|
||||
if self.pool.host_key_checking:
|
||||
try:
|
||||
if self.node.connection_type == 'ssh':
|
||||
if (self.node.connection_type == 'ssh' or
|
||||
self.node.connection_type == 'network_cli'):
|
||||
gather_hostkeys = True
|
||||
else:
|
||||
gather_hostkeys = False
|
||||
|
@ -217,8 +217,11 @@ class OpenStackNodeLauncher(NodeLauncher):
|
||||
try:
|
||||
self.log.debug(
|
||||
"Gathering host keys for node %s", self.node.id)
|
||||
# only gather host keys if the connection type is ssh
|
||||
gather_host_keys = connection_type == 'ssh'
|
||||
# only gather host keys if the connection type is ssh or
|
||||
# network_cli
|
||||
gather_host_keys = (
|
||||
connection_type == 'ssh' or
|
||||
connection_type == 'network_cli')
|
||||
host_keys = utils.nodescan(
|
||||
interface_ip,
|
||||
timeout=self.provider_config.boot_timeout,
|
||||
|
@ -36,8 +36,10 @@ class StaticNodeProvider(Provider):
|
||||
|
||||
def checkHost(self, node):
|
||||
'''Check node is reachable'''
|
||||
# only gather host keys if the connection type is ssh
|
||||
gather_hostkeys = node["connection-type"] == 'ssh'
|
||||
# only gather host keys if the connection type is ssh or network_cli
|
||||
gather_hostkeys = (
|
||||
node["connection-type"] == 'ssh' or
|
||||
node["connection-type"] == 'network_cli')
|
||||
try:
|
||||
keys = nodeutils.nodescan(node["name"],
|
||||
port=node["connection-port"],
|
||||
|
53
nodepool/tests/fixtures/node-network_cli.yaml
vendored
Normal file
53
nodepool/tests/fixtures/node-network_cli.yaml
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
elements-dir: .
|
||||
images-dir: '{images_dir}'
|
||||
build-log-dir: '{build_log_dir}'
|
||||
build-log-retention: 1
|
||||
|
||||
zookeeper-servers:
|
||||
- host: {zookeeper_host}
|
||||
port: {zookeeper_port}
|
||||
chroot: {zookeeper_chroot}
|
||||
|
||||
labels:
|
||||
- name: fake-label
|
||||
min-ready: 1
|
||||
|
||||
providers:
|
||||
- name: fake-provider
|
||||
cloud: fake
|
||||
driver: fake
|
||||
region-name: fake-region
|
||||
rate: 0.0001
|
||||
diskimages:
|
||||
- name: fake-image
|
||||
connection-type: network_cli
|
||||
meta:
|
||||
key: value
|
||||
key2: value
|
||||
pools:
|
||||
- name: main
|
||||
max-servers: 96
|
||||
node-attributes:
|
||||
key1: value1
|
||||
key2: value2
|
||||
availability-zones:
|
||||
- az1
|
||||
networks:
|
||||
- net-name
|
||||
labels:
|
||||
- name: fake-label
|
||||
diskimage: fake-image
|
||||
min-ram: 8192
|
||||
flavor-name: 'Fake'
|
||||
|
||||
diskimages:
|
||||
- name: fake-image
|
||||
elements:
|
||||
- fedora
|
||||
- vm
|
||||
release: 21
|
||||
env-vars:
|
||||
TMPDIR: /opt/dib_tmp
|
||||
DIB_IMAGE_CACHE: /opt/dib_cache
|
||||
DIB_CLOUD_IMAGES: http://download.fedoraproject.org/pub/fedora/linux/releases/test/21-Beta/Cloud/Images/x86_64/
|
||||
BASE_IMAGE_FILE: Fedora-Cloud-Base-20141029-21_Beta.x86_64.qcow2
|
@ -492,6 +492,24 @@ class TestLauncher(tests.DBTestCase):
|
||||
self.assertEqual(nodes[0].attributes,
|
||||
{'key1': 'value1', 'key2': 'value2'})
|
||||
|
||||
def test_node_network_cli(self):
|
||||
"""Same as test_node but using connection-type network_cli"""
|
||||
configfile = self.setup_config('node-network_cli.yaml')
|
||||
pool = self.useNodepool(configfile, watermark_sleep=1)
|
||||
self.useBuilder(configfile)
|
||||
pool.start()
|
||||
image = self.waitForImage('fake-provider', 'fake-image')
|
||||
self.assertEqual(image.username, 'zuul')
|
||||
nodes = self.waitForNodes('fake-label')
|
||||
|
||||
self.assertEqual(len(nodes), 1)
|
||||
self.assertEqual(nodes[0].provider, 'fake-provider')
|
||||
self.assertEqual(nodes[0].type, ['fake-label'])
|
||||
self.assertEqual(nodes[0].username, 'zuul')
|
||||
self.assertNotEqual(nodes[0].host_keys, [])
|
||||
self.assertEqual(nodes[0].attributes,
|
||||
{'key1': 'value1', 'key2': 'value2'})
|
||||
|
||||
def test_node_host_key_checking_false(self):
|
||||
"""Test that an image and node are created"""
|
||||
configfile = self.setup_config('node-host-key-checking.yaml')
|
||||
|
Loading…
x
Reference in New Issue
Block a user