From da95a817bbc742dbab587953b542686a4c375c89 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 13 Apr 2018 10:17:50 -0500 Subject: [PATCH] Support winrm hosts in static driver The static driver currently assumes ssh connectivity. Add a connection-type parameter and rename the ssh-port to connection-port to match the diskimages setting name. Keep the old 'ssh-port' setting for backwards compat. Change-Id: I1a96f03f9845b0d99d9ce89d2213be4d483afdd9 --- doc/source/configuration.rst | 12 +++++++++--- nodepool/driver/static/config.py | 8 ++++++-- nodepool/driver/static/handler.py | 4 ++-- nodepool/driver/static/provider.py | 4 +++- nodepool/tests/fixtures/config_validate/good.yaml | 2 +- nodepool/tests/fixtures/static.yaml | 9 ++++++++- .../static-driver-windows-cf80096636dbb428.yaml | 10 ++++++++++ 7 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/static-driver-windows-cf80096636dbb428.yaml diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index c5e3500dc..4b87929aa 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -714,7 +714,7 @@ Example:: labels: trusty-static host-key: fake-key timeout: 13 - ssh-port: 22022 + connection-port: 22022 username: zuul max-parallel-jobs: 1 @@ -747,8 +747,14 @@ corresponding label. ``host-key`` The ssh host key of the node. - ``ssh-port`` - The ssh port, default to *22* + ``connection-type`` (string) + The connection type that a consumer should use when connecting to the + node. Should be set to either 'ssh' or 'winrm'. Defaults to 'ssh'. + + ``connection-port`` (int) + The port that a consumer should use when connecting to the node. + For most nodes this is not necessary. This defaults to 22 when + ``connection-type`` is 'ssh' and 5986 when it is 'winrm'. ``max-parallel-jobs`` The number of jobs that can run in parallel on this node, default to *1*. diff --git a/nodepool/driver/static/config.py b/nodepool/driver/static/config.py index b684d5043..d0c0e3cdc 100644 --- a/nodepool/driver/static/config.py +++ b/nodepool/driver/static/config.py @@ -57,7 +57,10 @@ class StaticProviderConfig(ProviderConfig): 'labels': as_list(node['labels']), 'host-key': as_list(node.get('host-key', [])), 'timeout': int(node.get('timeout', 5)), - 'ssh-port': int(node.get('ssh-port', 22)), + # Read ssh-port values for backward compat, but prefer port + 'connection-port': int( + node.get('port', node.get('ssh-port', 22))), + 'connection-type': node.get('connection-type', 'ssh'), 'username': node.get('username', 'zuul'), 'max-parallel-jobs': int(node.get('max-parallel-jobs', 1)), }) @@ -72,7 +75,8 @@ class StaticProviderConfig(ProviderConfig): 'username': str, 'timeout': int, 'host-key': v.Any(str, [str]), - 'ssh-port': int, + 'connection-port': int, + 'connection-type': str, 'max-parallel-jobs': int, } pool = { diff --git a/nodepool/driver/static/handler.py b/nodepool/driver/static/handler.py index 498b6339b..26b2b79a8 100644 --- a/nodepool/driver/static/handler.py +++ b/nodepool/driver/static/handler.py @@ -120,8 +120,8 @@ class StaticNodeRequestHandler(NodeRequestHandler): node.hostname = static_node["name"] node.username = static_node["username"] node.interface_ip = static_node["name"] - node.connection_port = static_node["ssh-port"] - node.connection_type = "ssh" + node.connection_port = static_node["connection-port"] + node.connection_type = static_node["connection-type"] nodeutils.set_node_ip(node) node.host_keys = self.manager.nodes_keys[static_node["name"]] node.provider = self.provider.name diff --git a/nodepool/driver/static/provider.py b/nodepool/driver/static/provider.py index 42da57d81..40294db72 100644 --- a/nodepool/driver/static/provider.py +++ b/nodepool/driver/static/provider.py @@ -35,9 +35,11 @@ class StaticNodeProvider(Provider): def checkHost(self, node): # Check node is reachable + if node["connection-type"] != "ssh": + return try: keys = nodescan(node["name"], - port=node["ssh-port"], + port=node["connection-port"], timeout=node["timeout"]) except exceptions.ConnectionTimeoutException: raise StaticNodeError( diff --git a/nodepool/tests/fixtures/config_validate/good.yaml b/nodepool/tests/fixtures/config_validate/good.yaml index ae136a024..60af6958f 100644 --- a/nodepool/tests/fixtures/config_validate/good.yaml +++ b/nodepool/tests/fixtures/config_validate/good.yaml @@ -90,7 +90,7 @@ providers: labels: trusty-static host-key: fake-key timeout: 13 - ssh-port: 22022 + connection-port: 22022 username: zuul max-parallel-jobs: 1 diff --git a/nodepool/tests/fixtures/static.yaml b/nodepool/tests/fixtures/static.yaml index 500d7b350..d377840aa 100644 --- a/nodepool/tests/fixtures/static.yaml +++ b/nodepool/tests/fixtures/static.yaml @@ -10,6 +10,9 @@ labels: - name: fake-concurrent-label min-ready: 2 + - name: fake-windows-label + min-ready: 2 + providers: - name: static-provider driver: static @@ -20,10 +23,14 @@ providers: labels: fake-label host-key: ssh-rsa FAKEKEY timeout: 13 - ssh-port: 22022 + connection-port: 22022 username: zuul max-parallel-jobs: 1 - name: fake-host-2 labels: fake-concurrent-label host-key: ssh-rsa FAKEKEY max-parallel-jobs: 2 + - name: fake-host-3 + labels: fake-windows-label + max-parallel-jobs: 1 + connection-type: winrm diff --git a/releasenotes/notes/static-driver-windows-cf80096636dbb428.yaml b/releasenotes/notes/static-driver-windows-cf80096636dbb428.yaml new file mode 100644 index 000000000..416477fa5 --- /dev/null +++ b/releasenotes/notes/static-driver-windows-cf80096636dbb428.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Added support for configuring windows static nodes. A static node can now + define a ``connection-type``. The ``ssh-port`` option has been renamed + to ``connection-port``. +deprecations: + - | + ``ssh-port`` in static node config is deprecated. Please update config to + use ``connection-port`` instead.