Validate ovn_nb/sb_connection in config parser
... to detect invalid format early and return explicit error to users. Because these options accept comma-separated strings, use ListOpt to parse multiple items by the common implementation, instead of building own regex. Change-Id: I1546a2826741a0703c0673fcffeddb2356fb10f5
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
from keystoneauth1 import loading as ks_loading
|
from keystoneauth1 import loading as ks_loading
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_config import types
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from ovn_octavia_provider.i18n import _
|
from ovn_octavia_provider.i18n import _
|
||||||
@@ -20,8 +21,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
ovn_opts = [
|
ovn_opts = [
|
||||||
cfg.StrOpt('ovn_nb_connection',
|
cfg.ListOpt('ovn_nb_connection',
|
||||||
default='tcp:127.0.0.1:6641',
|
default=['tcp:127.0.0.1:6641'],
|
||||||
|
item_type=types.String(regex=r'^(tcp|ssl|unix):.+'),
|
||||||
help=_('The connection string for the OVN_Northbound OVSDB.\n'
|
help=_('The connection string for the OVN_Northbound OVSDB.\n'
|
||||||
'Use tcp:IP:PORT for TCP connection.\n'
|
'Use tcp:IP:PORT for TCP connection.\n'
|
||||||
'Use ssl:IP:PORT for SSL connection. The '
|
'Use ssl:IP:PORT for SSL connection. The '
|
||||||
@@ -40,8 +42,9 @@ ovn_opts = [
|
|||||||
default='',
|
default='',
|
||||||
help=_('The PEM file with CA certificate that OVN should use to'
|
help=_('The PEM file with CA certificate that OVN should use to'
|
||||||
' verify certificates presented to it by SSL peers')),
|
' verify certificates presented to it by SSL peers')),
|
||||||
cfg.StrOpt('ovn_sb_connection',
|
cfg.ListOpt('ovn_sb_connection',
|
||||||
default='tcp:127.0.0.1:6642',
|
default=['tcp:127.0.0.1:6642'],
|
||||||
|
item_type=types.String(regex=r'^(tcp|ssl|unix):.+'),
|
||||||
help=_('The connection string for the OVN_Southbound OVSDB.\n'
|
help=_('The connection string for the OVN_Southbound OVSDB.\n'
|
||||||
'Use tcp:IP:PORT for TCP connection.\n'
|
'Use tcp:IP:PORT for TCP connection.\n'
|
||||||
'Use ssl:IP:PORT for SSL connection. The '
|
'Use ssl:IP:PORT for SSL connection. The '
|
||||||
@@ -176,7 +179,7 @@ def list_opts():
|
|||||||
|
|
||||||
|
|
||||||
def get_ovn_nb_connection():
|
def get_ovn_nb_connection():
|
||||||
return cfg.CONF.ovn.ovn_nb_connection
|
return ','.join(cfg.CONF.ovn.ovn_nb_connection)
|
||||||
|
|
||||||
|
|
||||||
def get_ovn_nb_private_key():
|
def get_ovn_nb_private_key():
|
||||||
@@ -192,7 +195,7 @@ def get_ovn_nb_ca_cert():
|
|||||||
|
|
||||||
|
|
||||||
def get_ovn_sb_connection():
|
def get_ovn_sb_connection():
|
||||||
return cfg.CONF.ovn.ovn_sb_connection
|
return ','.join(cfg.CONF.ovn.ovn_sb_connection)
|
||||||
|
|
||||||
|
|
||||||
def get_ovn_sb_private_key():
|
def get_ovn_sb_private_key():
|
||||||
|
|||||||
Reference in New Issue
Block a user