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 5d6826e50..5e52c98f8 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 e25cb75b0..4c7a359f3 100644 --- a/nodepool/driver/static/handler.py +++ b/nodepool/driver/static/handler.py @@ -64,8 +64,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"]] self.zk.storeNode(node) 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 fc823a0ac..9a5d00c58 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.