Merge "Code move for metadata haproxy"
This commit is contained in:
commit
cdc40d9f43
|
@ -34,6 +34,7 @@ from neutron.agent.linux import external_process
|
|||
from neutron.agent.linux import ip_lib
|
||||
from neutron.agent.linux import utils as linux_utils
|
||||
from neutron.common import coordination
|
||||
from neutron.common import metadata as comm_meta
|
||||
from neutron.common import utils as common_utils
|
||||
|
||||
|
||||
|
@ -45,29 +46,7 @@ METADATA_SERVICE_NAME = 'metadata-proxy'
|
|||
HAPROXY_SERVICE = 'haproxy'
|
||||
|
||||
PROXY_CONFIG_DIR = "ns-metadata-proxy"
|
||||
_HAPROXY_CONFIG_TEMPLATE = """
|
||||
global
|
||||
log /dev/log local0 %(log_level)s
|
||||
log-tag %(log_tag)s
|
||||
user %(user)s
|
||||
group %(group)s
|
||||
maxconn 1024
|
||||
pidfile %(pidfile)s
|
||||
daemon
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
option dontlognull
|
||||
option http-server-close
|
||||
option forwardfor
|
||||
retries 3
|
||||
timeout http-request 30s
|
||||
timeout connect 30s
|
||||
timeout client 32s
|
||||
timeout server 32s
|
||||
timeout http-keep-alive 30s
|
||||
_HAPROXY_CONFIG_TEMPLATE = comm_meta.METADATA_HAPROXY_GLOBAL + """
|
||||
|
||||
listen listener
|
||||
bind %(host)s:%(port)s
|
||||
|
@ -78,10 +57,6 @@ listen listener
|
|||
"""
|
||||
|
||||
|
||||
class InvalidUserOrGroupException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class HaproxyConfigurator(object):
|
||||
def __init__(self, network_id, router_id, unix_socket_path, host, port,
|
||||
user, group, state_path, pid_file, host_v6=None,
|
||||
|
@ -118,7 +93,7 @@ class HaproxyConfigurator(object):
|
|||
try:
|
||||
username = pwd.getpwnam(self.user).pw_name
|
||||
except KeyError:
|
||||
raise InvalidUserOrGroupException(
|
||||
raise comm_meta.InvalidUserOrGroupException(
|
||||
_("Invalid user/uid: '%s'") % self.user)
|
||||
|
||||
try:
|
||||
|
@ -127,7 +102,7 @@ class HaproxyConfigurator(object):
|
|||
try:
|
||||
groupname = grp.getgrnam(self.group).gr_name
|
||||
except KeyError:
|
||||
raise InvalidUserOrGroupException(
|
||||
raise comm_meta.InvalidUserOrGroupException(
|
||||
_("Invalid group/gid: '%s'") % self.group)
|
||||
|
||||
cfg_info = {
|
||||
|
|
|
@ -24,6 +24,7 @@ from oslo_config import cfg
|
|||
from oslo_log import log as logging
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.common import metadata as comm_meta
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -31,29 +32,7 @@ METADATA_SERVICE_NAME = 'metadata-proxy'
|
|||
HAPROXY_SERVICE = 'haproxy'
|
||||
|
||||
PROXY_CONFIG_DIR = "ovn-metadata-proxy"
|
||||
_HAPROXY_CONFIG_TEMPLATE = """
|
||||
global
|
||||
log /dev/log local0 %(log_level)s
|
||||
log-tag %(log_tag)s
|
||||
user %(user)s
|
||||
group %(group)s
|
||||
maxconn 1024
|
||||
pidfile %(pidfile)s
|
||||
daemon
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
option dontlognull
|
||||
option http-server-close
|
||||
option forwardfor
|
||||
retries 3
|
||||
timeout http-request 30s
|
||||
timeout connect 30s
|
||||
timeout client 32s
|
||||
timeout server 32s
|
||||
timeout http-keep-alive 30s
|
||||
_HAPROXY_CONFIG_TEMPLATE = comm_meta.METADATA_HAPROXY_GLOBAL + """
|
||||
|
||||
listen listener
|
||||
bind %(host)s:%(port)s
|
||||
|
@ -62,10 +41,6 @@ listen listener
|
|||
"""
|
||||
|
||||
|
||||
class InvalidUserOrGroupException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class HaproxyConfigurator(object):
|
||||
def __init__(self, network_id, router_id, unix_socket_path, host,
|
||||
port, user, group, state_path, pid_file):
|
||||
|
@ -99,7 +74,7 @@ class HaproxyConfigurator(object):
|
|||
try:
|
||||
username = pwd.getpwnam(self.user).pw_name
|
||||
except KeyError:
|
||||
raise InvalidUserOrGroupException(
|
||||
raise comm_meta.InvalidUserOrGroupException(
|
||||
_("Invalid user/uid: '%s'") % self.user)
|
||||
|
||||
try:
|
||||
|
@ -108,7 +83,7 @@ class HaproxyConfigurator(object):
|
|||
try:
|
||||
groupname = grp.getgrnam(self.group).gr_name
|
||||
except KeyError:
|
||||
raise InvalidUserOrGroupException(
|
||||
raise comm_meta.InvalidUserOrGroupException(
|
||||
_("Invalid group/gid: '%s'") % self.group)
|
||||
|
||||
cfg_info = {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
PROXY_SERVICE_NAME = 'haproxy'
|
||||
PROXY_SERVICE_CMD = 'haproxy'
|
||||
|
||||
|
||||
class InvalidUserOrGroupException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
METADATA_HAPROXY_GLOBAL = """
|
||||
global
|
||||
log /dev/log local0 %(log_level)s
|
||||
log-tag %(log_tag)s
|
||||
user %(user)s
|
||||
group %(group)s
|
||||
maxconn 1024
|
||||
pidfile %(pidfile)s
|
||||
daemon
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
option dontlognull
|
||||
option http-server-close
|
||||
option forwardfor
|
||||
retries 3
|
||||
timeout http-request 30s
|
||||
timeout connect 30s
|
||||
timeout client 32s
|
||||
timeout server 32s
|
||||
timeout http-keep-alive 30s
|
||||
"""
|
|
@ -27,6 +27,7 @@ from neutron.agent.l3 import router_info
|
|||
from neutron.agent.linux import iptables_manager
|
||||
from neutron.agent.linux import utils as linux_utils
|
||||
from neutron.agent.metadata import driver as metadata_driver
|
||||
from neutron.common import metadata as comm_meta
|
||||
from neutron.conf.agent import common as agent_config
|
||||
from neutron.conf.agent.l3 import config as l3_config
|
||||
from neutron.conf.agent.l3 import ha as ha_conf
|
||||
|
@ -218,7 +219,7 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
|||
self.EUNAME,
|
||||
self.EGNAME,
|
||||
mock.ANY, mock.ANY)
|
||||
self.assertRaises(metadata_driver.InvalidUserOrGroupException,
|
||||
self.assertRaises(comm_meta.InvalidUserOrGroupException,
|
||||
config.create_config_file)
|
||||
|
||||
def test_create_config_file_wrong_group(self):
|
||||
|
@ -231,7 +232,7 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
|||
self.EUNAME,
|
||||
self.EGNAME,
|
||||
mock.ANY, mock.ANY)
|
||||
self.assertRaises(metadata_driver.InvalidUserOrGroupException,
|
||||
self.assertRaises(comm_meta.InvalidUserOrGroupException,
|
||||
config.create_config_file)
|
||||
|
||||
def test_destroy_monitored_metadata_proxy(self):
|
||||
|
|
|
@ -22,6 +22,7 @@ from oslo_utils import uuidutils
|
|||
|
||||
from neutron.agent.ovn.metadata import agent as metadata_agent
|
||||
from neutron.agent.ovn.metadata import driver as metadata_driver
|
||||
from neutron.common import metadata as comm_meta
|
||||
from neutron.conf.agent.metadata import config as meta_conf
|
||||
from neutron.conf.agent.ovn.metadata import config as ovn_meta_conf
|
||||
from neutron.conf.plugins.ml2.drivers.ovn import ovn_conf
|
||||
|
@ -119,7 +120,7 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
|||
mock.ANY, self.EUNAME,
|
||||
self.EGNAME, mock.ANY,
|
||||
mock.ANY)
|
||||
self.assertRaises(metadata_driver.InvalidUserOrGroupException,
|
||||
self.assertRaises(comm_meta.InvalidUserOrGroupException,
|
||||
config.create_config_file)
|
||||
|
||||
def test_create_config_file_wrong_group(self):
|
||||
|
@ -131,5 +132,5 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
|||
mock.ANY, self.EUNAME,
|
||||
self.EGNAME, mock.ANY,
|
||||
mock.ANY)
|
||||
self.assertRaises(metadata_driver.InvalidUserOrGroupException,
|
||||
self.assertRaises(comm_meta.InvalidUserOrGroupException,
|
||||
config.create_config_file)
|
||||
|
|
Loading…
Reference in New Issue