blob: 79c8bf04e81d7092e68dcfa6a6a637015500f9d6 [file] [log] [blame]
Jude Cross986e3f52017-07-24 14:57:20 -07001# Copyright 2018 Rackspace US Inc. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import ipaddress
Michael Johnsonbaf12e02020-10-27 16:10:28 -070016import os
Jude Cross986e3f52017-07-24 14:57:20 -070017import random
Gregory Thiemongea2c234e2021-11-02 17:08:29 +010018import re
Jude Cross986e3f52017-07-24 14:57:20 -070019import shlex
Jude Cross986e3f52017-07-24 14:57:20 -070020import string
21import subprocess
22import tempfile
23
Michael Johnsonbaf12e02020-10-27 16:10:28 -070024from cryptography.hazmat.primitives import serialization
Gregory Thiemongeb0da4f32022-02-04 08:58:06 +010025from oslo_config import cfg
Jude Cross986e3f52017-07-24 14:57:20 -070026from oslo_log import log as logging
27from oslo_utils import uuidutils
28from tempest import config
29from tempest.lib.common.utils import data_utils
30from tempest.lib.common.utils.linux import remote_client
Jude Cross986e3f52017-07-24 14:57:20 -070031from tempest.lib import exceptions
32from tempest import test
Michael Johnson04dc5cb2019-01-20 11:03:50 -080033import tenacity
Jude Cross986e3f52017-07-24 14:57:20 -070034
Michael Johnsonbaf12e02020-10-27 16:10:28 -070035from octavia_tempest_plugin.common import cert_utils
Jude Cross986e3f52017-07-24 14:57:20 -070036from octavia_tempest_plugin.common import constants as const
Ilya Bumarskov2f7eee62023-03-16 14:12:09 +040037from octavia_tempest_plugin import config as config_octavia
Michael Johnson6006de72021-02-21 01:42:39 +000038from octavia_tempest_plugin.tests import RBAC_tests
Jude Cross986e3f52017-07-24 14:57:20 -070039from octavia_tempest_plugin.tests import validators
40from octavia_tempest_plugin.tests import waiters
41
42CONF = config.CONF
43LOG = logging.getLogger(__name__)
44
Gregory Thiemonge29d17902019-04-30 15:06:17 +020045
Michael Johnson6006de72021-02-21 01:42:39 +000046class LoadBalancerBaseTest(validators.ValidatorsMixin,
47 RBAC_tests.RBACTestsMixin, test.BaseTestCase):
Jude Cross986e3f52017-07-24 14:57:20 -070048 """Base class for load balancer tests."""
49
Gregory Thiemonge3497f6c2021-04-19 21:33:13 +020050 if CONF.load_balancer.RBAC_test_type == const.OWNERADMIN:
51 credentials = [
52 'admin', 'primary', ['lb_admin', CONF.load_balancer.admin_role],
53 ['lb_member', CONF.load_balancer.member_role],
54 ['lb_member2', CONF.load_balancer.member_role]]
55 elif CONF.load_balancer.enforce_new_defaults:
Michael Johnson6006de72021-02-21 01:42:39 +000056 credentials = [
57 'admin', 'primary', ['lb_admin', CONF.load_balancer.admin_role],
58 ['lb_observer', CONF.load_balancer.observer_role, 'reader'],
59 ['lb_global_observer', CONF.load_balancer.global_observer_role,
60 'reader'],
61 ['lb_member', CONF.load_balancer.member_role, 'member'],
62 ['lb_member2', CONF.load_balancer.member_role, 'member'],
63 ['lb_member_not_default_member', CONF.load_balancer.member_role]]
64 else:
65 credentials = [
66 'admin', 'primary', ['lb_admin', CONF.load_balancer.admin_role],
67 ['lb_observer', CONF.load_balancer.observer_role, 'reader'],
68 ['lb_global_observer', CONF.load_balancer.global_observer_role,
69 'reader'],
Michael Johnson9e9f5262023-01-18 17:59:17 +000070 # Note: Some projects are now requiring the 'member' role by
71 # default (nova for example) so make sure our creds have this role
72 ['lb_member', CONF.load_balancer.member_role, 'member'],
73 ['lb_member2', CONF.load_balancer.member_role, 'member']]
Michael Johnson6006de72021-02-21 01:42:39 +000074
75 # If scope enforcement is enabled, add in the system scope credentials.
76 # The project scope is already handled by the above credentials.
77 if CONF.enforce_scope.octavia:
78 credentials.extend(['system_admin', 'system_reader'])
79
80 # A tuple of credentials that will be allocated by tempest using the
81 # 'credentials' list above. These are used to build RBAC test lists.
82 allocated_creds = []
83 for cred in credentials:
84 if isinstance(cred, list):
85 allocated_creds.append('os_roles_' + cred[0])
86 else:
87 allocated_creds.append('os_' + cred)
88 # Tests shall not mess with the list of allocated credentials
89 allocated_credentials = tuple(allocated_creds)
Jude Cross986e3f52017-07-24 14:57:20 -070090
Adam Harwelle029af22018-05-24 17:13:28 -070091 webserver1_response = 1
92 webserver2_response = 5
Michael Johnsondfd818a2018-08-21 20:54:54 -070093 used_ips = []
Jude Cross986e3f52017-07-24 14:57:20 -070094
Michael Johnson89bdbcd2020-03-19 15:59:19 -070095 SRC_PORT_NUMBER_MIN = 32768
96 SRC_PORT_NUMBER_MAX = 61000
Gregory Thiemonge29d17902019-04-30 15:06:17 +020097 src_port_number = SRC_PORT_NUMBER_MIN
98
Jude Cross986e3f52017-07-24 14:57:20 -070099 @classmethod
100 def skip_checks(cls):
101 """Check if we should skip all of the children tests."""
102 super(LoadBalancerBaseTest, cls).skip_checks()
103
104 service_list = {
105 'load_balancer': CONF.service_available.load_balancer,
106 }
107
108 live_service_list = {
109 'compute': CONF.service_available.nova,
110 'image': CONF.service_available.glance,
111 'neutron': CONF.service_available.neutron
112 }
113
114 if not CONF.load_balancer.test_with_noop:
115 service_list.update(live_service_list)
116
117 for service, available in service_list.items():
118 if not available:
zhangzs2a6cf672018-11-10 16:13:11 +0800119 skip_msg = ("{0} skipped as {1} service is not "
Jude Cross986e3f52017-07-24 14:57:20 -0700120 "available.".format(cls.__name__, service))
121 raise cls.skipException(skip_msg)
122
123 # We must be able to reach our VIP and instances
124 if not (CONF.network.project_networks_reachable
125 or CONF.network.public_network_id):
126 msg = ('Either project_networks_reachable must be "true", or '
127 'public_network_id must be defined.')
128 raise cls.skipException(msg)
129
130 @classmethod
131 def setup_credentials(cls):
132 """Setup test credentials and network resources."""
133 # Do not auto create network resources
134 cls.set_network_resources()
135 super(LoadBalancerBaseTest, cls).setup_credentials()
136
Bas de Bruijne530a88a2022-12-15 11:12:45 -0400137 if not CONF.load_balancer.log_user_roles:
138 return
139
Michael Johnson6006de72021-02-21 01:42:39 +0000140 # Log the user roles for this test run
141 role_name_cache = {}
142 for cred in cls.credentials:
143 user_roles = []
144 if isinstance(cred, list):
145 user_name = cred[0]
146 cred_obj = getattr(cls, 'os_roles_' + cred[0])
147 else:
148 user_name = cred
149 cred_obj = getattr(cls, 'os_' + cred)
150 params = {'user.id': cred_obj.credentials.user_id,
151 'project.id': cred_obj.credentials.project_id}
152 roles = cls.os_admin.role_assignments_client.list_role_assignments(
153 **params)['role_assignments']
154 for role in roles:
155 role_id = role['role']['id']
156 try:
157 role_name = role_name_cache[role_id]
158 except KeyError:
159 role_name = cls.os_admin.roles_v3_client.show_role(
160 role_id)['role']['name']
161 role_name_cache[role_id] = role_name
162 user_roles.append([role_name, role['scope']])
163 LOG.info("User %s has roles: %s", user_name, user_roles)
164
Jude Cross986e3f52017-07-24 14:57:20 -0700165 @classmethod
166 def setup_clients(cls):
167 """Setup client aliases."""
168 super(LoadBalancerBaseTest, cls).setup_clients()
Michael Johnson29d8e612021-06-23 16:16:12 +0000169 lb_admin_prefix = cls.os_roles_lb_admin.load_balancer_v2
Jude Cross986e3f52017-07-24 14:57:20 -0700170 cls.lb_mem_float_ip_client = cls.os_roles_lb_member.floating_ips_client
171 cls.lb_mem_keypairs_client = cls.os_roles_lb_member.keypairs_client
172 cls.lb_mem_net_client = cls.os_roles_lb_member.networks_client
173 cls.lb_mem_ports_client = cls.os_roles_lb_member.ports_client
174 cls.lb_mem_routers_client = cls.os_roles_lb_member.routers_client
175 cls.lb_mem_SG_client = cls.os_roles_lb_member.security_groups_client
176 cls.lb_mem_SGr_client = (
177 cls.os_roles_lb_member.security_group_rules_client)
178 cls.lb_mem_servers_client = cls.os_roles_lb_member.servers_client
179 cls.lb_mem_subnet_client = cls.os_roles_lb_member.subnets_client
Michael Johnson29d8e612021-06-23 16:16:12 +0000180 cls.mem_lb_client = (
181 cls.os_roles_lb_member.load_balancer_v2.LoadbalancerClient())
182 cls.mem_listener_client = (
183 cls.os_roles_lb_member.load_balancer_v2.ListenerClient())
184 cls.mem_pool_client = (
185 cls.os_roles_lb_member.load_balancer_v2.PoolClient())
186 cls.mem_member_client = (
187 cls.os_roles_lb_member.load_balancer_v2.MemberClient())
Adam Harwell60ed9d92018-05-10 13:23:13 -0700188 cls.mem_healthmonitor_client = (
Michael Johnson29d8e612021-06-23 16:16:12 +0000189 cls.os_roles_lb_member.load_balancer_v2.HealthMonitorClient())
190 cls.mem_l7policy_client = (
191 cls.os_roles_lb_member.load_balancer_v2.L7PolicyClient())
192 cls.mem_l7rule_client = (
193 cls.os_roles_lb_member.load_balancer_v2.L7RuleClient())
194 cls.lb_admin_amphora_client = lb_admin_prefix.AmphoraClient()
Michael Johnsonaff2e862019-01-11 16:38:00 -0800195 cls.lb_admin_flavor_profile_client = (
Michael Johnson29d8e612021-06-23 16:16:12 +0000196 lb_admin_prefix.FlavorProfileClient())
197 cls.lb_admin_flavor_client = lb_admin_prefix.FlavorClient()
198 cls.mem_flavor_client = (
199 cls.os_roles_lb_member.load_balancer_v2.FlavorClient())
200 cls.mem_provider_client = (
201 cls.os_roles_lb_member.load_balancer_v2.ProviderClient())
Carlos Goncalvesc2e12162019-02-14 23:57:44 +0100202 cls.os_admin_servers_client = cls.os_admin.servers_client
Gregory Thiemonge54225ad2021-02-04 15:25:17 +0100203 cls.os_admin_routers_client = cls.os_admin.routers_client
204 cls.os_admin_subnetpools_client = cls.os_admin.subnetpools_client
Adam Harwellc2aa20c2019-11-20 11:15:07 -0800205 cls.lb_admin_flavor_capabilities_client = (
Michael Johnson29d8e612021-06-23 16:16:12 +0000206 lb_admin_prefix.FlavorCapabilitiesClient())
Adam Harwellc2aa20c2019-11-20 11:15:07 -0800207 cls.lb_admin_availability_zone_capabilities_client = (
Michael Johnson29d8e612021-06-23 16:16:12 +0000208 lb_admin_prefix.AvailabilityZoneCapabilitiesClient())
Adam Harwellc2aa20c2019-11-20 11:15:07 -0800209 cls.lb_admin_availability_zone_profile_client = (
Michael Johnson29d8e612021-06-23 16:16:12 +0000210 lb_admin_prefix.AvailabilityZoneProfileClient())
Adam Harwellc2aa20c2019-11-20 11:15:07 -0800211 cls.lb_admin_availability_zone_client = (
Michael Johnson29d8e612021-06-23 16:16:12 +0000212 lb_admin_prefix.AvailabilityZoneClient())
Adam Harwellc2aa20c2019-11-20 11:15:07 -0800213 cls.mem_availability_zone_client = (
Michael Johnson29d8e612021-06-23 16:16:12 +0000214 cls.os_roles_lb_member.load_balancer_v2.AvailabilityZoneClient())
Jude Cross986e3f52017-07-24 14:57:20 -0700215
216 @classmethod
217 def resource_setup(cls):
218 """Setup resources needed by the tests."""
219 super(LoadBalancerBaseTest, cls).resource_setup()
220
221 conf_lb = CONF.load_balancer
222
Michael Johnsondfd818a2018-08-21 20:54:54 -0700223 cls.api_version = cls.mem_lb_client.get_max_api_version()
224
Jude Cross986e3f52017-07-24 14:57:20 -0700225 if conf_lb.test_subnet_override and not conf_lb.test_network_override:
226 raise exceptions.InvalidConfiguration(
227 "Configuration value test_network_override must be "
228 "specified if test_subnet_override is used.")
229
Michael Johnson6a9236a2020-08-04 23:54:54 +0000230 # TODO(johnsom) Remove this
Maciej Józefczykb6df5f82019-12-10 10:12:30 +0000231 # Get loadbalancing algorithms supported by provider driver.
232 try:
233 algorithms = const.SUPPORTED_LB_ALGORITHMS[
234 CONF.load_balancer.provider]
235 except KeyError:
236 algorithms = const.SUPPORTED_LB_ALGORITHMS['default']
237 # Set default algorithm as first from the list.
238 cls.lb_algorithm = algorithms[0]
239
Jude Cross986e3f52017-07-24 14:57:20 -0700240 show_subnet = cls.lb_mem_subnet_client.show_subnet
241 if CONF.load_balancer.test_with_noop:
242 cls.lb_member_vip_net = {'id': uuidutils.generate_uuid()}
243 cls.lb_member_vip_subnet = {'id': uuidutils.generate_uuid()}
244 cls.lb_member_1_net = {'id': uuidutils.generate_uuid()}
245 cls.lb_member_1_subnet = {'id': uuidutils.generate_uuid()}
246 cls.lb_member_2_net = {'id': uuidutils.generate_uuid()}
247 cls.lb_member_2_subnet = {'id': uuidutils.generate_uuid()}
248 if CONF.load_balancer.test_with_ipv6:
Michael Johnson5a16ad32018-10-18 14:49:11 -0700249 cls.lb_member_vip_ipv6_net = {'id': uuidutils.generate_uuid()}
Jude Cross986e3f52017-07-24 14:57:20 -0700250 cls.lb_member_vip_ipv6_subnet = {'id':
251 uuidutils.generate_uuid()}
252 cls.lb_member_1_ipv6_subnet = {'id': uuidutils.generate_uuid()}
253 cls.lb_member_2_ipv6_subnet = {'id': uuidutils.generate_uuid()}
Michael Johnson590fbe12019-07-03 14:30:01 -0700254 cls.lb_member_vip_ipv6_subnet_stateful = True
Jude Cross986e3f52017-07-24 14:57:20 -0700255 return
256 elif CONF.load_balancer.test_network_override:
257 if conf_lb.test_subnet_override:
258 override_subnet = show_subnet(conf_lb.test_subnet_override)
259 else:
260 override_subnet = None
261
262 show_net = cls.lb_mem_net_client.show_network
263 override_network = show_net(conf_lb.test_network_override)
264 override_network = override_network.get('network')
265
266 cls.lb_member_vip_net = override_network
267 cls.lb_member_vip_subnet = override_subnet
268 cls.lb_member_1_net = override_network
269 cls.lb_member_1_subnet = override_subnet
270 cls.lb_member_2_net = override_network
271 cls.lb_member_2_subnet = override_subnet
272
273 if (CONF.load_balancer.test_with_ipv6 and
Michael Polenchukf93cce72022-01-18 15:44:56 +0400274 conf_lb.test_ipv6_subnet_override):
Jude Cross986e3f52017-07-24 14:57:20 -0700275 override_ipv6_subnet = show_subnet(
Michael Polenchukf93cce72022-01-18 15:44:56 +0400276 conf_lb.test_ipv6_subnet_override)
Jude Cross986e3f52017-07-24 14:57:20 -0700277 cls.lb_member_vip_ipv6_subnet = override_ipv6_subnet
278 cls.lb_member_1_ipv6_subnet = override_ipv6_subnet
279 cls.lb_member_2_ipv6_subnet = override_ipv6_subnet
Michael Johnson590fbe12019-07-03 14:30:01 -0700280 cls.lb_member_vip_ipv6_subnet_stateful = False
281 if (override_ipv6_subnet[0]['ipv6_address_mode'] ==
282 'dhcpv6-stateful'):
283 cls.lb_member_vip_ipv6_subnet_stateful = True
Jude Cross986e3f52017-07-24 14:57:20 -0700284 else:
285 cls.lb_member_vip_ipv6_subnet = None
286 cls.lb_member_1_ipv6_subnet = None
287 cls.lb_member_2_ipv6_subnet = None
288 else:
289 cls._create_networks()
290
291 LOG.debug('Octavia Setup: lb_member_vip_net = {}'.format(
292 cls.lb_member_vip_net[const.ID]))
293 if cls.lb_member_vip_subnet:
294 LOG.debug('Octavia Setup: lb_member_vip_subnet = {}'.format(
295 cls.lb_member_vip_subnet[const.ID]))
296 LOG.debug('Octavia Setup: lb_member_1_net = {}'.format(
297 cls.lb_member_1_net[const.ID]))
298 if cls.lb_member_1_subnet:
299 LOG.debug('Octavia Setup: lb_member_1_subnet = {}'.format(
300 cls.lb_member_1_subnet[const.ID]))
301 LOG.debug('Octavia Setup: lb_member_2_net = {}'.format(
302 cls.lb_member_2_net[const.ID]))
303 if cls.lb_member_2_subnet:
304 LOG.debug('Octavia Setup: lb_member_2_subnet = {}'.format(
305 cls.lb_member_2_subnet[const.ID]))
Michael Johnson124ba8b2018-08-30 16:06:05 -0700306 if CONF.load_balancer.test_with_ipv6:
307 if cls.lb_member_vip_ipv6_subnet:
308 LOG.debug('Octavia Setup: lb_member_vip_ipv6_subnet = '
309 '{}'.format(cls.lb_member_vip_ipv6_subnet[const.ID]))
310 if cls.lb_member_1_ipv6_subnet:
311 LOG.debug('Octavia Setup: lb_member_1_ipv6_subnet = {}'.format(
312 cls.lb_member_1_ipv6_subnet[const.ID]))
313 if cls.lb_member_2_ipv6_subnet:
314 LOG.debug('Octavia Setup: lb_member_2_ipv6_subnet = {}'.format(
315 cls.lb_member_2_ipv6_subnet[const.ID]))
Jude Cross986e3f52017-07-24 14:57:20 -0700316
Jude Cross986e3f52017-07-24 14:57:20 -0700317 @classmethod
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800318 # Neutron can be slow to clean up ports from the subnets/networks.
319 # Retry this delete a few times if we get a "Conflict" error to give
320 # neutron time to fully cleanup the ports.
321 @tenacity.retry(
322 retry=tenacity.retry_if_exception_type(exceptions.Conflict),
323 wait=tenacity.wait_incrementing(
Vasyl Saienko7a5d9fb2021-05-12 16:30:26 +0300324 const.RETRY_INITIAL_DELAY, const.RETRY_BACKOFF, const.RETRY_MAX),
325 stop=tenacity.stop_after_attempt(const.RETRY_ATTEMPTS))
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800326 def _logging_delete_network(cls, net_id):
327 try:
328 cls.lb_mem_net_client.delete_network(net_id)
329 except Exception:
330 LOG.error('Unable to delete network {}. Active ports:'.format(
331 net_id))
332 LOG.error(cls.lb_mem_ports_client.list_ports())
333 raise
334
335 @classmethod
336 # Neutron can be slow to clean up ports from the subnets/networks.
337 # Retry this delete a few times if we get a "Conflict" error to give
338 # neutron time to fully cleanup the ports.
339 @tenacity.retry(
340 retry=tenacity.retry_if_exception_type(exceptions.Conflict),
341 wait=tenacity.wait_incrementing(
Vasyl Saienko7a5d9fb2021-05-12 16:30:26 +0300342 const.RETRY_INITIAL_DELAY, const.RETRY_BACKOFF, const.RETRY_MAX),
343 stop=tenacity.stop_after_attempt(const.RETRY_ATTEMPTS))
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800344 def _logging_delete_subnet(cls, subnet_id):
345 try:
346 cls.lb_mem_subnet_client.delete_subnet(subnet_id)
347 except Exception:
348 LOG.error('Unable to delete subnet {}. Active ports:'.format(
349 subnet_id))
350 LOG.error(cls.lb_mem_ports_client.list_ports())
351 raise
352
353 @classmethod
Jude Cross986e3f52017-07-24 14:57:20 -0700354 def _create_networks(cls):
355 """Creates networks, subnets, and routers used in tests.
356
357 The following are expected to be defined and available to the tests:
358 cls.lb_member_vip_net
359 cls.lb_member_vip_subnet
360 cls.lb_member_vip_ipv6_subnet (optional)
361 cls.lb_member_1_net
362 cls.lb_member_1_subnet
363 cls.lb_member_1_ipv6_subnet (optional)
364 cls.lb_member_2_net
365 cls.lb_member_2_subnet
366 cls.lb_member_2_ipv6_subnet (optional)
367 """
368
369 # Create tenant VIP network
370 network_kwargs = {
371 'name': data_utils.rand_name("lb_member_vip_network")}
372 if CONF.network_feature_enabled.port_security:
Andreas Jaeger4215b702020-03-28 20:13:46 +0100373 # Note: Allowed Address Pairs requires port security
374 network_kwargs['port_security_enabled'] = True
Jude Cross986e3f52017-07-24 14:57:20 -0700375 result = cls.lb_mem_net_client.create_network(**network_kwargs)
376 cls.lb_member_vip_net = result['network']
377 LOG.info('lb_member_vip_net: {}'.format(cls.lb_member_vip_net))
378 cls.addClassResourceCleanup(
379 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800380 cls._logging_delete_network,
Jude Cross986e3f52017-07-24 14:57:20 -0700381 cls.lb_mem_net_client.show_network,
382 cls.lb_member_vip_net['id'])
383
384 # Create tenant VIP subnet
385 subnet_kwargs = {
386 'name': data_utils.rand_name("lb_member_vip_subnet"),
387 'network_id': cls.lb_member_vip_net['id'],
388 'cidr': CONF.load_balancer.vip_subnet_cidr,
389 'ip_version': 4}
390 result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
391 cls.lb_member_vip_subnet = result['subnet']
392 LOG.info('lb_member_vip_subnet: {}'.format(cls.lb_member_vip_subnet))
393 cls.addClassResourceCleanup(
394 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800395 cls._logging_delete_subnet,
Jude Cross986e3f52017-07-24 14:57:20 -0700396 cls.lb_mem_subnet_client.show_subnet,
397 cls.lb_member_vip_subnet['id'])
398
399 # Create tenant VIP IPv6 subnet
400 if CONF.load_balancer.test_with_ipv6:
Michael Johnson590fbe12019-07-03 14:30:01 -0700401 cls.lb_member_vip_ipv6_subnet_stateful = False
Gregory Thiemonge54225ad2021-02-04 15:25:17 +0100402 cls.lb_member_vip_ipv6_subnet_use_subnetpool = False
403 subnet_kwargs = {
404 'name': data_utils.rand_name("lb_member_vip_ipv6_subnet"),
405 'network_id': cls.lb_member_vip_net['id'],
406 'ip_version': 6}
407
408 # Use a CIDR from devstack's default IPv6 subnetpool if it exists,
409 # the subnetpool's cidr is routable from the devstack node
410 # through the default router
411 subnetpool_name = CONF.load_balancer.default_ipv6_subnetpool
412 if subnetpool_name:
413 subnetpool = cls.os_admin_subnetpools_client.list_subnetpools(
414 name=subnetpool_name)['subnetpools']
415 if len(subnetpool) == 1:
416 subnetpool = subnetpool[0]
417 subnet_kwargs['subnetpool_id'] = subnetpool['id']
418 cls.lb_member_vip_ipv6_subnet_use_subnetpool = True
419
420 if 'subnetpool_id' not in subnet_kwargs:
421 subnet_kwargs['cidr'] = (
422 CONF.load_balancer.vip_ipv6_subnet_cidr)
423
424 result = cls.lb_mem_subnet_client.create_subnet(
425 **subnet_kwargs)
426 cls.lb_member_vip_ipv6_net = cls.lb_member_vip_net
427 cls.lb_member_vip_ipv6_subnet = result['subnet']
428 cls.addClassResourceCleanup(
429 waiters.wait_for_not_found,
430 cls._logging_delete_subnet,
431 cls.lb_mem_subnet_client.show_subnet,
432 cls.lb_member_vip_ipv6_subnet['id'])
Carlos Goncalves84af48c2019-07-25 15:51:30 +0200433
Jude Cross986e3f52017-07-24 14:57:20 -0700434 LOG.info('lb_member_vip_ipv6_subnet: {}'.format(
435 cls.lb_member_vip_ipv6_subnet))
Jude Cross986e3f52017-07-24 14:57:20 -0700436
437 # Create tenant member 1 network
438 network_kwargs = {
439 'name': data_utils.rand_name("lb_member_1_network")}
440 if CONF.network_feature_enabled.port_security:
441 if CONF.load_balancer.enable_security_groups:
442 network_kwargs['port_security_enabled'] = True
443 else:
444 network_kwargs['port_security_enabled'] = False
445 result = cls.lb_mem_net_client.create_network(**network_kwargs)
446 cls.lb_member_1_net = result['network']
447 LOG.info('lb_member_1_net: {}'.format(cls.lb_member_1_net))
448 cls.addClassResourceCleanup(
449 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800450 cls._logging_delete_network,
Jude Cross986e3f52017-07-24 14:57:20 -0700451 cls.lb_mem_net_client.show_network,
452 cls.lb_member_1_net['id'])
453
454 # Create tenant member 1 subnet
455 subnet_kwargs = {
456 'name': data_utils.rand_name("lb_member_1_subnet"),
457 'network_id': cls.lb_member_1_net['id'],
458 'cidr': CONF.load_balancer.member_1_ipv4_subnet_cidr,
459 'ip_version': 4}
460 result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
461 cls.lb_member_1_subnet = result['subnet']
462 LOG.info('lb_member_1_subnet: {}'.format(cls.lb_member_1_subnet))
463 cls.addClassResourceCleanup(
464 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800465 cls._logging_delete_subnet,
Jude Cross986e3f52017-07-24 14:57:20 -0700466 cls.lb_mem_subnet_client.show_subnet,
467 cls.lb_member_1_subnet['id'])
468
469 # Create tenant member 1 ipv6 subnet
470 if CONF.load_balancer.test_with_ipv6:
471 subnet_kwargs = {
472 'name': data_utils.rand_name("lb_member_1_ipv6_subnet"),
473 'network_id': cls.lb_member_1_net['id'],
474 'cidr': CONF.load_balancer.member_1_ipv6_subnet_cidr,
475 'ip_version': 6}
476 result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
Michael Johnsonbf916df2018-10-17 10:59:28 -0700477 cls.lb_member_1_subnet_prefix = (
478 CONF.load_balancer.member_1_ipv6_subnet_cidr.rpartition('/')[2]
479 )
480 assert(cls.lb_member_1_subnet_prefix.isdigit())
Jude Cross986e3f52017-07-24 14:57:20 -0700481 cls.lb_member_1_ipv6_subnet = result['subnet']
482 LOG.info('lb_member_1_ipv6_subnet: {}'.format(
483 cls.lb_member_1_ipv6_subnet))
484 cls.addClassResourceCleanup(
485 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800486 cls._logging_delete_subnet,
Jude Cross986e3f52017-07-24 14:57:20 -0700487 cls.lb_mem_subnet_client.show_subnet,
488 cls.lb_member_1_ipv6_subnet['id'])
489
490 # Create tenant member 2 network
491 network_kwargs = {
492 'name': data_utils.rand_name("lb_member_2_network")}
493 if CONF.network_feature_enabled.port_security:
494 if CONF.load_balancer.enable_security_groups:
495 network_kwargs['port_security_enabled'] = True
496 else:
497 network_kwargs['port_security_enabled'] = False
498 result = cls.lb_mem_net_client.create_network(**network_kwargs)
499 cls.lb_member_2_net = result['network']
500 LOG.info('lb_member_2_net: {}'.format(cls.lb_member_2_net))
501 cls.addClassResourceCleanup(
502 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800503 cls._logging_delete_network,
Jude Cross986e3f52017-07-24 14:57:20 -0700504 cls.lb_mem_net_client.show_network,
505 cls.lb_member_2_net['id'])
506
507 # Create tenant member 2 subnet
508 subnet_kwargs = {
509 'name': data_utils.rand_name("lb_member_2_subnet"),
510 'network_id': cls.lb_member_2_net['id'],
511 'cidr': CONF.load_balancer.member_2_ipv4_subnet_cidr,
512 'ip_version': 4}
513 result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
514 cls.lb_member_2_subnet = result['subnet']
515 LOG.info('lb_member_2_subnet: {}'.format(cls.lb_member_2_subnet))
516 cls.addClassResourceCleanup(
517 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800518 cls._logging_delete_subnet,
Jude Cross986e3f52017-07-24 14:57:20 -0700519 cls.lb_mem_subnet_client.show_subnet,
520 cls.lb_member_2_subnet['id'])
521
522 # Create tenant member 2 ipv6 subnet
523 if CONF.load_balancer.test_with_ipv6:
524 subnet_kwargs = {
525 'name': data_utils.rand_name("lb_member_2_ipv6_subnet"),
526 'network_id': cls.lb_member_2_net['id'],
527 'cidr': CONF.load_balancer.member_2_ipv6_subnet_cidr,
528 'ip_version': 6}
529 result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
Michael Johnsonbf916df2018-10-17 10:59:28 -0700530 cls.lb_member_2_subnet_prefix = (
531 CONF.load_balancer.member_2_ipv6_subnet_cidr.rpartition('/')[2]
532 )
533 assert(cls.lb_member_2_subnet_prefix.isdigit())
Jude Cross986e3f52017-07-24 14:57:20 -0700534 cls.lb_member_2_ipv6_subnet = result['subnet']
535 LOG.info('lb_member_2_ipv6_subnet: {}'.format(
536 cls.lb_member_2_ipv6_subnet))
537 cls.addClassResourceCleanup(
538 waiters.wait_for_not_found,
Michael Johnson04dc5cb2019-01-20 11:03:50 -0800539 cls._logging_delete_subnet,
Jude Cross986e3f52017-07-24 14:57:20 -0700540 cls.lb_mem_subnet_client.show_subnet,
541 cls.lb_member_2_ipv6_subnet['id'])
542
Adam Harwellcd72b562018-05-07 11:37:22 -0700543 @classmethod
Michael Johnson07c9a632018-06-07 13:27:42 -0700544 def _setup_lb_network_kwargs(cls, lb_kwargs, ip_version=None,
545 use_fixed_ip=False):
Adam Harwell60ed9d92018-05-10 13:23:13 -0700546 if not ip_version:
547 ip_version = 6 if CONF.load_balancer.test_with_ipv6 else 4
Michael Johnson5a16ad32018-10-18 14:49:11 -0700548 if cls.lb_member_vip_subnet or cls.lb_member_vip_ipv6_subnet:
Adam Harwellcd72b562018-05-07 11:37:22 -0700549 ip_index = data_utils.rand_int_id(start=10, end=100)
Michael Johnsondfd818a2018-08-21 20:54:54 -0700550 while ip_index in cls.used_ips:
551 ip_index = data_utils.rand_int_id(start=10, end=100)
552 cls.used_ips.append(ip_index)
Adam Harwellcd72b562018-05-07 11:37:22 -0700553 if ip_version == 4:
Adam Harwellcd72b562018-05-07 11:37:22 -0700554 subnet_id = cls.lb_member_vip_subnet[const.ID]
Michael Johnson5a16ad32018-10-18 14:49:11 -0700555 if CONF.load_balancer.test_with_noop:
556 lb_vip_address = '198.18.33.33'
557 else:
558 subnet = cls.os_admin.subnets_client.show_subnet(subnet_id)
559 network = ipaddress.IPv4Network(subnet['subnet']['cidr'])
560 lb_vip_address = str(network[ip_index])
Adam Harwellcd72b562018-05-07 11:37:22 -0700561 else:
Adam Harwellcd72b562018-05-07 11:37:22 -0700562 subnet_id = cls.lb_member_vip_ipv6_subnet[const.ID]
Michael Johnson5a16ad32018-10-18 14:49:11 -0700563 if CONF.load_balancer.test_with_noop:
564 lb_vip_address = '2001:db8:33:33:33:33:33:33'
565 else:
566 subnet = cls.os_admin.subnets_client.show_subnet(subnet_id)
567 network = ipaddress.IPv6Network(subnet['subnet']['cidr'])
568 lb_vip_address = str(network[ip_index])
Michael Johnson590fbe12019-07-03 14:30:01 -0700569 # If the subnet is IPv6 slaac or dhcpv6-stateless
570 # neutron does not allow a fixed IP
571 if not cls.lb_member_vip_ipv6_subnet_stateful:
572 use_fixed_ip = False
Adam Harwellcd72b562018-05-07 11:37:22 -0700573 lb_kwargs[const.VIP_SUBNET_ID] = subnet_id
Michael Johnson07c9a632018-06-07 13:27:42 -0700574 if use_fixed_ip:
575 lb_kwargs[const.VIP_ADDRESS] = lb_vip_address
Adam Harwellcd72b562018-05-07 11:37:22 -0700576 if CONF.load_balancer.test_with_noop:
577 lb_kwargs[const.VIP_NETWORK_ID] = (
578 cls.lb_member_vip_net[const.ID])
Carlos Goncalvesbb238552020-01-15 10:10:55 +0000579 if ip_version == 6:
580 lb_kwargs[const.VIP_ADDRESS] = lb_vip_address
Adam Harwellcd72b562018-05-07 11:37:22 -0700581 else:
582 lb_kwargs[const.VIP_NETWORK_ID] = cls.lb_member_vip_net[const.ID]
583 lb_kwargs[const.VIP_SUBNET_ID] = None
584
ibumarskovba79d2c2020-09-03 18:21:29 +0400585 @classmethod
586 def check_tf_compatibility(cls, protocol=None, algorithm=None):
587 # TungstenFabric supported protocols and algorithms
Ilya Bumarskov61889822021-02-03 16:16:42 +0400588 tf_protocols = [const.HTTP, const.HTTPS, const.TCP,
ibumarskovba79d2c2020-09-03 18:21:29 +0400589 const.TERMINATED_HTTPS]
590 tf_algorithms = [const.LB_ALGORITHM_ROUND_ROBIN,
591 const.LB_ALGORITHM_LEAST_CONNECTIONS,
592 const.LB_ALGORITHM_SOURCE_IP]
593
594 if algorithm and algorithm not in tf_algorithms:
595 raise cls.skipException(
596 'TungstenFabric does not support {} algorithm.'
597 ''.format(algorithm))
598 if protocol and protocol not in tf_protocols:
599 raise cls.skipException(
600 'TungstenFabric does not support {} protocol.'
601 ''.format(protocol))
602
603 @classmethod
604 def _tf_create_listener(cls, name, proto, port, lb_id):
605 listener_kwargs = {
606 const.NAME: name,
607 const.PROTOCOL: proto,
608 const.PROTOCOL_PORT: port,
609 const.LOADBALANCER_ID: lb_id,
610 }
611 listener = cls.mem_listener_client.create_listener(**listener_kwargs)
612 return listener
613
614 @classmethod
615 def _tf_get_free_port(cls, lb_id):
616 port = 8081
617 lb = cls.mem_lb_client.show_loadbalancer(lb_id)
618 listeners = lb[const.LISTENERS]
619 if not listeners:
620 return port
621 ports = [cls.mem_listener_client.show_listener(x[const.ID])[
622 const.PROTOCOL_PORT] for x in listeners]
623 while port in ports:
624 port = port + 1
625 return port
626
Adam Harwellcd72b562018-05-07 11:37:22 -0700627
628class LoadBalancerBaseTestWithCompute(LoadBalancerBaseTest):
629 @classmethod
Gregory Thiemongeb0da4f32022-02-04 08:58:06 +0100630 def remote_client_args(cls):
631 # In case we're using octavia-tempest-plugin with old tempest releases
632 # (for instance on stable/train) that don't support ssh_key_type, catch
633 # the exception and don't pass any argument
634 args = {}
635 try:
636 args['ssh_key_type'] = CONF.validation.ssh_key_type
637 except cfg.NoSuchOptError:
638 pass
639 return args
640
641 @classmethod
Adam Harwellcd72b562018-05-07 11:37:22 -0700642 def resource_setup(cls):
643 super(LoadBalancerBaseTestWithCompute, cls).resource_setup()
644 # If validation is disabled in this cloud, we won't be able to
645 # start the webservers, so don't even boot them.
646 if not CONF.validation.run_validation:
647 return
648
649 # Create a keypair for the webservers
650 keypair_name = data_utils.rand_name('lb_member_keypair')
651 result = cls.lb_mem_keypairs_client.create_keypair(
652 name=keypair_name)
653 cls.lb_member_keypair = result['keypair']
654 LOG.info('lb_member_keypair: {}'.format(cls.lb_member_keypair))
655 cls.addClassResourceCleanup(
656 waiters.wait_for_not_found,
657 cls.lb_mem_keypairs_client.delete_keypair,
658 cls.lb_mem_keypairs_client.show_keypair,
659 keypair_name)
660
661 if (CONF.load_balancer.enable_security_groups and
662 CONF.network_feature_enabled.port_security):
663 # Set up the security group for the webservers
664 SG_name = data_utils.rand_name('lb_member_SG')
665 cls.lb_member_sec_group = (
666 cls.lb_mem_SG_client.create_security_group(
667 name=SG_name)['security_group'])
668 cls.addClassResourceCleanup(
669 waiters.wait_for_not_found,
670 cls.lb_mem_SG_client.delete_security_group,
671 cls.lb_mem_SG_client.show_security_group,
672 cls.lb_member_sec_group['id'])
673
674 # Create a security group rule to allow 80-81 (test webservers)
675 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
676 direction='ingress',
677 security_group_id=cls.lb_member_sec_group['id'],
678 protocol='tcp',
679 ethertype='IPv4',
680 port_range_min=80,
681 port_range_max=81)['security_group_rule']
682 cls.addClassResourceCleanup(
683 waiters.wait_for_not_found,
684 cls.lb_mem_SGr_client.delete_security_group_rule,
685 cls.lb_mem_SGr_client.show_security_group_rule,
686 SGr['id'])
Gregory Thiemonge29d17902019-04-30 15:06:17 +0200687 # Create a security group rule to allow UDP 80-81 (test webservers)
688 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
689 direction='ingress',
690 security_group_id=cls.lb_member_sec_group['id'],
691 protocol='udp',
692 ethertype='IPv4',
693 port_range_min=80,
694 port_range_max=81)['security_group_rule']
695 cls.addClassResourceCleanup(
696 waiters.wait_for_not_found,
697 cls.lb_mem_SGr_client.delete_security_group_rule,
698 cls.lb_mem_SGr_client.show_security_group_rule,
699 SGr['id'])
Michael Johnson74b6f2f2020-10-29 15:11:39 -0700700 # Create a security group rule to allow 443 (test webservers)
701 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
702 direction='ingress',
703 security_group_id=cls.lb_member_sec_group['id'],
704 protocol='tcp',
705 ethertype='IPv4',
706 port_range_min=443,
707 port_range_max=443)['security_group_rule']
708 cls.addClassResourceCleanup(
709 waiters.wait_for_not_found,
710 cls.lb_mem_SGr_client.delete_security_group_rule,
711 cls.lb_mem_SGr_client.show_security_group_rule,
712 SGr['id'])
Michael Johnson031ecca2020-10-29 16:45:32 -0700713 # Create a security group rule to allow 9443 (test webservers)
714 # Used in the pool backend encryption client authentication tests
715 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
716 direction='ingress',
717 security_group_id=cls.lb_member_sec_group['id'],
718 protocol='tcp',
719 ethertype='IPv4',
720 port_range_min=9443,
721 port_range_max=9443)['security_group_rule']
722 cls.addClassResourceCleanup(
723 waiters.wait_for_not_found,
724 cls.lb_mem_SGr_client.delete_security_group_rule,
725 cls.lb_mem_SGr_client.show_security_group_rule,
726 SGr['id'])
Gregory Thiemonge29d17902019-04-30 15:06:17 +0200727 # Create a security group rule to allow UDP 9999 (test webservers)
728 # Port 9999 is used to illustrate health monitor ERRORs on closed
729 # ports.
730 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
731 direction='ingress',
732 security_group_id=cls.lb_member_sec_group['id'],
733 protocol='udp',
734 ethertype='IPv4',
735 port_range_min=9999,
736 port_range_max=9999)['security_group_rule']
737 cls.addClassResourceCleanup(
738 waiters.wait_for_not_found,
739 cls.lb_mem_SGr_client.delete_security_group_rule,
740 cls.lb_mem_SGr_client.show_security_group_rule,
741 SGr['id'])
Adam Harwellcd72b562018-05-07 11:37:22 -0700742 # Create a security group rule to allow 22 (ssh)
743 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
744 direction='ingress',
745 security_group_id=cls.lb_member_sec_group['id'],
746 protocol='tcp',
747 ethertype='IPv4',
748 port_range_min=22,
749 port_range_max=22)['security_group_rule']
750 cls.addClassResourceCleanup(
751 waiters.wait_for_not_found,
752 cls.lb_mem_SGr_client.delete_security_group_rule,
753 cls.lb_mem_SGr_client.show_security_group_rule,
754 SGr['id'])
755 if CONF.load_balancer.test_with_ipv6:
756 # Create a security group rule to allow 80-81 (test webservers)
757 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
758 direction='ingress',
759 security_group_id=cls.lb_member_sec_group['id'],
760 protocol='tcp',
761 ethertype='IPv6',
762 port_range_min=80,
763 port_range_max=81)['security_group_rule']
764 cls.addClassResourceCleanup(
765 waiters.wait_for_not_found,
766 cls.lb_mem_SGr_client.delete_security_group_rule,
767 cls.lb_mem_SGr_client.show_security_group_rule,
768 SGr['id'])
Gregory Thiemonge29d17902019-04-30 15:06:17 +0200769 # Create a security group rule to allow UDP 80-81 (test
770 # webservers)
771 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
772 direction='ingress',
773 security_group_id=cls.lb_member_sec_group['id'],
774 protocol='udp',
775 ethertype='IPv6',
776 port_range_min=80,
777 port_range_max=81)['security_group_rule']
778 cls.addClassResourceCleanup(
779 waiters.wait_for_not_found,
780 cls.lb_mem_SGr_client.delete_security_group_rule,
781 cls.lb_mem_SGr_client.show_security_group_rule,
782 SGr['id'])
Michael Johnson74b6f2f2020-10-29 15:11:39 -0700783 # Create a security group rule to allow 443 (test webservers)
784 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
785 direction='ingress',
786 security_group_id=cls.lb_member_sec_group['id'],
787 protocol='tcp',
788 ethertype='IPv6',
789 port_range_min=443,
790 port_range_max=443)['security_group_rule']
791 cls.addClassResourceCleanup(
792 waiters.wait_for_not_found,
793 cls.lb_mem_SGr_client.delete_security_group_rule,
794 cls.lb_mem_SGr_client.show_security_group_rule,
795 SGr['id'])
Michael Johnson031ecca2020-10-29 16:45:32 -0700796 # Create a security group rule to allow 9443 (test webservers)
797 # Used in the pool encryption client authentication tests
798 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
799 direction='ingress',
800 security_group_id=cls.lb_member_sec_group['id'],
801 protocol='tcp',
802 ethertype='IPv6',
803 port_range_min=9443,
804 port_range_max=9443)['security_group_rule']
805 cls.addClassResourceCleanup(
806 waiters.wait_for_not_found,
807 cls.lb_mem_SGr_client.delete_security_group_rule,
808 cls.lb_mem_SGr_client.show_security_group_rule,
809 SGr['id'])
Adam Harwellcd72b562018-05-07 11:37:22 -0700810 # Create a security group rule to allow 22 (ssh)
811 SGr = cls.lb_mem_SGr_client.create_security_group_rule(
812 direction='ingress',
813 security_group_id=cls.lb_member_sec_group['id'],
814 protocol='tcp',
815 ethertype='IPv6',
816 port_range_min=22,
817 port_range_max=22)['security_group_rule']
818 cls.addClassResourceCleanup(
819 waiters.wait_for_not_found,
820 cls.lb_mem_SGr_client.delete_security_group_rule,
821 cls.lb_mem_SGr_client.show_security_group_rule,
822 SGr['id'])
823
824 LOG.info('lb_member_sec_group: {}'.format(cls.lb_member_sec_group))
825
Michael Johnsonbaf12e02020-10-27 16:10:28 -0700826 # Setup backend member reencryption PKI
827 cls._create_backend_reencryption_pki()
828
Adam Harwellcd72b562018-05-07 11:37:22 -0700829 # Create webserver 1 instance
830 server_details = cls._create_webserver('lb_member_webserver1',
831 cls.lb_member_1_net)
832
833 cls.lb_member_webserver1 = server_details['server']
834 cls.webserver1_ip = server_details.get('ipv4_address')
835 cls.webserver1_ipv6 = server_details.get('ipv6_address')
836 cls.webserver1_public_ip = server_details['public_ipv4_address']
837
838 LOG.debug('Octavia Setup: lb_member_webserver1 = {}'.format(
839 cls.lb_member_webserver1[const.ID]))
840 LOG.debug('Octavia Setup: webserver1_ip = {}'.format(
841 cls.webserver1_ip))
842 LOG.debug('Octavia Setup: webserver1_ipv6 = {}'.format(
843 cls.webserver1_ipv6))
844 LOG.debug('Octavia Setup: webserver1_public_ip = {}'.format(
845 cls.webserver1_public_ip))
846
847 # Create webserver 2 instance
848 server_details = cls._create_webserver('lb_member_webserver2',
849 cls.lb_member_2_net)
850
851 cls.lb_member_webserver2 = server_details['server']
852 cls.webserver2_ip = server_details.get('ipv4_address')
853 cls.webserver2_ipv6 = server_details.get('ipv6_address')
854 cls.webserver2_public_ip = server_details['public_ipv4_address']
855
856 LOG.debug('Octavia Setup: lb_member_webserver2 = {}'.format(
857 cls.lb_member_webserver2[const.ID]))
858 LOG.debug('Octavia Setup: webserver2_ip = {}'.format(
859 cls.webserver2_ip))
860 LOG.debug('Octavia Setup: webserver2_ipv6 = {}'.format(
861 cls.webserver2_ipv6))
862 LOG.debug('Octavia Setup: webserver2_public_ip = {}'.format(
863 cls.webserver2_public_ip))
864
Ilya Bumarskov2f7eee62023-03-16 14:12:09 +0400865 if (CONF.load_balancer.test_with_ipv6 and not
866 config_octavia.is_tungstenfabric_backend_enabled()):
Michael Johnsonbf916df2018-10-17 10:59:28 -0700867 # Enable the IPv6 nic in webserver 1
868 cls._enable_ipv6_nic_webserver(
869 cls.webserver1_public_ip, cls.lb_member_keypair['private_key'],
870 cls.webserver1_ipv6, cls.lb_member_1_subnet_prefix)
871
872 # Enable the IPv6 nic in webserver 2
873 cls._enable_ipv6_nic_webserver(
874 cls.webserver2_public_ip, cls.lb_member_keypair['private_key'],
875 cls.webserver2_ipv6, cls.lb_member_2_subnet_prefix)
876
Adam Harwellcd72b562018-05-07 11:37:22 -0700877 # Set up serving on webserver 1
878 cls._install_start_webserver(cls.webserver1_public_ip,
Adam Harwelle029af22018-05-24 17:13:28 -0700879 cls.lb_member_keypair['private_key'],
880 cls.webserver1_response)
Adam Harwellcd72b562018-05-07 11:37:22 -0700881
882 # Validate webserver 1
Adam Harwelle029af22018-05-24 17:13:28 -0700883 cls._validate_webserver(cls.webserver1_public_ip,
884 cls.webserver1_response)
Adam Harwellcd72b562018-05-07 11:37:22 -0700885
Gregory Thiemonge29d17902019-04-30 15:06:17 +0200886 # Validate udp server 1
887 cls._validate_udp_server(cls.webserver1_public_ip,
888 cls.webserver1_response)
889
Adam Harwellcd72b562018-05-07 11:37:22 -0700890 # Set up serving on webserver 2
891 cls._install_start_webserver(cls.webserver2_public_ip,
Adam Harwelle029af22018-05-24 17:13:28 -0700892 cls.lb_member_keypair['private_key'],
Michael Johnsonbaf12e02020-10-27 16:10:28 -0700893 cls.webserver2_response, revoke_cert=True)
Adam Harwellcd72b562018-05-07 11:37:22 -0700894
895 # Validate webserver 2
Adam Harwelle029af22018-05-24 17:13:28 -0700896 cls._validate_webserver(cls.webserver2_public_ip,
897 cls.webserver2_response)
Adam Harwellcd72b562018-05-07 11:37:22 -0700898
Gregory Thiemonge29d17902019-04-30 15:06:17 +0200899 # Validate udp server 2
900 cls._validate_udp_server(cls.webserver2_public_ip,
901 cls.webserver2_response)
902
Adam Harwellcd72b562018-05-07 11:37:22 -0700903 @classmethod
904 def _create_networks(cls):
905 super(LoadBalancerBaseTestWithCompute, cls)._create_networks()
Jude Cross986e3f52017-07-24 14:57:20 -0700906 # Create a router for the subnets (required for the floating IP)
907 router_name = data_utils.rand_name("lb_member_router")
908 result = cls.lb_mem_routers_client.create_router(
909 name=router_name, admin_state_up=True,
910 external_gateway_info=dict(
911 network_id=CONF.network.public_network_id))
912 cls.lb_member_router = result['router']
913 LOG.info('lb_member_router: {}'.format(cls.lb_member_router))
914 cls.addClassResourceCleanup(
915 waiters.wait_for_not_found,
916 cls.lb_mem_routers_client.delete_router,
917 cls.lb_mem_routers_client.show_router,
918 cls.lb_member_router['id'])
919
920 # Add VIP subnet to router
921 cls.lb_mem_routers_client.add_router_interface(
922 cls.lb_member_router['id'],
923 subnet_id=cls.lb_member_vip_subnet['id'])
924 cls.addClassResourceCleanup(
925 waiters.wait_for_not_found,
926 cls.lb_mem_routers_client.remove_router_interface,
927 cls.lb_mem_routers_client.remove_router_interface,
928 cls.lb_member_router['id'],
929 subnet_id=cls.lb_member_vip_subnet['id'])
930
Gregory Thiemonge54225ad2021-02-04 15:25:17 +0100931 if (CONF.load_balancer.test_with_ipv6 and
932 CONF.load_balancer.default_router and
933 cls.lb_member_vip_ipv6_subnet_use_subnetpool):
934
935 router_name = CONF.load_balancer.default_router
936 # if lb_member_vip_ipv6_subnet uses devstack's subnetpool,
937 # plug the subnet into the default router
938 router = cls.os_admin.routers_client.list_routers(
939 name=router_name)['routers']
940
941 if len(router) == 1:
942 router = router[0]
943
944 # Add IPv6 VIP subnet to router1
945 cls.os_admin_routers_client.add_router_interface(
946 router['id'],
947 subnet_id=cls.lb_member_vip_ipv6_subnet['id'])
948 cls.addClassResourceCleanup(
949 waiters.wait_for_not_found,
950 cls.os_admin_routers_client.remove_router_interface,
951 cls.os_admin_routers_client.remove_router_interface,
952 router['id'],
953 subnet_id=cls.lb_member_vip_ipv6_subnet['id'])
954
Jude Cross986e3f52017-07-24 14:57:20 -0700955 # Add member subnet 1 to router
956 cls.lb_mem_routers_client.add_router_interface(
957 cls.lb_member_router['id'],
958 subnet_id=cls.lb_member_1_subnet['id'])
959 cls.addClassResourceCleanup(
960 waiters.wait_for_not_found,
Jude Cross986e3f52017-07-24 14:57:20 -0700961 cls.lb_mem_routers_client.remove_router_interface,
962 cls.lb_mem_routers_client.remove_router_interface,
963 cls.lb_member_router['id'], subnet_id=cls.lb_member_1_subnet['id'])
964
965 # Add member subnet 2 to router
966 cls.lb_mem_routers_client.add_router_interface(
967 cls.lb_member_router['id'],
968 subnet_id=cls.lb_member_2_subnet['id'])
969 cls.addClassResourceCleanup(
970 waiters.wait_for_not_found,
971 cls.lb_mem_routers_client.remove_router_interface,
972 cls.lb_mem_routers_client.remove_router_interface,
973 cls.lb_member_router['id'], subnet_id=cls.lb_member_2_subnet['id'])
974
975 @classmethod
976 def _create_webserver(cls, name, network):
977 """Creates a webserver with two ports.
978
979 webserver_details dictionary contains:
980 server - The compute server object
981 ipv4_address - The IPv4 address for the server (optional)
982 ipv6_address - The IPv6 address for the server (optional)
983 public_ipv4_address - The publicly accessible IPv4 address for the
984 server, this may be a floating IP (optional)
985
986 :param name: The name of the server to create.
987 :param network: The network to boot the server on.
988 :returns: webserver_details dictionary.
989 """
990 server_kwargs = {
991 'name': data_utils.rand_name(name),
992 'flavorRef': CONF.compute.flavor_ref,
993 'imageRef': CONF.compute.image_ref,
994 'key_name': cls.lb_member_keypair['name']}
995 if (CONF.load_balancer.enable_security_groups and
996 CONF.network_feature_enabled.port_security):
997 server_kwargs['security_groups'] = [
998 {'name': cls.lb_member_sec_group['name']}]
999 if not CONF.load_balancer.disable_boot_network:
1000 server_kwargs['networks'] = [{'uuid': network['id']}]
1001
1002 # Replace the name for clouds that have limitations
1003 if CONF.load_balancer.random_server_name_length:
1004 r = random.SystemRandom()
1005 server_kwargs['name'] = "m{}".format("".join(
1006 [r.choice(string.ascii_uppercase + string.digits)
1007 for _ in range(
1008 CONF.load_balancer.random_server_name_length - 1)]
1009 ))
1010 if CONF.load_balancer.availability_zone:
1011 server_kwargs['availability_zone'] = (
1012 CONF.load_balancer.availability_zone)
1013
1014 server = cls.lb_mem_servers_client.create_server(
1015 **server_kwargs)['server']
1016 cls.addClassResourceCleanup(
1017 waiters.wait_for_not_found,
1018 cls.lb_mem_servers_client.delete_server,
1019 cls.lb_mem_servers_client.show_server,
1020 server['id'])
1021 server = waiters.wait_for_status(
1022 cls.lb_mem_servers_client.show_server,
1023 server['id'], 'status', 'ACTIVE',
1024 CONF.load_balancer.build_interval,
1025 CONF.load_balancer.build_timeout,
1026 root_tag='server')
1027 webserver_details = {'server': server}
1028 LOG.info('Created server: {}'.format(server))
1029
1030 addresses = server['addresses']
1031 if CONF.load_balancer.disable_boot_network:
1032 instance_network = addresses.values()[0]
1033 else:
1034 instance_network = addresses[network['name']]
1035 for addr in instance_network:
1036 if addr['version'] == 4:
1037 webserver_details['ipv4_address'] = addr['addr']
1038 if addr['version'] == 6:
1039 webserver_details['ipv6_address'] = addr['addr']
1040
1041 if CONF.validation.connect_method == 'floating':
1042 result = cls.lb_mem_ports_client.list_ports(
1043 network_id=network['id'],
1044 mac_address=instance_network[0]['OS-EXT-IPS-MAC:mac_addr'])
1045 port_id = result['ports'][0]['id']
Ilya Bumarskov2f7eee62023-03-16 14:12:09 +04001046 if config_octavia.is_tungstenfabric_backend_enabled():
1047 port = result['ports'][0]
1048 fixed_ip = None
1049 for ip in port["fixed_ips"]:
1050 if (type(ipaddress.ip_address(ip["ip_address"])) is
1051 ipaddress.IPv4Address):
1052 fixed_ip = ip["ip_address"]
1053 break
1054 assert fixed_ip is not None, (f"Port doesn't have ipv4 "
1055 f"address: {port['fixed_ips']}")
1056 result = cls.lb_mem_float_ip_client.create_floatingip(
1057 floating_network_id=CONF.network.public_network_id,
1058 port_id=port_id,
1059 fixed_ip_address=fixed_ip)
1060 else:
1061 result = cls.lb_mem_float_ip_client.create_floatingip(
1062 floating_network_id=CONF.network.public_network_id,
1063 port_id=port_id)
Jude Cross986e3f52017-07-24 14:57:20 -07001064 floating_ip = result['floatingip']
1065 LOG.info('webserver1_floating_ip: {}'.format(floating_ip))
1066 cls.addClassResourceCleanup(
1067 waiters.wait_for_not_found,
1068 cls.lb_mem_float_ip_client.delete_floatingip,
1069 cls.lb_mem_float_ip_client.show_floatingip,
1070 floatingip_id=floating_ip['id'])
1071 webserver_details['public_ipv4_address'] = (
1072 floating_ip['floating_ip_address'])
1073 else:
1074 webserver_details['public_ipv4_address'] = (
1075 instance_network[0]['addr'])
1076
1077 return webserver_details
1078
1079 @classmethod
Gregory Thiemongea2c234e2021-11-02 17:08:29 +01001080 def _get_openssh_version(cls):
1081 p = subprocess.Popen(["ssh", "-V"],
1082 stdout=subprocess.PIPE,
1083 stderr=subprocess.PIPE)
1084 output = p.communicate()[1]
1085
1086 try:
1087 m = re.match(r"OpenSSH_(\d+)\.(\d+)", output.decode('utf-8'))
1088 version_maj = int(m.group(1))
1089 version_min = int(m.group(2))
1090 return version_maj, version_min
1091 except Exception:
1092 return None, None
1093
1094 @classmethod
1095 def _need_scp_protocol(cls):
1096 # When using scp >= 8.7, force the use of the SCP protocol,
1097 # the new default (SFTP protocol) doesn't work with
1098 # cirros VMs.
1099 ssh_version = cls._get_openssh_version()
1100 LOG.debug("ssh_version = {}".format(ssh_version))
1101 return (ssh_version[0] > 8 or
1102 (ssh_version[0] == 8 and ssh_version[1] >= 7))
1103
1104 @classmethod
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001105 def _install_start_webserver(cls, ip_address, ssh_key, start_id,
1106 revoke_cert=False):
Michael Johnson27357352020-11-13 13:55:09 -08001107 local_file = CONF.load_balancer.test_server_path
Adam Harwellcd72b562018-05-07 11:37:22 -07001108
1109 linux_client = remote_client.RemoteClient(
Ade Leed0ea4062021-09-06 15:33:27 -04001110 ip_address, CONF.validation.image_ssh_user, pkey=ssh_key,
Gregory Thiemongeb0da4f32022-02-04 08:58:06 +01001111 **cls.remote_client_args())
Adam Harwellcd72b562018-05-07 11:37:22 -07001112 linux_client.validate_authentication()
1113
1114 with tempfile.NamedTemporaryFile() as key:
1115 key.write(ssh_key.encode('utf-8'))
1116 key.flush()
Gregory Thiemongea2c234e2021-11-02 17:08:29 +01001117 ssh_extra_args = (
1118 "-o PubkeyAcceptedKeyTypes=+ssh-rsa")
1119 if cls._need_scp_protocol():
1120 ssh_extra_args += " -O"
Adam Harwellcd72b562018-05-07 11:37:22 -07001121 cmd = ("scp -v -o UserKnownHostsFile=/dev/null "
Gregory Thiemongea2c234e2021-11-02 17:08:29 +01001122 "{7} "
Adam Harwellcd72b562018-05-07 11:37:22 -07001123 "-o StrictHostKeyChecking=no "
1124 "-o ConnectTimeout={0} -o ConnectionAttempts={1} "
1125 "-i {2} {3} {4}@{5}:{6}").format(
1126 CONF.load_balancer.scp_connection_timeout,
1127 CONF.load_balancer.scp_connection_attempts,
1128 key.name, local_file, CONF.validation.image_ssh_user,
Gregory Thiemongea2c234e2021-11-02 17:08:29 +01001129 ip_address, const.TEST_SERVER_BINARY,
1130 ssh_extra_args)
Adam Harwellcd72b562018-05-07 11:37:22 -07001131 args = shlex.split(cmd)
1132 subprocess_args = {'stdout': subprocess.PIPE,
1133 'stderr': subprocess.STDOUT,
1134 'cwd': None}
1135 proc = subprocess.Popen(args, **subprocess_args)
1136 stdout, stderr = proc.communicate()
1137 if proc.returncode != 0:
1138 raise exceptions.CommandFailed(proc.returncode, cmd,
1139 stdout, stderr)
Gregory Thiemongef72a8862019-08-06 17:25:42 +02001140
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001141 cls._load_member_pki_content(ip_address, key,
1142 revoke_cert=revoke_cert)
1143
Gregory Thiemongef72a8862019-08-06 17:25:42 +02001144 # Enabling memory overcommit allows to run golang static binaries
1145 # compiled with a recent golang toolchain (>=1.11). Those binaries
1146 # allocate a large amount of virtual memory at init time, and this
1147 # allocation fails in tempest's nano flavor (64MB of RAM)
1148 # (golang issue reported in https://github.com/golang/go/issues/28114,
1149 # follow-up: https://github.com/golang/go/issues/28081)
1150 # TODO(gthiemonge): Remove this call when golang issue is resolved.
1151 linux_client.exec_command('sudo sh -c "echo 1 > '
1152 '/proc/sys/vm/overcommit_memory"')
1153
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001154 # The initial process also supports HTTPS and HTTPS with client auth
1155 linux_client.exec_command(
1156 'sudo screen -d -m {0} -port 80 -id {1} -https_port 443 -cert {2} '
1157 '-key {3} -https_client_auth_port 9443 -client_ca {4}'.format(
1158 const.TEST_SERVER_BINARY, start_id, const.TEST_SERVER_CERT,
1159 const.TEST_SERVER_KEY, const.TEST_SERVER_CLIENT_CA))
1160
Adam Harwellcd72b562018-05-07 11:37:22 -07001161 linux_client.exec_command('sudo screen -d -m {0} -port 81 '
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001162 '-id {1}'.format(const.TEST_SERVER_BINARY,
1163 start_id + 1))
Adam Harwellcd72b562018-05-07 11:37:22 -07001164
Michael Johnsonbf916df2018-10-17 10:59:28 -07001165 # Cirros does not configure the assigned IPv6 address by default
1166 # so enable it manually like tempest does here:
1167 # tempest/scenario/test_netowrk_v6.py turn_nic6_on()
1168 @classmethod
1169 def _enable_ipv6_nic_webserver(cls, ip_address, ssh_key,
1170 ipv6_address, ipv6_prefix):
1171 linux_client = remote_client.RemoteClient(
Ade Leed0ea4062021-09-06 15:33:27 -04001172 ip_address, CONF.validation.image_ssh_user, pkey=ssh_key,
Gregory Thiemongeb0da4f32022-02-04 08:58:06 +01001173 **cls.remote_client_args())
Michael Johnsonbf916df2018-10-17 10:59:28 -07001174 linux_client.validate_authentication()
1175
1176 linux_client.exec_command('sudo ip address add {0}/{1} dev '
1177 'eth0'.format(ipv6_address, ipv6_prefix))
1178
Adam Harwellcd72b562018-05-07 11:37:22 -07001179 @classmethod
Jude Cross986e3f52017-07-24 14:57:20 -07001180 def _validate_webserver(cls, ip_address, start_id):
1181 URL = 'http://{0}'.format(ip_address)
Michael Johnson89bdbcd2020-03-19 15:59:19 -07001182 cls.validate_URL_response(URL, expected_body=str(start_id))
Jude Cross986e3f52017-07-24 14:57:20 -07001183 URL = 'http://{0}:81'.format(ip_address)
Michael Johnson89bdbcd2020-03-19 15:59:19 -07001184 cls.validate_URL_response(URL, expected_body=str(start_id + 1))
Jude Cross986e3f52017-07-24 14:57:20 -07001185
Gregory Thiemonge29d17902019-04-30 15:06:17 +02001186 @classmethod
1187 def _validate_udp_server(cls, ip_address, start_id):
Michael Johnson89bdbcd2020-03-19 15:59:19 -07001188 res = cls.make_udp_request(ip_address, 80)
Gregory Thiemonge29d17902019-04-30 15:06:17 +02001189 if res != str(start_id):
1190 raise Exception("Response from test server doesn't match the "
1191 "expected value ({0} != {1}).".format(
1192 res, str(start_id)))
1193
Michael Johnson89bdbcd2020-03-19 15:59:19 -07001194 res = cls.make_udp_request(ip_address, 81)
Gregory Thiemonge29d17902019-04-30 15:06:17 +02001195 if res != str(start_id + 1):
1196 raise Exception("Response from test server doesn't match the "
1197 "expected value ({0} != {1}).".format(
1198 res, str(start_id + 1)))
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001199
1200 @classmethod
1201 def _create_backend_reencryption_pki(cls):
1202 # Create a CA self-signed cert and key for the member test servers
1203 cls.member_ca_cert, cls.member_ca_key = (
1204 cert_utils.generate_ca_cert_and_key())
1205
1206 LOG.debug('Member CA Cert: %s', cls.member_ca_cert.public_bytes(
1207 serialization.Encoding.PEM))
1208 LOG.debug('Member CA private Key: %s', cls.member_ca_key.private_bytes(
1209 encoding=serialization.Encoding.PEM,
1210 format=serialization.PrivateFormat.TraditionalOpenSSL,
1211 encryption_algorithm=serialization.NoEncryption()))
1212 LOG.debug('Member CA public Key: %s',
1213 cls.member_ca_key.public_key().public_bytes(
1214 encoding=serialization.Encoding.PEM,
1215 format=serialization.PublicFormat.SubjectPublicKeyInfo))
1216
1217 # Create the member client authentication CA
1218 cls.member_client_ca_cert, member_client_ca_key = (
1219 cert_utils.generate_ca_cert_and_key())
1220
1221 # Create client cert and key
1222 cls.member_client_cn = uuidutils.generate_uuid()
1223 cls.member_client_cert, cls.member_client_key = (
1224 cert_utils.generate_client_cert_and_key(
1225 cls.member_client_ca_cert, member_client_ca_key,
1226 cls.member_client_cn))
1227 # Note: We are not revoking a client cert here as we don't need to
1228 # test the backend web server CRL checking.
1229
1230 @classmethod
1231 def _load_member_pki_content(cls, ip_address, ssh_key, revoke_cert=False):
1232 # Create webserver certificate and key
1233 cert, key = cert_utils.generate_server_cert_and_key(
1234 cls.member_ca_cert, cls.member_ca_key, ip_address)
1235
1236 LOG.debug('%s Cert: %s', ip_address, cert.public_bytes(
1237 serialization.Encoding.PEM))
1238 LOG.debug('%s private Key: %s', ip_address, key.private_bytes(
1239 encoding=serialization.Encoding.PEM,
1240 format=serialization.PrivateFormat.TraditionalOpenSSL,
1241 encryption_algorithm=serialization.NoEncryption()))
1242 public_key = key.public_key()
1243 LOG.debug('%s public Key: %s', ip_address, public_key.public_bytes(
1244 encoding=serialization.Encoding.PEM,
1245 format=serialization.PublicFormat.SubjectPublicKeyInfo))
1246
1247 # Create a CRL with a revoked certificate
1248 if revoke_cert:
1249 # Create a CRL with webserver 2 revoked
1250 cls.member_crl = cert_utils.generate_certificate_revocation_list(
1251 cls.member_ca_cert, cls.member_ca_key, cert)
1252
1253 # Load the certificate, key, and client CA certificate into the
1254 # test server.
1255 with tempfile.TemporaryDirectory() as tmpdir:
1256 os.umask(0)
1257 files_to_send = []
1258 cert_filename = os.path.join(tmpdir, const.CERT_PEM)
1259 files_to_send.append(cert_filename)
1260 with open(os.open(cert_filename, os.O_CREAT | os.O_WRONLY,
1261 0o700), 'w') as fh:
1262 fh.write(cert.public_bytes(
1263 serialization.Encoding.PEM).decode('utf-8'))
1264 fh.flush()
1265 key_filename = os.path.join(tmpdir, const.KEY_PEM)
1266 files_to_send.append(key_filename)
1267 with open(os.open(key_filename, os.O_CREAT | os.O_WRONLY,
1268 0o700), 'w') as fh:
1269 fh.write(key.private_bytes(
1270 encoding=serialization.Encoding.PEM,
1271 format=serialization.PrivateFormat.TraditionalOpenSSL,
1272 encryption_algorithm=serialization.NoEncryption()).decode(
1273 'utf-8'))
1274 fh.flush()
1275 client_ca_filename = os.path.join(tmpdir, const.CLIENT_CA_PEM)
1276 files_to_send.append(client_ca_filename)
1277 with open(os.open(client_ca_filename, os.O_CREAT | os.O_WRONLY,
1278 0o700), 'w') as fh:
1279 fh.write(cls.member_client_ca_cert.public_bytes(
1280 serialization.Encoding.PEM).decode('utf-8'))
1281 fh.flush()
1282
1283 # For security, we don't want to use a shell that can glob
1284 # the file names, so iterate over them.
1285 subprocess_args = {'stdout': subprocess.PIPE,
1286 'stderr': subprocess.STDOUT,
1287 'cwd': None}
Gregory Thiemongea2c234e2021-11-02 17:08:29 +01001288 ssh_extra_args = (
1289 "-o PubkeyAcceptedKeyTypes=+ssh-rsa")
1290 if cls._need_scp_protocol():
1291 ssh_extra_args += " -O"
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001292 cmd = ("scp -v -o UserKnownHostsFile=/dev/null "
Gregory Thiemongea2c234e2021-11-02 17:08:29 +01001293 "{9} "
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001294 "-o StrictHostKeyChecking=no "
1295 "-o ConnectTimeout={0} -o ConnectionAttempts={1} "
1296 "-i {2} {3} {4} {5} {6}@{7}:{8}").format(
1297 CONF.load_balancer.scp_connection_timeout,
1298 CONF.load_balancer.scp_connection_attempts,
1299 ssh_key.name, cert_filename, key_filename, client_ca_filename,
Gregory Thiemongea2c234e2021-11-02 17:08:29 +01001300 CONF.validation.image_ssh_user, ip_address, const.DEV_SHM_PATH,
1301 ssh_extra_args)
Michael Johnsonbaf12e02020-10-27 16:10:28 -07001302 args = shlex.split(cmd)
1303 proc = subprocess.Popen(args, **subprocess_args)
1304 stdout, stderr = proc.communicate()
1305 if proc.returncode != 0:
1306 raise exceptions.CommandFailed(proc.returncode, cmd,
1307 stdout, stderr)