diff --git a/nodepool/driver/aws/handler.py b/nodepool/driver/aws/handler.py index 47da54d56..8b0d05862 100644 --- a/nodepool/driver/aws/handler.py +++ b/nodepool/driver/aws/handler.py @@ -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 diff --git a/nodepool/driver/openstack/handler.py b/nodepool/driver/openstack/handler.py index 16f426adb..7df3f191d 100644 --- a/nodepool/driver/openstack/handler.py +++ b/nodepool/driver/openstack/handler.py @@ -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, diff --git a/nodepool/driver/static/provider.py b/nodepool/driver/static/provider.py index a256bd5b0..40290a97f 100644 --- a/nodepool/driver/static/provider.py +++ b/nodepool/driver/static/provider.py @@ -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"], diff --git a/nodepool/tests/fixtures/node-network_cli.yaml b/nodepool/tests/fixtures/node-network_cli.yaml new file mode 100644 index 000000000..fb2484c27 --- /dev/null +++ b/nodepool/tests/fixtures/node-network_cli.yaml @@ -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 diff --git a/nodepool/tests/unit/test_launcher.py b/nodepool/tests/unit/test_launcher.py index 14cda183d..78d12a6b0 100644 --- a/nodepool/tests/unit/test_launcher.py +++ b/nodepool/tests/unit/test_launcher.py @@ -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')