String conversion to f-strings
Ran `flynt octavia` in order to replace old style string format with f-strings. Manually corrected lines that got too long and some occurences that were not converted to f-strings. Change-Id: I228a78baf2f4b6c47229d7dce1fcd81ef27c0030
This commit is contained in:
@@ -129,7 +129,7 @@ class AmphoraInfo:
|
||||
extend_data = {}
|
||||
for extend in extend_info:
|
||||
package_version = self._get_version_of_installed_package(extend)
|
||||
extend_data['%s_version' % extend] = package_version
|
||||
extend_data[f'{extend}_version'] = package_version
|
||||
return extend_data
|
||||
|
||||
def _get_meminfo(self):
|
||||
|
||||
@@ -138,7 +138,7 @@ class KeepalivedLvs(lvs_listener_base.LvsListenerApiServerBase):
|
||||
# Make sure the keepalivedlvs service is enabled on boot
|
||||
if init_system == consts.INIT_SYSTEMD:
|
||||
util.run_systemctl_command(
|
||||
consts.ENABLE, "octavia-keepalivedlvs-%s" % str(listener_id))
|
||||
consts.ENABLE, f"octavia-keepalivedlvs-{str(listener_id)}")
|
||||
elif init_system == consts.INIT_SYSVINIT:
|
||||
init_enable_cmd = f"insserv {file_path}"
|
||||
try:
|
||||
@@ -316,8 +316,8 @@ class KeepalivedLvs(lvs_listener_base.LvsListenerApiServerBase):
|
||||
"%(err)s", {'list': listener_id, 'err': str(e)})
|
||||
return webob.Response(json={
|
||||
'message': (
|
||||
"Error disabling octavia-keepalivedlvs-"
|
||||
"{} service".format(listener_id)),
|
||||
f"Error disabling octavia-keepalivedlvs-{listener_id} "
|
||||
f"service"),
|
||||
'details': e.output}, status=500)
|
||||
|
||||
elif init_system != consts.INIT_UPSTART:
|
||||
|
||||
@@ -129,9 +129,8 @@ class Loadbalancer:
|
||||
file.write(new_config)
|
||||
|
||||
# use haproxy to check the config
|
||||
cmd = "haproxy -c -L {peer} -f {config_file} -f {haproxy_ug}".format(
|
||||
config_file=name, peer=peer_name,
|
||||
haproxy_ug=consts.HAPROXY_USER_GROUP_CFG)
|
||||
cmd = (f"haproxy -c -L {peer_name} -f {name} -f "
|
||||
f"{consts.HAPROXY_USER_GROUP_CFG}")
|
||||
|
||||
try:
|
||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||
@@ -282,8 +281,7 @@ class Loadbalancer:
|
||||
else 1)
|
||||
saved_exc = None
|
||||
for idx in range(retries):
|
||||
cmd = ("/usr/sbin/service haproxy-{lb_id} {action}".format(
|
||||
lb_id=lb_id, action=action))
|
||||
cmd = f"/usr/sbin/service haproxy-{lb_id} {action}"
|
||||
|
||||
try:
|
||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||
@@ -338,12 +336,10 @@ class Loadbalancer:
|
||||
consts.AMP_ACTION_RELOAD]:
|
||||
return webob.Response(json={
|
||||
'message': 'OK',
|
||||
'details': 'Listener {lb_id} {action}ed'.format(
|
||||
lb_id=lb_id, action=action)}, status=202)
|
||||
'details': f'Listener {lb_id} {action}ed'}, status=202)
|
||||
|
||||
details = (
|
||||
'Configuration file is valid\n'
|
||||
'haproxy daemon for {} started'.format(lb_id)
|
||||
f'Configuration file is valid\nhaproxy daemon for {lb_id} started'
|
||||
)
|
||||
|
||||
return webob.Response(json={'message': 'OK', 'details': details},
|
||||
@@ -394,9 +390,7 @@ class Loadbalancer:
|
||||
|
||||
if init_system == consts.INIT_SYSTEMD:
|
||||
util.run_systemctl_command(
|
||||
consts.DISABLE, "haproxy-{lb_id}".format(
|
||||
lb_id=lb_id))
|
||||
|
||||
consts.DISABLE, f"haproxy-{lb_id}")
|
||||
elif init_system == consts.INIT_SYSVINIT:
|
||||
init_disable_cmd = f"insserv -r {init_path}"
|
||||
try:
|
||||
@@ -475,8 +469,8 @@ class Loadbalancer:
|
||||
if not path_exists:
|
||||
return webob.Response(json={
|
||||
'message': 'Certificate Not Found',
|
||||
'details': "No certificate with filename: {f}".format(
|
||||
f=filename)}, status=404)
|
||||
'details': f"No certificate with filename: {filename}"},
|
||||
status=404)
|
||||
|
||||
with open(cert_path, encoding='utf-8') as crt_file:
|
||||
cert = crt_file.read()
|
||||
@@ -512,8 +506,8 @@ class Loadbalancer:
|
||||
raise exceptions.HTTPException(
|
||||
response=webob.Response(json={
|
||||
'message': 'Loadbalancer Not Found',
|
||||
'details': "No loadbalancer with UUID: {}".format(
|
||||
lb_id)}, status=404))
|
||||
'details': f"No loadbalancer with UUID: {lb_id}"},
|
||||
status=404))
|
||||
|
||||
def _check_ssl_filename_format(self, filename):
|
||||
# check if the format is (xxx.)*xxx.pem
|
||||
|
||||
@@ -239,8 +239,7 @@ class Plug:
|
||||
|
||||
return webob.Response(json={
|
||||
'message': "OK",
|
||||
'details': "Plugged on interface {interface}".format(
|
||||
interface=netns_interface)}, status=202)
|
||||
'details': f"Plugged on interface {netns_interface}"}, status=202)
|
||||
|
||||
def _interface_by_mac(self, mac):
|
||||
try:
|
||||
@@ -277,8 +276,7 @@ class Plug:
|
||||
with os.fdopen(os.open(plug_inf_file, flags, mode), 'r+') as text_file:
|
||||
inf_list = [inf.split()[0].rstrip() for inf in text_file]
|
||||
if mac_address not in inf_list:
|
||||
text_file.write("{mac_address} {interface}\n".format(
|
||||
mac_address=mac_address, interface=interface))
|
||||
text_file.write(f"{mac_address} {interface}\n")
|
||||
|
||||
def _netns_interface_by_mac(self, mac_address):
|
||||
with pyroute2.NetNS(consts.AMPHORA_NAMESPACE,
|
||||
|
||||
@@ -92,15 +92,14 @@ def keepalived_lvs_pids_path(listener_id):
|
||||
for file_ext in ['pid', 'vrrp.pid', 'check.pid']:
|
||||
pids_path[file_ext] = (
|
||||
os.path.join(CONF.haproxy_amphora.base_path,
|
||||
('lvs/octavia-keepalivedlvs-%s.%s') %
|
||||
(str(listener_id), file_ext)))
|
||||
f"lvs/octavia-keepalivedlvs-{str(listener_id)}."
|
||||
f"{file_ext}"))
|
||||
return pids_path['pid'], pids_path['vrrp.pid'], pids_path['check.pid']
|
||||
|
||||
|
||||
def keepalived_lvs_cfg_path(listener_id):
|
||||
return os.path.join(CONF.haproxy_amphora.base_path,
|
||||
('lvs/octavia-keepalivedlvs-%s.conf') %
|
||||
str(listener_id))
|
||||
f"lvs/octavia-keepalivedlvs-{str(listener_id)}.conf")
|
||||
|
||||
|
||||
def haproxy_dir(lb_id):
|
||||
@@ -363,7 +362,7 @@ def vrrp_check_script_update(lb_id, action):
|
||||
for lbid in lb_ids:
|
||||
args.append(haproxy_sock_path(lbid))
|
||||
|
||||
cmd = 'haproxy-vrrp-check {args}; exit $?'.format(args=' '.join(args))
|
||||
cmd = f"haproxy-vrrp-check {' '.join(args)}; exit $?"
|
||||
with open(haproxy_check_script_path(), 'w', encoding='utf-8') as text_file:
|
||||
text_file.write(cmd)
|
||||
|
||||
|
||||
@@ -95,10 +95,7 @@ class HAProxyQuery:
|
||||
"""
|
||||
|
||||
results = self._query(
|
||||
'show stat {proxy_iid} {object_type} {server_id}'.format(
|
||||
proxy_iid=proxy_iid,
|
||||
object_type=object_type,
|
||||
server_id=server_id))
|
||||
f'show stat {proxy_iid} {object_type} {server_id}')
|
||||
list_results = results[2:].split('\n')
|
||||
csv_reader = csv.DictReader(list_results)
|
||||
stats_list = list(csv_reader)
|
||||
|
||||
@@ -106,8 +106,7 @@ class InterfaceController:
|
||||
def _dhclient_up(self, interface_name):
|
||||
cmd = ["/sbin/dhclient",
|
||||
"-lf",
|
||||
"/var/lib/dhclient/dhclient-{}.leases".format(
|
||||
interface_name),
|
||||
f"/var/lib/dhclient/dhclient-{interface_name}.leases",
|
||||
"-pf",
|
||||
f"/run/dhclient-{interface_name}.pid",
|
||||
interface_name]
|
||||
@@ -118,8 +117,7 @@ class InterfaceController:
|
||||
cmd = ["/sbin/dhclient",
|
||||
"-r",
|
||||
"-lf",
|
||||
"/var/lib/dhclient/dhclient-{}.leases".format(
|
||||
interface_name),
|
||||
f"/var/lib/dhclient/dhclient-{interface_name}.leases",
|
||||
"-pf",
|
||||
f"/run/dhclient-{interface_name}.pid",
|
||||
interface_name]
|
||||
@@ -134,8 +132,7 @@ class InterfaceController:
|
||||
('autoconf', 1)):
|
||||
cmd = ["/sbin/sysctl",
|
||||
"-w",
|
||||
"net.ipv6.conf.{}.{}={}".format(interface_name,
|
||||
key, value)]
|
||||
f"net.ipv6.conf.{interface_name}.{key}={value}"]
|
||||
LOG.debug("Running '%s'", cmd)
|
||||
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
||||
|
||||
@@ -144,8 +141,7 @@ class InterfaceController:
|
||||
('autoconf', 0)):
|
||||
cmd = ["/sbin/sysctl",
|
||||
"-w",
|
||||
"net.ipv6.conf.{}.{}={}".format(interface_name,
|
||||
key, value)]
|
||||
f"net.ipv6.conf.{interface_name}.{key}={value}"]
|
||||
LOG.debug("Running '%s'", cmd)
|
||||
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
||||
|
||||
@@ -305,8 +301,8 @@ class InterfaceController:
|
||||
'RTA_DST',
|
||||
'0.0.0.0' if family == socket.AF_INET else '::') # nosec
|
||||
|
||||
key = ("{}/{}".format(self._normalize_ip_address(dst),
|
||||
route.get('dst_len', 0)),
|
||||
key = (f"{self._normalize_ip_address(dst)}/"
|
||||
f"{route.get('dst_len', 0)}",
|
||||
self._normalize_ip_address(attrs.get('RTA_GATEWAY')),
|
||||
self._normalize_ip_address(attrs.get('RTA_PREFSRC')),
|
||||
attrs.get('RTA_TABLE'))
|
||||
|
||||
@@ -168,7 +168,7 @@ class VIPInterfaceFile(InterfaceFile):
|
||||
})
|
||||
|
||||
vip_cidr = ipaddress.ip_network(
|
||||
"{}/{}".format(vip['ip_address'], vip['prefixlen']),
|
||||
f"{vip['ip_address']}/{vip['prefixlen']}",
|
||||
strict=False)
|
||||
self.routes.append({
|
||||
consts.DST: vip_cidr.exploded,
|
||||
|
||||
@@ -80,7 +80,7 @@ def calculate_icmpv6_checksum(packet):
|
||||
|
||||
# Add up 16-bit words
|
||||
num_words = len(packet) // 2
|
||||
for chunk in struct.unpack("!%sH" % num_words, packet[0:num_words * 2]):
|
||||
for chunk in struct.unpack(f"!{num_words}H", packet[0:num_words * 2]):
|
||||
total += chunk
|
||||
|
||||
# Add any left over byte
|
||||
|
||||
@@ -42,8 +42,7 @@ CHECKER_REGEX = re.compile(r"(MISC_CHECK|HTTP_GET|TCP_CHECK)")
|
||||
|
||||
|
||||
def read_kernel_file(ns_name, file_path):
|
||||
cmd = ("ip netns exec {ns} cat {lvs_stat_path}".format(
|
||||
ns=ns_name, lvs_stat_path=file_path))
|
||||
cmd = f"ip netns exec {ns_name} cat {file_path}"
|
||||
try:
|
||||
output = subprocess.check_output(cmd.split(),
|
||||
stderr=subprocess.STDOUT)
|
||||
@@ -75,12 +74,12 @@ def get_listener_realserver_mapping(ns_name, listener_ip_ports,
|
||||
ip_obj = ipaddress.ip_address(listener_ip.strip('[]'))
|
||||
output = read_kernel_file(ns_name, KERNEL_LVS_PATH).split('\n')
|
||||
if ip_obj.version == 4:
|
||||
ip_to_hex_format = "%.8X" % ip_obj._ip
|
||||
ip_to_hex_format = f"{ip_obj._ip:08X}"
|
||||
else:
|
||||
ip_to_hex_format = r'\[' + ip_obj.exploded + r'\]'
|
||||
port_hex_format = "%.4X" % int(listener_port)
|
||||
port_hex_format = f"{int(listener_port):04X}"
|
||||
idex_list.append(ip_to_hex_format + ':' + port_hex_format)
|
||||
idex = "({})".format("|".join(idex_list))
|
||||
idex = f"({'|'.join(idex_list)})"
|
||||
|
||||
if health_monitor_enabled:
|
||||
member_status = constants.UP
|
||||
@@ -192,7 +191,7 @@ def get_lvs_listener_resource_ipports_nsname(listener_id):
|
||||
for resource_type, resource_id in resource_type_ids:
|
||||
value = {'id': resource_id}
|
||||
if resource_type == 'Member':
|
||||
resource_type = '%ss' % resource_type
|
||||
resource_type = f'{resource_type}s'
|
||||
if resource_type not in resource_ipport_mapping:
|
||||
value = [value]
|
||||
if resource_type not in resource_ipport_mapping:
|
||||
|
||||
@@ -625,7 +625,7 @@ class CustomHostNameCheckingAdapter(requests.adapters.HTTPAdapter):
|
||||
|
||||
def init_poolmanager(self, *pool_args, **pool_kwargs):
|
||||
proto = CONF.amphora_agent.agent_tls_protocol.replace('.', '_')
|
||||
pool_kwargs['ssl_version'] = getattr(ssl, "PROTOCOL_%s" % proto)
|
||||
pool_kwargs['ssl_version'] = getattr(ssl, f"PROTOCOL_{proto}")
|
||||
return super().init_poolmanager(*pool_args, **pool_kwargs)
|
||||
|
||||
|
||||
@@ -646,19 +646,13 @@ class AmphoraAPIClientBase:
|
||||
|
||||
def _base_url(self, ip, api_version=None):
|
||||
if utils.is_ipv6_lla(ip):
|
||||
ip = '[{ip}%{interface}]'.format(
|
||||
ip=ip,
|
||||
interface=CONF.haproxy_amphora.lb_network_interface)
|
||||
ip = f'[{ip}%{CONF.haproxy_amphora.lb_network_interface}]'
|
||||
elif utils.is_ipv6(ip):
|
||||
ip = f'[{ip}]'
|
||||
if api_version:
|
||||
return "https://{ip}:{port}/{version}/".format(
|
||||
ip=ip,
|
||||
port=CONF.haproxy_amphora.bind_port,
|
||||
version=api_version)
|
||||
return "https://{ip}:{port}/".format(
|
||||
ip=ip,
|
||||
port=CONF.haproxy_amphora.bind_port)
|
||||
return (f"https://{ip}:{CONF.haproxy_amphora.bind_port}"
|
||||
f"/{api_version}/")
|
||||
return f"https://{ip}:{CONF.haproxy_amphora.bind_port}/"
|
||||
|
||||
def request(self, method: str, amp: db_models.Amphora, path: str = '/',
|
||||
timeout_dict: Optional[dict] = None,
|
||||
@@ -774,8 +768,7 @@ class AmphoraAPIClient1_0(AmphoraAPIClientBase):
|
||||
def upload_config(self, amp, loadbalancer_id, config, timeout_dict=None):
|
||||
r = self.put(
|
||||
amp,
|
||||
'loadbalancer/{amphora_id}/{loadbalancer_id}/haproxy'.format(
|
||||
amphora_id=amp.id, loadbalancer_id=loadbalancer_id),
|
||||
f'loadbalancer/{amp.id}/{loadbalancer_id}/haproxy',
|
||||
timeout_dict, data=config)
|
||||
return exc.check_exception(r)
|
||||
|
||||
@@ -789,16 +782,14 @@ class AmphoraAPIClient1_0(AmphoraAPIClientBase):
|
||||
|
||||
def _action(self, action, amp, object_id, timeout_dict=None):
|
||||
r = self.put(
|
||||
amp, 'loadbalancer/{object_id}/{action}'.format(
|
||||
object_id=object_id, action=action),
|
||||
amp, f'loadbalancer/{object_id}/{action}',
|
||||
timeout_dict=timeout_dict)
|
||||
return exc.check_exception(r)
|
||||
|
||||
def upload_cert_pem(self, amp, loadbalancer_id, pem_filename, pem_file):
|
||||
r = self.put(
|
||||
amp,
|
||||
'loadbalancer/{loadbalancer_id}/certificates/{filename}'.format(
|
||||
loadbalancer_id=loadbalancer_id, filename=pem_filename),
|
||||
f'loadbalancer/{loadbalancer_id}/certificates/{pem_filename}',
|
||||
data=pem_file)
|
||||
return exc.check_exception(r)
|
||||
|
||||
@@ -806,8 +797,7 @@ class AmphoraAPIClient1_0(AmphoraAPIClientBase):
|
||||
ignore=tuple()):
|
||||
r = self.get(
|
||||
amp,
|
||||
'loadbalancer/{loadbalancer_id}/certificates/{filename}'.format(
|
||||
loadbalancer_id=loadbalancer_id, filename=pem_filename))
|
||||
f'loadbalancer/{loadbalancer_id}/certificates/{pem_filename}')
|
||||
if exc.check_exception(r, ignore):
|
||||
return r.json().get("md5sum")
|
||||
return None
|
||||
@@ -815,8 +805,7 @@ class AmphoraAPIClient1_0(AmphoraAPIClientBase):
|
||||
def delete_cert_pem(self, amp, loadbalancer_id, pem_filename):
|
||||
r = self.delete(
|
||||
amp,
|
||||
'loadbalancer/{loadbalancer_id}/certificates/{filename}'.format(
|
||||
loadbalancer_id=loadbalancer_id, filename=pem_filename))
|
||||
f'loadbalancer/{loadbalancer_id}/certificates/{pem_filename}')
|
||||
return exc.check_exception(r, (404,))
|
||||
|
||||
def update_cert_for_rotation(self, amp, pem_file):
|
||||
@@ -877,8 +866,7 @@ class AmphoraAPIClient1_0(AmphoraAPIClientBase):
|
||||
def upload_udp_config(self, amp, listener_id, config, timeout_dict=None):
|
||||
r = self.put(
|
||||
amp,
|
||||
'listeners/{amphora_id}/{listener_id}/udp_listener'.format(
|
||||
amphora_id=amp.id, listener_id=listener_id), timeout_dict,
|
||||
f'listeners/{amp.id}/{listener_id}/udp_listener', timeout_dict,
|
||||
data=config)
|
||||
return exc.check_exception(r)
|
||||
|
||||
|
||||
@@ -142,40 +142,34 @@ class PaginationHelper:
|
||||
|
||||
def _make_links(self, model_list):
|
||||
if CONF.api_settings.api_base_uri:
|
||||
path_url = "{api_base_url}{path}".format(
|
||||
api_base_url=CONF.api_settings.api_base_uri.rstrip('/'),
|
||||
path=request.path)
|
||||
path_url = (f"{CONF.api_settings.api_base_uri.rstrip('/')}"
|
||||
f"{request.path}")
|
||||
else:
|
||||
path_url = request.path_url
|
||||
links = []
|
||||
if model_list:
|
||||
prev_attr = [f"limit={self.limit}"]
|
||||
if self.params.get('sort'):
|
||||
prev_attr.append("sort={}".format(self.params.get('sort')))
|
||||
prev_attr.append(f"sort={self.params.get('sort')}")
|
||||
if self.params.get('sort_key'):
|
||||
prev_attr.append("sort_key={}".format(
|
||||
self.params.get('sort_key')))
|
||||
prev_attr.append(f"sort_key={self.params.get('sort_key')}")
|
||||
next_attr = copy.copy(prev_attr)
|
||||
if self.marker:
|
||||
prev_attr.append("marker={}".format(model_list[0].get('id')))
|
||||
prev_attr.append(f"marker={model_list[0].get('id')}")
|
||||
prev_attr.append("page_reverse=True")
|
||||
prev_link = {
|
||||
"rel": "previous",
|
||||
"href": "{url}?{params}".format(
|
||||
url=path_url,
|
||||
params="&".join(prev_attr))
|
||||
"href": f"{path_url}?{'&'.join(prev_attr)}"
|
||||
}
|
||||
links.append(prev_link)
|
||||
# TODO(rm_work) Do we need to know when there are more vs exact?
|
||||
# We safely know if we have a full page, but it might include the
|
||||
# last element or it might not, it is unclear
|
||||
if self.limit is None or len(model_list) >= self.limit:
|
||||
next_attr.append("marker={}".format(model_list[-1].get('id')))
|
||||
next_attr.append(f"marker={model_list[-1].get('id')}")
|
||||
next_link = {
|
||||
"rel": "next",
|
||||
"href": "{url}?{params}".format(
|
||||
url=path_url,
|
||||
params="&".join(next_attr))
|
||||
"href": f"{path_url}?{'&'.join(next_attr)}"
|
||||
}
|
||||
links.append(next_link)
|
||||
links = [types.PageType(**link) for link in links]
|
||||
|
||||
@@ -76,8 +76,8 @@ class AmphoraProviderDriver(driver_base.ProviderDriver):
|
||||
|
||||
def _validate_pool_algorithm(self, pool):
|
||||
if pool.lb_algorithm not in AMPHORA_SUPPORTED_LB_ALGORITHMS:
|
||||
msg = ('Amphora provider does not support %s algorithm.'
|
||||
% pool.lb_algorithm)
|
||||
msg = (f'Amphora provider does not support {pool.lb_algorithm} '
|
||||
f'algorithm.')
|
||||
raise exceptions.UnsupportedOptionError(
|
||||
user_fault_string=msg,
|
||||
operator_fault_string=msg)
|
||||
|
||||
@@ -223,8 +223,7 @@ class BaseController(pecan_rest.RestController):
|
||||
|
||||
def _auth_get_all(self, context, project_id):
|
||||
# Check authorization to list objects under all projects
|
||||
action = '{rbac_obj}{action}'.format(
|
||||
rbac_obj=self.RBAC_TYPE, action=constants.RBAC_GET_ALL_GLOBAL)
|
||||
action = f'{self.RBAC_TYPE}{constants.RBAC_GET_ALL_GLOBAL}'
|
||||
target = {'project_id': project_id}
|
||||
if not policy.get_enforcer().authorize(action, target,
|
||||
context, do_raise=False):
|
||||
@@ -247,8 +246,7 @@ class BaseController(pecan_rest.RestController):
|
||||
|
||||
def _auth_validate_action(self, context, project_id, action):
|
||||
# Check that the user is authorized to do an action in this object
|
||||
action = '{rbac_obj}{action}'.format(
|
||||
rbac_obj=self.RBAC_TYPE, action=action)
|
||||
action = f'{self.RBAC_TYPE}{action}'
|
||||
target = {'project_id': project_id}
|
||||
policy.get_enforcer().authorize(action, target, context)
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ class HealthMonitorController(base.BaseController):
|
||||
if hm_dict.get('http_version') and hm_dict.get('domain_name'):
|
||||
if hm_dict['http_version'] < 1.1:
|
||||
raise exceptions.InvalidOption(
|
||||
value='http_version %s' % hm_dict['http_version'],
|
||||
value=f"http_version {hm_dict['http_version']}",
|
||||
option='health monitors HTTP 1.1 domain name health check')
|
||||
|
||||
try:
|
||||
@@ -317,7 +317,7 @@ class HealthMonitorController(base.BaseController):
|
||||
http_version = health_monitor.http_version or db_hm.http_version
|
||||
if http_version < 1.1:
|
||||
raise exceptions.InvalidOption(
|
||||
value='http_version %s' % http_version,
|
||||
value=f'http_version {http_version}',
|
||||
option='health monitors HTTP 1.1 domain name health check')
|
||||
|
||||
def _set_default_on_none(self, health_monitor):
|
||||
|
||||
@@ -136,7 +136,7 @@ class ListenersController(base.BaseController):
|
||||
constants.LISTENER_PROTOCOLS_SUPPORTING_HEADER_INSERTION):
|
||||
raise exceptions.InvalidOption(
|
||||
value='insert-headers',
|
||||
option='a %s protocol listener.' % listener_protocol)
|
||||
option=f'a {listener_protocol} protocol listener.')
|
||||
if list(set(insert_header_list) - (
|
||||
set(constants.SUPPORTED_HTTP_HEADERS +
|
||||
constants.SUPPORTED_SSL_HEADERS))):
|
||||
@@ -155,7 +155,7 @@ class ListenersController(base.BaseController):
|
||||
headers.append(header_name)
|
||||
raise exceptions.InvalidOption(
|
||||
value=headers,
|
||||
option='%s protocol listener.' % listener_protocol)
|
||||
option=f'{listener_protocol} protocol listener.')
|
||||
|
||||
def _validate_cidr_compatible_with_vip(self, vips, allowed_cidrs):
|
||||
for cidr in allowed_cidrs:
|
||||
|
||||
@@ -96,7 +96,7 @@ class LocalCertGenerator(cert_gen.CertGenerator):
|
||||
algorithm = getattr(hashes, ca_digest.upper())()
|
||||
except AttributeError as e:
|
||||
raise crypto_exceptions.UnsupportedAlgorithm(
|
||||
"Supplied digest method not found: %s" % ca_digest
|
||||
f"Supplied digest method not found: {ca_digest}"
|
||||
) from e
|
||||
|
||||
if not ca_cert:
|
||||
|
||||
@@ -75,14 +75,14 @@ def main():
|
||||
'certfile': CONF.amphora_agent.agent_server_cert,
|
||||
'ca_certs': CONF.amphora_agent.agent_server_ca,
|
||||
'cert_reqs': ssl.CERT_REQUIRED,
|
||||
'ssl_version': getattr(ssl, "PROTOCOL_%s" % proto),
|
||||
'ssl_version': getattr(ssl, f"PROTOCOL_{proto}"),
|
||||
'preload_app': True,
|
||||
'accesslog': '/var/log/amphora-agent.log',
|
||||
'errorlog': '/var/log/amphora-agent.log',
|
||||
'loglevel': 'debug',
|
||||
'syslog': True,
|
||||
'syslog_facility': 'local{}'.format(
|
||||
CONF.amphora_agent.administrative_log_facility),
|
||||
'syslog_facility': (
|
||||
f'local{CONF.amphora_agent.administrative_log_facility}'),
|
||||
'syslog_addr': 'unix://run/rsyslog/octavia/log#dgram',
|
||||
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ def _process_wrapper(exit_event, proc_name, function, agent_name=None):
|
||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
signal.signal(signal.SIGHUP, _mutate_config)
|
||||
if agent_name:
|
||||
process_title = 'octavia-driver-agent - {} -- {}'.format(
|
||||
proc_name, agent_name)
|
||||
process_title = f'octavia-driver-agent - {proc_name} -- {agent_name}'
|
||||
else:
|
||||
process_title = f'octavia-driver-agent - {proc_name}'
|
||||
setproctitle.setproctitle(process_title)
|
||||
|
||||
@@ -751,7 +751,7 @@ class PrometheusProxy(SimpleHTTPRequestHandler):
|
||||
metrics_buffer += line.replace(match,
|
||||
map_tuple[0])
|
||||
elif PRINT_REJECTED:
|
||||
print("REJECTED: %s" % line)
|
||||
print(f"REJECTED: {line}")
|
||||
except Exception as e:
|
||||
print(str(e), flush=True)
|
||||
traceback.print_tb(e.__traceback__)
|
||||
|
||||
@@ -967,7 +967,7 @@ def handle_neutron_deprecations():
|
||||
def init(args, **kwargs):
|
||||
register_cli_opts()
|
||||
cfg.CONF(args=args, project='octavia',
|
||||
version='%%prog %s' % version.version_info.release_string(),
|
||||
version=f'%prog {version.version_info.release_string()}',
|
||||
**kwargs)
|
||||
validate.check_default_tls_versions_min_conflict()
|
||||
setup_remote_debugger()
|
||||
|
||||
@@ -784,13 +784,13 @@ RBAC_QUOTA = f'{LOADBALANCER_API}:quota:'
|
||||
RBAC_AMPHORA = f'{LOADBALANCER_API}:amphora:'
|
||||
RBAC_PROVIDER = f'{LOADBALANCER_API}:provider:'
|
||||
RBAC_PROVIDER_FLAVOR = f'{LOADBALANCER_API}:provider-flavor:'
|
||||
RBAC_PROVIDER_AVAILABILITY_ZONE = '{}:provider-availability-zone:'.format(
|
||||
LOADBALANCER_API)
|
||||
RBAC_PROVIDER_AVAILABILITY_ZONE = (f'{LOADBALANCER_API}:'
|
||||
f'provider-availability-zone:')
|
||||
RBAC_FLAVOR = f'{LOADBALANCER_API}:flavor:'
|
||||
RBAC_FLAVOR_PROFILE = f'{LOADBALANCER_API}:flavor-profile:'
|
||||
RBAC_AVAILABILITY_ZONE = f'{LOADBALANCER_API}:availability-zone:'
|
||||
RBAC_AVAILABILITY_ZONE_PROFILE = '{}:availability-zone-profile:'.format(
|
||||
LOADBALANCER_API)
|
||||
RBAC_AVAILABILITY_ZONE_PROFILE = (f'{LOADBALANCER_API}:'
|
||||
f'availability-zone-profile:')
|
||||
|
||||
RBAC_POST = 'post'
|
||||
RBAC_PUT = 'put'
|
||||
|
||||
@@ -175,8 +175,8 @@ class JinjaTemplater:
|
||||
tls_certs,
|
||||
feature_compatibility)
|
||||
if not socket_path:
|
||||
socket_path = '{}/{}.sock'.format(self.base_amp_path,
|
||||
listeners[0].load_balancer.id)
|
||||
socket_path = (f'{self.base_amp_path}/'
|
||||
f'{listeners[0].load_balancer.id}.sock')
|
||||
state_file_path = '{}/{}/servers-state'.format(
|
||||
self.base_amp_path,
|
||||
listeners[0].load_balancer.id) if feature_compatibility.get(
|
||||
|
||||
@@ -198,11 +198,9 @@ def validate_l7rule_ssl_types(l7rule):
|
||||
# key and value are not allowed
|
||||
if req_key:
|
||||
# log error or raise
|
||||
msg = 'L7rule type {} does not use the "key" field.'.format(
|
||||
rule_type)
|
||||
msg = f'L7rule type {rule_type} does not use the "key" field.'
|
||||
elif req_value.lower() != 'true':
|
||||
msg = 'L7rule value {} is not a boolean True string.'.format(
|
||||
req_value)
|
||||
msg = f'L7rule value {req_value} is not a boolean True string.'
|
||||
elif compare_type != constants.L7RULE_COMPARE_TYPE_EQUAL_TO:
|
||||
msg = 'L7rule type {} only supports the {} compare type.'.format(
|
||||
rule_type, constants.L7RULE_COMPARE_TYPE_EQUAL_TO)
|
||||
@@ -210,12 +208,10 @@ def validate_l7rule_ssl_types(l7rule):
|
||||
if rule_type == constants.L7RULE_TYPE_SSL_VERIFY_RESULT:
|
||||
if req_key:
|
||||
# log or raise req_key not used
|
||||
msg = 'L7rule type {} does not use the "key" field.'.format(
|
||||
rule_type)
|
||||
msg = f'L7rule type {rule_type} does not use the "key" field.'
|
||||
elif not req_value.isdigit() or int(req_value) < 0:
|
||||
# log or raise req_value must be int
|
||||
msg = 'L7rule type {} needs a int value, which is >= 0'.format(
|
||||
rule_type)
|
||||
msg = f'L7rule type {rule_type} needs a int value, which is >= 0'
|
||||
elif compare_type != constants.L7RULE_COMPARE_TYPE_EQUAL_TO:
|
||||
msg = 'L7rule type {} only supports the {} compare type.'.format(
|
||||
rule_type, constants.L7RULE_COMPARE_TYPE_EQUAL_TO)
|
||||
@@ -227,9 +223,9 @@ def validate_l7rule_ssl_types(l7rule):
|
||||
|
||||
if not req_key or not req_value:
|
||||
# log or raise key and value must be specified.
|
||||
msg = 'L7rule type {} needs to specify a key and a value.'.format(
|
||||
rule_type)
|
||||
# log or raise the key must be split by '-'
|
||||
msg = (f'L7rule type {rule_type} needs to specify a '
|
||||
f'key and a value.')
|
||||
# log or raise the key must be splited by '-'
|
||||
elif not dn_regex.match(req_key):
|
||||
msg = 'Invalid L7rule distinguished name field.'
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class VirtualMachineManager(compute_base.ComputeBase):
|
||||
# device id = volume_id, device type and size unspecified,
|
||||
# delete-on-terminate = true (volume will be deleted by Nova
|
||||
# on instance termination)
|
||||
block_device_mapping = {'vda': '%s:::true' % volume_id}
|
||||
block_device_mapping = {'vda': f'{volume_id}:::true'}
|
||||
amphora = self.manager.create(
|
||||
name=name, image=image_id, flavor=amphora_flavor,
|
||||
block_device_mapping=block_device_mapping,
|
||||
|
||||
@@ -53,8 +53,7 @@ class ConsumerService(cotyledon.Service):
|
||||
if CONF.task_flow.jobboard_enabled:
|
||||
for e in self.endpoints:
|
||||
e.worker.services_controller.run_conductor(
|
||||
'octavia-task-flow-conductor-%s' %
|
||||
uuidutils.generate_uuid())
|
||||
f'octavia-task-flow-conductor-{uuidutils.generate_uuid()}')
|
||||
|
||||
def terminate(self):
|
||||
if self.message_listener:
|
||||
|
||||
@@ -148,49 +148,42 @@ class MemberFlows:
|
||||
unordered_members_flow.add(
|
||||
lifecycle_tasks.MembersToErrorOnRevertTask(
|
||||
inject={constants.MEMBERS: old_members},
|
||||
name='{flow}-deleted'.format(
|
||||
flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW)))
|
||||
name=f'{constants.MEMBER_TO_ERROR_ON_REVERT_FLOW}-deleted'))
|
||||
for m in old_members:
|
||||
unordered_members_flow.add(database_tasks.DeleteMemberInDB(
|
||||
inject={constants.MEMBER: m},
|
||||
name='{flow}-{id}'.format(
|
||||
id=m[constants.MEMBER_ID],
|
||||
flow=constants.DELETE_MEMBER_INDB)))
|
||||
name=f'{constants.DELETE_MEMBER_INDB}-'
|
||||
f'{m[constants.MEMBER_ID]}'))
|
||||
unordered_members_flow.add(database_tasks.DecrementMemberQuota(
|
||||
requires=constants.PROJECT_ID,
|
||||
name='{flow}-{id}'.format(
|
||||
id=m[constants.MEMBER_ID],
|
||||
flow=constants.DECREMENT_MEMBER_QUOTA_FLOW)))
|
||||
name=f'{constants.DECREMENT_MEMBER_QUOTA_FLOW}-'
|
||||
f'{m[constants.MEMBER_ID]}'))
|
||||
|
||||
# Create new members
|
||||
unordered_members_flow.add(
|
||||
lifecycle_tasks.MembersToErrorOnRevertTask(
|
||||
inject={constants.MEMBERS: new_members},
|
||||
name='{flow}-created'.format(
|
||||
flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW)))
|
||||
name=f'{constants.MEMBER_TO_ERROR_ON_REVERT_FLOW}-created'))
|
||||
for m in new_members:
|
||||
unordered_members_active_flow.add(
|
||||
database_tasks.MarkMemberActiveInDB(
|
||||
inject={constants.MEMBER: m},
|
||||
name='{flow}-{id}'.format(
|
||||
id=m[constants.MEMBER_ID],
|
||||
flow=constants.MARK_MEMBER_ACTIVE_INDB)))
|
||||
name=f'{constants.MARK_MEMBER_ACTIVE_INDB}-'
|
||||
f'{m[constants.MEMBER_ID]}'))
|
||||
|
||||
# Update existing members
|
||||
unordered_members_flow.add(
|
||||
lifecycle_tasks.MembersToErrorOnRevertTask(
|
||||
# updated_members is a list of (obj, dict), only pass `obj`
|
||||
inject={constants.MEMBERS: [m[0] for m in updated_members]},
|
||||
name='{flow}-updated'.format(
|
||||
flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW)))
|
||||
name=f'{constants.MEMBER_TO_ERROR_ON_REVERT_FLOW}-updated'))
|
||||
for m, um in updated_members:
|
||||
um.pop(constants.ID, None)
|
||||
unordered_members_active_flow.add(
|
||||
database_tasks.MarkMemberActiveInDB(
|
||||
inject={constants.MEMBER: m},
|
||||
name='{flow}-{id}'.format(
|
||||
id=m[constants.MEMBER_ID],
|
||||
flow=constants.MARK_MEMBER_ACTIVE_INDB)))
|
||||
name=f'{constants.MARK_MEMBER_ACTIVE_INDB}-'
|
||||
f'{m[constants.MEMBER_ID]}'))
|
||||
|
||||
batch_update_members_flow.add(unordered_members_flow)
|
||||
|
||||
|
||||
@@ -617,8 +617,8 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
|
||||
try:
|
||||
subnet = self.get_subnet(vip.subnet_id)
|
||||
except base.SubnetNotFound as e:
|
||||
msg = ("Can't unplug vip because vip subnet {} was not "
|
||||
"found").format(vip.subnet_id)
|
||||
msg = (f"Can't unplug vip because vip subnet {vip.subnet_id} "
|
||||
f"was not found")
|
||||
LOG.exception(msg)
|
||||
raise base.PluggedVIPNotFound(msg) from e
|
||||
for amphora in filter(
|
||||
@@ -639,8 +639,8 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
|
||||
except Exception as e:
|
||||
message = _('Error plugging amphora (compute_id: {compute_id}) '
|
||||
'into network {network_id}.').format(
|
||||
compute_id=compute_id,
|
||||
network_id=network_id)
|
||||
compute_id=compute_id,
|
||||
network_id=network_id)
|
||||
LOG.exception(message)
|
||||
raise base.PlugNetworkException(message) from e
|
||||
|
||||
@@ -649,8 +649,8 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
|
||||
def unplug_network(self, compute_id, network_id):
|
||||
interfaces = self.get_plugged_networks(compute_id)
|
||||
if not interfaces:
|
||||
msg = ('Amphora with compute id {compute_id} does not have any '
|
||||
'plugged networks').format(compute_id=compute_id)
|
||||
msg = (f'Amphora with compute id {compute_id} does not have any '
|
||||
f'plugged networks')
|
||||
raise base.NetworkNotFound(msg)
|
||||
|
||||
unpluggers = self._get_interfaces_to_unplug(interfaces, network_id)
|
||||
|
||||
@@ -188,8 +188,8 @@ class BaseNeutronDriver(base.AbstractNetworkDriver):
|
||||
try:
|
||||
resource = getattr(
|
||||
network, f"get_{resource_type}")(resource_id)
|
||||
return getattr(utils, 'convert_%s_to_model' %
|
||||
resource_type)(resource)
|
||||
return getattr(
|
||||
utils, f'convert_{resource_type}_to_model')(resource)
|
||||
except os_exceptions.ResourceNotFound as e:
|
||||
message = _('{resource_type} not found '
|
||||
'({resource_type} id: {resource_id}).').format(
|
||||
@@ -215,7 +215,7 @@ class BaseNeutronDriver(base.AbstractNetworkDriver):
|
||||
self.network_proxy, f"{resource_type}s")(**filters)
|
||||
conversion_function = getattr(
|
||||
utils,
|
||||
'convert_%s_to_model' % resource_type)
|
||||
f'convert_{resource_type}_to_model')
|
||||
try:
|
||||
# get first item to see if there is at least one resource
|
||||
res_list = [conversion_function(next(resources))]
|
||||
|
||||
@@ -17,45 +17,39 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AMPHORA,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_AMPHORA}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"List Amphorae",
|
||||
[{'method': 'GET', 'path': '/v2/octavia/amphorae'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AMPHORA,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_AMPHORA}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Show Amphora details",
|
||||
[{'method': 'GET', 'path': '/v2/octavia/amphorae/{amphora_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AMPHORA,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_AMPHORA}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Delete an Amphora",
|
||||
[{'method': 'DELETE', 'path': '/v2/octavia/amphorae/{amphora_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AMPHORA,
|
||||
action=constants.RBAC_PUT_CONFIG),
|
||||
f'{constants.RBAC_AMPHORA}{constants.RBAC_PUT_CONFIG}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Update Amphora Agent Configuration",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/octavia/amphorae/{amphora_id}/config'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AMPHORA,
|
||||
action=constants.RBAC_PUT_FAILOVER),
|
||||
f'{constants.RBAC_AMPHORA}{constants.RBAC_PUT_FAILOVER}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Failover Amphora",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/octavia/amphorae/{amphora_id}/failover'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AMPHORA,
|
||||
action=constants.RBAC_GET_STATS),
|
||||
f'{constants.RBAC_AMPHORA}{constants.RBAC_GET_STATS}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Show Amphora statistics",
|
||||
[{'method': 'GET', 'path': '/v2/octavia/amphorae/{amphora_id}/stats'}]
|
||||
|
||||
@@ -18,38 +18,33 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AVAILABILITY_ZONE,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List Availability Zones",
|
||||
[{'method': 'GET', 'path': '/v2.0/lbaas/availabilityzones'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AVAILABILITY_ZONE,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE}{constants.RBAC_POST}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Create an Availability Zone",
|
||||
[{'method': 'POST', 'path': '/v2.0/lbaas/availabilityzones'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AVAILABILITY_ZONE,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Update an Availability Zone",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2.0/lbaas/availabilityzones/{availability_zone_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AVAILABILITY_ZONE,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Availability Zone details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2.0/lbaas/availabilityzones/{availability_zone_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_AVAILABILITY_ZONE,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Remove an Availability Zone",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -18,25 +18,19 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(
|
||||
rbac_obj=constants.RBAC_AVAILABILITY_ZONE_PROFILE,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE_PROFILE}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"List Availability Zones",
|
||||
[{'method': 'GET', 'path': '/v2.0/lbaas/availabilityzoneprofiles'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(
|
||||
rbac_obj=constants.RBAC_AVAILABILITY_ZONE_PROFILE,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE_PROFILE}{constants.RBAC_POST}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Create an Availability Zone",
|
||||
[{'method': 'POST', 'path': '/v2.0/lbaas/availabilityzoneprofiles'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(
|
||||
rbac_obj=constants.RBAC_AVAILABILITY_ZONE_PROFILE,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE_PROFILE}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Update an Availability Zone",
|
||||
[{'method': 'PUT',
|
||||
@@ -44,9 +38,7 @@ rules = [
|
||||
'{availability_zone_profile_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(
|
||||
rbac_obj=constants.RBAC_AVAILABILITY_ZONE_PROFILE,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE_PROFILE}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Show Availability Zone details",
|
||||
[{'method': 'GET',
|
||||
@@ -54,9 +46,7 @@ rules = [
|
||||
'{availability_zone_profile_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(
|
||||
rbac_obj=constants.RBAC_AVAILABILITY_ZONE_PROFILE,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_AVAILABILITY_ZONE_PROFILE}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Remove an Availability Zone",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -18,37 +18,32 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_FLAVOR}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List Flavors",
|
||||
[{'method': 'GET', 'path': '/v2.0/lbaas/flavors'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_FLAVOR}{constants.RBAC_POST}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Create a Flavor",
|
||||
[{'method': 'POST', 'path': '/v2.0/lbaas/flavors'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_FLAVOR}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Update a Flavor",
|
||||
[{'method': 'PUT', 'path': '/v2.0/lbaas/flavors/{flavor_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_FLAVOR}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Flavor details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2.0/lbaas/flavors/{flavor_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_FLAVOR}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Remove a Flavor",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -18,38 +18,33 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR_PROFILE,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_FLAVOR_PROFILE}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"List Flavor Profiles",
|
||||
[{'method': 'GET', 'path': '/v2.0/lbaas/flavorprofiles'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR_PROFILE,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_FLAVOR_PROFILE}{constants.RBAC_POST}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Create a Flavor Profile",
|
||||
[{'method': 'POST', 'path': '/v2.0/lbaas/flavorprofiles'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR_PROFILE,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_FLAVOR_PROFILE}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Update a Flavor Profile",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2.0/lbaas/flavorprofiles/{flavor_profile_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR_PROFILE,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_FLAVOR_PROFILE}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Show Flavor Profile details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2.0/lbaas/flavorprofiles/{flavor_profile_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_FLAVOR_PROFILE,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_FLAVOR_PROFILE}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Remove a Flavor Profile",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -17,45 +17,39 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_HEALTHMONITOR,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_HEALTHMONITOR}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List Health Monitors of a Pool",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/healthmonitors'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_HEALTHMONITOR,
|
||||
action=constants.RBAC_GET_ALL_GLOBAL),
|
||||
f'{constants.RBAC_HEALTHMONITOR}{constants.RBAC_GET_ALL_GLOBAL}',
|
||||
constants.RULE_API_READ_GLOBAL,
|
||||
"List Health Monitors including resources owned by others",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/healthmonitors'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_HEALTHMONITOR,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_HEALTHMONITOR}{constants.RBAC_POST}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Create a Health Monitor",
|
||||
[{'method': 'POST', 'path': '/v2/lbaas/healthmonitors'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_HEALTHMONITOR,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_HEALTHMONITOR}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Health Monitor details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/healthmonitors/{healthmonitor_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_HEALTHMONITOR,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_HEALTHMONITOR}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Update a Health Monitor",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/healthmonitors/{healthmonitor_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_HEALTHMONITOR,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_HEALTHMONITOR}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Remove a Health Monitor",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -17,45 +17,39 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7POLICY,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_L7POLICY}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List L7 Policys",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/l7policies'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7POLICY,
|
||||
action=constants.RBAC_GET_ALL_GLOBAL),
|
||||
f'{constants.RBAC_L7POLICY}{constants.RBAC_GET_ALL_GLOBAL}',
|
||||
constants.RULE_API_READ_GLOBAL,
|
||||
"List L7 Policys including resources owned by others",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/l7policies'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7POLICY,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_L7POLICY}{constants.RBAC_POST}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Create a L7 Policy",
|
||||
[{'method': 'POST', 'path': '/v2/lbaas/l7policies'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7POLICY,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_L7POLICY}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show L7 Policy details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/l7policies/{l7policy_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7POLICY,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_L7POLICY}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Update a L7 Policy",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/l7policies/{l7policy_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7POLICY,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_L7POLICY}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Remove a L7 Policy",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -17,40 +17,35 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7RULE,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_L7RULE}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List L7 Rules",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/l7policies/{l7policy_id}/rules'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7RULE,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_L7RULE}{constants.RBAC_POST}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Create a L7 Rule",
|
||||
[{'method': 'POST',
|
||||
'path': '/v2/lbaas/l7policies/{l7policy_id}/rules'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7RULE,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_L7RULE}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show L7 Rule details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/l7policies/{l7policy_id}/rules/{l7rule_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7RULE,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_L7RULE}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Update a L7 Rule",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/l7policies/{l7policy_id}/rules/{l7rule_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_L7RULE,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_L7RULE}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Remove a L7 Rule",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -17,53 +17,46 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LISTENER,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_LISTENER}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List Listeners",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/listeners'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LISTENER,
|
||||
action=constants.RBAC_GET_ALL_GLOBAL),
|
||||
f'{constants.RBAC_LISTENER}{constants.RBAC_GET_ALL_GLOBAL}',
|
||||
constants.RULE_API_READ_GLOBAL,
|
||||
"List Listeners including resources owned by others",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/listeners'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LISTENER,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_LISTENER}{constants.RBAC_POST}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Create a Listener",
|
||||
[{'method': 'POST', 'path': '/v2/lbaas/listeners'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LISTENER,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_LISTENER}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Listener details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/listeners/{listener_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LISTENER,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_LISTENER}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Update a Listener",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/listeners/{listener_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LISTENER,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_LISTENER}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Remove a Listener",
|
||||
[{'method': 'DELETE',
|
||||
'path': '/v2/lbaas/listeners/{listener_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LISTENER,
|
||||
action=constants.RBAC_GET_STATS),
|
||||
f'{constants.RBAC_LISTENER}{constants.RBAC_GET_STATS}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Listener statistics",
|
||||
[{'method': 'GET',
|
||||
|
||||
@@ -17,69 +17,60 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List Load Balancers",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/loadbalancers'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_GET_ALL_GLOBAL),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_GET_ALL_GLOBAL}',
|
||||
constants.RULE_API_READ_GLOBAL,
|
||||
"List Load Balancers including resources owned by others",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/loadbalancers'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_POST}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Create a Load Balancer",
|
||||
[{'method': 'POST', 'path': '/v2/lbaas/loadbalancers'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Load Balancer details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/loadbalancers/{loadbalancer_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Update a Load Balancer",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/loadbalancers/{loadbalancer_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Remove a Load Balancer",
|
||||
[{'method': 'DELETE',
|
||||
'path': '/v2/lbaas/loadbalancers/{loadbalancer_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_GET_STATS),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_GET_STATS}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Load Balancer statistics",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/loadbalancers/{loadbalancer_id}/stats'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_GET_STATUS),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_GET_STATUS}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Load Balancer status",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/loadbalancers/{loadbalancer_id}/status'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_LOADBALANCER,
|
||||
action=constants.RBAC_PUT_FAILOVER),
|
||||
f'{constants.RBAC_LOADBALANCER}{constants.RBAC_PUT_FAILOVER}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"Failover a Load Balancer",
|
||||
[{'method': 'PUT',
|
||||
|
||||
@@ -17,38 +17,33 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_MEMBER,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_MEMBER}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List Members of a Pool",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/pools/{pool_id}/members'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_MEMBER,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_MEMBER}{constants.RBAC_POST}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Create a Member",
|
||||
[{'method': 'POST', 'path': '/v2/lbaas/pools/{pool_id}/members'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_MEMBER,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_MEMBER}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Member details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/pools/{pool_id}/members/{member_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_MEMBER,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_MEMBER}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Update a Member",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/pools/{pool_id}/members/{member_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_MEMBER,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_MEMBER}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Remove a Member",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -17,45 +17,39 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_POOL,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_POOL}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List Pools",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/pools'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_POOL,
|
||||
action=constants.RBAC_GET_ALL_GLOBAL),
|
||||
f'{constants.RBAC_POOL}{constants.RBAC_GET_ALL_GLOBAL}',
|
||||
constants.RULE_API_READ_GLOBAL,
|
||||
"List Pools including resources owned by others",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/pools'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_POOL,
|
||||
action=constants.RBAC_POST),
|
||||
f'{constants.RBAC_POOL}{constants.RBAC_POST}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Create a Pool",
|
||||
[{'method': 'POST', 'path': '/v2/lbaas/pools'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_POOL,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_POOL}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ,
|
||||
"Show Pool details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/pools/{pool_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_POOL,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_POOL}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Update a Pool",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/pools/{pool_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_POOL,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_POOL}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE,
|
||||
"Remove a Pool",
|
||||
[{'method': 'DELETE',
|
||||
|
||||
@@ -17,8 +17,7 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_PROVIDER,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_PROVIDER}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ,
|
||||
"List enabled providers",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/providers'}]
|
||||
|
||||
@@ -17,9 +17,7 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(
|
||||
rbac_obj=constants.RBAC_PROVIDER_AVAILABILITY_ZONE,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_PROVIDER_AVAILABILITY_ZONE}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"List the provider availability zone capabilities.",
|
||||
[{'method': 'GET',
|
||||
|
||||
@@ -17,8 +17,7 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_PROVIDER_FLAVOR,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_PROVIDER_FLAVOR}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_ADMIN,
|
||||
"List the provider flavor capabilities.",
|
||||
[{'method': 'GET',
|
||||
|
||||
@@ -17,46 +17,40 @@ from octavia.common import constants
|
||||
|
||||
rules = [
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_QUOTA,
|
||||
action=constants.RBAC_GET_ALL),
|
||||
f'{constants.RBAC_QUOTA}{constants.RBAC_GET_ALL}',
|
||||
constants.RULE_API_READ_QUOTA,
|
||||
"List Quotas",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/quotas'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_QUOTA,
|
||||
action=constants.RBAC_GET_ALL_GLOBAL),
|
||||
f'{constants.RBAC_QUOTA}{constants.RBAC_GET_ALL_GLOBAL}',
|
||||
constants.RULE_API_READ_QUOTA_GLOBAL,
|
||||
"List Quotas including resources owned by others",
|
||||
[{'method': 'GET', 'path': '/v2/lbaas/quotas'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_QUOTA,
|
||||
action=constants.RBAC_GET_ONE),
|
||||
f'{constants.RBAC_QUOTA}{constants.RBAC_GET_ONE}',
|
||||
constants.RULE_API_READ_QUOTA,
|
||||
"Show Quota details",
|
||||
[{'method': 'GET',
|
||||
'path': '/v2/lbaas/quotas/{project_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_QUOTA,
|
||||
action=constants.RBAC_PUT),
|
||||
f'{constants.RBAC_QUOTA}{constants.RBAC_PUT}',
|
||||
constants.RULE_API_WRITE_QUOTA,
|
||||
"Update a Quota",
|
||||
[{'method': 'PUT',
|
||||
'path': '/v2/lbaas/quotas/{project_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_QUOTA,
|
||||
action=constants.RBAC_DELETE),
|
||||
f'{constants.RBAC_QUOTA}{constants.RBAC_DELETE}',
|
||||
constants.RULE_API_WRITE_QUOTA,
|
||||
"Reset a Quota",
|
||||
[{'method': 'DELETE',
|
||||
'path': '/v2/lbaas/quotas/{project_id}'}]
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
'{rbac_obj}{action}'.format(rbac_obj=constants.RBAC_QUOTA,
|
||||
action=constants.RBAC_GET_DEFAULTS),
|
||||
f'{constants.RBAC_QUOTA}{constants.RBAC_GET_DEFAULTS}',
|
||||
constants.RULE_API_READ_QUOTA,
|
||||
"Show Default Quota for a Project",
|
||||
[{'method': 'GET',
|
||||
|
||||
@@ -145,7 +145,7 @@ class KeepalivedLvsTestCase(base.TestCase):
|
||||
mock.call(consts.ENABLE,
|
||||
consts.AMP_NETNS_SVC_PREFIX),
|
||||
mock.call(consts.ENABLE,
|
||||
'octavia-keepalivedlvs-%s' % str(self.FAKE_ID)),
|
||||
f'octavia-keepalivedlvs-{str(self.FAKE_ID)}'),
|
||||
]
|
||||
mock_systemctl.assert_has_calls(systemctl_calls)
|
||||
os_mkdir_calls = [
|
||||
@@ -221,7 +221,7 @@ class KeepalivedLvsTestCase(base.TestCase):
|
||||
mock.call(consts.ENABLE,
|
||||
consts.AMP_NETNS_SVC_PREFIX),
|
||||
mock.call(consts.ENABLE,
|
||||
'octavia-keepalivedlvs-%s' % str(self.FAKE_ID)),
|
||||
f'octavia-keepalivedlvs-{str(self.FAKE_ID)}'),
|
||||
]
|
||||
mock_systemctl.assert_has_calls(systemctl_calls)
|
||||
|
||||
@@ -285,7 +285,7 @@ class KeepalivedLvsTestCase(base.TestCase):
|
||||
mock.call(consts.ENABLE,
|
||||
consts.AMP_NETNS_SVC_PREFIX),
|
||||
mock.call(consts.ENABLE,
|
||||
'octavia-keepalivedlvs-%s' % str(self.FAKE_ID)),
|
||||
f'octavia-keepalivedlvs-{str(self.FAKE_ID)}'),
|
||||
]
|
||||
mock_systemctl.assert_has_calls(systemctl_calls)
|
||||
|
||||
@@ -311,8 +311,7 @@ class KeepalivedLvsTestCase(base.TestCase):
|
||||
def test_manage_lvs_listener(self, mock_lvs_exist, mock_check_output):
|
||||
res = self.test_keepalivedlvs.manage_lvs_listener(self.FAKE_ID,
|
||||
'start')
|
||||
cmd = ("/usr/sbin/service octavia-keepalivedlvs-{listener_id}"
|
||||
" {action}".format(listener_id=self.FAKE_ID, action='start'))
|
||||
cmd = f"/usr/sbin/service octavia-keepalivedlvs-{self.FAKE_ID} start"
|
||||
mock_check_output.assert_called_once_with(cmd.split(),
|
||||
stderr=subprocess.STDOUT)
|
||||
self.assertEqual(202, res.status_code)
|
||||
@@ -342,10 +341,8 @@ class KeepalivedLvsTestCase(base.TestCase):
|
||||
m_exist.return_value = True
|
||||
res = self.test_keepalivedlvs.delete_lvs_listener(self.FAKE_ID)
|
||||
|
||||
cmd1 = ("/usr/sbin/service "
|
||||
"octavia-keepalivedlvs-{} stop".format(self.FAKE_ID))
|
||||
cmd2 = ("systemctl disable "
|
||||
"octavia-keepalivedlvs-{list}".format(list=self.FAKE_ID))
|
||||
cmd1 = f"/usr/sbin/service octavia-keepalivedlvs-{self.FAKE_ID} stop"
|
||||
cmd2 = f"systemctl disable octavia-keepalivedlvs-{self.FAKE_ID}"
|
||||
calls = [
|
||||
mock.call(cmd1.split(), stderr=subprocess.STDOUT),
|
||||
mock.call(cmd2.split(), stderr=subprocess.STDOUT)
|
||||
@@ -399,8 +396,8 @@ class KeepalivedLvsTestCase(base.TestCase):
|
||||
res = self.test_keepalivedlvs.delete_lvs_listener(self.FAKE_ID)
|
||||
self.assertEqual(500, res.status_code)
|
||||
self.assertEqual({
|
||||
'message': 'Error disabling '
|
||||
'octavia-keepalivedlvs-%s service' % self.FAKE_ID,
|
||||
'message': f'Error disabling octavia-keepalivedlvs-{self.FAKE_ID} '
|
||||
f'service',
|
||||
'details': None}, res.json)
|
||||
|
||||
@mock.patch('octavia.amphorae.backends.agent.api_server.util.'
|
||||
|
||||
@@ -1073,8 +1073,7 @@ class TestServerTestCase(base.TestCase):
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_APPEND
|
||||
|
||||
else:
|
||||
file_name = ('/etc/octavia/interfaces/'
|
||||
'eth{}.json'.format(test_int_num))
|
||||
file_name = f'/etc/octavia/interfaces/eth{test_int_num}.json'
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
@@ -1157,8 +1156,7 @@ class TestServerTestCase(base.TestCase):
|
||||
file_name = self.conf.conf.amphora_agent.agent_server_network_file
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_APPEND
|
||||
else:
|
||||
file_name = ('/etc/octavia/interfaces/'
|
||||
'eth{}.json'.format(test_int_num))
|
||||
file_name = f'/etc/octavia/interfaces/eth{test_int_num}.json'
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
@@ -1227,8 +1225,7 @@ class TestServerTestCase(base.TestCase):
|
||||
file_name = self.conf.conf.amphora_agent.agent_server_network_file
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_APPEND
|
||||
else:
|
||||
file_name = ('/etc/octavia/interfaces/'
|
||||
'eth{}.json'.format(test_int_num))
|
||||
file_name = f'/etc/octavia/interfaces/eth{test_int_num}.json'
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
@@ -1293,8 +1290,7 @@ class TestServerTestCase(base.TestCase):
|
||||
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||
file_name = ('/etc/octavia/interfaces/'
|
||||
'eth{}.json'.format(test_int_num))
|
||||
file_name = f'/etc/octavia/interfaces/eth{test_int_num}.json'
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
with mock.patch('os.open') as mock_open, mock.patch.object(
|
||||
os, 'fdopen', m) as mock_fdopen:
|
||||
@@ -1983,8 +1979,8 @@ class TestServerTestCase(base.TestCase):
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||
|
||||
file_name = ('/etc/octavia/interfaces/{netns_int}.json'.format(
|
||||
netns_int=consts.NETNS_PRIMARY_INTERFACE))
|
||||
file_name = (f'/etc/octavia/interfaces/'
|
||||
f'{consts.NETNS_PRIMARY_INTERFACE}.json')
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
|
||||
with mock.patch('os.open') as mock_open, mock.patch.object(
|
||||
@@ -2094,8 +2090,8 @@ class TestServerTestCase(base.TestCase):
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||
|
||||
file_name = ('/etc/octavia/interfaces/{netns_int}.json'.format(
|
||||
netns_int=consts.NETNS_PRIMARY_INTERFACE))
|
||||
file_name = (f'/etc/octavia/interfaces/'
|
||||
f'{consts.NETNS_PRIMARY_INTERFACE}.json')
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
|
||||
with mock.patch('os.open') as mock_open, mock.patch.object(
|
||||
@@ -2271,8 +2267,8 @@ class TestServerTestCase(base.TestCase):
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||
|
||||
file_name = ('/etc/octavia/interfaces/{netns_int}.json'.format(
|
||||
netns_int=consts.NETNS_PRIMARY_INTERFACE))
|
||||
file_name = (f'/etc/octavia/interfaces/'
|
||||
f'{consts.NETNS_PRIMARY_INTERFACE}.json')
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
|
||||
with mock.patch('os.open') as mock_open, mock.patch.object(
|
||||
@@ -2489,8 +2485,8 @@ class TestServerTestCase(base.TestCase):
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||
|
||||
file_name = ('/etc/octavia/interfaces/{netns_int}.json'.format(
|
||||
netns_int=consts.NETNS_PRIMARY_INTERFACE))
|
||||
file_name = (f'/etc/octavia/interfaces/'
|
||||
f'{consts.NETNS_PRIMARY_INTERFACE}.json')
|
||||
m = self.useFixture(test_utils.OpenFixture(file_name)).mock_open
|
||||
|
||||
with mock.patch('os.open') as mock_open, mock.patch.object(
|
||||
|
||||
@@ -46,14 +46,12 @@ class DriverAgentTest(base.OctaviaDBTestBase):
|
||||
self.get_listener_proc.join(5)
|
||||
|
||||
def setUp(self):
|
||||
status_socket_file = '/tmp/octavia-{}.status.sock'.format(
|
||||
uuidutils.generate_uuid())
|
||||
stats_socket_file = '/tmp/octavia-{}.stats.sock'.format(
|
||||
uuidutils.generate_uuid())
|
||||
get_socket_file = '/tmp/octavia-{}.get.sock'.format(
|
||||
uuidutils.generate_uuid())
|
||||
sqlite_db_file = '/tmp/octavia-{}.sqlite.db'.format(
|
||||
uuidutils.generate_uuid())
|
||||
status_socket_file = (f'/tmp/octavia-{uuidutils.generate_uuid()}'
|
||||
f'.status.sock')
|
||||
stats_socket_file = (f'/tmp/octavia-{uuidutils.generate_uuid()}'
|
||||
f'.stats.sock')
|
||||
get_socket_file = f'/tmp/octavia-{uuidutils.generate_uuid()}.get.sock'
|
||||
sqlite_db_file = f'/tmp/octavia-{uuidutils.generate_uuid()}.sqlite.db'
|
||||
sqlite_db_connection = f'sqlite:///{sqlite_db_file}'
|
||||
|
||||
# Note that because the driver agent is a multi-process
|
||||
|
||||
@@ -172,8 +172,7 @@ class BaseAPITest(base_db_test.OctaviaDBTestBase):
|
||||
for k, v in params.items():
|
||||
param_string += f"{k}={v}&"
|
||||
if param_string:
|
||||
full_path = "{path}?{params}".format(
|
||||
path=full_path, params=param_string.rstrip("&"))
|
||||
full_path = f"{full_path}?{param_string.rstrip('&')}"
|
||||
response = self.app.delete(full_path,
|
||||
headers=headers,
|
||||
status=status,
|
||||
|
||||
@@ -375,8 +375,7 @@ class TestAvailabilityZoneProfiles(base.BaseAPITest):
|
||||
def _test_update_param_none(self, param_name):
|
||||
azp = self.create_availability_zone_profile(
|
||||
'test_profile', 'noop_driver', '{"x": "y"}')
|
||||
expect_error_msg = ("None is not a valid option for %s" %
|
||||
param_name)
|
||||
expect_error_msg = f"None is not a valid option for {param_name}"
|
||||
body = self._build_body({param_name: None})
|
||||
response = self.put(self.AZP_PATH.format(azp_id=azp.get('id')), body,
|
||||
status=400)
|
||||
@@ -513,7 +512,7 @@ class TestAvailabilityZoneProfiles(base.BaseAPITest):
|
||||
self.delete(self.AZP_PATH.format(azp_id=azp.get('id')))
|
||||
response = self.get(self.AZP_PATH.format(
|
||||
azp_id=azp.get('id')), status=404)
|
||||
err_msg = "Availability Zone Profile %s not found." % azp.get('id')
|
||||
err_msg = f"Availability Zone Profile {azp.get('id')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_deleted_id(self):
|
||||
@@ -560,7 +559,7 @@ class TestAvailabilityZoneProfiles(base.BaseAPITest):
|
||||
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||
response = self.get(self.AZP_PATH.format(
|
||||
azp_id=azp.get('id')), status=404)
|
||||
err_msg = "Availability Zone Profile %s not found." % azp.get('id')
|
||||
err_msg = f"Availability Zone Profile {azp.get('id')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_not_authorized(self):
|
||||
|
||||
@@ -492,7 +492,7 @@ class TestAvailabilityZones(base.BaseAPITest):
|
||||
self.delete(self.AZ_PATH.format(az_name=az.get('name')))
|
||||
response = self.get(self.AZ_PATH.format(az_name=az.get('name')),
|
||||
status=404)
|
||||
err_msg = "Availability Zone %s not found." % az.get('name')
|
||||
err_msg = f"Availability Zone {az.get('name')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_nonexistent_name(self):
|
||||
@@ -539,7 +539,7 @@ class TestAvailabilityZones(base.BaseAPITest):
|
||||
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||
response = self.get(self.AZ_PATH.format(az_name=az.get('name')),
|
||||
status=404)
|
||||
err_msg = "Availability Zone %s not found." % az.get('name')
|
||||
err_msg = f"Availability Zone {az.get('name')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_not_authorized(self):
|
||||
|
||||
@@ -373,8 +373,7 @@ class TestFlavorProfiles(base.BaseAPITest):
|
||||
def _test_update_param_none(self, param_name):
|
||||
fp = self.create_flavor_profile('test_profile', 'noop_driver',
|
||||
'{"x": "y"}')
|
||||
expect_error_msg = ("None is not a valid option for %s" %
|
||||
param_name)
|
||||
expect_error_msg = f"None is not a valid option for {param_name}"
|
||||
body = self._build_body({param_name: None})
|
||||
response = self.put(self.FP_PATH.format(fp_id=fp.get('id')), body,
|
||||
status=400)
|
||||
@@ -465,8 +464,8 @@ class TestFlavorProfiles(base.BaseAPITest):
|
||||
body = self._build_body(update_data)
|
||||
response = self.put(self.FP_PATH.format(fp_id=fp.get('id')), body,
|
||||
status=409)
|
||||
err_msg = ("Flavor profile {} is in use and cannot be "
|
||||
"modified.".format(fp.get('id')))
|
||||
err_msg = (f"Flavor profile {fp.get('id')} is in use and cannot be "
|
||||
f"modified.")
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
response = self.get(
|
||||
self.FP_PATH.format(fp_id=fp.get('id'))).json.get(self.root_tag)
|
||||
@@ -480,8 +479,8 @@ class TestFlavorProfiles(base.BaseAPITest):
|
||||
body = self._build_body(update_data)
|
||||
response = self.put(self.FP_PATH.format(fp_id=fp.get('id')), body,
|
||||
status=409)
|
||||
err_msg = ("Flavor profile {} is in use and cannot be "
|
||||
"modified.".format(fp.get('id')))
|
||||
err_msg = (f"Flavor profile {fp.get('id')} is in use and cannot "
|
||||
f"be modified.")
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
response = self.get(
|
||||
self.FP_PATH.format(fp_id=fp.get('id'))).json.get(self.root_tag)
|
||||
@@ -506,7 +505,7 @@ class TestFlavorProfiles(base.BaseAPITest):
|
||||
self.delete(self.FP_PATH.format(fp_id=fp.get('id')))
|
||||
response = self.get(self.FP_PATH.format(
|
||||
fp_id=fp.get('id')), status=404)
|
||||
err_msg = "Flavor Profile %s not found." % fp.get('id')
|
||||
err_msg = f"Flavor Profile {fp.get('id')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_deleted_id(self):
|
||||
@@ -552,7 +551,7 @@ class TestFlavorProfiles(base.BaseAPITest):
|
||||
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||
response = self.get(self.FP_PATH.format(
|
||||
fp_id=fp.get('id')), status=404)
|
||||
err_msg = "Flavor Profile %s not found." % fp.get('id')
|
||||
err_msg = f"Flavor Profile {fp.get('id')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_not_authorized(self):
|
||||
@@ -578,8 +577,8 @@ class TestFlavorProfiles(base.BaseAPITest):
|
||||
self.create_flavor('name1', 'description', fp.get('id'), True)
|
||||
response = self.delete(self.FP_PATH.format(fp_id=fp.get('id')),
|
||||
status=409)
|
||||
err_msg = ("Flavor profile {} is in use and cannot be "
|
||||
"modified.".format(fp.get('id')))
|
||||
err_msg = (f"Flavor profile {fp.get('id')} is in use and cannot be "
|
||||
f"modified.")
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
response = self.get(
|
||||
self.FP_PATH.format(fp_id=fp.get('id'))).json.get(self.root_tag)
|
||||
|
||||
@@ -510,7 +510,7 @@ class TestFlavors(base.BaseAPITest):
|
||||
self.delete(self.FLAVOR_PATH.format(flavor_id=flavor.get('id')))
|
||||
response = self.get(self.FLAVOR_PATH.format(
|
||||
flavor_id=flavor.get('id')), status=404)
|
||||
err_msg = "Flavor %s not found." % flavor.get('id')
|
||||
err_msg = f"Flavor {flavor.get('id')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_nonexistent_id(self):
|
||||
@@ -557,7 +557,7 @@ class TestFlavors(base.BaseAPITest):
|
||||
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||
response = self.get(self.FLAVOR_PATH.format(
|
||||
flavor_id=flavor.get('id')), status=404)
|
||||
err_msg = "Flavor %s not found." % flavor.get('id')
|
||||
err_msg = f"Flavor {flavor.get('id')} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_delete_not_authorized(self):
|
||||
|
||||
@@ -1323,7 +1323,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
||||
provisioning_status=constants.ERROR)
|
||||
api_hm = self.create_health_monitor(
|
||||
pool1_id, constants.HEALTH_MONITOR_HTTP, 1, 1, 1, 1, status=409)
|
||||
ref_msg = 'Pool %s is immutable and cannot be updated.' % pool1_id
|
||||
ref_msg = f'Pool {pool1_id} is immutable and cannot be updated.'
|
||||
self.assertEqual(ref_msg, api_hm.get('faultstring'))
|
||||
|
||||
def test_create_with_listener(self):
|
||||
@@ -1852,8 +1852,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
||||
1, 1, 1, 1).get(self.root_tag)
|
||||
new_hm = {constants.DELAY: None}
|
||||
self.set_lb_status(self.lb_id)
|
||||
expect_error_msg = ("None is not a valid option for %s" %
|
||||
constants.DELAY)
|
||||
expect_error_msg = f"None is not a valid option for {constants.DELAY}"
|
||||
res = self.put(self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
||||
self._build_body(new_hm), status=400)
|
||||
self.assertEqual(expect_error_msg, res.json['faultstring'])
|
||||
@@ -1864,8 +1863,8 @@ class TestHealthMonitor(base.BaseAPITest):
|
||||
1, 1, 1, 1).get(self.root_tag)
|
||||
new_hm = {constants.MAX_RETRIES: None}
|
||||
self.set_lb_status(self.lb_id)
|
||||
expect_error_msg = ("None is not a valid option for %s" %
|
||||
constants.MAX_RETRIES)
|
||||
expect_error_msg = (f"None is not a valid option for "
|
||||
f"{constants.MAX_RETRIES}")
|
||||
res = self.put(self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
||||
self._build_body(new_hm), status=400)
|
||||
self.assertEqual(expect_error_msg, res.json['faultstring'])
|
||||
@@ -1876,8 +1875,8 @@ class TestHealthMonitor(base.BaseAPITest):
|
||||
1, 1, 1, 1).get(self.root_tag)
|
||||
new_hm = {constants.TIMEOUT: None}
|
||||
self.set_lb_status(self.lb_id)
|
||||
expect_error_msg = ("None is not a valid option for %s" %
|
||||
constants.TIMEOUT)
|
||||
expect_error_msg = (f"None is not a valid option for "
|
||||
f"{constants.TIMEOUT}")
|
||||
res = self.put(self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
||||
self._build_body(new_hm), status=400)
|
||||
self.assertEqual(expect_error_msg, res.json['faultstring'])
|
||||
|
||||
@@ -599,8 +599,7 @@ class TestL7Rule(base.BaseAPITest):
|
||||
l7policy_id, constants.L7RULE_TYPE_HOST_NAME,
|
||||
constants.L7RULE_COMPARE_TYPE_EQUAL_TO,
|
||||
'www.example.com', status=409)
|
||||
ref_msg = ('L7Policy %s is immutable and cannot be updated.' %
|
||||
l7policy_id)
|
||||
ref_msg = f'L7Policy {l7policy_id} is immutable and cannot be updated.'
|
||||
self.assertEqual(ref_msg, api_l7rule.get('faultstring'))
|
||||
|
||||
def test_create_path_rule(self):
|
||||
|
||||
@@ -699,11 +699,10 @@ class TestListener(base.BaseAPITest):
|
||||
optionals.update({field[0]: 1})
|
||||
fault = resp.get('faultstring')
|
||||
self.assertIn(
|
||||
'Invalid input for field/attribute {}'.format(
|
||||
field[0]), fault)
|
||||
f'Invalid input for field/attribute {field[0]}', fault)
|
||||
self.assertIn(
|
||||
'Value should be lower or equal to {}'.format(
|
||||
constants.MAX_TIMEOUT), fault)
|
||||
f'Value should be lower or equal to {constants.MAX_TIMEOUT}',
|
||||
fault)
|
||||
|
||||
def test_create_with_timeouts_too_low(self):
|
||||
optionals = {
|
||||
@@ -717,8 +716,8 @@ class TestListener(base.BaseAPITest):
|
||||
self.assertIn(
|
||||
'Invalid input for field/attribute timeout_tcp_inspect', fault)
|
||||
self.assertIn(
|
||||
'Value should be greater or equal to {}'.format(
|
||||
constants.MIN_TIMEOUT), fault)
|
||||
f'Value should be greater or equal to {constants.MIN_TIMEOUT}',
|
||||
fault)
|
||||
|
||||
def test_create_udp_case(self):
|
||||
api_listener = self.create_listener(constants.PROTOCOL_UDP, 6666,
|
||||
@@ -1715,8 +1714,7 @@ class TestListener(base.BaseAPITest):
|
||||
fault = response.get('faultstring')
|
||||
self.assertIn(
|
||||
'Certificate container references are not allowed on ', fault)
|
||||
self.assertIn('{} protocol listeners.'.format(
|
||||
constants.PROTOCOL_TCP), fault)
|
||||
self.assertIn(f'{constants.PROTOCOL_TCP} protocol listeners.', fault)
|
||||
|
||||
def test_update_with_ca_cert(self):
|
||||
self.cert_manager_mock().get_secret.return_value = (
|
||||
@@ -2778,7 +2776,7 @@ class TestListener(base.BaseAPITest):
|
||||
listener = self.post(self.LISTENERS_PATH, body, status=400).json
|
||||
self.assertIn('{} is not a valid option for {}'.format(
|
||||
[name],
|
||||
'%s protocol listener.' % constants.PROTOCOL_HTTP),
|
||||
f'{constants.PROTOCOL_HTTP} protocol listener.'),
|
||||
listener.get('faultstring'))
|
||||
|
||||
@mock.patch('octavia.common.tls_utils.cert_parser.load_certificates_data')
|
||||
@@ -2829,9 +2827,9 @@ class TestListener(base.BaseAPITest):
|
||||
listener_id=listener['listener'].get('id'))
|
||||
update_listener = self.put(
|
||||
listener_path, new_listener, status=400).json
|
||||
self.assertIn('{} is not a valid option for {}'.format(
|
||||
'[\'X-Bad-Header\']', 'insert_headers'),
|
||||
update_listener.get('faultstring'))
|
||||
self.assertIn('[\'X-Bad-Header\'] is not a valid option for '
|
||||
'insert_headers',
|
||||
update_listener.get('faultstring'))
|
||||
|
||||
# test client certificate http headers
|
||||
header = {}
|
||||
|
||||
@@ -850,7 +850,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
||||
mock_get_subnet.return_value = subnet
|
||||
mock_get_qos.side_effect = Exception()
|
||||
response = self.post(self.LBS_PATH, body, status=400)
|
||||
err_msg = "qos_policy %s not found." % qos_policy_id
|
||||
err_msg = f"qos_policy {qos_policy_id} not found."
|
||||
self.assertEqual(err_msg, response.json.get('faultstring'))
|
||||
|
||||
def test_create_with_long_name(self):
|
||||
|
||||
@@ -591,7 +591,7 @@ class TestMember(base.BaseAPITest):
|
||||
self.set_object_status(self.pool_repo, pool1_id,
|
||||
provisioning_status=constants.ERROR)
|
||||
api_member = self.create_member(pool1_id, '192.0.2.1', 80, status=409)
|
||||
ref_msg = 'Pool %s is immutable and cannot be updated.' % pool1_id
|
||||
ref_msg = f'Pool {pool1_id} is immutable and cannot be updated.'
|
||||
self.assertEqual(ref_msg, api_member.get('faultstring'))
|
||||
|
||||
# TODO(rm_work) Remove after deprecation of project_id in POST (R series)
|
||||
@@ -1402,7 +1402,7 @@ class TestMember(base.BaseAPITest):
|
||||
member_path = self.MEMBERS_PATH.format(
|
||||
pool_id=bad_pool_id) + '/' + api_member['id']
|
||||
result = self.delete(member_path, status=404).json
|
||||
ref_msg = 'Member %s not found.' % api_member['id']
|
||||
ref_msg = f"Member {api_member['id']} not found."
|
||||
self.assertEqual(ref_msg, result.get('faultstring'))
|
||||
|
||||
@mock.patch('octavia.api.drivers.utils.call_provider')
|
||||
|
||||
@@ -128,8 +128,8 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
||||
'additional_vip')
|
||||
for repo_attr in repo_attr_names:
|
||||
single_repo = getattr(self.repos, repo_attr, None)
|
||||
message = ("Class Repositories should have %s instance"
|
||||
" variable.") % repo_attr
|
||||
message = (f"Class Repositories should have {repo_attr} instance "
|
||||
f"variable.")
|
||||
self.assertIsNotNone(single_repo, message=message)
|
||||
message = (("instance variable, %(repo_name)s, of class "
|
||||
"Repositories should be an instance of %(base)s") %
|
||||
|
||||
@@ -32,8 +32,7 @@ class KeepalivedTestCase(base.TestCase):
|
||||
@mock.patch('subprocess.check_output')
|
||||
def test_manager_keepalived_service(self, mock_check_output):
|
||||
res = self.test_keepalived.manager_keepalived_service('start')
|
||||
cmd = ("/usr/sbin/service octavia-keepalived {action}".format(
|
||||
action='start'))
|
||||
cmd = "/usr/sbin/service octavia-keepalived start"
|
||||
mock_check_output.assert_called_once_with(cmd.split(),
|
||||
stderr=subprocess.STDOUT)
|
||||
self.assertEqual(202, res.status_code)
|
||||
|
||||
@@ -117,8 +117,7 @@ class ListenerTestCase(base.TestCase):
|
||||
consts.AMP_ACTION_RELOAD)
|
||||
self.assertEqual(202, result.status_code)
|
||||
self.assertEqual('OK', result.json['message'])
|
||||
ref_details = ('Listener {} {}ed'.format(listener_id,
|
||||
consts.AMP_ACTION_RELOAD))
|
||||
ref_details = f'Listener {listener_id} {consts.AMP_ACTION_RELOAD}ed'
|
||||
self.assertEqual(ref_details, result.json['details'])
|
||||
|
||||
# Happy path - VRRP - RELOAD - OFFLINE
|
||||
|
||||
@@ -67,10 +67,8 @@ class TestOSUtils(base.TestCase):
|
||||
|
||||
def test_cmd_get_version_of_installed_package(self):
|
||||
package_name = 'foo'
|
||||
ubuntu_cmd = "dpkg-query -W -f=${{Version}} {name}".format(
|
||||
name=package_name)
|
||||
rh_cmd = "rpm -q --queryformat %{{VERSION}} {name}".format(
|
||||
name=package_name)
|
||||
ubuntu_cmd = f"dpkg-query -W -f=${{Version}} {package_name}"
|
||||
rh_cmd = f"rpm -q --queryformat %{{VERSION}} {package_name}"
|
||||
|
||||
returned_ubuntu_cmd = (
|
||||
self.ubuntu_os_util.cmd_get_version_of_installed_package(
|
||||
|
||||
@@ -111,8 +111,7 @@ class TestPlug(base.TestCase):
|
||||
)
|
||||
mock_webob.Response.assert_any_call(json={
|
||||
'message': 'OK',
|
||||
'details': 'VIPs plugged on interface {interface}: {vips}'.format(
|
||||
vips=FAKE_IP_IPV4, interface='eth1')
|
||||
'details': f'VIPs plugged on interface eth1: {FAKE_IP_IPV4}'
|
||||
}, status=202)
|
||||
|
||||
@mock.patch('octavia.amphorae.backends.agent.api_server.plug.Plug.'
|
||||
@@ -140,8 +139,8 @@ class TestPlug(base.TestCase):
|
||||
)
|
||||
mock_webob.Response.assert_any_call(json={
|
||||
'message': 'OK',
|
||||
'details': 'VIPs plugged on interface {interface}: {vips}'.format(
|
||||
vips=FAKE_IP_IPV6_EXPANDED, interface='eth1')
|
||||
'details': f'VIPs plugged on interface eth1: '
|
||||
f'{FAKE_IP_IPV6_EXPANDED}'
|
||||
}, status=202)
|
||||
|
||||
@mock.patch('octavia.amphorae.backends.agent.api_server.plug.Plug.'
|
||||
@@ -338,8 +337,7 @@ class TestPlug(base.TestCase):
|
||||
|
||||
mock_webob.Response.assert_any_call(
|
||||
json={'message': 'OK',
|
||||
'details': 'Updated existing interface {}'.format(
|
||||
FAKE_INTERFACE)},
|
||||
'details': f'Updated existing interface {FAKE_INTERFACE}'},
|
||||
status=202)
|
||||
|
||||
@mock.patch.object(plug, "webob")
|
||||
@@ -408,8 +406,7 @@ class TestPlug(base.TestCase):
|
||||
|
||||
mock_webob.Response.assert_any_call(
|
||||
json={'message': 'OK',
|
||||
'details': 'Updated existing interface {}'.format(
|
||||
FAKE_INTERFACE)},
|
||||
'details': f'Updated existing interface {FAKE_INTERFACE}'},
|
||||
status=202)
|
||||
|
||||
@mock.patch('pyroute2.NetNS', create=True)
|
||||
|
||||
@@ -170,4 +170,4 @@ class QueryTestCase(base.TestCase):
|
||||
try:
|
||||
self.q.save_state(filename)
|
||||
except Exception as ex:
|
||||
self.fail("save_state() raised %r unexpectedly!" % ex)
|
||||
self.fail(f"save_state() raised {ex!r} unexpectedly!")
|
||||
|
||||
@@ -274,8 +274,7 @@ class TestInterface(base.TestCase):
|
||||
mock_check_output.assert_called_once_with(
|
||||
["/sbin/dhclient",
|
||||
"-lf",
|
||||
"/var/lib/dhclient/dhclient-{}.leases".format(
|
||||
iface),
|
||||
f"/var/lib/dhclient/dhclient-{iface}.leases",
|
||||
"-pf",
|
||||
f"/run/dhclient-{iface}.pid",
|
||||
iface], stderr=-2)
|
||||
@@ -291,8 +290,7 @@ class TestInterface(base.TestCase):
|
||||
["/sbin/dhclient",
|
||||
"-r",
|
||||
"-lf",
|
||||
"/var/lib/dhclient/dhclient-{}.leases".format(
|
||||
iface),
|
||||
f"/var/lib/dhclient/dhclient-{iface}.leases",
|
||||
"-pf",
|
||||
f"/run/dhclient-{iface}.pid",
|
||||
iface], stderr=-2)
|
||||
@@ -921,8 +919,7 @@ class TestInterface(base.TestCase):
|
||||
mock_check_output.assert_has_calls([
|
||||
mock.call(["/sbin/dhclient",
|
||||
"-lf",
|
||||
"/var/lib/dhclient/dhclient-{}.leases".format(
|
||||
iface.name),
|
||||
f"/var/lib/dhclient/dhclient-{iface.name}.leases",
|
||||
"-pf",
|
||||
f"/run/dhclient-{iface.name}.pid",
|
||||
iface.name], stderr=-2),
|
||||
@@ -1338,8 +1335,7 @@ class TestInterface(base.TestCase):
|
||||
mock.call(["/sbin/dhclient",
|
||||
"-r",
|
||||
"-lf",
|
||||
"/var/lib/dhclient/dhclient-{}.leases".format(
|
||||
iface.name),
|
||||
f"/var/lib/dhclient/dhclient-{iface.name}.leases",
|
||||
"-pf",
|
||||
f"/run/dhclient-{iface.name}.pid",
|
||||
iface.name], stderr=-2),
|
||||
|
||||
@@ -112,13 +112,13 @@ class TestInterfaceFile(base.TestCase):
|
||||
consts.SCRIPTS: {
|
||||
consts.IFACE_UP: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
f"{netns_interface}")
|
||||
}],
|
||||
consts.IFACE_DOWN: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"{netns_interface}")
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -244,13 +244,13 @@ class TestInterfaceFile(base.TestCase):
|
||||
consts.SCRIPTS: {
|
||||
consts.IFACE_UP: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
f"{netns_interface}")
|
||||
}],
|
||||
consts.IFACE_DOWN: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"{netns_interface}")
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -323,13 +323,13 @@ class TestInterfaceFile(base.TestCase):
|
||||
consts.SCRIPTS: {
|
||||
consts.IFACE_UP: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
f"{netns_interface}")
|
||||
}],
|
||||
consts.IFACE_DOWN: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
f"{netns_interface}")
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -404,13 +404,13 @@ class TestInterfaceFile(base.TestCase):
|
||||
consts.SCRIPTS: {
|
||||
consts.IFACE_UP: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
f"{netns_interface}")
|
||||
}],
|
||||
consts.IFACE_DOWN: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
f"{netns_interface}")
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -516,13 +516,13 @@ class TestInterfaceFile(base.TestCase):
|
||||
consts.SCRIPTS: {
|
||||
consts.IFACE_UP: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv6 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv6 "
|
||||
f"{netns_interface}")
|
||||
}],
|
||||
consts.IFACE_DOWN: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv6 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh delete ipv6 "
|
||||
f"{netns_interface}")
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -603,21 +603,21 @@ class TestInterfaceFile(base.TestCase):
|
||||
consts.SCRIPTS: {
|
||||
consts.IFACE_UP: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
f"{netns_interface}")
|
||||
}, {
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv6 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv6 "
|
||||
f"{netns_interface}")
|
||||
}],
|
||||
consts.IFACE_DOWN: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
f"{netns_interface}")
|
||||
}, {
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv6 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh delete ipv6 "
|
||||
f"{netns_interface}")
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -654,21 +654,21 @@ class TestInterfaceFile(base.TestCase):
|
||||
consts.SCRIPTS: {
|
||||
consts.IFACE_UP: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv4 "
|
||||
f"{netns_interface}")
|
||||
}, {
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh add ipv6 "
|
||||
"{}".format(netns_interface))
|
||||
f"/usr/local/bin/lvs-masquerade.sh add ipv6 "
|
||||
f"{netns_interface}")
|
||||
}],
|
||||
consts.IFACE_DOWN: [{
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv4 "
|
||||
"{}".format(netns_interface))
|
||||
f"{netns_interface}")
|
||||
}, {
|
||||
consts.COMMAND: (
|
||||
"/usr/local/bin/lvs-masquerade.sh delete ipv6 "
|
||||
"{}".format(netns_interface))
|
||||
f"{netns_interface}")
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ class TestNetworkNamespace(base.TestCase):
|
||||
mock_cdll.return_value = mock_cdll_obj
|
||||
mock_getpid.return_value = FAKE_PID
|
||||
expected_current_netns = f'/proc/{FAKE_PID}/ns/net'
|
||||
expected_target_netns = '/var/run/netns/{netns}'.format(
|
||||
netns=FAKE_NETNS)
|
||||
expected_target_netns = f'/var/run/netns/{FAKE_NETNS}'
|
||||
|
||||
netns = network_namespace.NetworkNamespace(FAKE_NETNS)
|
||||
|
||||
@@ -73,8 +72,7 @@ class TestNetworkNamespace(base.TestCase):
|
||||
mock_cdll_obj = mock.MagicMock()
|
||||
mock_cdll.return_value = mock_cdll_obj
|
||||
expected_current_netns = f'/proc/{FAKE_PID}/ns/net'
|
||||
expected_target_netns = '/var/run/netns/{netns}'.format(
|
||||
netns=FAKE_NETNS)
|
||||
expected_target_netns = f'/var/run/netns/{FAKE_NETNS}'
|
||||
|
||||
netns = network_namespace.NetworkNamespace(FAKE_NETNS)
|
||||
|
||||
|
||||
@@ -420,9 +420,8 @@ class TestHaproxyAmphoraLoadBalancerDriverTest(base.TestCase):
|
||||
mock_build_pem.return_value = fake_pem
|
||||
ref_md5 = md5(fake_pem, usedforsecurity=False).hexdigest() # nosec
|
||||
ref_name = f'{pool_cert.id}.pem'
|
||||
ref_path = '{cert_dir}/{lb_id}/{name}'.format(
|
||||
cert_dir=fake_cert_dir, lb_id=sample_listener.load_balancer.id,
|
||||
name=ref_name)
|
||||
ref_path = (f'{fake_cert_dir}/{sample_listener.load_balancer.id}/'
|
||||
f'{ref_name}')
|
||||
ref_ca_name = 'fake_ca.pem'
|
||||
ref_ca_path = '{cert_dir}/{lb_id}/{name}'.format(
|
||||
cert_dir=fake_cert_dir, lb_id=sample_listener.load_balancer.id,
|
||||
@@ -1083,81 +1082,71 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_start_loadbalancer(self, m):
|
||||
m.put("{base}/loadbalancer/{loadbalancer_id}/start".format(
|
||||
base=self.base_url_ver, loadbalancer_id=FAKE_UUID_1))
|
||||
m.put(f"{self.base_url_ver}/loadbalancer/{FAKE_UUID_1}/start")
|
||||
self.driver.start_listener(self.amp, FAKE_UUID_1)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_start_loadbalancer_missing(self, m):
|
||||
m.put("{base}/loadbalancer/{loadbalancer_id}/start".format(
|
||||
base=self.base_url_ver, loadbalancer_id=FAKE_UUID_1),
|
||||
status_code=404,
|
||||
headers={'content-type': 'application/json'})
|
||||
m.put(f"{self.base_url_ver}/loadbalancer/{FAKE_UUID_1}/start",
|
||||
status_code=404,
|
||||
headers={'content-type': 'application/json'})
|
||||
self.assertRaises(exc.NotFound, self.driver.start_listener,
|
||||
self.amp, FAKE_UUID_1)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_start_loadbalancer_unauthorized(self, m):
|
||||
m.put("{base}/loadbalancer/{loadbalancer_id}/start".format(
|
||||
base=self.base_url_ver, loadbalancer_id=FAKE_UUID_1),
|
||||
status_code=401)
|
||||
m.put(f"{self.base_url_ver}/loadbalancer/{FAKE_UUID_1}/start",
|
||||
status_code=401)
|
||||
self.assertRaises(exc.Unauthorized, self.driver.start_listener,
|
||||
self.amp, FAKE_UUID_1)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_start_loadbalancer_server_error(self, m):
|
||||
m.put("{base}/loadbalancer/{loadbalancer_id}/start".format(
|
||||
base=self.base_url_ver, loadbalancer_id=FAKE_UUID_1),
|
||||
status_code=500)
|
||||
m.put(f"{self.base_url_ver}/loadbalancer/{FAKE_UUID_1}/start",
|
||||
status_code=500)
|
||||
self.assertRaises(exc.InternalServerError, self.driver.start_listener,
|
||||
self.amp, FAKE_UUID_1)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_start_loadbalancer_service_unavailable(self, m):
|
||||
m.put("{base}/loadbalancer/{loadbalancer_id}/start".format(
|
||||
base=self.base_url_ver, loadbalancer_id=FAKE_UUID_1),
|
||||
status_code=503)
|
||||
m.put(f"{self.base_url_ver}/loadbalancer/{FAKE_UUID_1}/start",
|
||||
status_code=503)
|
||||
self.assertRaises(exc.ServiceUnavailable, self.driver.start_listener,
|
||||
self.amp, FAKE_UUID_1)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_delete_listener(self, m):
|
||||
m.delete("{base}/listeners/{listener_id}".format(
|
||||
base=self.base_url_ver, listener_id=FAKE_UUID_1), json={})
|
||||
m.delete(f"{self.base_url_ver}/listeners/{FAKE_UUID_1}", json={})
|
||||
self.driver.delete_listener(self.amp, FAKE_UUID_1)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_delete_listener_missing(self, m):
|
||||
m.delete("{base}/listeners/{listener_id}".format(
|
||||
base=self.base_url_ver, listener_id=FAKE_UUID_1),
|
||||
status_code=404,
|
||||
headers={'content-type': 'application/json'})
|
||||
m.delete(f"{self.base_url_ver}/listeners/{FAKE_UUID_1}",
|
||||
status_code=404,
|
||||
headers={'content-type': 'application/json'})
|
||||
self.driver.delete_listener(self.amp, FAKE_UUID_1)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_delete_listener_unauthorized(self, m):
|
||||
m.delete("{base}/listeners/{listener_id}".format(
|
||||
base=self.base_url_ver, listener_id=FAKE_UUID_1),
|
||||
status_code=401)
|
||||
m.delete(f"{self.base_url_ver}/listeners/{FAKE_UUID_1}",
|
||||
status_code=401)
|
||||
self.assertRaises(exc.Unauthorized, self.driver.delete_listener,
|
||||
self.amp, FAKE_UUID_1)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_delete_listener_server_error(self, m):
|
||||
m.delete("{base}/listeners/{listener_id}".format(
|
||||
base=self.base_url_ver, listener_id=FAKE_UUID_1),
|
||||
status_code=500)
|
||||
m.delete(f"{self.base_url_ver}/listeners/{FAKE_UUID_1}",
|
||||
status_code=500)
|
||||
self.assertRaises(exc.InternalServerError, self.driver.delete_listener,
|
||||
self.amp, FAKE_UUID_1)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_delete_listener_service_unavailable(self, m):
|
||||
m.delete("{base}/listeners/{listener_id}".format(
|
||||
base=self.base_url_ver, listener_id=FAKE_UUID_1),
|
||||
status_code=503)
|
||||
m.delete(f"{self.base_url_ver}/listeners/{FAKE_UUID_1}",
|
||||
status_code=503)
|
||||
self.assertRaises(exc.ServiceUnavailable, self.driver.delete_listener,
|
||||
self.amp, FAKE_UUID_1)
|
||||
|
||||
@@ -1356,10 +1345,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_config(self, m):
|
||||
config = {"name": "fake_config"}
|
||||
m.put(
|
||||
"{base}/loadbalancer/{"
|
||||
"amphora_id}/{loadbalancer_id}/haproxy".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
loadbalancer_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/loadbalancer/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/haproxy",
|
||||
json=config)
|
||||
self.driver.upload_config(self.amp, FAKE_UUID_1,
|
||||
config)
|
||||
@@ -1369,10 +1356,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_invalid_config(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/loadbalancer/{"
|
||||
"amphora_id}/{loadbalancer_id}/haproxy".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
loadbalancer_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/loadbalancer/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/haproxy",
|
||||
status_code=400)
|
||||
self.assertRaises(exc.InvalidRequest, self.driver.upload_config,
|
||||
self.amp, FAKE_UUID_1, config)
|
||||
@@ -1381,10 +1366,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_config_unauthorized(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/loadbalancer/{"
|
||||
"amphora_id}/{loadbalancer_id}/haproxy".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
loadbalancer_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/loadbalancer/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/haproxy",
|
||||
status_code=401)
|
||||
self.assertRaises(exc.Unauthorized, self.driver.upload_config,
|
||||
self.amp, FAKE_UUID_1, config)
|
||||
@@ -1393,10 +1376,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_config_server_error(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/loadbalancer/{"
|
||||
"amphora_id}/{loadbalancer_id}/haproxy".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
loadbalancer_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/loadbalancer/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/haproxy",
|
||||
status_code=500)
|
||||
self.assertRaises(exc.InternalServerError, self.driver.upload_config,
|
||||
self.amp, FAKE_UUID_1, config)
|
||||
@@ -1405,10 +1386,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_config_service_unavailable(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/loadbalancer/{"
|
||||
"amphora_id}/{loadbalancer_id}/haproxy".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
loadbalancer_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/loadbalancer/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/haproxy",
|
||||
status_code=503)
|
||||
self.assertRaises(exc.ServiceUnavailable, self.driver.upload_config,
|
||||
self.amp, FAKE_UUID_1, config)
|
||||
@@ -1417,10 +1396,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_udp_config(self, m):
|
||||
config = {"name": "fake_config"}
|
||||
m.put(
|
||||
"{base}/listeners/"
|
||||
"{amphora_id}/{listener_id}/udp_listener".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
listener_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/listeners/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/udp_listener",
|
||||
json=config)
|
||||
self.driver.upload_udp_config(self.amp, FAKE_UUID_1, config)
|
||||
self.assertTrue(m.called)
|
||||
@@ -1429,10 +1406,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_udp_invalid_config(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/listeners/"
|
||||
"{amphora_id}/{listener_id}/udp_listener".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
listener_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/listeners/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/udp_listener",
|
||||
status_code=400)
|
||||
self.assertRaises(exc.InvalidRequest, self.driver.upload_udp_config,
|
||||
self.amp, FAKE_UUID_1, config)
|
||||
@@ -1441,10 +1416,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_udp_config_unauthorized(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/listeners/"
|
||||
"{amphora_id}/{listener_id}/udp_listener".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
listener_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/listeners/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/udp_listener",
|
||||
status_code=401)
|
||||
self.assertRaises(exc.Unauthorized, self.driver.upload_udp_config,
|
||||
self.amp, FAKE_UUID_1, config)
|
||||
@@ -1453,10 +1426,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_udp_config_server_error(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/listeners/"
|
||||
"{amphora_id}/{listener_id}/udp_listener".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
listener_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/listeners/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/udp_listener",
|
||||
status_code=500)
|
||||
self.assertRaises(exc.InternalServerError,
|
||||
self.driver.upload_udp_config,
|
||||
@@ -1466,10 +1437,8 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_upload_udp_config_service_unavailable(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put(
|
||||
"{base}/listeners/"
|
||||
"{amphora_id}/{listener_id}/udp_listener".format(
|
||||
amphora_id=self.amp.id, base=self.base_url_ver,
|
||||
listener_id=FAKE_UUID_1),
|
||||
f"{self.base_url_ver}/listeners/{self.amp.id}/"
|
||||
f"{FAKE_UUID_1}/udp_listener",
|
||||
status_code=503)
|
||||
self.assertRaises(exc.ServiceUnavailable,
|
||||
self.driver.upload_udp_config,
|
||||
@@ -1477,18 +1446,14 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_plug_vip(self, m):
|
||||
m.post("{base}/plug/vip/{vip}".format(
|
||||
base=self.base_url_ver, vip=FAKE_IP)
|
||||
)
|
||||
m.post(f"{self.base_url_ver}/plug/vip/{FAKE_IP}")
|
||||
self.driver.plug_vip(self.amp, FAKE_IP, self.subnet_info)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_plug_vip_api_not_ready(self, m):
|
||||
m.post("{base}/plug/vip/{vip}".format(
|
||||
base=self.base_url_ver, vip=FAKE_IP),
|
||||
status_code=404, headers={'content-type': 'text/html'}
|
||||
)
|
||||
m.post(f"{self.base_url_ver}/plug/vip/{FAKE_IP}",
|
||||
status_code=404, headers={'content-type': 'text/html'})
|
||||
self.assertRaises(driver_except.TimeOutException,
|
||||
self.driver.plug_vip,
|
||||
self.amp, FAKE_IP, self.subnet_info)
|
||||
@@ -1496,26 +1461,21 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_plug_network(self, m):
|
||||
m.post("{base}/plug/network".format(
|
||||
base=self.base_url_ver)
|
||||
)
|
||||
m.post(f"{self.base_url_ver}/plug/network")
|
||||
self.driver.plug_network(self.amp, self.port_info)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_upload_vrrp_config(self, m):
|
||||
config = '{"name": "bad_config"}'
|
||||
m.put("{base}/vrrp/upload".format(
|
||||
base=self.base_url_ver)
|
||||
)
|
||||
m.put(f"{self.base_url_ver}/vrrp/upload")
|
||||
self.driver.upload_vrrp_config(self.amp, config)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@requests_mock.mock()
|
||||
def test_vrrp_action(self, m):
|
||||
action = 'start'
|
||||
m.put("{base}/vrrp/{action}".format(base=self.base_url_ver,
|
||||
action=action))
|
||||
m.put(f"{self.base_url_ver}/vrrp/{action}")
|
||||
self.driver._vrrp_action(action, self.amp)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@@ -1523,8 +1483,7 @@ class TestAmphoraAPIClientTest(base.TestCase):
|
||||
def test_get_interface(self, m):
|
||||
interface = [{"interface": "eth1"}]
|
||||
ip_addr = '192.51.100.1'
|
||||
m.get("{base}/interface/{ip_addr}".format(base=self.base_url_ver,
|
||||
ip_addr=ip_addr),
|
||||
m.get(f"{self.base_url_ver}/interface/{ip_addr}",
|
||||
json=interface)
|
||||
self.driver.get_interface(self.amp, ip_addr)
|
||||
self.assertTrue(m.called)
|
||||
|
||||
@@ -353,7 +353,7 @@ class TestUpdateHealthDb(base.TestCase):
|
||||
mock_listener1.default_pool = mock_pool1
|
||||
for i in range(members):
|
||||
mock_member_x = mock.Mock()
|
||||
mock_member_x.id = 'member-id-%s' % (i + 1)
|
||||
mock_member_x.id = f'member-id-{i + 1}'
|
||||
if health_monitor:
|
||||
mock_member_x.operating_status = 'NOTHING_MATCHABLE'
|
||||
else:
|
||||
@@ -381,7 +381,7 @@ class TestUpdateHealthDb(base.TestCase):
|
||||
member_operating_status = constants.NO_MONITOR
|
||||
|
||||
for i in range(members):
|
||||
member_id = 'member-id-%s' % (i + 1)
|
||||
member_id = f'member-id-{i + 1}'
|
||||
members_dict[member_id] = {
|
||||
constants.OPERATING_STATUS: member_operating_status}
|
||||
|
||||
@@ -1245,7 +1245,7 @@ class TestUpdateHealthDb(base.TestCase):
|
||||
# Build our own custom listeners/pools/members
|
||||
for i in [1, 2, 3, 4, 5]:
|
||||
|
||||
lb_ref['listeners']['listener-id-%s' % i] = {
|
||||
lb_ref['listeners'][f'listener-id-{i}'] = {
|
||||
constants.OPERATING_STATUS: 'bogus',
|
||||
'protocol': constants.PROTOCOL_TCP,
|
||||
'enabled': True}
|
||||
@@ -1255,9 +1255,9 @@ class TestUpdateHealthDb(base.TestCase):
|
||||
constants.OPERATING_STATUS: 'bogus'}, 'member-id-31': {
|
||||
constants.OPERATING_STATUS: 'bogus'}}
|
||||
else:
|
||||
members_dict = {'member-id-%s' % i: {
|
||||
members_dict = {f'member-id-{i}': {
|
||||
constants.OPERATING_STATUS: 'bogus'}}
|
||||
lb_ref['pools']['pool-id-%s' % i] = {
|
||||
lb_ref['pools'][f'pool-id-{i}'] = {
|
||||
'members': members_dict, constants.OPERATING_STATUS: 'bogus'}
|
||||
|
||||
self.amphora_repo.get_lb_for_health_update.return_value = lb_ref
|
||||
|
||||
@@ -180,11 +180,8 @@ class TestPaginationHelper(base.TestCase):
|
||||
self.assertEqual(links[0].rel, "next")
|
||||
self.assertEqual(
|
||||
links[0].href,
|
||||
"{path_url}?limit={limit}&marker={marker}".format(
|
||||
path_url=request_mock.path_url,
|
||||
limit=params['limit'],
|
||||
marker=member1.id
|
||||
))
|
||||
f"{request_mock.path_url}?limit={params['limit']}&"
|
||||
f"marker={member1.id}")
|
||||
|
||||
@mock.patch('octavia.api.common.pagination.request')
|
||||
def test_make_links_prev(self, request_mock):
|
||||
@@ -200,17 +197,13 @@ class TestPaginationHelper(base.TestCase):
|
||||
self.assertEqual(links[0].rel, "previous")
|
||||
self.assertEqual(
|
||||
links[1].href,
|
||||
"{path_url}?limit={limit}&marker={marker}".format(
|
||||
path_url=request_mock.path_url,
|
||||
limit=params['limit'],
|
||||
marker=member1.id))
|
||||
f"{request_mock.path_url}?limit={params['limit']}&"
|
||||
f"marker={member1.id}")
|
||||
self.assertEqual(links[1].rel, "next")
|
||||
self.assertEqual(
|
||||
links[1].href,
|
||||
"{path_url}?limit={limit}&marker={marker}".format(
|
||||
path_url=request_mock.path_url,
|
||||
limit=params['limit'],
|
||||
marker=member1.id))
|
||||
f"{request_mock.path_url}?limit={params['limit']}&"
|
||||
f"marker={member1.id}")
|
||||
|
||||
@mock.patch('octavia.api.common.pagination.request')
|
||||
def test_make_links_with_configured_url(self, request_mock):
|
||||
|
||||
@@ -34,9 +34,8 @@ class TestBarbicanManager(base.TestCase):
|
||||
self.barbican_endpoint = 'http://localhost:9311/v1'
|
||||
self.secret_uuid = uuid.uuid4()
|
||||
|
||||
self.secret_ref = '{}/secrets/{}'.format(
|
||||
self.barbican_endpoint, self.secret_uuid
|
||||
)
|
||||
self.secret_ref = (f'{self.barbican_endpoint}/secrets/'
|
||||
f'{self.secret_uuid}')
|
||||
|
||||
self.name = 'My Fancy Cert'
|
||||
self.secret_pkcs12 = secrets.Secret(
|
||||
|
||||
@@ -47,23 +47,21 @@ class TestHaproxyCfg(base.TestCase):
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 "
|
||||
"ssl crt-list {crt_list} "
|
||||
f"ssl crt-list {FAKE_CRT_LIST_FILENAME} "
|
||||
"ca-file /var/lib/octavia/certs/sample_loadbalancer_id_1/"
|
||||
"client_ca.pem verify required crl-file /var/lib/octavia/"
|
||||
"certs/sample_loadbalancer_id_1/SHA_ID.pem ciphers {ciphers} "
|
||||
"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
"certs/sample_loadbalancer_id_1/SHA_ID.pem ciphers "
|
||||
f"{constants.CIPHERS_OWASP_SUITE_B} "
|
||||
"no-sslv3 no-tlsv10 no-tlsv11 alpn "
|
||||
f"{','.join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)}\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -71,7 +69,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -80,8 +78,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"sample_member_id_2\n\n")
|
||||
tls_tupe = {'cont_id_1':
|
||||
sample_configs_combined.sample_tls_container_tuple(
|
||||
id='tls_container_id',
|
||||
@@ -106,20 +103,18 @@ class TestHaproxyCfg(base.TestCase):
|
||||
FAKE_CRT_LIST_FILENAME = os.path.join(
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list {crt_list}"
|
||||
" ciphers {ciphers} no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
f" bind 10.0.0.2:443 ssl crt-list {FAKE_CRT_LIST_FILENAME}"
|
||||
f" ciphers {constants.CIPHERS_OWASP_SUITE_B} no-sslv3 "
|
||||
f"no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -127,7 +122,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -136,8 +131,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -159,19 +153,18 @@ class TestHaproxyCfg(base.TestCase):
|
||||
FAKE_CRT_LIST_FILENAME = os.path.join(
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list {crt_list} "
|
||||
"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list "
|
||||
f"{FAKE_CRT_LIST_FILENAME} "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -211,24 +204,22 @@ class TestHaproxyCfg(base.TestCase):
|
||||
FAKE_CRT_LIST_FILENAME = os.path.join(
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 "
|
||||
"ssl crt-list {crt_list} "
|
||||
f"ssl crt-list {FAKE_CRT_LIST_FILENAME} "
|
||||
"ca-file /var/lib/octavia/certs/sample_loadbalancer_id_1/"
|
||||
"client_ca.pem verify required crl-file /var/lib/octavia/"
|
||||
"certs/sample_loadbalancer_id_1/SHA_ID.pem ciphers {ciphers} "
|
||||
"alpn {alpn}\n"
|
||||
"certs/sample_loadbalancer_id_1/SHA_ID.pem ciphers "
|
||||
f"{constants.CIPHERS_OWASP_SUITE_B} "
|
||||
f"alpn {alpn}\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -271,19 +262,18 @@ class TestHaproxyCfg(base.TestCase):
|
||||
FAKE_CRT_LIST_FILENAME = os.path.join(
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list {crt_list} "
|
||||
"alpn {alpn}\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list "
|
||||
f"{FAKE_CRT_LIST_FILENAME} "
|
||||
f"alpn {alpn}\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -325,20 +315,19 @@ class TestHaproxyCfg(base.TestCase):
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
alpn_protocols = ['chip', 'dale']
|
||||
alpn = ",".join(alpn_protocols)
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list {crt_list} "
|
||||
"ciphers {ciphers} no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list "
|
||||
f"{FAKE_CRT_LIST_FILENAME} "
|
||||
f"ciphers {constants.CIPHERS_OWASP_SUITE_B} "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B,
|
||||
alpn=",".join(alpn_protocols))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -380,18 +369,17 @@ class TestHaproxyCfg(base.TestCase):
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list {crt_list} "
|
||||
"ciphers {ciphers} no-sslv3 no-tlsv10 no-tlsv11\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list "
|
||||
f"{FAKE_CRT_LIST_FILENAME} "
|
||||
f"ciphers {constants.CIPHERS_OWASP_SUITE_B} no-sslv3 "
|
||||
f"no-tlsv10 no-tlsv11\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B)
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -433,18 +421,17 @@ class TestHaproxyCfg(base.TestCase):
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000;\"\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list {crt_list} "
|
||||
"ciphers {ciphers} no-sslv3 no-tlsv10 no-tlsv11\n"
|
||||
" bind 10.0.0.2:443 ssl crt-list "
|
||||
f"{FAKE_CRT_LIST_FILENAME} "
|
||||
f"ciphers {constants.CIPHERS_OWASP_SUITE_B} "
|
||||
"no-sslv3 no-tlsv10 no-tlsv11\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B)
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -486,22 +473,20 @@ class TestHaproxyCfg(base.TestCase):
|
||||
FAKE_CRT_LIST_FILENAME = os.path.join(
|
||||
CONF.haproxy_amphora.base_cert_dir,
|
||||
'sample_loadbalancer_id_1/sample_listener_id_1.pem')
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" bind 10.0.0.2:443 "
|
||||
"ssl crt-list {crt_list} "
|
||||
f"ssl crt-list {FAKE_CRT_LIST_FILENAME} "
|
||||
"ca-file /var/lib/octavia/certs/sample_loadbalancer_id_1/"
|
||||
"client_ca.pem verify required crl-file /var/lib/octavia/"
|
||||
"certs/sample_loadbalancer_id_1/SHA_ID.pem ciphers {ciphers} "
|
||||
"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
"certs/sample_loadbalancer_id_1/SHA_ID.pem ciphers "
|
||||
f"{constants.CIPHERS_OWASP_SUITE_B} "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" mode http\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
crt_list=FAKE_CRT_LIST_FILENAME,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -881,7 +866,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option external-check\n"
|
||||
" external-check command /var/lib/octavia/ping-wrapper.sh\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -890,10 +875,9 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
go = " maxconn {maxconn}\n external-check\n\n".format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
go = (f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
f" external-check\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -910,7 +894,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option external-check\n"
|
||||
" external-check command /var/lib/octavia/ping-wrapper.sh\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -919,8 +903,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
go = (
|
||||
" server-state-file /var/lib/octavia/sample_loadbalancer_id_1/"
|
||||
"servers-state\n"
|
||||
@@ -938,12 +921,11 @@ class TestHaproxyCfg(base.TestCase):
|
||||
|
||||
def test_render_template_no_monitor_https(self):
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" bind 10.0.0.2:443\n"
|
||||
" mode tcp\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
" timeout client 50000\n")
|
||||
lg = (" log-format 12345\\ sample_loadbalancer_id_1\\ %f\\ "
|
||||
"%ci\\ %cp\\ %t\\ -\\ -\\ %B\\ %U\\ "
|
||||
"%[ssl_c_verify]\\ %{+Q}[ssl_c_s_dn]\\ %b\\ %s\\ %Tt\\ "
|
||||
@@ -952,15 +934,14 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" mode tcp\n"
|
||||
" balance roundrobin\n"
|
||||
" cookie SRV insert indirect nocache\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(proto='HTTPS',
|
||||
@@ -977,7 +958,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" option httpchk GET /index.html HTTP/1.1\\r\\nHost:\\ "
|
||||
"testlab.com\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -986,8 +967,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -997,12 +977,11 @@ class TestHaproxyCfg(base.TestCase):
|
||||
|
||||
def test_render_template_no_persistence_https(self):
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" bind 10.0.0.2:443\n"
|
||||
" mode tcp\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
" timeout client 50000\n")
|
||||
lg = (" log-format 12345\\ sample_loadbalancer_id_1\\ %f\\ "
|
||||
"%ci\\ %cp\\ %t\\ -\\ -\\ %B\\ %U\\ "
|
||||
"%[ssl_c_verify]\\ %{+Q}[ssl_c_s_dn]\\ %b\\ %s\\ %Tt\\ "
|
||||
@@ -1010,14 +989,13 @@ class TestHaproxyCfg(base.TestCase):
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode tcp\n"
|
||||
" balance roundrobin\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"weight 13\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1029,14 +1007,13 @@ class TestHaproxyCfg(base.TestCase):
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"weight 13\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1053,15 +1030,14 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"weight 13 check inter 30s fall 3 rise 2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1080,15 +1056,14 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"weight 13 check inter 30s fall 3 rise 2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1115,21 +1090,19 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"%ci\\ %cp\\ %t\\ -\\ -\\ %B\\ %U\\ "
|
||||
"%[ssl_c_verify]\\ %{+Q}[ssl_c_s_dn]\\ %b\\ %s\\ %Tt\\ "
|
||||
"%tsc\n\n")
|
||||
be = ("backend {pool_id}:{listener_id}\n"
|
||||
be = (f"backend {sample_listener.default_pool.id}:"
|
||||
f"{sample_listener.id}\n"
|
||||
" mode tcp\n"
|
||||
" balance roundrobin\n"
|
||||
" cookie SRV insert indirect nocache\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
pool_id=sample_listener.default_pool.id,
|
||||
listener_id=sample_listener.id)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_amphora,
|
||||
[sample_listener])
|
||||
@@ -1203,7 +1176,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1219,13 +1192,12 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /healthmon.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_3 10.0.0.97:82 weight 13 check "
|
||||
"inter 30s fall 3 rise 2 cookie sample_member_id_3\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"inter 30s fall 3 rise 2 cookie sample_member_id_3\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(l7=True)])
|
||||
@@ -1241,7 +1213,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" option forwardfor\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1250,8 +1222,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1270,7 +1241,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" http-check expect rstatus 418\n"
|
||||
" option forwardfor\n"
|
||||
" http-request set-header X-Forwarded-Port %[dst_port]\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1279,8 +1250,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1296,7 +1266,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" balance roundrobin\n"
|
||||
" cookie SRV insert indirect nocache\n"
|
||||
" timeout check 31s\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1305,8 +1275,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1 send-proxy\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2 send-proxy\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"cookie sample_member_id_2 send-proxy\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(be_proto='PROXY')])
|
||||
@@ -1318,6 +1287,10 @@ class TestHaproxyCfg(base.TestCase):
|
||||
feature_compatibility = {constants.POOL_ALPN: True}
|
||||
cert_file_path = os.path.join(self.jinja_cfg.base_crt_dir,
|
||||
'sample_listener_id_1', 'fake path')
|
||||
opts = (f"ssl crt {cert_file_path} verify none sni ssl_fc_sni "
|
||||
f"ciphers {constants.CIPHERS_OWASP_SUITE_B} "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11")
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -1325,21 +1298,16 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_2 {opts} alpn {alpn}\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
opts="ssl crt %s verify none sni ssl_fc_sni" % cert_file_path +
|
||||
" ciphers " + constants.CIPHERS_OWASP_SUITE_B +
|
||||
" no-sslv3 no-tlsv10 no-tlsv11",
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_2 {opts} alpn {alpn}\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1358,6 +1326,9 @@ class TestHaproxyCfg(base.TestCase):
|
||||
feature_compatibility = {constants.POOL_ALPN: False}
|
||||
cert_file_path = os.path.join(self.jinja_cfg.base_crt_dir,
|
||||
'sample_listener_id_1', 'fake path')
|
||||
opts = (f"ssl crt {cert_file_path} verify none sni ssl_fc_sni "
|
||||
f"ciphers {constants.CIPHERS_OWASP_SUITE_B} "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -1365,20 +1336,16 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"check inter 30s fall 3 rise 2 cookie sample_member_id_1 "
|
||||
"{opts}\n"
|
||||
f"{opts}\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"check inter 30s fall 3 rise 2 cookie sample_member_id_2 "
|
||||
"{opts}\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
opts="ssl crt %s verify none sni ssl_fc_sni" % cert_file_path +
|
||||
" ciphers " + constants.CIPHERS_OWASP_SUITE_B +
|
||||
" no-sslv3 no-tlsv10 no-tlsv11")
|
||||
f"{opts}\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1397,6 +1364,9 @@ class TestHaproxyCfg(base.TestCase):
|
||||
feature_compatibility = {constants.POOL_ALPN: True}
|
||||
cert_file_path = os.path.join(self.jinja_cfg.base_crt_dir,
|
||||
'sample_listener_id_1', 'fake path')
|
||||
opts = (f"ssl crt {cert_file_path} verify none sni ssl_fc_sni "
|
||||
f"ciphers {constants.CIPHERS_OWASP_SUITE_B}")
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -1404,20 +1374,17 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_2 {opts} alpn {alpn}\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
opts="ssl crt %s verify none sni ssl_fc_sni" % cert_file_path +
|
||||
" ciphers " + constants.CIPHERS_OWASP_SUITE_B,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_2 {opts} alpn {alpn}\n\n"
|
||||
)
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1437,6 +1404,9 @@ class TestHaproxyCfg(base.TestCase):
|
||||
feature_compatibility = {constants.POOL_ALPN: True}
|
||||
cert_file_path = os.path.join(self.jinja_cfg.base_crt_dir,
|
||||
'sample_listener_id_1', 'fake path')
|
||||
opts = (f"ssl crt {cert_file_path} verify none sni ssl_fc_sni "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11")
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -1444,20 +1414,16 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_2 {opts} alpn {alpn}\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
opts="ssl crt %s verify none sni ssl_fc_sni" % cert_file_path +
|
||||
" no-sslv3 no-tlsv10 no-tlsv11",
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_2 {opts} alpn {alpn}\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1474,6 +1440,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
def test_render_template_pool_cert_no_ciphers_or_versions_or_alpn(self):
|
||||
cert_file_path = os.path.join(self.jinja_cfg.base_crt_dir,
|
||||
'sample_listener_id_1', 'fake path')
|
||||
opts = f"ssl crt {cert_file_path} verify none sni ssl_fc_sni"
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -1481,18 +1448,16 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"check inter 30s fall 3 rise 2 cookie sample_member_id_1 "
|
||||
"{opts}\n"
|
||||
f"{opts}\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"check inter 30s fall 3 rise 2 cookie sample_member_id_2 "
|
||||
"{opts}\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
opts="ssl crt %s verify none sni ssl_fc_sni" % cert_file_path)
|
||||
f"{opts}\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1514,7 +1479,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1522,8 +1487,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"check inter 30s fall 3 rise 2 cookie sample_member_id_1\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"check inter 30s fall 3 rise 2 cookie sample_member_id_2"
|
||||
"\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
"\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1537,6 +1501,10 @@ class TestHaproxyCfg(base.TestCase):
|
||||
pool_client_cert = '/foo/cert.pem'
|
||||
pool_ca_cert = '/foo/ca.pem'
|
||||
pool_crl = '/foo/crl.pem'
|
||||
opts = (f"ssl crt {pool_client_cert} ca-file {pool_ca_cert} "
|
||||
f"crl-file {pool_crl} verify required sni ssl_fc_sni "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11")
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -1544,21 +1512,16 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_1 10.0.0.99:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_1 {opts} alpn {alpn}\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 weight 13 "
|
||||
"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
"sample_member_id_2 {opts} alpn {alpn}\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
opts=(f"ssl crt {pool_client_cert} ca-file {pool_ca_cert} "
|
||||
f"crl-file {pool_crl} verify required sni ssl_fc_sni "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11"),
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS))
|
||||
f"check check-alpn {alpn} inter 30s fall 3 rise 2 cookie "
|
||||
f"sample_member_id_2 {opts} alpn {alpn}\n\n")
|
||||
rendered_obj = self.jinja_cfg.render_loadbalancer_obj(
|
||||
sample_configs_combined.sample_amphora_tuple(),
|
||||
[sample_configs_combined.sample_listener_tuple(
|
||||
@@ -1837,14 +1800,15 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"servers-state\n"
|
||||
" maxconn {maxconn}\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
be = ("backend {pool_id}:{listener_id}\n"
|
||||
be = (f"backend {sample_proxy_listener.default_pool.id}:"
|
||||
f"{sample_proxy_listener.id}\n"
|
||||
" mode http\n"
|
||||
" http-reuse safe\n"
|
||||
" balance roundrobin\n"
|
||||
" cookie SRV insert indirect nocache\n"
|
||||
" load-server-state-from-file global\n"
|
||||
" timeout check 31s\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1853,10 +1817,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1 send-proxy\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2 send-proxy\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
pool_id=sample_proxy_listener.default_pool.id,
|
||||
listener_id=sample_proxy_listener.id)
|
||||
"cookie sample_member_id_2 send-proxy\n\n")
|
||||
rendered_obj = j_cfg.build_config(
|
||||
sample_amphora,
|
||||
[sample_proxy_listener],
|
||||
@@ -1869,12 +1830,13 @@ class TestHaproxyCfg(base.TestCase):
|
||||
rendered_obj)
|
||||
|
||||
# Without http-reuse and server-state-file
|
||||
be = ("backend {pool_id}:{listener_id}\n"
|
||||
be = (f"backend {sample_proxy_listener.default_pool.id}:"
|
||||
f"{sample_proxy_listener.id}\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
" cookie SRV insert indirect nocache\n"
|
||||
" timeout check 31s\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1883,10 +1845,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"cookie sample_member_id_1 send-proxy\n"
|
||||
" server sample_member_id_2 10.0.0.98:82 "
|
||||
"weight 13 check inter 30s fall 3 rise 2 "
|
||||
"cookie sample_member_id_2 send-proxy\n\n").format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
pool_id=sample_proxy_listener.default_pool.id,
|
||||
listener_id=sample_proxy_listener.id)
|
||||
"cookie sample_member_id_2 send-proxy\n\n")
|
||||
rendered_obj = j_cfg.build_config(
|
||||
sample_amphora,
|
||||
[sample_proxy_listener],
|
||||
@@ -1901,13 +1860,15 @@ class TestHaproxyCfg(base.TestCase):
|
||||
j_cfg = jinja_cfg.JinjaTemplater(
|
||||
base_amp_path='/var/lib/octavia',
|
||||
base_crt_dir='/var/lib/octavia/certs')
|
||||
alpn = ",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
||||
fe = ("frontend sample_listener_id_1\n"
|
||||
" maxconn {maxconn}\n"
|
||||
" redirect scheme https if !{{ ssl_fc }}\n"
|
||||
f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" redirect scheme https if !{ ssl_fc }\n"
|
||||
" http-response set-header Strict-Transport-Security "
|
||||
"\"max-age=10000000; includeSubDomains; preload;\"\n"
|
||||
" bind 10.0.0.2:443 ciphers {ciphers} "
|
||||
"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" bind 10.0.0.2:443 ciphers "
|
||||
f"{constants.CIPHERS_OWASP_SUITE_B} "
|
||||
f"no-sslv3 no-tlsv10 no-tlsv11 alpn {alpn}\n"
|
||||
" mode http\n"
|
||||
" acl sample_l7rule_id_1 path -m beg /api\n"
|
||||
" use_backend sample_pool_id_2:sample_listener_id_1"
|
||||
@@ -1941,10 +1902,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
"if sample_l7rule_id_7 !sample_l7rule_id_8 !sample_l7rule_id_9 "
|
||||
"!sample_l7rule_id_10 sample_l7rule_id_11\n"
|
||||
" default_backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" timeout client 50000\n".format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN,
|
||||
ciphers=constants.CIPHERS_OWASP_SUITE_B,
|
||||
alpn=",".join(constants.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)))
|
||||
" timeout client 50000\n")
|
||||
be = ("backend sample_pool_id_1:sample_listener_id_1\n"
|
||||
" mode http\n"
|
||||
" balance roundrobin\n"
|
||||
@@ -1952,7 +1910,7 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /index.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
@@ -1967,13 +1925,12 @@ class TestHaproxyCfg(base.TestCase):
|
||||
" timeout check 31s\n"
|
||||
" option httpchk GET /healthmon.html HTTP/1.0\\r\\n\n"
|
||||
" http-check expect rstatus 418\n"
|
||||
" fullconn {maxconn}\n"
|
||||
f" fullconn {constants.HAPROXY_DEFAULT_MAXCONN}\n"
|
||||
" option allbackups\n"
|
||||
" timeout connect 5000\n"
|
||||
" timeout server 50000\n"
|
||||
" server sample_member_id_3 10.0.0.97:82 weight 13 check "
|
||||
"inter 30s fall 3 rise 2 cookie sample_member_id_3\n\n".format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN))
|
||||
"inter 30s fall 3 rise 2 cookie sample_member_id_3\n\n")
|
||||
sample_listener = sample_configs_combined.sample_listener_tuple(
|
||||
proto=constants.PROTOCOL_TERMINATED_HTTPS, l7=True,
|
||||
ssl_type_l7=True)
|
||||
|
||||
@@ -1262,8 +1262,7 @@ def sample_base_expected_config(frontend=None, logging=None, backend=None,
|
||||
if peers is None:
|
||||
peers = "\n\n"
|
||||
if global_opts is None:
|
||||
global_opts = " maxconn {maxconn}\n\n".format(
|
||||
maxconn=constants.HAPROXY_DEFAULT_MAXCONN)
|
||||
global_opts = f" maxconn {constants.HAPROXY_DEFAULT_MAXCONN}\n\n"
|
||||
if defaults is None:
|
||||
defaults = ("defaults\n"
|
||||
" log global\n"
|
||||
|
||||
@@ -92,7 +92,7 @@ class TestTaskFlowServiceController(base.TestCase):
|
||||
def test_run_poster(self, mock_engines, mockuuid):
|
||||
flow_factory = mock.MagicMock()
|
||||
flow_factory.__name__ = 'testname'
|
||||
job_name = 'testname-%s' % self._mock_uuid
|
||||
job_name = f'testname-{self._mock_uuid}'
|
||||
job_details = {'store': 'test'}
|
||||
with mock.patch.object(self.service_controller, '_wait_for_job'
|
||||
) as wait:
|
||||
|
||||
@@ -164,7 +164,7 @@ class HackingTestCase(base.BaseTestCase):
|
||||
self.assertEqual(
|
||||
1, len(list(checks.no_translate_logs(bad, 'f'))))
|
||||
# Do not do validations in tests
|
||||
ok = 'LOG.%s(_("OK - unit tests"))' % log
|
||||
ok = f'LOG.{log}(_("OK - unit tests"))'
|
||||
self.assertEqual(
|
||||
0, len(list(checks.no_translate_logs(ok, 'f/tests/f'))))
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestBaseNeutronNetworkDriver(base.TestCase):
|
||||
new_dict = abclass.__dict__.copy()
|
||||
for abstractmethod in abclass.__abstractmethods__:
|
||||
new_dict[abstractmethod] = lambda x, *args, **kw: (x, args, kw)
|
||||
impl_class = type("partially_implemented_abc_%s" % abclass.__name__,
|
||||
impl_class = type(f"partially_implemented_abc_{abclass.__name__}",
|
||||
(abclass,), new_dict)
|
||||
return impl_class()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user