Merge "Add new options to HealthMonitor CLI"
This commit is contained in:
commit
9f0c348b0d
@ -213,7 +213,9 @@ MONITOR_ROWS = (
|
|||||||
'url_path',
|
'url_path',
|
||||||
'type',
|
'type',
|
||||||
'id',
|
'id',
|
||||||
'operating_status'
|
'operating_status',
|
||||||
|
'http_version',
|
||||||
|
'domain_name'
|
||||||
)
|
)
|
||||||
|
|
||||||
MONITOR_COLUMNS = (
|
MONITOR_COLUMNS = (
|
||||||
|
@ -24,6 +24,7 @@ from octaviaclient.osc.v2 import utils as v2_utils
|
|||||||
|
|
||||||
HTTP_METHODS = ['GET', 'POST', 'DELETE', 'PUT', 'HEAD', 'OPTIONS', 'PATCH',
|
HTTP_METHODS = ['GET', 'POST', 'DELETE', 'PUT', 'HEAD', 'OPTIONS', 'PATCH',
|
||||||
'CONNECT', 'TRACE']
|
'CONNECT', 'TRACE']
|
||||||
|
HTTP_VERSIONS = [1.0, 1.1]
|
||||||
TYPE_CHOICES = ['PING', 'HTTP', 'TCP', 'HTTPS', 'TLS-HELLO',
|
TYPE_CHOICES = ['PING', 'HTTP', 'TCP', 'HTTPS', 'TLS-HELLO',
|
||||||
'UDP-CONNECT']
|
'UDP-CONNECT']
|
||||||
|
|
||||||
@ -50,6 +51,12 @@ class CreateHealthMonitor(command.ShowOne):
|
|||||||
required=True,
|
required=True,
|
||||||
help="Set the time in seconds, between sending probes to members."
|
help="Set the time in seconds, between sending probes to members."
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--domain-name',
|
||||||
|
metavar='<domain_name>',
|
||||||
|
help=("Set the domain name, which be injected into the HTTP Host "
|
||||||
|
"Header to the backend server for HTTP health check.")
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--expected-codes',
|
'--expected-codes',
|
||||||
metavar='<codes>',
|
metavar='<codes>',
|
||||||
@ -64,6 +71,13 @@ class CreateHealthMonitor(command.ShowOne):
|
|||||||
help="Set the HTTP method that the health monitor uses for "
|
help="Set the HTTP method that the health monitor uses for "
|
||||||
"requests."
|
"requests."
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--http-version',
|
||||||
|
metavar='<http_version>',
|
||||||
|
choices=HTTP_VERSIONS,
|
||||||
|
type=float,
|
||||||
|
help="Set the HTTP version."
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--timeout',
|
'--timeout',
|
||||||
metavar='<timeout>',
|
metavar='<timeout>',
|
||||||
@ -231,6 +245,12 @@ class SetHealthMonitor(command.Command):
|
|||||||
metavar='<delay>',
|
metavar='<delay>',
|
||||||
help="Set the time in seconds, between sending probes to members."
|
help="Set the time in seconds, between sending probes to members."
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--domain-name',
|
||||||
|
metavar='<domain_name>',
|
||||||
|
help=("Set the domain name, which be injected into the HTTP Host "
|
||||||
|
"Header to the backend server for HTTP health check.")
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--expected-codes',
|
'--expected-codes',
|
||||||
metavar='<codes>',
|
metavar='<codes>',
|
||||||
@ -245,6 +265,13 @@ class SetHealthMonitor(command.Command):
|
|||||||
help="Set the HTTP method that the health monitor uses for "
|
help="Set the HTTP method that the health monitor uses for "
|
||||||
"requests."
|
"requests."
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--http-version',
|
||||||
|
metavar='<http_version>',
|
||||||
|
choices=HTTP_VERSIONS,
|
||||||
|
type=float,
|
||||||
|
help="Set the HTTP version."
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--timeout',
|
'--timeout',
|
||||||
metavar='<timeout>',
|
metavar='<timeout>',
|
||||||
|
@ -411,7 +411,9 @@ def get_health_monitor_attrs(client_manager, parsed_args):
|
|||||||
'max_retries_down': ('max_retries_down', int),
|
'max_retries_down': ('max_retries_down', int),
|
||||||
'url_path': ('url_path', str),
|
'url_path': ('url_path', str),
|
||||||
'enable': ('admin_state_up', lambda x: True),
|
'enable': ('admin_state_up', lambda x: True),
|
||||||
'disable': ('admin_state_up', lambda x: False)
|
'disable': ('admin_state_up', lambda x: False),
|
||||||
|
'http_version': ('http_version', float),
|
||||||
|
'domain_name': ('domain_name', str)
|
||||||
}
|
}
|
||||||
|
|
||||||
_attrs = vars(parsed_args)
|
_attrs = vars(parsed_args)
|
||||||
|
@ -52,6 +52,8 @@ HM_ATTRS = {
|
|||||||
"url_path": "/some/custom/path",
|
"url_path": "/some/custom/path",
|
||||||
"type": "HTTP",
|
"type": "HTTP",
|
||||||
"id": uuidutils.generate_uuid(dashed=True),
|
"id": uuidutils.generate_uuid(dashed=True),
|
||||||
|
"http_version": 1.1,
|
||||||
|
"domain_name": "testlab.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
LISTENER_ATTRS = {
|
LISTENER_ATTRS = {
|
||||||
|
@ -109,7 +109,9 @@ class TestHealthMonitorCreate(TestHealthMonitor):
|
|||||||
'--timeout', str(self._hm.timeout),
|
'--timeout', str(self._hm.timeout),
|
||||||
'--max-retries', str(self._hm.max_retries),
|
'--max-retries', str(self._hm.max_retries),
|
||||||
'--type', self._hm.type.lower(),
|
'--type', self._hm.type.lower(),
|
||||||
'--http-method', self._hm.http_method.lower()]
|
'--http-method', self._hm.http_method.lower(),
|
||||||
|
'--http-version', str(self._hm.http_version),
|
||||||
|
'--domain-name', self._hm.domain_name]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('pool', 'mock_pool_id'),
|
('pool', 'mock_pool_id'),
|
||||||
('name', self._hm.name),
|
('name', self._hm.name),
|
||||||
@ -118,6 +120,8 @@ class TestHealthMonitorCreate(TestHealthMonitor):
|
|||||||
('max_retries', self._hm.max_retries),
|
('max_retries', self._hm.max_retries),
|
||||||
('type', self._hm.type),
|
('type', self._hm.type),
|
||||||
('http_method', self._hm.http_method),
|
('http_method', self._hm.http_method),
|
||||||
|
('http_version', self._hm.http_version),
|
||||||
|
('domain_name', self._hm.domain_name)
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -157,13 +161,19 @@ class TestHealthMonitorSet(TestHealthMonitor):
|
|||||||
self.cmd = health_monitor.SetHealthMonitor(self.app, None)
|
self.cmd = health_monitor.SetHealthMonitor(self.app, None)
|
||||||
|
|
||||||
def test_health_monitor_set(self):
|
def test_health_monitor_set(self):
|
||||||
arglist = [self._hm.id, '--name', 'new_name']
|
arglist = [self._hm.id, '--name', 'new_name',
|
||||||
|
'--http-version', str(self._hm.http_version),
|
||||||
|
'--domain-name', self._hm.domain_name]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('health_monitor', self._hm.id),
|
('health_monitor', self._hm.id),
|
||||||
('name', 'new_name')
|
('name', 'new_name'),
|
||||||
|
('http_version', self._hm.http_version),
|
||||||
|
('domain_name', self._hm.domain_name)
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.api_mock.health_monitor_set.assert_called_with(
|
self.api_mock.health_monitor_set.assert_called_with(
|
||||||
self._hm.id, json={'healthmonitor': {'name': 'new_name'}})
|
self._hm.id, json={'healthmonitor': {
|
||||||
|
'name': 'new_name', 'http_version': self._hm.http_version,
|
||||||
|
'domain_name': self._hm.domain_name}})
|
||||||
|
Loading…
Reference in New Issue
Block a user