Add --haproxy-service option.
This option allows the user to dynamically choose which OS services to use with the HAProxy driver. Ubuntu is the one and only option at this moment.
This commit is contained in:
@@ -19,10 +19,7 @@ from libra.worker.drivers.haproxy.services_base import ServicesBase
|
||||
|
||||
class HAProxyDriver(LoadBalancerDriver):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
ossvc='libra.worker.drivers.haproxy.ubuntu_services.UbuntuServices'
|
||||
):
|
||||
def __init__(self, ossvc):
|
||||
ossvc_driver = import_class(ossvc)
|
||||
self.ossvc = ossvc_driver()
|
||||
if not isinstance(self.ossvc, ServicesBase):
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
# Mapping of --haproxy-services options to a class
|
||||
haproxy_services = {
|
||||
'ubuntu': 'libra.worker.drivers.haproxy.ubuntu_services.UbuntuServices'
|
||||
}
|
||||
|
||||
|
||||
class ServicesBase:
|
||||
"""
|
||||
Operating system services needed by the HAProxy driver.
|
||||
|
||||
@@ -26,6 +26,7 @@ from libra.common.options import Options, setup_logging
|
||||
from libra.common.utils import import_class
|
||||
from libra.worker.controller import LBaaSController
|
||||
from libra.worker.drivers.base import known_drivers
|
||||
from libra.worker.drivers.haproxy.services_base import haproxy_services
|
||||
|
||||
|
||||
def lbaas_task(worker, job):
|
||||
@@ -115,6 +116,11 @@ def main():
|
||||
default=[],
|
||||
help='add a Gearman job server to the connection list'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--haproxy-service', dest='haproxy_service',
|
||||
choices=haproxy_services.keys(), default='ubuntu',
|
||||
help='os services to use with HAProxy driver (when used)'
|
||||
)
|
||||
args = options.run()
|
||||
|
||||
logger = setup_logging('libra_worker', args)
|
||||
@@ -136,6 +142,10 @@ def main():
|
||||
|
||||
logger.info("Selected driver: %s" % args.driver)
|
||||
driver_class = import_class(known_drivers[args.driver])
|
||||
|
||||
if args.driver == 'haproxy':
|
||||
driver = driver_class(args.haproxy_service)
|
||||
else:
|
||||
driver = driver_class()
|
||||
|
||||
logger.info("Job server list: %s" % args.server)
|
||||
|
||||
Reference in New Issue
Block a user