Documentation and pool manager configuration changes
* Add options to pool manager * Add required options tester * Improve api_server multi option handling * Make option names more sensible * Document options * Fix documentation errors Change-Id: I7a175b23ba3cf8fa40dea746901f260981e3af4c
This commit is contained in:
parent
8c24bdcb0b
commit
f69fd0f4cf
@ -30,7 +30,9 @@ Global Section
|
||||
|
||||
The ``[global]`` section contains options common to the various Libra
|
||||
utilities (worker, mgm, etc). This section is read before any other
|
||||
section, so values may be overridden by the other sections::
|
||||
section, so values may be overridden by the other sections:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[global]
|
||||
verbose = true
|
||||
@ -70,11 +72,11 @@ Pool Manager Section
|
||||
nova_region = region
|
||||
nova_keyname = default
|
||||
nova_secgroup = default
|
||||
haproxy_image = 12345
|
||||
api_servers = 10.0.0.1:8889 10.0.0.2:8889
|
||||
nova_image = 12345
|
||||
nova_image_size = 102
|
||||
api_server = 10.0.0.1:8889 10.0.0.2:8889
|
||||
nodes = 10
|
||||
check_interval = 5
|
||||
image_size = 102
|
||||
|
||||
|
||||
Worker Command Line Options
|
||||
@ -147,16 +149,34 @@ Pool Manager Command Line Options
|
||||
---------------------------------
|
||||
.. program:: libra_pool_mgm.py
|
||||
|
||||
.. option:: --api_server <HOST:PORT>
|
||||
|
||||
The hostname/IP and port colon separated for use with the HP REST API
|
||||
driver. Can be specified multiple times for multiple servers
|
||||
|
||||
.. option:: -c <FILE>, --config <FILE>
|
||||
|
||||
Load options from the specified configuration file. Command line
|
||||
options will take precedence over any options specified in the
|
||||
configuration file.
|
||||
|
||||
.. option:: --check_interval <CHECK_INTERVAL>
|
||||
|
||||
How often to check the API server to see if noew nodes are needed
|
||||
(in value is minutes)
|
||||
|
||||
.. option:: -d, --debug
|
||||
|
||||
Enable debugging output.
|
||||
|
||||
.. option:: --driver <DRIVER>
|
||||
|
||||
API driver to use. Valid driver options are:
|
||||
|
||||
* *hp_rest* - HP REST API, talks to the HP Cloud API server (based
|
||||
on Atlas API)
|
||||
This is the default driver.
|
||||
|
||||
.. option:: --group <GROUP>
|
||||
|
||||
Specifies the group for the process when run in daemon mode.
|
||||
@ -176,6 +196,43 @@ Pool Manager Command Line Options
|
||||
Do not run as a daemon. This option is useful for debugging purposes
|
||||
only as the worker is intended to be run as a daemon normally.
|
||||
|
||||
.. option:: --nodes <NODES>
|
||||
|
||||
The size of the pool of spare nodes the pool manager should keep.
|
||||
|
||||
.. option:: --nova_auth_url <NOVA_AUTH_URL>
|
||||
|
||||
The URL used to authenticate for the Nova API
|
||||
|
||||
.. option:: --nova_user <NOVA_USER>
|
||||
|
||||
The username to autenticate for the Nova API
|
||||
|
||||
.. option:: --nova_tenant <NOVA_TENANT>
|
||||
|
||||
The tenant to use for the Nova API
|
||||
|
||||
.. option:: --nova_region <NOVA_REGION>
|
||||
|
||||
The region to use for the Nova API
|
||||
|
||||
.. option:: --nova_keyname <NOVA_KEYNAME>
|
||||
|
||||
The key name to use when spinning up nodes in the Nova API
|
||||
|
||||
.. option:: --nova_secgroup <NOVA_SECGROUP>
|
||||
|
||||
The security group to use when spinning up nodes in the Nova API
|
||||
|
||||
.. option:: --nova_image <NOVA_IMAGE>
|
||||
|
||||
The image ID to use on new nodes spun up in the Nova API
|
||||
|
||||
.. option:: --nova_image_size <NOVA_IMAGE_SIZE>
|
||||
|
||||
The flavor ID (image size ID) to use for new nodes spun up in the Nova
|
||||
API
|
||||
|
||||
.. option:: -p <PID>, --pid <PID>
|
||||
|
||||
Name of the PID file to use. Default is:
|
||||
|
@ -15,7 +15,10 @@ Gearman Task
|
||||
Server Class
|
||||
------------
|
||||
|
||||
.. py:module:: libra.worker.worker
|
||||
..
|
||||
Commenting out this because it causes error, should fall through from
|
||||
previous usage
|
||||
.. py:module:: libra.worker.worker
|
||||
|
||||
.. py:class:: Server(logger, servers, reconnect_sleep)
|
||||
|
||||
@ -85,8 +88,10 @@ LoadBalancerDriver Class
|
||||
|
||||
Known Load Balancer Drivers Dictionary
|
||||
--------------------------------------
|
||||
|
||||
.. py:module:: libra.worker.drivers
|
||||
..
|
||||
Commenting out this because it causes error, should fall through from
|
||||
previous usage
|
||||
.. py:module:: libra.worker.drivers
|
||||
|
||||
.. py:data:: known_drivers
|
||||
|
||||
@ -135,4 +140,4 @@ The steps shown above are:
|
||||
* The :py:class:`~controller.LBaaSController` object then creates a response
|
||||
message and returns this message back to the Gearman worker task.
|
||||
* The Gearman worker task sends the response message back through the Gearman
|
||||
job server to the originating client (not represented above).
|
||||
job server to the originating client (not represented above).
|
||||
|
@ -44,9 +44,8 @@ nova_tenant = tenant
|
||||
nova_region = region
|
||||
nova_keyname = default
|
||||
nova_secgroup = default
|
||||
haproxy_image = 12345
|
||||
api_servers = 10.0.0.1:8889 10.0.0.2:8889
|
||||
nova_image = 12345
|
||||
nova_image_size = 102
|
||||
api_server = 10.0.0.1:8889 10.0.0.2:8889
|
||||
nodes = 10
|
||||
check_interval = 5
|
||||
# 100 - xsmall, 101 - small, 102 - medium
|
||||
image_size = 102
|
||||
|
@ -25,7 +25,6 @@ API_VERSION = 'v1'
|
||||
class HPRestDriver(MgmDriver):
|
||||
|
||||
def __init__(self, addresses, logger):
|
||||
addresses = addresses.split(' ')
|
||||
self.logger = logger
|
||||
random.shuffle(addresses)
|
||||
for address in addresses:
|
||||
|
@ -19,6 +19,7 @@ import pwd
|
||||
import signal
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import threading
|
||||
|
||||
from libra.openstack.common import importutils
|
||||
@ -53,6 +54,9 @@ class Server(object):
|
||||
'Scheduling node check for {check} minutes'
|
||||
.format(check=self.args.check_interval)
|
||||
)
|
||||
# NOTE(LinuxJedi): Threading lock is for the case in the future where
|
||||
# we need two timers, we don't want them to both execute their trigger
|
||||
# at the same time.
|
||||
self.rlock = threading.RLock()
|
||||
self.check_nodes()
|
||||
while True:
|
||||
@ -62,7 +66,7 @@ class Server(object):
|
||||
""" check if known nodes are used """
|
||||
with self.rlock:
|
||||
self.logger.info('Checking if new nodes are needed')
|
||||
api = self.driver_class(self.args.api_servers, self.logger)
|
||||
api = self.driver_class(self.args.api_server, self.logger)
|
||||
if api.is_online():
|
||||
self.logger.info(
|
||||
'Connected to {url}'.format(url=api.get_url())
|
||||
@ -143,6 +147,10 @@ class Server(object):
|
||||
|
||||
def main():
|
||||
options = Options('mgm', 'Node Management Daemon')
|
||||
options.parser.add_argument(
|
||||
'--api_server', action='append', metavar='HOST:POST',
|
||||
help='a list of API servers to connect to (for HP REST API driver)'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nodes', type=int, default=1,
|
||||
help='number of nodes'
|
||||
@ -156,8 +164,69 @@ def main():
|
||||
choices=known_drivers.keys(), default='hp_rest',
|
||||
help='type of device to use'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_auth_url',
|
||||
help='the auth URL for the Nova API'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_user',
|
||||
help='the username for the Nova API'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_region',
|
||||
help='the region to use for the Nova API'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_tenant',
|
||||
help='the tenant for the Nova API'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_keyname',
|
||||
help='the key name for new nodes spun up in the Nova API'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_secgroup',
|
||||
help='the security group for new nodes spun up in the Nova API'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_image',
|
||||
help='the image ID to use for new nodes spun up in the Nova API'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--nova_image_size',
|
||||
help='the image size ID (flavor ID) to use for new nodes spun up in'
|
||||
' the Nova API'
|
||||
)
|
||||
|
||||
args = options.run()
|
||||
|
||||
required_args = [
|
||||
'nova_image', 'nova_image_size', 'nova_secgroup', 'nova_keyname',
|
||||
'nova_tenant', 'nova_region', 'nova_user', 'nova_auth_url'
|
||||
]
|
||||
|
||||
# NOTE(LinuxJedi): We are checking for required args here because the
|
||||
# parser can't yet check both command line and config file to see if an
|
||||
# option has been set
|
||||
for req in required_args:
|
||||
test_var = getattr(args, req)
|
||||
if test_var is None:
|
||||
sys.stderr.write(
|
||||
'{app}: error: argument --{test_var} is required\n'
|
||||
.format(app=os.path.basename(sys.argv[0]), test_var=req))
|
||||
return 2
|
||||
|
||||
if not args.api_server:
|
||||
# NOTE(shrews): Can't set a default in argparse method because the
|
||||
# value is appended to the specified default.
|
||||
args.api_server.append('localhost:8889')
|
||||
elif not isinstance(args.api_server, list):
|
||||
# NOTE(shrews): The Options object cannot intelligently handle
|
||||
# creating a list from an option that may have multiple values.
|
||||
# We convert it to the expected type here.
|
||||
svr_list = args.api_server.split()
|
||||
args.api_server = svr_list
|
||||
|
||||
logger = setup_logging('libra_mgm', args)
|
||||
server = Server(logger, args)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user