Coverage for nova/console/rfb/auths.py: 100%
17 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-24 11:16 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-24 11:16 +0000
1# Copyright (c) 2014-2017 Red Hat, Inc
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
15from oslo_config import cfg
17from nova.console.rfb import authnone
18from nova.console.rfb import authvencrypt
19from nova import exception
21CONF = cfg.CONF
24class RFBAuthSchemeList(object):
26 AUTH_SCHEME_MAP = {
27 "none": authnone.RFBAuthSchemeNone,
28 "vencrypt": authvencrypt.RFBAuthSchemeVeNCrypt,
29 }
31 def __init__(self):
32 self.schemes = {}
34 for name in CONF.vnc.auth_schemes:
35 scheme = self.AUTH_SCHEME_MAP[name]()
37 self.schemes[scheme.security_type()] = scheme
39 def find_scheme(self, desired_types):
40 """Find a suitable authentication scheme to use with compute node.
42 Identify which of the ``desired_types`` we can accept.
44 :param desired_types: A list of ints corresponding to the various
45 authentication types supported.
46 """
47 for security_type in desired_types:
48 if security_type in self.schemes:
49 return self.schemes[security_type]
51 raise exception.RFBAuthNoAvailableScheme(
52 allowed_types=", ".join([str(s) for s in self.schemes.keys()]),
53 desired_types=", ".join([str(s) for s in desired_types]))