pre-commit: Migrate pyupgrade to ruff
Change-Id: Ic50d2a5e0bc9dcdfe29f382607135cab510cd396 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
fc6852cd94
commit
f98006ca9d
@ -14,16 +14,11 @@ repos:
|
|||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
files: .*\.(yaml|yml)$
|
files: .*\.(yaml|yml)$
|
||||||
args: ['--unsafe']
|
args: ['--unsafe']
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
|
||||||
rev: v3.17.0
|
|
||||||
hooks:
|
|
||||||
- id: pyupgrade
|
|
||||||
args: ['--py38-plus']
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.6.2
|
rev: v0.6.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: ['--fix']
|
args: ['--fix', '--unsafe-fixes']
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
- repo: https://opendev.org/openstack/hacking
|
- repo: https://opendev.org/openstack/hacking
|
||||||
rev: 7.0.0
|
rev: 7.0.0
|
||||||
|
@ -241,9 +241,9 @@ def run(opts):
|
|||||||
|
|
||||||
# Do some basic testing here
|
# Do some basic testing here
|
||||||
sys.stdout.write("Default run command\n")
|
sys.stdout.write("Default run command\n")
|
||||||
sys.stdout.write("Verbose level: %s\n" % opts.verbose_level)
|
sys.stdout.write(f"Verbose level: {opts.verbose_level}\n")
|
||||||
sys.stdout.write("Debug: %s\n" % opts.debug)
|
sys.stdout.write(f"Debug: {opts.debug}\n")
|
||||||
sys.stdout.write("dump_stack_trace: %s\n" % dump_stack_trace)
|
sys.stdout.write(f"dump_stack_trace: {dump_stack_trace}\n")
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
|
@ -101,7 +101,7 @@ def run(opts):
|
|||||||
o_list = obj_api.object_list(c_list[0]['name'])
|
o_list = obj_api.object_list(c_list[0]['name'])
|
||||||
print("\nObject")
|
print("\nObject")
|
||||||
for o in o_list:
|
for o in o_list:
|
||||||
print("%s" % o)
|
print(f"{o}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -94,13 +94,13 @@ def run(opts):
|
|||||||
o_list = client_manager.object_store.object_list(c_list[0]['name'])
|
o_list = client_manager.object_store.object_list(c_list[0]['name'])
|
||||||
print("\nObject")
|
print("\nObject")
|
||||||
for o in o_list:
|
for o in o_list:
|
||||||
print("%s" % o)
|
print(f"{o}")
|
||||||
|
|
||||||
# Look at the compute flavors
|
# Look at the compute flavors
|
||||||
flavor_list = client_manager.compute.flavors.list()
|
flavor_list = client_manager.compute.flavors.list()
|
||||||
print("\nFlavors:")
|
print("\nFlavors:")
|
||||||
for f in flavor_list:
|
for f in flavor_list:
|
||||||
print("%s" % f)
|
print(f"{f}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -307,7 +307,7 @@ class BaseAPI(KeystoneSession):
|
|||||||
except ks_exceptions.NotFound:
|
except ks_exceptions.NotFound:
|
||||||
kwargs = {attr: value}
|
kwargs = {attr: value}
|
||||||
try:
|
try:
|
||||||
ret = self.find_one("/%s/detail" % (path), **kwargs)
|
ret = self.find_one(f"/{path}/detail", **kwargs)
|
||||||
except ks_exceptions.NotFound:
|
except ks_exceptions.NotFound:
|
||||||
msg = _("%s not found") % value
|
msg = _("%s not found") % value
|
||||||
raise exceptions.NotFound(msg)
|
raise exceptions.NotFound(msg)
|
||||||
|
@ -256,10 +256,7 @@ class APIv1(api.BaseAPI):
|
|||||||
# object's name in the container.
|
# object's name in the container.
|
||||||
object_name_str = name if name else object
|
object_name_str = name if name else object
|
||||||
|
|
||||||
full_url = "{}/{}".format(
|
full_url = f"{urllib.parse.quote(container)}/{urllib.parse.quote(object_name_str)}"
|
||||||
urllib.parse.quote(container),
|
|
||||||
urllib.parse.quote(object_name_str),
|
|
||||||
)
|
|
||||||
with open(object, 'rb') as f:
|
with open(object, 'rb') as f:
|
||||||
response = self.create(
|
response = self.create(
|
||||||
full_url,
|
full_url,
|
||||||
@ -293,8 +290,7 @@ class APIv1(api.BaseAPI):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.delete(
|
self.delete(
|
||||||
"%s/%s"
|
f"{urllib.parse.quote(container)}/{urllib.parse.quote(object)}"
|
||||||
% (urllib.parse.quote(container), urllib.parse.quote(object))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def object_list(
|
def object_list(
|
||||||
@ -395,8 +391,7 @@ class APIv1(api.BaseAPI):
|
|||||||
|
|
||||||
response = self._request(
|
response = self._request(
|
||||||
'GET',
|
'GET',
|
||||||
"%s/%s"
|
f"{urllib.parse.quote(container)}/{urllib.parse.quote(object)}",
|
||||||
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
|
||||||
stream=True,
|
stream=True,
|
||||||
)
|
)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
@ -431,8 +426,7 @@ class APIv1(api.BaseAPI):
|
|||||||
headers = self._set_properties(properties, 'X-Object-Meta-%s')
|
headers = self._set_properties(properties, 'X-Object-Meta-%s')
|
||||||
if headers:
|
if headers:
|
||||||
self.create(
|
self.create(
|
||||||
"%s/%s"
|
f"{urllib.parse.quote(container)}/{urllib.parse.quote(object)}",
|
||||||
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -455,8 +449,7 @@ class APIv1(api.BaseAPI):
|
|||||||
headers = self._unset_properties(properties, 'X-Remove-Object-Meta-%s')
|
headers = self._unset_properties(properties, 'X-Remove-Object-Meta-%s')
|
||||||
if headers:
|
if headers:
|
||||||
self.create(
|
self.create(
|
||||||
"%s/%s"
|
f"{urllib.parse.quote(container)}/{urllib.parse.quote(object)}",
|
||||||
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -480,8 +473,7 @@ class APIv1(api.BaseAPI):
|
|||||||
|
|
||||||
response = self._request(
|
response = self._request(
|
||||||
'HEAD',
|
'HEAD',
|
||||||
"%s/%s"
|
f"{urllib.parse.quote(container)}/{urllib.parse.quote(object)}",
|
||||||
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
@ -507,8 +507,8 @@ class SetQuota(common.NetDetectionMixin, command.Command):
|
|||||||
)
|
)
|
||||||
for k, v, h in self._build_options_list():
|
for k, v, h in self._build_options_list():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--%s' % v,
|
f'--{v}',
|
||||||
metavar='<%s>' % v,
|
metavar=f'<{v}>',
|
||||||
dest=k,
|
dest=k,
|
||||||
type=int,
|
type=int,
|
||||||
help=h,
|
help=h,
|
||||||
@ -590,7 +590,7 @@ class SetQuota(common.NetDetectionMixin, command.Command):
|
|||||||
parsed_args.volume_type
|
parsed_args.volume_type
|
||||||
and k in IMPACT_VOLUME_TYPE_QUOTAS
|
and k in IMPACT_VOLUME_TYPE_QUOTAS
|
||||||
):
|
):
|
||||||
k = k + '_%s' % parsed_args.volume_type
|
k = k + f'_{parsed_args.volume_type}'
|
||||||
volume_kwargs[k] = value
|
volume_kwargs[k] = value
|
||||||
|
|
||||||
if self.app.client_manager.is_network_endpoint_enabled():
|
if self.app.client_manager.is_network_endpoint_enabled():
|
||||||
|
@ -1504,7 +1504,7 @@ class CreateServer(command.ShowOne):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -2189,7 +2189,7 @@ class DeleteServer(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -3198,7 +3198,7 @@ revert to release the new server and restart the old one."""
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -3350,7 +3350,7 @@ class RebootServer(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -3555,7 +3555,7 @@ class RebuildServer(command.ShowOne):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -3816,7 +3816,7 @@ host."""
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -4188,7 +4188,7 @@ release the new server and restart the old one."""
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -4584,7 +4584,7 @@ class ShelveServer(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
@ -5181,7 +5181,7 @@ class UnshelveServer(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
@ -68,7 +68,7 @@ class CreateServerBackup(command.ShowOne):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stderr.write('\rProgress: %s' % progress)
|
self.app.stderr.write(f'\rProgress: {progress}')
|
||||||
self.app.stderr.flush()
|
self.app.stderr.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
@ -69,7 +69,7 @@ class CreateServerImage(command.ShowOne):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
def _show_progress(progress):
|
def _show_progress(progress):
|
||||||
if progress:
|
if progress:
|
||||||
self.app.stdout.write('\rProgress: %s' % progress)
|
self.app.stdout.write(f'\rProgress: {progress}')
|
||||||
self.app.stdout.flush()
|
self.app.stdout.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.sdk_connection.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
@ -60,7 +60,7 @@ class CountColumn(cliff_columns.FormattableColumn):
|
|||||||
|
|
||||||
class FloatColumn(cliff_columns.FormattableColumn):
|
class FloatColumn(cliff_columns.FormattableColumn):
|
||||||
def human_readable(self):
|
def human_readable(self):
|
||||||
return float("%.2f" % self._value)
|
return float(f"{self._value:.2f}")
|
||||||
|
|
||||||
|
|
||||||
def _formatters(project_cache):
|
def _formatters(project_cache):
|
||||||
|
@ -34,7 +34,7 @@ def find_service_in_list(service_list, service_id):
|
|||||||
if service.id == service_id:
|
if service.id == service_id:
|
||||||
return service
|
return service
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
"No service with a type, name or ID of '%s' exists." % service_id
|
f"No service with a type, name or ID of '{service_id}' exists."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -421,8 +421,8 @@ class CreateImage(command.ShowOne):
|
|||||||
identity_common.add_project_domain_option_to_parser(parser)
|
identity_common.add_project_domain_option_to_parser(parser)
|
||||||
for deadopt in self.deadopts:
|
for deadopt in self.deadopts:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--%s" % deadopt,
|
f"--{deadopt}",
|
||||||
metavar="<%s>" % deadopt,
|
metavar=f"<{deadopt}>",
|
||||||
dest=deadopt.replace('-', '_'),
|
dest=deadopt.replace('-', '_'),
|
||||||
help=argparse.SUPPRESS,
|
help=argparse.SUPPRESS,
|
||||||
)
|
)
|
||||||
@ -488,7 +488,7 @@ class CreateImage(command.ShowOne):
|
|||||||
fp = open(parsed_args.filename, 'rb')
|
fp = open(parsed_args.filename, 'rb')
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
'%r is not a valid file' % parsed_args.filename,
|
f'{parsed_args.filename!r} is not a valid file',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
fp = get_data_from_stdin()
|
fp = get_data_from_stdin()
|
||||||
@ -1209,8 +1209,8 @@ class SetImage(command.Command):
|
|||||||
identity_common.add_project_domain_option_to_parser(parser)
|
identity_common.add_project_domain_option_to_parser(parser)
|
||||||
for deadopt in self.deadopts:
|
for deadopt in self.deadopts:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--%s" % deadopt,
|
f"--{deadopt}",
|
||||||
metavar="<%s>" % deadopt,
|
metavar=f"<{deadopt}>",
|
||||||
dest=f"dead_{deadopt.replace('-', '_')}",
|
dest=f"dead_{deadopt.replace('-', '_')}",
|
||||||
help=argparse.SUPPRESS,
|
help=argparse.SUPPRESS,
|
||||||
)
|
)
|
||||||
@ -1575,7 +1575,7 @@ class StageImage(command.Command):
|
|||||||
fp = open(parsed_args.filename, 'rb')
|
fp = open(parsed_args.filename, 'rb')
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
'%r is not a valid file' % parsed_args.filename,
|
f'{parsed_args.filename!r} is not a valid file',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
fp = get_data_from_stdin()
|
fp = get_data_from_stdin()
|
||||||
|
@ -120,15 +120,16 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def split_help(network_help, compute_help):
|
def split_help(network_help, compute_help):
|
||||||
return (
|
return (
|
||||||
"*%(network_qualifier)s:*\n %(network_help)s\n\n"
|
"*{network_qualifier}:*\n {network_help}\n\n"
|
||||||
"*%(compute_qualifier)s:*\n %(compute_help)s"
|
"*{compute_qualifier}:*\n {compute_help}".format(
|
||||||
% dict(
|
**dict(
|
||||||
network_qualifier=_("Network version 2"),
|
network_qualifier=_("Network version 2"),
|
||||||
network_help=network_help,
|
network_help=network_help,
|
||||||
compute_qualifier=_("Compute version 2"),
|
compute_qualifier=_("Compute version 2"),
|
||||||
compute_help=compute_help,
|
compute_help=compute_help,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
LOG.debug('get_parser(%s)', prog_name)
|
LOG.debug('get_parser(%s)', prog_name)
|
||||||
|
@ -89,9 +89,7 @@ class AddNetworkToAgent(command.Command):
|
|||||||
try:
|
try:
|
||||||
client.add_dhcp_agent_to_network(agent, network)
|
client.add_dhcp_agent_to_network(agent, network)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = 'Failed to add {} to {}'.format(
|
msg = f'Failed to add {network.name} to {agent.agent_type}'
|
||||||
network.name, agent.agent_type
|
|
||||||
)
|
|
||||||
exceptions.CommandError(msg)
|
exceptions.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
@ -321,9 +319,7 @@ class RemoveNetworkFromAgent(command.Command):
|
|||||||
try:
|
try:
|
||||||
client.remove_dhcp_agent_from_network(agent, network)
|
client.remove_dhcp_agent_from_network(agent, network)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = 'Failed to remove {} to {}'.format(
|
msg = f'Failed to remove {network.name} to {agent.agent_type}'
|
||||||
network.name, agent.agent_type
|
|
||||||
)
|
|
||||||
exceptions.CommandError(msg)
|
exceptions.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,10 +159,7 @@ def _get_item_properties(item, fields):
|
|||||||
|
|
||||||
def _rule_action_call(client, action, rule_type):
|
def _rule_action_call(client, action, rule_type):
|
||||||
rule_type = rule_type.replace('-', '_')
|
rule_type = rule_type.replace('-', '_')
|
||||||
func_name = '{action}_qos_{rule_type}_rule'.format(
|
func_name = f'{action}_qos_{rule_type}_rule'
|
||||||
action=action,
|
|
||||||
rule_type=rule_type,
|
|
||||||
)
|
|
||||||
return getattr(client, func_name)
|
return getattr(client, func_name)
|
||||||
|
|
||||||
|
|
||||||
@ -311,7 +308,7 @@ class DeleteNetworkQosRule(command.Command):
|
|||||||
)
|
)
|
||||||
rule_type = _find_rule_type(qos, rule_id)
|
rule_type = _find_rule_type(qos, rule_id)
|
||||||
if not rule_type:
|
if not rule_type:
|
||||||
raise Exception('Rule %s not found' % rule_id)
|
raise Exception(f'Rule {rule_id} not found')
|
||||||
_rule_action_call(network_client, ACTION_DELETE, rule_type)(
|
_rule_action_call(network_client, ACTION_DELETE, rule_type)(
|
||||||
rule_id, qos.id
|
rule_id, qos.id
|
||||||
)
|
)
|
||||||
|
@ -274,13 +274,13 @@ def _prepare_filter_fixed_ips(client_manager, parsed_args):
|
|||||||
_subnet = client.find_subnet(
|
_subnet = client.find_subnet(
|
||||||
subnet_name_id, ignore_missing=False
|
subnet_name_id, ignore_missing=False
|
||||||
)
|
)
|
||||||
ips.append('subnet_id=%s' % _subnet.id)
|
ips.append(f'subnet_id={_subnet.id}')
|
||||||
|
|
||||||
if 'ip-address' in ip_spec:
|
if 'ip-address' in ip_spec:
|
||||||
ips.append('ip_address=%s' % ip_spec['ip-address'])
|
ips.append('ip_address={}'.format(ip_spec['ip-address']))
|
||||||
|
|
||||||
if 'ip-substring' in ip_spec:
|
if 'ip-substring' in ip_spec:
|
||||||
ips.append('ip_address_substr=%s' % ip_spec['ip-substring'])
|
ips.append('ip_address_substr={}'.format(ip_spec['ip-substring']))
|
||||||
return ips
|
return ips
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,8 +96,9 @@ class OpenStackShell(shell.OpenStackShell):
|
|||||||
key=lambda s: list(map(int, s.split('.'))),
|
key=lambda s: list(map(int, s.split('.'))),
|
||||||
)
|
)
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"%s version %s is not in supported versions: %s"
|
"{} version {} is not in supported versions: {}".format(
|
||||||
% (api, version_opt, ', '.join(sorted_versions))
|
api, version_opt, ', '.join(sorted_versions)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Command groups deal only with major versions
|
# Command groups deal only with major versions
|
||||||
|
@ -60,15 +60,9 @@ class HelpTests(base.TestCase):
|
|||||||
"""Check server commands in main help message."""
|
"""Check server commands in main help message."""
|
||||||
raw_output = self.openstack('help')
|
raw_output = self.openstack('help')
|
||||||
for command, description in self.SERVER_COMMANDS:
|
for command, description in self.SERVER_COMMANDS:
|
||||||
msg = 'Command: {} not found in help output:\n{}'.format(
|
msg = f'Command: {command} not found in help output:\n{raw_output}'
|
||||||
command,
|
|
||||||
raw_output,
|
|
||||||
)
|
|
||||||
self.assertIn(command, raw_output, msg)
|
self.assertIn(command, raw_output, msg)
|
||||||
msg = 'Description: {} not found in help output:\n{}'.format(
|
msg = f'Description: {description} not found in help output:\n{raw_output}'
|
||||||
description,
|
|
||||||
raw_output,
|
|
||||||
)
|
|
||||||
self.assertIn(description, raw_output, msg)
|
self.assertIn(description, raw_output, msg)
|
||||||
|
|
||||||
def test_server_only_help(self):
|
def test_server_only_help(self):
|
||||||
|
@ -59,7 +59,7 @@ class CommandTest(base.TestCase):
|
|||||||
input_groups = ['volume', 'network', 'image', 'identity', 'compute.v2']
|
input_groups = ['volume', 'network', 'image', 'identity', 'compute.v2']
|
||||||
for each_input in input_groups:
|
for each_input in input_groups:
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'command list --group %s' % each_input,
|
f'command list --group {each_input}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
group_names = [each.get('Command Group') for each in cmd_output]
|
group_names = [each.get('Command Group') for each in cmd_output]
|
||||||
|
@ -165,8 +165,7 @@ class QuotaTests(base.TestCase):
|
|||||||
# That will ensure we have at least two networks in the system.
|
# That will ensure we have at least two networks in the system.
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network create --project %s %s'
|
f'network create --project {self.PROJECT_NAME} {uuid.uuid4().hex}'
|
||||||
% (self.PROJECT_NAME, uuid.uuid4().hex)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
@ -211,8 +210,7 @@ class QuotaTests(base.TestCase):
|
|||||||
# That will ensure we have at least two networks in the system.
|
# That will ensure we have at least two networks in the system.
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network create --project %s %s'
|
f'network create --project {self.PROJECT_NAME} {uuid.uuid4().hex}'
|
||||||
% (self.PROJECT_NAME, uuid.uuid4().hex)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.openstack('quota set --networks 1 --force ' + self.PROJECT_NAME)
|
self.openstack('quota set --networks 1 --force ' + self.PROJECT_NAME)
|
||||||
|
@ -132,9 +132,7 @@ class ComputeTestCase(base.TestCase):
|
|||||||
print(f'Server {name} now has status {status}')
|
print(f'Server {name} now has status {status}')
|
||||||
break
|
break
|
||||||
print(
|
print(
|
||||||
'Server {}: Waiting for {}, current status: {}'.format(
|
f'Server {name}: Waiting for {expected_status}, current status: {status}'
|
||||||
name, expected_status, status
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
self.assertNotIn(status, failures)
|
self.assertNotIn(status, failures)
|
||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
|
@ -37,8 +37,8 @@ class HypervisorTests(base.TestCase):
|
|||||||
for i in ids1:
|
for i in ids1:
|
||||||
cmd_output = json.loads(
|
cmd_output = json.loads(
|
||||||
self.openstack(
|
self.openstack(
|
||||||
"hypervisor show %s -f json "
|
f"hypervisor show {i} -f json "
|
||||||
" --os-compute-api-version 2.1" % (i)
|
" --os-compute-api-version 2.1"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(cmd_output)
|
self.assertIsNotNone(cmd_output)
|
||||||
@ -47,6 +47,6 @@ class HypervisorTests(base.TestCase):
|
|||||||
# Show test - latest microversion
|
# Show test - latest microversion
|
||||||
for i in ids2:
|
for i in ids2:
|
||||||
cmd_output = json.loads(
|
cmd_output = json.loads(
|
||||||
self.openstack("hypervisor show %s -f json" % (i))
|
self.openstack(f"hypervisor show {i} -f json")
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(cmd_output)
|
self.assertIsNotNone(cmd_output)
|
||||||
|
@ -96,7 +96,7 @@ class KeypairTests(KeypairBase):
|
|||||||
f.flush()
|
f.flush()
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'keypair create --public-key %s tmpkey' % f.name,
|
f'keypair create --public-key {f.name} tmpkey',
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
@ -113,7 +113,7 @@ class KeypairTests(KeypairBase):
|
|||||||
"""
|
"""
|
||||||
with tempfile.NamedTemporaryFile(mode='w+') as f:
|
with tempfile.NamedTemporaryFile(mode='w+') as f:
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'keypair create --private-key %s tmpkey' % f.name,
|
f'keypair create --private-key {f.name} tmpkey',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'keypair delete tmpkey')
|
self.addCleanup(self.openstack, 'keypair delete tmpkey')
|
||||||
|
@ -111,7 +111,7 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
)
|
)
|
||||||
except exceptions.CommandFailed as e:
|
except exceptions.CommandFailed as e:
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'marker [%s] not found' % (name2), e.stderr.decode('utf-8')
|
f'marker [{name2}] not found', e.stderr.decode('utf-8')
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_server_list_with_changes_before(self):
|
def test_server_list_with_changes_before(self):
|
||||||
|
@ -67,13 +67,9 @@ class IdentityTests(base.TestCase):
|
|||||||
cls.openstack(
|
cls.openstack(
|
||||||
'--os-identity-api-version 2 '
|
'--os-identity-api-version 2 '
|
||||||
'project create '
|
'project create '
|
||||||
'--description %(description)s '
|
f'--description {cls.project_description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(name)s'
|
f'{cls.project_name}'
|
||||||
% {
|
|
||||||
'description': cls.project_description,
|
|
||||||
'name': cls.project_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
except tempest_exceptions.CommandFailed:
|
except tempest_exceptions.CommandFailed:
|
||||||
# Good chance this is due to Identity v2 admin not being enabled
|
# Good chance this is due to Identity v2 admin not being enabled
|
||||||
@ -87,7 +83,7 @@ class IdentityTests(base.TestCase):
|
|||||||
try:
|
try:
|
||||||
cls.openstack(
|
cls.openstack(
|
||||||
'--os-identity-api-version 2 '
|
'--os-identity-api-version 2 '
|
||||||
'project delete %s' % cls.project_name
|
f'project delete {cls.project_name}'
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
super().tearDownClass()
|
super().tearDownClass()
|
||||||
@ -111,14 +107,13 @@ class IdentityTests(base.TestCase):
|
|||||||
project_description = data_utils.rand_name('description')
|
project_description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project create '
|
'project create '
|
||||||
'--description %(description)s '
|
f'--description {project_description} '
|
||||||
'--enable %(name)s'
|
f'--enable {project_name}'
|
||||||
% {'description': project_description, 'name': project_name}
|
|
||||||
)
|
)
|
||||||
project = self.parse_show_as_object(raw_output)
|
project = self.parse_show_as_object(raw_output)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'project delete %s' % project['id']
|
self.openstack, 'project delete {}'.format(project['id'])
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.PROJECT_FIELDS)
|
self.assert_show_fields(items, self.PROJECT_FIELDS)
|
||||||
@ -130,22 +125,18 @@ class IdentityTests(base.TestCase):
|
|||||||
email = data_utils.rand_name() + '@example.com'
|
email = data_utils.rand_name() + '@example.com'
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user create '
|
'user create '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--password %(password)s '
|
f'--password {password} '
|
||||||
'--email %(email)s '
|
f'--email {email} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(name)s'
|
f'{username}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'email': email,
|
|
||||||
'password': password,
|
|
||||||
'name': username,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'user delete %s' % self.parse_show_as_object(raw_output)['id'],
|
'user delete {}'.format(
|
||||||
|
self.parse_show_as_object(raw_output)['id']
|
||||||
|
),
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.USER_FIELDS)
|
self.assert_show_fields(items, self.USER_FIELDS)
|
||||||
@ -153,10 +144,12 @@ class IdentityTests(base.TestCase):
|
|||||||
|
|
||||||
def _create_dummy_role(self, add_clean_up=True):
|
def _create_dummy_role(self, add_clean_up=True):
|
||||||
role_name = data_utils.rand_name('TestRole')
|
role_name = data_utils.rand_name('TestRole')
|
||||||
raw_output = self.openstack('role create %s' % role_name)
|
raw_output = self.openstack(f'role create {role_name}')
|
||||||
role = self.parse_show_as_object(raw_output)
|
role = self.parse_show_as_object(raw_output)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(self.openstack, 'role delete %s' % role['id'])
|
self.addCleanup(
|
||||||
|
self.openstack, 'role delete {}'.format(role['id'])
|
||||||
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ROLE_FIELDS)
|
self.assert_show_fields(items, self.ROLE_FIELDS)
|
||||||
self.assertEqual(role_name, role['name'])
|
self.assertEqual(role_name, role['name'])
|
||||||
@ -168,7 +161,7 @@ class IdentityTests(base.TestCase):
|
|||||||
access_key = ec2_credentials['access']
|
access_key = ec2_credentials['access']
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'ec2 credentials delete %s' % access_key
|
self.openstack, f'ec2 credentials delete {access_key}'
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS)
|
self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS)
|
||||||
@ -178,7 +171,9 @@ class IdentityTests(base.TestCase):
|
|||||||
raw_output = self.openstack('token issue')
|
raw_output = self.openstack('token issue')
|
||||||
token = self.parse_show_as_object(raw_output)
|
token = self.parse_show_as_object(raw_output)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(self.openstack, 'token revoke %s' % token['id'])
|
self.addCleanup(
|
||||||
|
self.openstack, 'token revoke {}'.format(token['id'])
|
||||||
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.TOKEN_FIELDS)
|
self.assert_show_fields(items, self.TOKEN_FIELDS)
|
||||||
return token['id']
|
return token['id']
|
||||||
@ -189,19 +184,14 @@ class IdentityTests(base.TestCase):
|
|||||||
type_name = data_utils.rand_name('TestType')
|
type_name = data_utils.rand_name('TestType')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'service create '
|
'service create '
|
||||||
'--name %(name)s '
|
f'--name {service_name} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'%(type)s'
|
f'{type_name}'
|
||||||
% {
|
|
||||||
'name': service_name,
|
|
||||||
'description': description,
|
|
||||||
'type': type_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
service = self.parse_show_as_object(raw_output)
|
service = self.parse_show_as_object(raw_output)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'service delete %s' % service['id']
|
self.openstack, 'service delete {}'.format(service['id'])
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
||||||
@ -215,23 +205,16 @@ class IdentityTests(base.TestCase):
|
|||||||
internal_url = data_utils.rand_url()
|
internal_url = data_utils.rand_url()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'endpoint create '
|
'endpoint create '
|
||||||
'--publicurl %(publicurl)s '
|
f'--publicurl {public_url} '
|
||||||
'--adminurl %(adminurl)s '
|
f'--adminurl {admin_url} '
|
||||||
'--internalurl %(internalurl)s '
|
f'--internalurl {internal_url} '
|
||||||
'--region %(region)s '
|
f'--region {region_id} '
|
||||||
'%(service)s'
|
f'{service_name}'
|
||||||
% {
|
|
||||||
'publicurl': public_url,
|
|
||||||
'adminurl': admin_url,
|
|
||||||
'internalurl': internal_url,
|
|
||||||
'region': region_id,
|
|
||||||
'service': service_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
endpoint = self.parse_show_as_object(raw_output)
|
endpoint = self.parse_show_as_object(raw_output)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'endpoint delete %s' % endpoint['id']
|
self.openstack, 'endpoint delete {}'.format(endpoint['id'])
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
||||||
|
@ -35,7 +35,7 @@ class CatalogTests(common.IdentityTests):
|
|||||||
| type | identity |
|
| type | identity |
|
||||||
+-----------+-------------------------------------------+
|
+-----------+-------------------------------------------+
|
||||||
"""
|
"""
|
||||||
raw_output = self.openstack('catalog show %s' % 'identity')
|
raw_output = self.openstack('catalog show {}'.format('identity'))
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
# items may have multiple endpoint urls with empty key
|
# items may have multiple endpoint urls with empty key
|
||||||
self.assert_show_fields(items, ['endpoints', 'name', 'type', ''])
|
self.assert_show_fields(items, ['endpoints', 'name', 'type', ''])
|
||||||
|
@ -20,7 +20,7 @@ class EC2CredentialsTests(common.IdentityTests):
|
|||||||
def test_ec2_credentials_delete(self):
|
def test_ec2_credentials_delete(self):
|
||||||
access_key = self._create_dummy_ec2_credentials(add_clean_up=False)
|
access_key = self._create_dummy_ec2_credentials(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'ec2 credentials delete %s' % access_key,
|
f'ec2 credentials delete {access_key}',
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ class EC2CredentialsTests(common.IdentityTests):
|
|||||||
def test_ec2_credentials_show(self):
|
def test_ec2_credentials_show(self):
|
||||||
access_key = self._create_dummy_ec2_credentials()
|
access_key = self._create_dummy_ec2_credentials()
|
||||||
show_output = self.openstack(
|
show_output = self.openstack(
|
||||||
'ec2 credentials show %s' % access_key,
|
f'ec2 credentials show {access_key}',
|
||||||
)
|
)
|
||||||
items = self.parse_show(show_output)
|
items = self.parse_show(show_output)
|
||||||
self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS)
|
self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS)
|
||||||
|
@ -19,7 +19,7 @@ class EndpointTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_endpoint_delete(self):
|
def test_endpoint_delete(self):
|
||||||
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
||||||
raw_output = self.openstack('endpoint delete %s' % endpoint_id)
|
raw_output = self.openstack(f'endpoint delete {endpoint_id}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_endpoint_multi_delete(self):
|
def test_endpoint_multi_delete(self):
|
||||||
@ -39,6 +39,6 @@ class EndpointTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_endpoint_show(self):
|
def test_endpoint_show(self):
|
||||||
endpoint_id = self._create_dummy_endpoint()
|
endpoint_id = self._create_dummy_endpoint()
|
||||||
raw_output = self.openstack('endpoint show %s' % endpoint_id)
|
raw_output = self.openstack(f'endpoint show {endpoint_id}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
||||||
|
@ -21,13 +21,13 @@ class ProjectTests(common.IdentityTests):
|
|||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project create '
|
'project create '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'--property k1=v1 '
|
'--property k1=v1 '
|
||||||
'--property k2=v2 '
|
'--property k2=v2 '
|
||||||
'%(name)s' % {'description': description, 'name': project_name}
|
f'{project_name}'
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'project delete %s' % project_name)
|
self.addCleanup(self.openstack, f'project delete {project_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
show_fields = list(self.PROJECT_FIELDS)
|
show_fields = list(self.PROJECT_FIELDS)
|
||||||
show_fields.extend(['k1', 'k2'])
|
show_fields.extend(['k1', 'k2'])
|
||||||
@ -38,7 +38,7 @@ class ProjectTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_project_delete(self):
|
def test_project_delete(self):
|
||||||
project_name = self._create_dummy_project(add_clean_up=False)
|
project_name = self._create_dummy_project(add_clean_up=False)
|
||||||
raw_output = self.openstack('project delete %s' % project_name)
|
raw_output = self.openstack(f'project delete {project_name}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_project_list(self):
|
def test_project_list(self):
|
||||||
@ -51,14 +51,14 @@ class ProjectTests(common.IdentityTests):
|
|||||||
new_project_name = data_utils.rand_name('NewTestProject')
|
new_project_name = data_utils.rand_name('NewTestProject')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project set '
|
'project set '
|
||||||
'--name %(new_name)s '
|
f'--name {new_project_name} '
|
||||||
'--disable '
|
'--disable '
|
||||||
'--property k0=v0 '
|
'--property k0=v0 '
|
||||||
'%(name)s' % {'new_name': new_project_name, 'name': project_name}
|
f'{project_name}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
# check project details
|
# check project details
|
||||||
raw_output = self.openstack('project show %s' % new_project_name)
|
raw_output = self.openstack(f'project show {new_project_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
fields = list(self.PROJECT_FIELDS)
|
fields = list(self.PROJECT_FIELDS)
|
||||||
fields.extend(['properties'])
|
fields.extend(['properties'])
|
||||||
@ -70,7 +70,7 @@ class ProjectTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_project_show(self):
|
def test_project_show(self):
|
||||||
project_name = self._create_dummy_project()
|
project_name = self._create_dummy_project()
|
||||||
raw_output = self.openstack('project show %s' % project_name)
|
raw_output = self.openstack(f'project show {project_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
fields = list(self.PROJECT_FIELDS)
|
fields = list(self.PROJECT_FIELDS)
|
||||||
fields.extend(['properties'])
|
fields.extend(['properties'])
|
||||||
|
@ -19,7 +19,7 @@ class RoleTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_role_delete(self):
|
def test_role_delete(self):
|
||||||
role_name = self._create_dummy_role(add_clean_up=False)
|
role_name = self._create_dummy_role(add_clean_up=False)
|
||||||
raw_output = self.openstack('role delete %s' % role_name)
|
raw_output = self.openstack(f'role delete {role_name}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_role_list(self):
|
def test_role_list(self):
|
||||||
@ -30,7 +30,7 @@ class RoleTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_role_show(self):
|
def test_role_show(self):
|
||||||
role_name = self._create_dummy_role()
|
role_name = self._create_dummy_role()
|
||||||
raw_output = self.openstack('role show %s' % role_name)
|
raw_output = self.openstack(f'role show {role_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ROLE_FIELDS)
|
self.assert_show_fields(items, self.ROLE_FIELDS)
|
||||||
|
|
||||||
@ -39,26 +39,16 @@ class RoleTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'role remove '
|
'role remove '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}',
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ROLE_FIELDS)
|
self.assert_show_fields(items, self.ROLE_FIELDS)
|
||||||
@ -68,25 +58,15 @@ class RoleTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
add_raw_output = self.openstack(
|
add_raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
del_raw_output = self.openstack(
|
del_raw_output = self.openstack(
|
||||||
'role remove '
|
'role remove '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
items = self.parse_show(add_raw_output)
|
items = self.parse_show(add_raw_output)
|
||||||
self.assert_show_fields(items, self.ROLE_FIELDS)
|
self.assert_show_fields(items, self.ROLE_FIELDS)
|
||||||
|
@ -19,7 +19,7 @@ class ServiceTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_service_delete(self):
|
def test_service_delete(self):
|
||||||
service_name = self._create_dummy_service(add_clean_up=False)
|
service_name = self._create_dummy_service(add_clean_up=False)
|
||||||
raw_output = self.openstack('service delete %s' % service_name)
|
raw_output = self.openstack(f'service delete {service_name}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_service_multi_delete(self):
|
def test_service_multi_delete(self):
|
||||||
@ -38,6 +38,6 @@ class ServiceTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_service_show(self):
|
def test_service_show(self):
|
||||||
service_name = self._create_dummy_service()
|
service_name = self._create_dummy_service()
|
||||||
raw_output = self.openstack('service show %s' % service_name)
|
raw_output = self.openstack(f'service show {service_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
||||||
|
@ -19,5 +19,5 @@ class TokenTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_token_revoke(self):
|
def test_token_revoke(self):
|
||||||
token_id = self._create_dummy_token(add_clean_up=False)
|
token_id = self._create_dummy_token(add_clean_up=False)
|
||||||
raw_output = self.openstack('token revoke %s' % token_id)
|
raw_output = self.openstack(f'token revoke {token_id}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
@ -22,7 +22,7 @@ class UserTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_user_delete(self):
|
def test_user_delete(self):
|
||||||
username = self._create_dummy_user(add_clean_up=False)
|
username = self._create_dummy_user(add_clean_up=False)
|
||||||
raw_output = self.openstack('user delete %s' % username)
|
raw_output = self.openstack(f'user delete {username}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_user_list(self):
|
def test_user_list(self):
|
||||||
@ -32,26 +32,24 @@ class UserTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_user_set(self):
|
def test_user_set(self):
|
||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack('user show %s' % username)
|
raw_output = self.openstack(f'user show {username}')
|
||||||
user = self.parse_show_as_object(raw_output)
|
user = self.parse_show_as_object(raw_output)
|
||||||
new_username = data_utils.rand_name('NewTestUser')
|
new_username = data_utils.rand_name('NewTestUser')
|
||||||
new_email = data_utils.rand_name() + '@example.com'
|
new_email = data_utils.rand_name() + '@example.com'
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user set '
|
'user set ' '--email {email} ' '--name {new_name} ' '{id}'.format(
|
||||||
'--email %(email)s '
|
email=new_email, new_name=new_username, id=user['id']
|
||||||
'--name %(new_name)s '
|
)
|
||||||
'%(id)s'
|
|
||||||
% {'email': new_email, 'new_name': new_username, 'id': user['id']}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack('user show %s' % new_username)
|
raw_output = self.openstack(f'user show {new_username}')
|
||||||
new_user = self.parse_show_as_object(raw_output)
|
new_user = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(user['id'], new_user['id'])
|
self.assertEqual(user['id'], new_user['id'])
|
||||||
self.assertEqual(new_email, new_user['email'])
|
self.assertEqual(new_email, new_user['email'])
|
||||||
|
|
||||||
def test_user_show(self):
|
def test_user_show(self):
|
||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack('user show %s' % username)
|
raw_output = self.openstack(f'user show {username}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.USER_FIELDS)
|
self.assert_show_fields(items, self.USER_FIELDS)
|
||||||
|
|
||||||
|
@ -156,10 +156,9 @@ class IdentityTests(base.TestCase):
|
|||||||
cls.openstack(
|
cls.openstack(
|
||||||
'--os-identity-api-version 3 '
|
'--os-identity-api-version 3 '
|
||||||
'domain create '
|
'domain create '
|
||||||
'--description %(description)s '
|
f'--description {cls.domain_description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(name)s'
|
f'{cls.domain_name}'
|
||||||
% {'description': cls.domain_description, 'name': cls.domain_name}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# create dummy project
|
# create dummy project
|
||||||
@ -168,15 +167,10 @@ class IdentityTests(base.TestCase):
|
|||||||
cls.openstack(
|
cls.openstack(
|
||||||
'--os-identity-api-version 3 '
|
'--os-identity-api-version 3 '
|
||||||
'project create '
|
'project create '
|
||||||
'--domain %(domain)s '
|
f'--domain {cls.domain_name} '
|
||||||
'--description %(description)s '
|
f'--description {cls.project_description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(name)s'
|
f'{cls.project_name}'
|
||||||
% {
|
|
||||||
'domain': cls.domain_name,
|
|
||||||
'description': cls.project_description,
|
|
||||||
'name': cls.project_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -185,16 +179,16 @@ class IdentityTests(base.TestCase):
|
|||||||
# delete dummy project
|
# delete dummy project
|
||||||
cls.openstack(
|
cls.openstack(
|
||||||
'--os-identity-api-version 3 '
|
'--os-identity-api-version 3 '
|
||||||
'project delete %s' % cls.project_name
|
f'project delete {cls.project_name}'
|
||||||
)
|
)
|
||||||
# disable and delete dummy domain
|
# disable and delete dummy domain
|
||||||
cls.openstack(
|
cls.openstack(
|
||||||
'--os-identity-api-version 3 '
|
'--os-identity-api-version 3 '
|
||||||
'domain set --disable %s' % cls.domain_name
|
f'domain set --disable {cls.domain_name}'
|
||||||
)
|
)
|
||||||
cls.openstack(
|
cls.openstack(
|
||||||
'--os-identity-api-version 3 '
|
'--os-identity-api-version 3 '
|
||||||
'domain delete %s' % cls.domain_name
|
f'domain delete {cls.domain_name}'
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
super().tearDownClass()
|
super().tearDownClass()
|
||||||
@ -220,28 +214,21 @@ class IdentityTests(base.TestCase):
|
|||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user create '
|
'user create '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--project-domain %(project_domain)s '
|
f'--project-domain {self.domain_name} '
|
||||||
'--password %(password)s '
|
f'--password {password} '
|
||||||
'--email %(email)s '
|
f'--email {email} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(name)s'
|
f'{username}'
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'project': self.project_name,
|
|
||||||
'project_domain': self.domain_name,
|
|
||||||
'email': email,
|
|
||||||
'password': password,
|
|
||||||
'description': description,
|
|
||||||
'name': username,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'user delete %s' % self.parse_show_as_object(raw_output)['id'],
|
'user delete {}'.format(
|
||||||
|
self.parse_show_as_object(raw_output)['id']
|
||||||
|
),
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.USER_FIELDS)
|
self.assert_show_fields(items, self.USER_FIELDS)
|
||||||
@ -249,10 +236,12 @@ class IdentityTests(base.TestCase):
|
|||||||
|
|
||||||
def _create_dummy_role(self, add_clean_up=True):
|
def _create_dummy_role(self, add_clean_up=True):
|
||||||
role_name = data_utils.rand_name('TestRole')
|
role_name = data_utils.rand_name('TestRole')
|
||||||
raw_output = self.openstack('role create %s' % role_name)
|
raw_output = self.openstack(f'role create {role_name}')
|
||||||
role = self.parse_show_as_object(raw_output)
|
role = self.parse_show_as_object(raw_output)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(self.openstack, 'role delete %s' % role['id'])
|
self.addCleanup(
|
||||||
|
self.openstack, 'role delete {}'.format(role['id'])
|
||||||
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ROLE_FIELDS)
|
self.assert_show_fields(items, self.ROLE_FIELDS)
|
||||||
self.assertEqual(role_name, role['name'])
|
self.assertEqual(role_name, role['name'])
|
||||||
@ -263,8 +252,8 @@ class IdentityTests(base.TestCase):
|
|||||||
implied_role_name = self._create_dummy_role(add_clean_up)
|
implied_role_name = self._create_dummy_role(add_clean_up)
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'implied role create '
|
'implied role create '
|
||||||
'--implied-role %(implied_role)s '
|
f'--implied-role {implied_role_name} '
|
||||||
'%(role)s' % {'implied_role': implied_role_name, 'role': role_name}
|
f'{role_name}'
|
||||||
)
|
)
|
||||||
|
|
||||||
return implied_role_name, role_name
|
return implied_role_name, role_name
|
||||||
@ -274,21 +263,16 @@ class IdentityTests(base.TestCase):
|
|||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group create '
|
'group create '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'%(name)s'
|
f'{group_name}'
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'description': description,
|
|
||||||
'name': group_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'group delete '
|
'group delete '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': group_name},
|
f'{group_name}',
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.GROUP_FIELDS)
|
self.assert_show_fields(items, self.GROUP_FIELDS)
|
||||||
@ -299,14 +283,13 @@ class IdentityTests(base.TestCase):
|
|||||||
domain_description = data_utils.rand_name('description')
|
domain_description = data_utils.rand_name('description')
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'domain create '
|
'domain create '
|
||||||
'--description %(description)s '
|
f'--description {domain_description} '
|
||||||
'--enable %(name)s'
|
f'--enable {domain_name}'
|
||||||
% {'description': domain_description, 'name': domain_name}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(self.openstack, 'domain delete %s' % domain_name)
|
self.addCleanup(self.openstack, f'domain delete {domain_name}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'domain set --disable %s' % domain_name
|
self.openstack, f'domain set --disable {domain_name}'
|
||||||
)
|
)
|
||||||
return domain_name
|
return domain_name
|
||||||
|
|
||||||
@ -315,22 +298,16 @@ class IdentityTests(base.TestCase):
|
|||||||
project_description = data_utils.rand_name('description')
|
project_description = data_utils.rand_name('description')
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'project create '
|
'project create '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--description %(description)s '
|
f'--description {project_description} '
|
||||||
'--enable %(name)s'
|
f'--enable {project_name}'
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'description': project_description,
|
|
||||||
'name': project_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'project delete '
|
'project delete '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'%(name)s'
|
f'{project_name}',
|
||||||
% {'domain': self.domain_name, 'name': project_name},
|
|
||||||
)
|
)
|
||||||
return project_name
|
return project_name
|
||||||
|
|
||||||
@ -339,20 +316,15 @@ class IdentityTests(base.TestCase):
|
|||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
parent_region_arg = ''
|
parent_region_arg = ''
|
||||||
if parent_region is not None:
|
if parent_region is not None:
|
||||||
parent_region_arg = '--parent-region %s' % parent_region
|
parent_region_arg = f'--parent-region {parent_region}'
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'region create '
|
'region create '
|
||||||
'%(parent_region_arg)s '
|
f'{parent_region_arg} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'%(id)s'
|
f'{region_id}'
|
||||||
% {
|
|
||||||
'parent_region_arg': parent_region_arg,
|
|
||||||
'description': description,
|
|
||||||
'id': region_id,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(self.openstack, 'region delete %s' % region_id)
|
self.addCleanup(self.openstack, f'region delete {region_id}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.REGION_FIELDS)
|
self.assert_show_fields(items, self.REGION_FIELDS)
|
||||||
return region_id
|
return region_id
|
||||||
@ -363,20 +335,15 @@ class IdentityTests(base.TestCase):
|
|||||||
type_name = data_utils.rand_name('TestType')
|
type_name = data_utils.rand_name('TestType')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'service create '
|
'service create '
|
||||||
'--name %(name)s '
|
f'--name {service_name} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(type)s'
|
f'{type_name}'
|
||||||
% {
|
|
||||||
'name': service_name,
|
|
||||||
'description': description,
|
|
||||||
'type': type_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
service = self.parse_show_as_object(raw_output)
|
service = self.parse_show_as_object(raw_output)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'service delete %s' % service['id']
|
self.openstack, 'service delete {}'.format(service['id'])
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
||||||
@ -388,22 +355,16 @@ class IdentityTests(base.TestCase):
|
|||||||
endpoint_url = data_utils.rand_url()
|
endpoint_url = data_utils.rand_url()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'endpoint create '
|
'endpoint create '
|
||||||
'--region %(region)s '
|
f'--region {region_id} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(service)s '
|
f'{service_name} '
|
||||||
'%(interface)s '
|
f'{interface} '
|
||||||
'%(url)s'
|
f'{endpoint_url}'
|
||||||
% {
|
|
||||||
'region': region_id,
|
|
||||||
'service': service_name,
|
|
||||||
'interface': interface,
|
|
||||||
'url': endpoint_url,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
endpoint = self.parse_show_as_object(raw_output)
|
endpoint = self.parse_show_as_object(raw_output)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'endpoint delete %s' % endpoint['id']
|
self.openstack, 'endpoint delete {}'.format(endpoint['id'])
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
||||||
@ -414,15 +375,14 @@ class IdentityTests(base.TestCase):
|
|||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'identity provider create '
|
'identity provider create '
|
||||||
' %(name)s '
|
f' {identity_provider} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
% {'name': identity_provider, 'description': description}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'identity provider delete %s' % identity_provider,
|
f'identity provider delete {identity_provider}',
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.IDENTITY_PROVIDER_FIELDS)
|
self.assert_show_fields(items, self.IDENTITY_PROVIDER_FIELDS)
|
||||||
@ -433,16 +393,15 @@ class IdentityTests(base.TestCase):
|
|||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'service provider create '
|
'service provider create '
|
||||||
' %(name)s '
|
f' {service_provider} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'--auth-url https://sp.example.com:35357 '
|
'--auth-url https://sp.example.com:35357 '
|
||||||
'--service-provider-url https://sp.example.com:5000 '
|
'--service-provider-url https://sp.example.com:5000 '
|
||||||
'--enable '
|
'--enable '
|
||||||
% {'name': service_provider, 'description': description}
|
|
||||||
)
|
)
|
||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'service provider delete %s' % service_provider
|
self.openstack, f'service provider delete {service_provider}'
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.SERVICE_PROVIDER_FIELDS)
|
self.assert_show_fields(items, self.SERVICE_PROVIDER_FIELDS)
|
||||||
@ -458,9 +417,9 @@ class IdentityTests(base.TestCase):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit create'
|
'registered limit create'
|
||||||
' --service %(service_name)s'
|
' --service {service_name}'
|
||||||
' --default-limit %(default_limit)s'
|
' --default-limit {default_limit}'
|
||||||
' %(resource_name)s' % params,
|
' {resource_name}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -469,7 +428,7 @@ class IdentityTests(base.TestCase):
|
|||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'registered limit delete %s' % registered_limit_id,
|
f'registered limit delete {registered_limit_id}',
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -486,7 +445,7 @@ class IdentityTests(base.TestCase):
|
|||||||
registered_limit_id = self._create_dummy_registered_limit()
|
registered_limit_id = self._create_dummy_registered_limit()
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit show %s' % registered_limit_id,
|
f'registered limit show {registered_limit_id}',
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -495,7 +454,7 @@ class IdentityTests(base.TestCase):
|
|||||||
resource_limit = 15
|
resource_limit = 15
|
||||||
|
|
||||||
project_name = self._create_dummy_project()
|
project_name = self._create_dummy_project()
|
||||||
raw_output = self.openstack('project show %s' % project_name)
|
raw_output = self.openstack(f'project show {project_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
project_id = self._extract_value_from_items('id', items)
|
project_id = self._extract_value_from_items('id', items)
|
||||||
|
|
||||||
@ -508,10 +467,10 @@ class IdentityTests(base.TestCase):
|
|||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit create'
|
'limit create'
|
||||||
' --project %(project_id)s'
|
' --project {project_id}'
|
||||||
' --service %(service_id)s'
|
' --service {service_id}'
|
||||||
' --resource-limit %(resource_limit)s'
|
' --resource-limit {resource_limit}'
|
||||||
' %(resource_name)s' % params,
|
' {resource_name}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -520,7 +479,7 @@ class IdentityTests(base.TestCase):
|
|||||||
if add_clean_up:
|
if add_clean_up:
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'limit delete %s' % limit_id,
|
f'limit delete {limit_id}',
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -85,34 +85,20 @@ class ApplicationCredentialTests(common.IdentityTests):
|
|||||||
for role in role1, role2:
|
for role in role1, role2:
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'role add'
|
'role add'
|
||||||
' --user %(user)s'
|
f' --user {user}'
|
||||||
' --user-domain %(user_domain)s'
|
f' --user-domain {user_domain}'
|
||||||
' --project %(project)s'
|
f' --project {project}'
|
||||||
' --project-domain %(project_domain)s'
|
f' --project-domain {project_domain}'
|
||||||
' %(role)s'
|
f' {role}'
|
||||||
% {
|
|
||||||
'user': user,
|
|
||||||
'user_domain': user_domain,
|
|
||||||
'project': project,
|
|
||||||
'project_domain': project_domain,
|
|
||||||
'role': role,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'role remove'
|
'role remove'
|
||||||
' --user %(user)s'
|
f' --user {user}'
|
||||||
' --user-domain %(user_domain)s'
|
f' --user-domain {user_domain}'
|
||||||
' --project %(project)s'
|
f' --project {project}'
|
||||||
' --project-domain %(project_domain)s'
|
f' --project-domain {project_domain}'
|
||||||
' %(role)s'
|
f' {role}',
|
||||||
% {
|
|
||||||
'user': user,
|
|
||||||
'user_domain': user_domain,
|
|
||||||
'project': project,
|
|
||||||
'project_domain': project_domain,
|
|
||||||
'role': role,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
return role1, role2
|
return role1, role2
|
||||||
|
|
||||||
@ -125,21 +111,13 @@ class ApplicationCredentialTests(common.IdentityTests):
|
|||||||
).strftime('%Y-%m-%dT%H:%M:%S%z')
|
).strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||||
role1, role2 = self._create_role_assignments()
|
role1, role2 = self._create_role_assignments()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'application credential create %(name)s'
|
f'application credential create {name}'
|
||||||
' --secret %(secret)s'
|
f' --secret {secret}'
|
||||||
' --description %(description)s'
|
f' --description {description}'
|
||||||
' --expiration %(tomorrow)s'
|
f' --expiration {tomorrow}'
|
||||||
' --role %(role1)s'
|
f' --role {role1}'
|
||||||
' --role %(role2)s'
|
f' --role {role2}'
|
||||||
' --unrestricted'
|
' --unrestricted'
|
||||||
% {
|
|
||||||
'name': name,
|
|
||||||
'secret': secret,
|
|
||||||
'description': description,
|
|
||||||
'tomorrow': tomorrow,
|
|
||||||
'role1': role1,
|
|
||||||
'role2': role2,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
@ -151,9 +129,7 @@ class ApplicationCredentialTests(common.IdentityTests):
|
|||||||
def test_application_credential_delete(self):
|
def test_application_credential_delete(self):
|
||||||
name = data_utils.rand_name('name')
|
name = data_utils.rand_name('name')
|
||||||
self.openstack(f'application credential create {name}')
|
self.openstack(f'application credential create {name}')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack('application credential delete ' f'{name}')
|
||||||
'application credential delete ' '%(name)s' % {'name': name}
|
|
||||||
)
|
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_application_credential_list(self):
|
def test_application_credential_list(self):
|
||||||
@ -170,8 +146,6 @@ class ApplicationCredentialTests(common.IdentityTests):
|
|||||||
self.openstack,
|
self.openstack,
|
||||||
f'application credential delete {name}',
|
f'application credential delete {name}',
|
||||||
)
|
)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack('application credential show ' f'{name}')
|
||||||
'application credential show ' '%(name)s' % {'name': name}
|
|
||||||
)
|
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.APPLICATION_CREDENTIAL_FIELDS)
|
self.assert_show_fields(items, self.APPLICATION_CREDENTIAL_FIELDS)
|
||||||
|
@ -38,7 +38,7 @@ class CatalogTests(common.IdentityTests):
|
|||||||
| type | identity |
|
| type | identity |
|
||||||
+-----------+----------------------------------------+
|
+-----------+----------------------------------------+
|
||||||
"""
|
"""
|
||||||
raw_output = self.openstack('catalog show %s' % 'identity')
|
raw_output = self.openstack('catalog show {}'.format('identity'))
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
# items may have multiple endpoint urls with empty key
|
# items may have multiple endpoint urls with empty key
|
||||||
self.assert_show_fields(items, ['endpoints', 'name', 'type', '', 'id'])
|
self.assert_show_fields(items, ['endpoints', 'name', 'type', '', 'id'])
|
||||||
|
@ -19,12 +19,10 @@ from openstackclient.tests.functional.identity.v3 import common
|
|||||||
class DomainTests(common.IdentityTests):
|
class DomainTests(common.IdentityTests):
|
||||||
def test_domain_create(self):
|
def test_domain_create(self):
|
||||||
domain_name = data_utils.rand_name('TestDomain')
|
domain_name = data_utils.rand_name('TestDomain')
|
||||||
raw_output = self.openstack('domain create %s' % domain_name)
|
raw_output = self.openstack(f'domain create {domain_name}')
|
||||||
# disable domain first before deleting it
|
# disable domain first before deleting it
|
||||||
self.addCleanup(self.openstack, 'domain delete %s' % domain_name)
|
self.addCleanup(self.openstack, f'domain delete {domain_name}')
|
||||||
self.addCleanup(
|
self.addCleanup(self.openstack, f'domain set --disable {domain_name}')
|
||||||
self.openstack, 'domain set --disable %s' % domain_name
|
|
||||||
)
|
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.DOMAIN_FIELDS)
|
self.assert_show_fields(items, self.DOMAIN_FIELDS)
|
||||||
|
|
||||||
@ -37,18 +35,18 @@ class DomainTests(common.IdentityTests):
|
|||||||
def test_domain_delete(self):
|
def test_domain_delete(self):
|
||||||
domain_name = self._create_dummy_domain(add_clean_up=False)
|
domain_name = self._create_dummy_domain(add_clean_up=False)
|
||||||
# cannot delete enabled domain, disable it first
|
# cannot delete enabled domain, disable it first
|
||||||
raw_output = self.openstack('domain set --disable %s' % domain_name)
|
raw_output = self.openstack(f'domain set --disable {domain_name}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack('domain delete %s' % domain_name)
|
raw_output = self.openstack(f'domain delete {domain_name}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_domain_multi_delete(self):
|
def test_domain_multi_delete(self):
|
||||||
domain_1 = self._create_dummy_domain(add_clean_up=False)
|
domain_1 = self._create_dummy_domain(add_clean_up=False)
|
||||||
domain_2 = self._create_dummy_domain(add_clean_up=False)
|
domain_2 = self._create_dummy_domain(add_clean_up=False)
|
||||||
# cannot delete enabled domain, disable it first
|
# cannot delete enabled domain, disable it first
|
||||||
raw_output = self.openstack('domain set --disable %s' % domain_1)
|
raw_output = self.openstack(f'domain set --disable {domain_1}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack('domain set --disable %s' % domain_2)
|
raw_output = self.openstack(f'domain set --disable {domain_2}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(f'domain delete {domain_1} {domain_2}')
|
raw_output = self.openstack(f'domain delete {domain_1} {domain_2}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
@ -59,11 +57,11 @@ class DomainTests(common.IdentityTests):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exceptions.CommandFailed,
|
exceptions.CommandFailed,
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'domain delete %s' % domain_name,
|
f'domain delete {domain_name}',
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_domain_show(self):
|
def test_domain_show(self):
|
||||||
domain_name = self._create_dummy_domain()
|
domain_name = self._create_dummy_domain()
|
||||||
raw_output = self.openstack('domain show %s' % domain_name)
|
raw_output = self.openstack(f'domain show {domain_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.DOMAIN_FIELDS)
|
self.assert_show_fields(items, self.DOMAIN_FIELDS)
|
||||||
|
@ -23,7 +23,7 @@ class EndpointTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_endpoint_delete(self):
|
def test_endpoint_delete(self):
|
||||||
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
||||||
raw_output = self.openstack('endpoint delete %s' % endpoint_id)
|
raw_output = self.openstack(f'endpoint delete {endpoint_id}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_endpoint_multi_delete(self):
|
def test_endpoint_multi_delete(self):
|
||||||
@ -45,20 +45,15 @@ class EndpointTests(common.IdentityTests):
|
|||||||
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
||||||
project_id = self._create_dummy_project(add_clean_up=False)
|
project_id = self._create_dummy_project(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'endpoint add project '
|
'endpoint add project ' f'{endpoint_id} ' f'{project_id}'
|
||||||
'%(endpoint_id)s '
|
|
||||||
'%(project_id)s'
|
|
||||||
% {'project_id': project_id, 'endpoint_id': endpoint_id}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(f'endpoint list --endpoint {endpoint_id}')
|
||||||
'endpoint list --endpoint %s' % endpoint_id
|
|
||||||
)
|
|
||||||
self.assertIn(project_id, raw_output)
|
self.assertIn(project_id, raw_output)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ENDPOINT_LIST_PROJECT_HEADERS)
|
self.assert_table_structure(items, self.ENDPOINT_LIST_PROJECT_HEADERS)
|
||||||
|
|
||||||
raw_output = self.openstack('endpoint list --project %s' % project_id)
|
raw_output = self.openstack(f'endpoint list --project {project_id}')
|
||||||
self.assertIn(endpoint_id, raw_output)
|
self.assertIn(endpoint_id, raw_output)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
|
self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
|
||||||
@ -68,18 +63,17 @@ class EndpointTests(common.IdentityTests):
|
|||||||
new_endpoint_url = data_utils.rand_url()
|
new_endpoint_url = data_utils.rand_url()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'endpoint set '
|
'endpoint set '
|
||||||
'--interface %(interface)s '
|
'--interface {interface} '
|
||||||
'--url %(url)s '
|
'--url {url} '
|
||||||
'--disable '
|
'--disable '
|
||||||
'%(endpoint_id)s'
|
'{endpoint_id}'.format(
|
||||||
% {
|
interface='admin',
|
||||||
'interface': 'admin',
|
url=new_endpoint_url,
|
||||||
'url': new_endpoint_url,
|
endpoint_id=endpoint_id,
|
||||||
'endpoint_id': endpoint_id,
|
)
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack('endpoint show %s' % endpoint_id)
|
raw_output = self.openstack(f'endpoint show {endpoint_id}')
|
||||||
endpoint = self.parse_show_as_object(raw_output)
|
endpoint = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual('admin', endpoint['interface'])
|
self.assertEqual('admin', endpoint['interface'])
|
||||||
self.assertEqual(new_endpoint_url, endpoint['url'])
|
self.assertEqual(new_endpoint_url, endpoint['url'])
|
||||||
@ -87,7 +81,7 @@ class EndpointTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_endpoint_show(self):
|
def test_endpoint_show(self):
|
||||||
endpoint_id = self._create_dummy_endpoint()
|
endpoint_id = self._create_dummy_endpoint()
|
||||||
raw_output = self.openstack('endpoint show %s' % endpoint_id)
|
raw_output = self.openstack(f'endpoint show {endpoint_id}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
||||||
|
|
||||||
@ -95,17 +89,11 @@ class EndpointTests(common.IdentityTests):
|
|||||||
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
||||||
project_id = self._create_dummy_project(add_clean_up=False)
|
project_id = self._create_dummy_project(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'endpoint add project '
|
'endpoint add project ' f'{endpoint_id} ' f'{project_id}'
|
||||||
'%(endpoint_id)s '
|
|
||||||
'%(project_id)s'
|
|
||||||
% {'project_id': project_id, 'endpoint_id': endpoint_id}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'endpoint remove project '
|
'endpoint remove project ' f'{endpoint_id} ' f'{project_id}'
|
||||||
'%(endpoint_id)s '
|
|
||||||
'%(project_id)s'
|
|
||||||
% {'project_id': project_id, 'endpoint_id': endpoint_id}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
@ -28,9 +28,7 @@ class GroupTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_group_list_with_domain(self):
|
def test_group_list_with_domain(self):
|
||||||
group_name = self._create_dummy_group()
|
group_name = self._create_dummy_group()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(f'group list --domain {self.domain_name}')
|
||||||
'group list --domain %s' % self.domain_name
|
|
||||||
)
|
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
|
self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
|
||||||
self.assertIn(group_name, raw_output)
|
self.assertIn(group_name, raw_output)
|
||||||
@ -38,18 +36,14 @@ class GroupTests(common.IdentityTests):
|
|||||||
def test_group_delete(self):
|
def test_group_delete(self):
|
||||||
group_name = self._create_dummy_group(add_clean_up=False)
|
group_name = self._create_dummy_group(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group delete '
|
'group delete ' f'--domain {self.domain_name} ' f'{group_name}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': group_name}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_group_show(self):
|
def test_group_show(self):
|
||||||
group_name = self._create_dummy_group()
|
group_name = self._create_dummy_group()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group show '
|
'group show ' f'--domain {self.domain_name} ' f'{group_name}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': group_name}
|
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.GROUP_FIELDS)
|
self.assert_show_fields(items, self.GROUP_FIELDS)
|
||||||
@ -59,34 +53,22 @@ class GroupTests(common.IdentityTests):
|
|||||||
new_group_name = data_utils.rand_name('NewTestGroup')
|
new_group_name = data_utils.rand_name('NewTestGroup')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group set '
|
'group set '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--name %(new_group)s '
|
f'--name {new_group_name} '
|
||||||
'%(group)s'
|
f'{group_name}'
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'new_group': new_group_name,
|
|
||||||
'group': group_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group show '
|
'group show ' f'--domain {self.domain_name} ' f'{new_group_name}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(group)s' % {'domain': self.domain_name, 'group': new_group_name}
|
|
||||||
)
|
)
|
||||||
group = self.parse_show_as_object(raw_output)
|
group = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(new_group_name, group['name'])
|
self.assertEqual(new_group_name, group['name'])
|
||||||
# reset group name to make sure it will be cleaned up
|
# reset group name to make sure it will be cleaned up
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group set '
|
'group set '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--name %(new_group)s '
|
f'--name {group_name} '
|
||||||
'%(group)s'
|
f'{new_group_name}'
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'new_group': group_name,
|
|
||||||
'group': new_group_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
@ -95,28 +77,16 @@ class GroupTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group add user '
|
'group add user '
|
||||||
'--group-domain %(group_domain)s '
|
f'--group-domain {self.domain_name} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(group)s %(user)s'
|
f'{group_name} {username}'
|
||||||
% {
|
|
||||||
'group_domain': self.domain_name,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'group': group_name,
|
|
||||||
'user': username,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'group remove user '
|
'group remove user '
|
||||||
'--group-domain %(group_domain)s '
|
f'--group-domain {self.domain_name} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(group)s %(user)s'
|
f'{group_name} {username}',
|
||||||
% {
|
|
||||||
'group_domain': self.domain_name,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'group': group_name,
|
|
||||||
'user': username,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
@ -125,45 +95,26 @@ class GroupTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group add user '
|
'group add user '
|
||||||
'--group-domain %(group_domain)s '
|
f'--group-domain {self.domain_name} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(group)s %(user)s'
|
f'{group_name} {username}'
|
||||||
% {
|
|
||||||
'group_domain': self.domain_name,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'group': group_name,
|
|
||||||
'user': username,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'group remove user '
|
'group remove user '
|
||||||
'--group-domain %(group_domain)s '
|
f'--group-domain {self.domain_name} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(group)s %(user)s'
|
f'{group_name} {username}',
|
||||||
% {
|
|
||||||
'group_domain': self.domain_name,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'group': group_name,
|
|
||||||
'user': username,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'group contains user '
|
'group contains user '
|
||||||
'--group-domain %(group_domain)s '
|
f'--group-domain {self.domain_name} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(group)s %(user)s'
|
f'{group_name} {username}'
|
||||||
% {
|
|
||||||
'group_domain': self.domain_name,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'group': group_name,
|
|
||||||
'user': username,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'%(user)s in group %(group)s\n'
|
f'{username} in group {group_name}\n',
|
||||||
% {'user': username, 'group': group_name},
|
|
||||||
raw_output,
|
raw_output,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -172,27 +123,15 @@ class GroupTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
add_raw_output = self.openstack(
|
add_raw_output = self.openstack(
|
||||||
'group add user '
|
'group add user '
|
||||||
'--group-domain %(group_domain)s '
|
f'--group-domain {self.domain_name} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(group)s %(user)s'
|
f'{group_name} {username}'
|
||||||
% {
|
|
||||||
'group_domain': self.domain_name,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'group': group_name,
|
|
||||||
'user': username,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
remove_raw_output = self.openstack(
|
remove_raw_output = self.openstack(
|
||||||
'group remove user '
|
'group remove user '
|
||||||
'--group-domain %(group_domain)s '
|
f'--group-domain {self.domain_name} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(group)s %(user)s'
|
f'{group_name} {username}'
|
||||||
% {
|
|
||||||
'group_domain': self.domain_name,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'group': group_name,
|
|
||||||
'user': username,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertOutput('', add_raw_output)
|
self.assertOutput('', add_raw_output)
|
||||||
self.assertOutput('', remove_raw_output)
|
self.assertOutput('', remove_raw_output)
|
||||||
|
@ -24,7 +24,7 @@ class IdentityProviderTests(common.IdentityTests):
|
|||||||
def test_idp_delete(self):
|
def test_idp_delete(self):
|
||||||
identity_provider = self._create_dummy_idp(add_clean_up=False)
|
identity_provider = self._create_dummy_idp(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'identity provider delete %s' % identity_provider
|
f'identity provider delete {identity_provider}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ class IdentityProviderTests(common.IdentityTests):
|
|||||||
def test_idp_show(self):
|
def test_idp_show(self):
|
||||||
identity_provider = self._create_dummy_idp(add_clean_up=True)
|
identity_provider = self._create_dummy_idp(add_clean_up=True)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'identity provider show %s' % identity_provider
|
f'identity provider show {identity_provider}'
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.IDENTITY_PROVIDER_FIELDS)
|
self.assert_show_fields(items, self.IDENTITY_PROVIDER_FIELDS)
|
||||||
@ -64,7 +64,7 @@ class IdentityProviderTests(common.IdentityTests):
|
|||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'identity provider show %s' % identity_provider
|
f'identity provider show {identity_provider}'
|
||||||
)
|
)
|
||||||
updated_value = self.parse_show_as_object(raw_output)
|
updated_value = self.parse_show_as_object(raw_output)
|
||||||
self.assertIn(new_remoteid, updated_value['remote_ids'])
|
self.assertIn(new_remoteid, updated_value['remote_ids'])
|
||||||
|
@ -23,19 +23,19 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
def test_limit_create_with_service_name(self):
|
def test_limit_create_with_service_name(self):
|
||||||
registered_limit_id = self._create_dummy_registered_limit()
|
registered_limit_id = self._create_dummy_registered_limit()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit show %s' % registered_limit_id,
|
f'registered limit show {registered_limit_id}',
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
service_id = self._extract_value_from_items('service_id', items)
|
service_id = self._extract_value_from_items('service_id', items)
|
||||||
resource_name = self._extract_value_from_items('resource_name', items)
|
resource_name = self._extract_value_from_items('resource_name', items)
|
||||||
|
|
||||||
raw_output = self.openstack('service show %s' % service_id)
|
raw_output = self.openstack(f'service show {service_id}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
service_name = self._extract_value_from_items('name', items)
|
service_name = self._extract_value_from_items('name', items)
|
||||||
|
|
||||||
project_name = self._create_dummy_project()
|
project_name = self._create_dummy_project()
|
||||||
raw_output = self.openstack('project show %s' % project_name)
|
raw_output = self.openstack(f'project show {project_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
project_id = self._extract_value_from_items('id', items)
|
project_id = self._extract_value_from_items('id', items)
|
||||||
|
|
||||||
@ -47,16 +47,16 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit create'
|
'limit create'
|
||||||
' --project %(project_id)s'
|
' --project {project_id}'
|
||||||
' --service %(service_name)s'
|
' --service {service_name}'
|
||||||
' --resource-limit %(resource_limit)s'
|
' --resource-limit {resource_limit}'
|
||||||
' %(resource_name)s' % params,
|
' {resource_name}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
limit_id = self._extract_value_from_items('id', items)
|
limit_id = self._extract_value_from_items('id', items)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'limit delete %s' % limit_id, cloud=SYSTEM_CLOUD
|
self.openstack, f'limit delete {limit_id}', cloud=SYSTEM_CLOUD
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||||
@ -64,14 +64,14 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
def test_limit_create_with_project_name(self):
|
def test_limit_create_with_project_name(self):
|
||||||
registered_limit_id = self._create_dummy_registered_limit()
|
registered_limit_id = self._create_dummy_registered_limit()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit show %s' % registered_limit_id,
|
f'registered limit show {registered_limit_id}',
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
service_id = self._extract_value_from_items('service_id', items)
|
service_id = self._extract_value_from_items('service_id', items)
|
||||||
resource_name = self._extract_value_from_items('resource_name', items)
|
resource_name = self._extract_value_from_items('resource_name', items)
|
||||||
|
|
||||||
raw_output = self.openstack('service show %s' % service_id)
|
raw_output = self.openstack(f'service show {service_id}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
service_name = self._extract_value_from_items('name', items)
|
service_name = self._extract_value_from_items('name', items)
|
||||||
|
|
||||||
@ -85,16 +85,16 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit create'
|
'limit create'
|
||||||
' --project %(project_name)s'
|
' --project {project_name}'
|
||||||
' --service %(service_name)s'
|
' --service {service_name}'
|
||||||
' --resource-limit %(resource_limit)s'
|
' --resource-limit {resource_limit}'
|
||||||
' %(resource_name)s' % params,
|
' {resource_name}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
limit_id = self._extract_value_from_items('id', items)
|
limit_id = self._extract_value_from_items('id', items)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'limit delete %s' % limit_id, cloud=SYSTEM_CLOUD
|
self.openstack, f'limit delete {limit_id}', cloud=SYSTEM_CLOUD
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||||
@ -117,8 +117,8 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit set'
|
'registered limit set'
|
||||||
' %(registered_limit_id)s'
|
' {registered_limit_id}'
|
||||||
' --region %(region_id)s' % params,
|
' --region {region_id}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -126,7 +126,7 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
resource_name = self._extract_value_from_items('resource_name', items)
|
resource_name = self._extract_value_from_items('resource_name', items)
|
||||||
|
|
||||||
project_name = self._create_dummy_project()
|
project_name = self._create_dummy_project()
|
||||||
raw_output = self.openstack('project show %s' % project_name)
|
raw_output = self.openstack(f'project show {project_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
project_id = self._extract_value_from_items('id', items)
|
project_id = self._extract_value_from_items('id', items)
|
||||||
description = data_utils.arbitrary_string()
|
description = data_utils.arbitrary_string()
|
||||||
@ -141,18 +141,18 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit create'
|
'limit create'
|
||||||
' --project %(project_id)s'
|
' --project {project_id}'
|
||||||
' --service %(service_id)s'
|
' --service {service_id}'
|
||||||
' --resource-limit %(resource_limit)s'
|
' --resource-limit {resource_limit}'
|
||||||
' --region %(region_id)s'
|
' --region {region_id}'
|
||||||
' --description %(description)s'
|
' --description {description}'
|
||||||
' %(resource_name)s' % params,
|
' {resource_name}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
limit_id = self._extract_value_from_items('id', items)
|
limit_id = self._extract_value_from_items('id', items)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'limit delete %s' % limit_id, cloud=SYSTEM_CLOUD
|
self.openstack, f'limit delete {limit_id}', cloud=SYSTEM_CLOUD
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||||
@ -160,7 +160,7 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
def test_limit_show(self):
|
def test_limit_show(self):
|
||||||
limit_id = self._create_dummy_limit()
|
limit_id = self._create_dummy_limit()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit show %s' % limit_id, cloud=SYSTEM_CLOUD
|
f'limit show {limit_id}', cloud=SYSTEM_CLOUD
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||||
@ -174,9 +174,9 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit set'
|
'limit set' ' --description {description}' ' {limit_id}'.format(
|
||||||
' --description %(description)s'
|
**params
|
||||||
' %(limit_id)s' % params,
|
),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -189,8 +189,8 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit set'
|
'limit set'
|
||||||
' --resource-limit %(resource_limit)s'
|
' --resource-limit {resource_limit}'
|
||||||
' %(limit_id)s' % params,
|
' {limit_id}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -205,6 +205,6 @@ class LimitTestCase(common.IdentityTests):
|
|||||||
def test_limit_delete(self):
|
def test_limit_delete(self):
|
||||||
limit_id = self._create_dummy_limit(add_clean_up=False)
|
limit_id = self._create_dummy_limit(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'limit delete %s' % limit_id, cloud=SYSTEM_CLOUD
|
f'limit delete {limit_id}', cloud=SYSTEM_CLOUD
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
@ -21,23 +21,18 @@ class ProjectTests(common.IdentityTests):
|
|||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project create '
|
'project create '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--description %(description)s '
|
f'--description {description} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'--property k1=v1 '
|
'--property k1=v1 '
|
||||||
'--property k2=v2 '
|
'--property k2=v2 '
|
||||||
'%(name)s'
|
f'{project_name}'
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'description': description,
|
|
||||||
'name': project_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'project delete '
|
'project delete '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': project_name},
|
f'{project_name}',
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
show_fields = list(self.PROJECT_FIELDS)
|
show_fields = list(self.PROJECT_FIELDS)
|
||||||
@ -50,9 +45,7 @@ class ProjectTests(common.IdentityTests):
|
|||||||
def test_project_delete(self):
|
def test_project_delete(self):
|
||||||
project_name = self._create_dummy_project(add_clean_up=False)
|
project_name = self._create_dummy_project(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project delete '
|
'project delete ' f'--domain {self.domain_name} ' f'{project_name}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': project_name}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
@ -64,7 +57,7 @@ class ProjectTests(common.IdentityTests):
|
|||||||
def test_project_list_with_domain(self):
|
def test_project_list_with_domain(self):
|
||||||
project_name = self._create_dummy_project()
|
project_name = self._create_dummy_project()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project list --domain %s' % self.domain_name
|
f'project list --domain {self.domain_name}'
|
||||||
)
|
)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
|
self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
|
||||||
@ -76,17 +69,17 @@ class ProjectTests(common.IdentityTests):
|
|||||||
new_project_name = data_utils.rand_name('NewTestProject')
|
new_project_name = data_utils.rand_name('NewTestProject')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project set '
|
'project set '
|
||||||
'--name %(new_name)s '
|
f'--name {new_project_name} '
|
||||||
'--disable '
|
'--disable '
|
||||||
'--property k0=v0 '
|
'--property k0=v0 '
|
||||||
'%(name)s' % {'new_name': new_project_name, 'name': project_name}
|
f'{project_name}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
# check project details
|
# check project details
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project show '
|
'project show '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': new_project_name}
|
f'{new_project_name}'
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
fields = list(self.PROJECT_FIELDS)
|
fields = list(self.PROJECT_FIELDS)
|
||||||
@ -99,17 +92,16 @@ class ProjectTests(common.IdentityTests):
|
|||||||
# reset project to make sure it will be cleaned up
|
# reset project to make sure it will be cleaned up
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'project set '
|
'project set '
|
||||||
'--name %(new_name)s '
|
f'--name {project_name} '
|
||||||
'--enable '
|
'--enable '
|
||||||
'%(name)s' % {'new_name': project_name, 'name': new_project_name}
|
f'{new_project_name}'
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_project_show(self):
|
def test_project_show(self):
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project show '
|
'project show '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'%(name)s'
|
f'{self.project_name}'
|
||||||
% {'domain': self.domain_name, 'name': self.project_name}
|
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.PROJECT_FIELDS)
|
self.assert_show_fields(items, self.PROJECT_FIELDS)
|
||||||
@ -118,9 +110,8 @@ class ProjectTests(common.IdentityTests):
|
|||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'project show '
|
'project show '
|
||||||
'--parents --children '
|
'--parents --children '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'%(name)s'
|
f'{self.project_name}',
|
||||||
% {'domain': self.domain_name, 'name': self.project_name},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
for attr_name in self.PROJECT_FIELDS + ['parents', 'subtree']:
|
for attr_name in self.PROJECT_FIELDS + ['parents', 'subtree']:
|
||||||
|
@ -23,7 +23,7 @@ class RegionTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_region_delete(self):
|
def test_region_delete(self):
|
||||||
region_id = self._create_dummy_region(add_clean_up=False)
|
region_id = self._create_dummy_region(add_clean_up=False)
|
||||||
raw_output = self.openstack('region delete %s' % region_id)
|
raw_output = self.openstack(f'region delete {region_id}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_region_multi_delete(self):
|
def test_region_multi_delete(self):
|
||||||
@ -43,27 +43,26 @@ class RegionTests(common.IdentityTests):
|
|||||||
new_parent_region_id = self._create_dummy_region()
|
new_parent_region_id = self._create_dummy_region()
|
||||||
region_id = self._create_dummy_region(parent_region_id)
|
region_id = self._create_dummy_region(parent_region_id)
|
||||||
# check region details
|
# check region details
|
||||||
raw_output = self.openstack('region show %s' % region_id)
|
raw_output = self.openstack(f'region show {region_id}')
|
||||||
region = self.parse_show_as_object(raw_output)
|
region = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(parent_region_id, region['parent_region'])
|
self.assertEqual(parent_region_id, region['parent_region'])
|
||||||
self.assertEqual(region_id, region['region'])
|
self.assertEqual(region_id, region['region'])
|
||||||
# update parent-region
|
# update parent-region
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'region set '
|
'region set '
|
||||||
'--parent-region %(parent_region)s '
|
f'--parent-region {new_parent_region_id} '
|
||||||
'%(region)s'
|
f'{region_id}'
|
||||||
% {'parent_region': new_parent_region_id, 'region': region_id}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
# check updated region details
|
# check updated region details
|
||||||
raw_output = self.openstack('region show %s' % region_id)
|
raw_output = self.openstack(f'region show {region_id}')
|
||||||
region = self.parse_show_as_object(raw_output)
|
region = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(new_parent_region_id, region['parent_region'])
|
self.assertEqual(new_parent_region_id, region['parent_region'])
|
||||||
self.assertEqual(region_id, region['region'])
|
self.assertEqual(region_id, region['region'])
|
||||||
|
|
||||||
def test_region_show(self):
|
def test_region_show(self):
|
||||||
region_id = self._create_dummy_region()
|
region_id = self._create_dummy_region()
|
||||||
raw_output = self.openstack('region show %s' % region_id)
|
raw_output = self.openstack(f'region show {region_id}')
|
||||||
region = self.parse_show_as_object(raw_output)
|
region = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(region_id, region['region'])
|
self.assertEqual(region_id, region['region'])
|
||||||
self.assertEqual('None', region['parent_region'])
|
self.assertEqual('None', region['parent_region'])
|
||||||
|
@ -25,31 +25,26 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
|
|
||||||
def test_registered_limit_create_with_service_id(self):
|
def test_registered_limit_create_with_service_id(self):
|
||||||
service_name = self._create_dummy_service()
|
service_name = self._create_dummy_service()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack('service show' f' {service_name}')
|
||||||
'service show' ' %(service_name)s' % {'service_name': service_name}
|
|
||||||
)
|
|
||||||
service_items = self.parse_show(raw_output)
|
service_items = self.parse_show(raw_output)
|
||||||
service_id = self._extract_value_from_items('id', service_items)
|
service_id = self._extract_value_from_items('id', service_items)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit create'
|
'registered limit create'
|
||||||
' --service %(service_id)s'
|
' --service {service_id}'
|
||||||
' --default-limit %(default_limit)s'
|
' --default-limit {default_limit}'
|
||||||
' %(resource_name)s'
|
' {resource_name}'.format(
|
||||||
% {
|
service_id=service_id,
|
||||||
'service_id': service_id,
|
default_limit=10,
|
||||||
'default_limit': 10,
|
resource_name='cores',
|
||||||
'resource_name': 'cores',
|
),
|
||||||
},
|
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
registered_limit_id = self._extract_value_from_items('id', items)
|
registered_limit_id = self._extract_value_from_items('id', items)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'registered limit delete'
|
'registered limit delete' f' {registered_limit_id}',
|
||||||
' %(registered_limit_id)s'
|
|
||||||
% {'registered_limit_id': registered_limit_id},
|
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,19 +63,18 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit create'
|
'registered limit create'
|
||||||
' --description \'%(description)s\''
|
' --description \'{description}\''
|
||||||
' --region %(region_id)s'
|
' --region {region_id}'
|
||||||
' --service %(service_name)s'
|
' --service {service_name}'
|
||||||
' --default-limit %(default_limit)s'
|
' --default-limit {default_limit}'
|
||||||
' %(resource_name)s' % params,
|
' {resource_name}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
registered_limit_id = self._extract_value_from_items('id', items)
|
registered_limit_id = self._extract_value_from_items('id', items)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'registered limit delete %(registered_limit_id)s'
|
f'registered limit delete {registered_limit_id}',
|
||||||
% {'registered_limit_id': registered_limit_id},
|
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -89,8 +83,7 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
def test_registered_limit_show(self):
|
def test_registered_limit_show(self):
|
||||||
registered_limit_id = self._create_dummy_registered_limit()
|
registered_limit_id = self._create_dummy_registered_limit()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit show %(registered_limit_id)s'
|
f'registered limit show {registered_limit_id}'
|
||||||
% {'registered_limit_id': registered_limit_id}
|
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||||
@ -105,8 +98,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit set'
|
'registered limit set'
|
||||||
' %(registered_limit_id)s'
|
' {registered_limit_id}'
|
||||||
' --region %(region_id)s' % params,
|
' --region {region_id}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -120,8 +113,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit set'
|
'registered limit set'
|
||||||
' %(registered_limit_id)s'
|
' {registered_limit_id}'
|
||||||
' --description \'%(description)s\'' % params,
|
' --description \'{description}\''.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -136,8 +129,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit set'
|
'registered limit set'
|
||||||
' %(registered_limit_id)s'
|
' {registered_limit_id}'
|
||||||
' --service %(service)s' % params,
|
' --service {service}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -151,8 +144,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit set'
|
'registered limit set'
|
||||||
' %(registered_limit_id)s'
|
' {registered_limit_id}'
|
||||||
' --default-limit %(default_limit)s' % params,
|
' --default-limit {default_limit}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -167,8 +160,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
}
|
}
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit set'
|
'registered limit set'
|
||||||
' %(registered_limit_id)s'
|
' {registered_limit_id}'
|
||||||
' --resource-name %(resource_name)s' % params,
|
' --resource-name {resource_name}'.format(**params),
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
@ -185,9 +178,7 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
|||||||
add_clean_up=False
|
add_clean_up=False
|
||||||
)
|
)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'registered limit delete'
|
'registered limit delete' f' {registered_limit_id}',
|
||||||
' %(registered_limit_id)s'
|
|
||||||
% {'registered_limit_id': registered_limit_id},
|
|
||||||
cloud=SYSTEM_CLOUD,
|
cloud=SYSTEM_CLOUD,
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
@ -23,12 +23,10 @@ class RoleTests(common.IdentityTests):
|
|||||||
role_name = data_utils.rand_name('TestRole')
|
role_name = data_utils.rand_name('TestRole')
|
||||||
description = data_utils.rand_name('description')
|
description = data_utils.rand_name('description')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role create '
|
'role create ' f'--description {description} ' f'{role_name}'
|
||||||
'--description %(description)s '
|
|
||||||
'%(name)s' % {'description': description, 'name': role_name}
|
|
||||||
)
|
)
|
||||||
role = self.parse_show_as_object(raw_output)
|
role = self.parse_show_as_object(raw_output)
|
||||||
self.addCleanup(self.openstack, 'role delete %s' % role['id'])
|
self.addCleanup(self.openstack, 'role delete {}'.format(role['id']))
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ROLE_FIELDS)
|
self.assert_show_fields(items, self.ROLE_FIELDS)
|
||||||
self.assertEqual(description, role['description'])
|
self.assertEqual(description, role['description'])
|
||||||
@ -36,7 +34,7 @@ class RoleTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_role_delete(self):
|
def test_role_delete(self):
|
||||||
role_name = self._create_dummy_role(add_clean_up=False)
|
role_name = self._create_dummy_role(add_clean_up=False)
|
||||||
raw_output = self.openstack('role delete %s' % role_name)
|
raw_output = self.openstack(f'role delete {role_name}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_role_list(self):
|
def test_role_list(self):
|
||||||
@ -47,7 +45,7 @@ class RoleTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_role_show(self):
|
def test_role_show(self):
|
||||||
role_name = self._create_dummy_role()
|
role_name = self._create_dummy_role()
|
||||||
raw_output = self.openstack('role show %s' % role_name)
|
raw_output = self.openstack(f'role show {role_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.ROLE_FIELDS)
|
self.assert_show_fields(items, self.ROLE_FIELDS)
|
||||||
|
|
||||||
@ -58,7 +56,7 @@ class RoleTests(common.IdentityTests):
|
|||||||
f'role set --name {new_role_name} {role_name}'
|
f'role set --name {new_role_name} {role_name}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack('role show %s' % new_role_name)
|
raw_output = self.openstack(f'role show {new_role_name}')
|
||||||
role = self.parse_show_as_object(raw_output)
|
role = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(new_role_name, role['name'])
|
self.assertEqual(new_role_name, role['name'])
|
||||||
|
|
||||||
@ -69,7 +67,7 @@ class RoleTests(common.IdentityTests):
|
|||||||
f'role set --description {description} {role_name}'
|
f'role set --description {description} {role_name}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack('role show %s' % role_name)
|
raw_output = self.openstack(f'role show {role_name}')
|
||||||
role = self.parse_show_as_object(raw_output)
|
role = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(description, role['description'])
|
self.assertEqual(description, role['description'])
|
||||||
|
|
||||||
@ -78,34 +76,20 @@ class RoleTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--project-domain %(project_domain)s '
|
f'--project-domain {self.domain_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'project_domain': self.domain_name,
|
|
||||||
'user': username,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'role remove '
|
'role remove '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--project-domain %(project_domain)s '
|
f'--project-domain {self.domain_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(role)s'
|
f'{role_name}',
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'project_domain': self.domain_name,
|
|
||||||
'user': username,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'role': role_name,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
@ -114,33 +98,19 @@ class RoleTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
add_raw_output = self.openstack(
|
add_raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--project-domain %(project_domain)s '
|
f'--project-domain {self.domain_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'project_domain': self.domain_name,
|
|
||||||
'user': username,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
remove_raw_output = self.openstack(
|
remove_raw_output = self.openstack(
|
||||||
'role remove '
|
'role remove '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--project-domain %(project_domain)s '
|
f'--project-domain {self.domain_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'--user-domain %(user_domain)s '
|
f'--user-domain {self.domain_name} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'project_domain': self.domain_name,
|
|
||||||
'user': username,
|
|
||||||
'user_domain': self.domain_name,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(add_raw_output))
|
self.assertEqual(0, len(add_raw_output))
|
||||||
self.assertEqual(0, len(remove_raw_output))
|
self.assertEqual(0, len(remove_raw_output))
|
||||||
@ -165,15 +135,15 @@ class RoleTests(common.IdentityTests):
|
|||||||
implied_role_name = self._create_dummy_role()
|
implied_role_name = self._create_dummy_role()
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'implied role create '
|
'implied role create '
|
||||||
'--implied-role %(implied_role)s '
|
f'--implied-role {implied_role_name} '
|
||||||
'%(role)s' % {'implied_role': implied_role_name, 'role': role_name}
|
f'{role_name}'
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_implied_role_delete(self):
|
def test_implied_role_delete(self):
|
||||||
implied_role_name, role_name = self._create_dummy_implied_role()
|
implied_role_name, role_name = self._create_dummy_implied_role()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'implied role delete '
|
'implied role delete '
|
||||||
'--implied-role %(implied_role)s '
|
f'--implied-role {implied_role_name} '
|
||||||
'%(role)s' % {'implied_role': implied_role_name, 'role': role_name}
|
f'{role_name}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
@ -25,43 +25,33 @@ class RoleAssignmentTests(common.IdentityTests):
|
|||||||
system = 'all'
|
system = 'all'
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'--system %(system)s '
|
f'--system {system} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'user': username,
|
|
||||||
'system': system,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'role remove '
|
'role remove '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'--system %(system)s '
|
f'--system {system} '
|
||||||
'%(role)s'
|
f'{role_name}',
|
||||||
% {
|
|
||||||
'user': username,
|
|
||||||
'system': system,
|
|
||||||
'role': role_name,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role assignment list ' '--user %(user)s ' % {'user': username}
|
'role assignment list ' f'--user {username} '
|
||||||
)
|
)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role assignment list ' '--role %(role)s ' % {'role': role_name}
|
'role assignment list ' f'--role {role_name} '
|
||||||
)
|
)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role assignment list ' '--system %(system)s ' % {'system': system}
|
'role assignment list ' f'--system {system} '
|
||||||
)
|
)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
||||||
@ -72,30 +62,20 @@ class RoleAssignmentTests(common.IdentityTests):
|
|||||||
system = 'all'
|
system = 'all'
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--group %(group)s '
|
f'--group {group} '
|
||||||
'--system %(system)s '
|
f'--system {system} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'group': group,
|
|
||||||
'system': system,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'role remove '
|
'role remove '
|
||||||
'--group %(group)s '
|
f'--group {group} '
|
||||||
'--system %(system)s '
|
f'--system {system} '
|
||||||
'%(role)s'
|
f'{role_name}',
|
||||||
% {
|
|
||||||
'group': group,
|
|
||||||
'system': system,
|
|
||||||
'role': role_name,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role assignment list ' '--group %(group)s ' % {'group': group}
|
'role assignment list ' f'--group {group} '
|
||||||
)
|
)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
||||||
@ -105,31 +85,20 @@ class RoleAssignmentTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'role remove '
|
'role remove '
|
||||||
'--domain %(domain)s '
|
f'--domain {self.domain_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}',
|
||||||
% {
|
|
||||||
'domain': self.domain_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role assignment list '
|
'role assignment list ' f'--domain {self.domain_name} '
|
||||||
'--domain %(domain)s ' % {'domain': self.domain_name}
|
|
||||||
)
|
)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
||||||
@ -139,31 +108,20 @@ class RoleAssignmentTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'role remove '
|
'role remove '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'%(role)s'
|
f'{role_name}',
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role assignment list '
|
'role assignment list ' f'--project {self.project_name} '
|
||||||
'--project %(project)s ' % {'project': self.project_name}
|
|
||||||
)
|
)
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
|
||||||
@ -188,15 +146,10 @@ class RoleAssignmentTests(common.IdentityTests):
|
|||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'role add '
|
'role add '
|
||||||
'--project %(project)s '
|
f'--project {self.project_name} '
|
||||||
'--user %(user)s '
|
f'--user {username} '
|
||||||
'--inherited '
|
'--inherited '
|
||||||
'%(role)s'
|
f'{role_name}'
|
||||||
% {
|
|
||||||
'project': self.project_name,
|
|
||||||
'user': username,
|
|
||||||
'role': role_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class ServiceTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_service_delete(self):
|
def test_service_delete(self):
|
||||||
service_name = self._create_dummy_service(add_clean_up=False)
|
service_name = self._create_dummy_service(add_clean_up=False)
|
||||||
raw_output = self.openstack('service delete %s' % service_name)
|
raw_output = self.openstack(f'service delete {service_name}')
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
def test_service_multi_delete(self):
|
def test_service_multi_delete(self):
|
||||||
@ -44,21 +44,15 @@ class ServiceTests(common.IdentityTests):
|
|||||||
new_service_type = data_utils.rand_name('NewTestType')
|
new_service_type = data_utils.rand_name('NewTestType')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'service set '
|
'service set '
|
||||||
'--type %(type)s '
|
f'--type {new_service_type} '
|
||||||
'--name %(name)s '
|
f'--name {new_service_name} '
|
||||||
'--description %(description)s '
|
f'--description {new_service_description} '
|
||||||
'--disable '
|
'--disable '
|
||||||
'%(service)s'
|
f'{service_name}'
|
||||||
% {
|
|
||||||
'type': new_service_type,
|
|
||||||
'name': new_service_name,
|
|
||||||
'description': new_service_description,
|
|
||||||
'service': service_name,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
# get service details
|
# get service details
|
||||||
raw_output = self.openstack('service show %s' % new_service_name)
|
raw_output = self.openstack(f'service show {new_service_name}')
|
||||||
# assert service details
|
# assert service details
|
||||||
service = self.parse_show_as_object(raw_output)
|
service = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(new_service_type, service['type'])
|
self.assertEqual(new_service_type, service['type'])
|
||||||
@ -67,6 +61,6 @@ class ServiceTests(common.IdentityTests):
|
|||||||
|
|
||||||
def test_service_show(self):
|
def test_service_show(self):
|
||||||
service_name = self._create_dummy_service()
|
service_name = self._create_dummy_service()
|
||||||
raw_output = self.openstack('service show %s' % service_name)
|
raw_output = self.openstack(f'service show {service_name}')
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
||||||
|
@ -24,7 +24,7 @@ class ServiceProviderTests(common.IdentityTests):
|
|||||||
def test_sp_delete(self):
|
def test_sp_delete(self):
|
||||||
service_provider = self._create_dummy_sp(add_clean_up=False)
|
service_provider = self._create_dummy_sp(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'service provider delete %s' % service_provider
|
f'service provider delete {service_provider}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class ServiceProviderTests(common.IdentityTests):
|
|||||||
def test_sp_show(self):
|
def test_sp_show(self):
|
||||||
service_provider = self._create_dummy_sp(add_clean_up=True)
|
service_provider = self._create_dummy_sp(add_clean_up=True)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'service provider show %s' % service_provider
|
f'service provider show {service_provider}'
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.SERVICE_PROVIDER_FIELDS)
|
self.assert_show_fields(items, self.SERVICE_PROVIDER_FIELDS)
|
||||||
@ -62,7 +62,7 @@ class ServiceProviderTests(common.IdentityTests):
|
|||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'service provider show %s' % service_provider
|
f'service provider show {service_provider}'
|
||||||
)
|
)
|
||||||
updated_value = self.parse_show_as_object(raw_output)
|
updated_value = self.parse_show_as_object(raw_output)
|
||||||
self.assertIn(new_description, updated_value['description'])
|
self.assertIn(new_description, updated_value['description'])
|
||||||
|
@ -22,9 +22,7 @@ class UserTests(common.IdentityTests):
|
|||||||
def test_user_delete(self):
|
def test_user_delete(self):
|
||||||
username = self._create_dummy_user(add_clean_up=False)
|
username = self._create_dummy_user(add_clean_up=False)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user delete '
|
'user delete ' f'--domain {self.domain_name} ' f'{username}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': username}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
|
||||||
@ -36,25 +34,19 @@ class UserTests(common.IdentityTests):
|
|||||||
def test_user_set(self):
|
def test_user_set(self):
|
||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user show '
|
'user show ' f'--domain {self.domain_name} ' f'{username}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': username}
|
|
||||||
)
|
)
|
||||||
user = self.parse_show_as_object(raw_output)
|
user = self.parse_show_as_object(raw_output)
|
||||||
new_username = data_utils.rand_name('NewTestUser')
|
new_username = data_utils.rand_name('NewTestUser')
|
||||||
new_email = data_utils.rand_name() + '@example.com'
|
new_email = data_utils.rand_name() + '@example.com'
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user set '
|
'user set ' '--email {email} ' '--name {new_name} ' '{id}'.format(
|
||||||
'--email %(email)s '
|
email=new_email, new_name=new_username, id=user['id']
|
||||||
'--name %(new_name)s '
|
)
|
||||||
'%(id)s'
|
|
||||||
% {'email': new_email, 'new_name': new_username, 'id': user['id']}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user show '
|
'user show ' f'--domain {self.domain_name} ' f'{new_username}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': new_username}
|
|
||||||
)
|
)
|
||||||
updated_user = self.parse_show_as_object(raw_output)
|
updated_user = self.parse_show_as_object(raw_output)
|
||||||
self.assertEqual(user['id'], updated_user['id'])
|
self.assertEqual(user['id'], updated_user['id'])
|
||||||
@ -65,36 +57,29 @@ class UserTests(common.IdentityTests):
|
|||||||
project_name = self._create_dummy_project()
|
project_name = self._create_dummy_project()
|
||||||
# get original user details
|
# get original user details
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user show '
|
'user show ' f'--domain {self.domain_name} ' f'{username}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': username}
|
|
||||||
)
|
)
|
||||||
user = self.parse_show_as_object(raw_output)
|
user = self.parse_show_as_object(raw_output)
|
||||||
# update user
|
# update user
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user set '
|
'user set '
|
||||||
'--project %(project)s '
|
'--project {project} '
|
||||||
'--project-domain %(project_domain)s '
|
'--project-domain {project_domain} '
|
||||||
'%(id)s'
|
'{id}'.format(
|
||||||
% {
|
project=project_name,
|
||||||
'project': project_name,
|
project_domain=self.domain_name,
|
||||||
'project_domain': self.domain_name,
|
id=user['id'],
|
||||||
'id': user['id'],
|
)
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
# get updated user details
|
# get updated user details
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user show '
|
'user show ' f'--domain {self.domain_name} ' f'{username}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': username}
|
|
||||||
)
|
)
|
||||||
updated_user = self.parse_show_as_object(raw_output)
|
updated_user = self.parse_show_as_object(raw_output)
|
||||||
# get project details
|
# get project details
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'project show '
|
'project show ' f'--domain {self.domain_name} ' f'{project_name}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': project_name}
|
|
||||||
)
|
)
|
||||||
project = self.parse_show_as_object(raw_output)
|
project = self.parse_show_as_object(raw_output)
|
||||||
# check updated user details
|
# check updated user details
|
||||||
@ -104,9 +89,7 @@ class UserTests(common.IdentityTests):
|
|||||||
def test_user_show(self):
|
def test_user_show(self):
|
||||||
username = self._create_dummy_user()
|
username = self._create_dummy_user()
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'user show '
|
'user show ' f'--domain {self.domain_name} ' f'{username}'
|
||||||
'--domain %(domain)s '
|
|
||||||
'%(name)s' % {'domain': self.domain_name, 'name': username}
|
|
||||||
)
|
)
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.USER_FIELDS)
|
self.assert_show_fields(items, self.USER_FIELDS)
|
||||||
|
@ -30,9 +30,7 @@ class ImageTests(base.BaseImageTests):
|
|||||||
self.image_tag = 'my_tag'
|
self.image_tag = 'my_tag'
|
||||||
self.image_tag1 = 'random'
|
self.image_tag1 = 'random'
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'image create --tag {tag} {name}'.format(
|
f'image create --tag {self.image_tag} {self.name}',
|
||||||
tag=self.image_tag, name=self.name
|
|
||||||
),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.image_id = output["id"]
|
self.image_id = output["id"]
|
||||||
|
@ -80,9 +80,7 @@ class NetworkTagTests(NetworkTests):
|
|||||||
|
|
||||||
def _list_tag_check(self, project_id, expected):
|
def _list_tag_check(self, project_id, expected):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'{} list --long --project {}'.format(
|
f'{self.base_command} list --long --project {project_id}',
|
||||||
self.base_command, project_id
|
|
||||||
),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
for name, tags in expected:
|
for name, tags in expected:
|
||||||
|
@ -30,14 +30,9 @@ class SecurityGroupRuleTests(common.NetworkTests):
|
|||||||
# Create the default security group rule.
|
# Create the default security group rule.
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'default security group rule create '
|
'default security group rule create '
|
||||||
'--protocol %(protocol)s '
|
f'--protocol {self.protocol} '
|
||||||
'--dst-port %(port)s:%(port)s '
|
f'--dst-port {self.port}:{self.port} '
|
||||||
'--%(direction)s --ethertype IPv4 '
|
f'--{self.direction} --ethertype IPv4 ',
|
||||||
% {
|
|
||||||
'protocol': self.protocol,
|
|
||||||
'port': self.port,
|
|
||||||
'direction': self.direction,
|
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
|
@ -41,15 +41,14 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
|||||||
created_helpers = []
|
created_helpers = []
|
||||||
for helper in helpers:
|
for helper in helpers:
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'network l3 conntrack helper create %(router)s '
|
'network l3 conntrack helper create {router} '
|
||||||
'--helper %(helper)s --protocol %(protocol)s '
|
'--helper {helper} --protocol {protocol} '
|
||||||
'--port %(port)s '
|
'--port {port} '.format(
|
||||||
% {
|
router=router_id,
|
||||||
'router': router_id,
|
helper=helper['helper'],
|
||||||
'helper': helper['helper'],
|
protocol=helper['protocol'],
|
||||||
'protocol': helper['protocol'],
|
port=helper['port'],
|
||||||
'port': helper['port'],
|
),
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(helper['helper'], output['helper'])
|
self.assertEqual(helper['helper'], output['helper'])
|
||||||
@ -70,8 +69,8 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
|||||||
ct_ids = " ".join([ct['id'] for ct in created_helpers])
|
ct_ids = " ".join([ct['id'] for ct in created_helpers])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'--debug network l3 conntrack helper delete %(router)s '
|
f'--debug network l3 conntrack helper delete {router_id} '
|
||||||
'%(ct_ids)s' % {'router': router_id, 'ct_ids': ct_ids}
|
f'{ct_ids}'
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
|||||||
router_id = self._create_router()
|
router_id = self._create_router()
|
||||||
self._create_helpers(router_id, helpers)
|
self._create_helpers(router_id, helpers)
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'network l3 conntrack helper list %s ' % router_id,
|
f'network l3 conntrack helper list {router_id} ',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
for ct in output:
|
for ct in output:
|
||||||
@ -100,12 +99,11 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
|||||||
router_id = self._create_router()
|
router_id = self._create_router()
|
||||||
created_helper = self._create_helpers(router_id, [helper])[0]
|
created_helper = self._create_helpers(router_id, [helper])[0]
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'network l3 conntrack helper show %(router_id)s %(ct_id)s '
|
'network l3 conntrack helper show {router_id} {ct_id} '
|
||||||
'-f json'
|
'-f json'.format(
|
||||||
% {
|
router_id=router_id,
|
||||||
'router_id': router_id,
|
ct_id=created_helper['id'],
|
||||||
'ct_id': created_helper['id'],
|
),
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(helper['helper'], output['helper'])
|
self.assertEqual(helper['helper'], output['helper'])
|
||||||
@ -113,23 +111,21 @@ class L3ConntrackHelperTests(common.NetworkTests):
|
|||||||
self.assertEqual(helper['port'], output['port'])
|
self.assertEqual(helper['port'], output['port'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'network l3 conntrack helper set %(router_id)s %(ct_id)s '
|
'network l3 conntrack helper set {router_id} {ct_id} '
|
||||||
'--port %(port)s '
|
'--port {port} '.format(
|
||||||
% {
|
router_id=router_id,
|
||||||
'router_id': router_id,
|
ct_id=created_helper['id'],
|
||||||
'ct_id': created_helper['id'],
|
port=helper['port'] + 1,
|
||||||
'port': helper['port'] + 1,
|
)
|
||||||
}
|
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'network l3 conntrack helper show %(router_id)s %(ct_id)s '
|
'network l3 conntrack helper show {router_id} {ct_id} '
|
||||||
'-f json'
|
'-f json'.format(
|
||||||
% {
|
router_id=router_id,
|
||||||
'router_id': router_id,
|
ct_id=created_helper['id'],
|
||||||
'ct_id': created_helper['id'],
|
),
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(helper['port'] + 1, output['port'])
|
self.assertEqual(helper['port'] + 1, output['port'])
|
||||||
|
@ -206,7 +206,7 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'network create ' + network_options + name1,
|
'network create ' + network_options + name1,
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'network delete %s' % name1)
|
self.addCleanup(self.openstack, f'network delete {name1}')
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
if self.haz_network:
|
if self.haz_network:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -342,33 +342,30 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
|
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network create --description aaaa %s' % name1,
|
f'network create --description aaaa {name1}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.addCleanup(self.openstack, 'network delete %s' % name1)
|
self.addCleanup(self.openstack, f'network delete {name1}')
|
||||||
|
|
||||||
# Get network ID
|
# Get network ID
|
||||||
network_id = cmd_output['id']
|
network_id = cmd_output['id']
|
||||||
|
|
||||||
# Add Agent to Network
|
# Add Agent to Network
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network agent add network --dhcp {} {}'.format(
|
f'network agent add network --dhcp {agent_id} {network_id}'
|
||||||
agent_id, network_id
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test network list --agent
|
# Test network list --agent
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network list --agent %s' % agent_id,
|
f'network list --agent {agent_id}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
# Remove Agent from Network
|
# Remove Agent from Network
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network agent remove network --dhcp %s %s'
|
f'network agent remove network --dhcp {agent_id} {network_id}'
|
||||||
% (agent_id, network_id)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
@ -388,10 +385,10 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'--no-share '
|
'--no-share '
|
||||||
'--internal '
|
'--internal '
|
||||||
'--no-default '
|
'--no-default '
|
||||||
'--enable-port-security %s' % name,
|
f'--enable-port-security {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'network delete %s' % name)
|
self.addCleanup(self.openstack, f'network delete {name}')
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'aaaa',
|
'aaaa',
|
||||||
@ -416,7 +413,7 @@ class NetworkTests(common.NetworkTagTests):
|
|||||||
'--disable '
|
'--disable '
|
||||||
'--share '
|
'--share '
|
||||||
'--external '
|
'--external '
|
||||||
'--disable-port-security %s' % name
|
f'--disable-port-security {name}'
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class TestAgent(common.NetworkTests):
|
|||||||
|
|
||||||
# agent show
|
# agent show
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network agent show %s' % agent_ids[0],
|
f'network agent show {agent_ids[0]}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -57,12 +57,12 @@ class TestAgent(common.NetworkTests):
|
|||||||
|
|
||||||
# agent set
|
# agent set
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'network agent set --disable %s' % agent_ids[0]
|
f'network agent set --disable {agent_ids[0]}'
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network agent show %s' % agent_ids[0],
|
f'network agent show {agent_ids[0]}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -71,12 +71,12 @@ class TestAgent(common.NetworkTests):
|
|||||||
)
|
)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'network agent set --enable %s' % agent_ids[0]
|
f'network agent set --enable {agent_ids[0]}'
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network agent show %s' % agent_ids[0],
|
f'network agent show {agent_ids[0]}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -112,33 +112,30 @@ class TestAgentList(common.NetworkTests):
|
|||||||
|
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network create --description aaaa %s' % name1,
|
f'network create --description aaaa {name1}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.addCleanup(self.openstack, 'network delete %s' % name1)
|
self.addCleanup(self.openstack, f'network delete {name1}')
|
||||||
|
|
||||||
# Get network ID
|
# Get network ID
|
||||||
network_id = cmd_output['id']
|
network_id = cmd_output['id']
|
||||||
|
|
||||||
# Add Agent to Network
|
# Add Agent to Network
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network agent add network --dhcp {} {}'.format(
|
f'network agent add network --dhcp {agent_id} {network_id}'
|
||||||
agent_id, network_id
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test network agent list --network
|
# Test network agent list --network
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network agent list --network %s' % network_id,
|
f'network agent list --network {network_id}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
# Remove Agent from Network
|
# Remove Agent from Network
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network agent remove network --dhcp %s %s'
|
f'network agent remove network --dhcp {agent_id} {network_id}'
|
||||||
% (agent_id, network_id)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
@ -153,11 +150,11 @@ class TestAgentList(common.NetworkTests):
|
|||||||
|
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'router create %s' % name,
|
f'router create {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.addCleanup(self.openstack, 'router delete %s' % name)
|
self.addCleanup(self.openstack, f'router delete {name}')
|
||||||
# Get router ID
|
# Get router ID
|
||||||
router_id = cmd_output['id']
|
router_id = cmd_output['id']
|
||||||
# Get l3 agent id
|
# Get l3 agent id
|
||||||
@ -175,7 +172,7 @@ class TestAgentList(common.NetworkTests):
|
|||||||
|
|
||||||
# Test router list --agent
|
# Test router list --agent
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network agent list --router %s' % router_id,
|
f'network agent list --router {router_id}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -184,12 +181,10 @@ class TestAgentList(common.NetworkTests):
|
|||||||
|
|
||||||
# Remove router from agent
|
# Remove router from agent
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network agent remove router --l3 {} {}'.format(
|
f'network agent remove router --l3 {agent_id} {router_id}'
|
||||||
agent_id, router_id
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network agent list --router %s' % router_id,
|
f'network agent list --router {router_id}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
agent_ids = [x['ID'] for x in cmd_output]
|
agent_ids = [x['ID'] for x in cmd_output]
|
||||||
|
@ -37,10 +37,10 @@ class NetworkFlavorTests(common.NetworkTests):
|
|||||||
)
|
)
|
||||||
service_profile_id = cmd_output2.get('id')
|
service_profile_id = cmd_output2.get('id')
|
||||||
|
|
||||||
self.addCleanup(self.openstack, 'network flavor delete %s' % flavor_id)
|
self.addCleanup(self.openstack, f'network flavor delete {flavor_id}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network flavor profile delete %s' % service_profile_id,
|
f'network flavor profile delete {service_profile_id}',
|
||||||
)
|
)
|
||||||
# Add flavor to service profile
|
# Add flavor to service profile
|
||||||
self.openstack(
|
self.openstack(
|
||||||
|
@ -31,20 +31,15 @@ class L3NDPProxyTests(common.NetworkTests):
|
|||||||
self.created_ndp_proxies = []
|
self.created_ndp_proxies = []
|
||||||
|
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'address scope create --ip-version 6 '
|
'address scope create --ip-version 6 ' f'{self.ADDR_SCOPE_NAME}',
|
||||||
'%(address_s_name)s' % {'address_s_name': self.ADDR_SCOPE_NAME},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(json_output['id'])
|
self.assertIsNotNone(json_output['id'])
|
||||||
self.ADDRESS_SCOPE_ID = json_output['id']
|
self.ADDRESS_SCOPE_ID = json_output['id']
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'subnet pool create %(subnet_p_name)s '
|
f'subnet pool create {self.SUBNET_P_NAME} '
|
||||||
'--address-scope %(address_scope)s '
|
f'--address-scope {self.ADDRESS_SCOPE_ID} '
|
||||||
'--pool-prefix 2001:db8::/96 --default-prefix-length 112'
|
'--pool-prefix 2001:db8::/96 --default-prefix-length 112',
|
||||||
% {
|
|
||||||
'subnet_p_name': self.SUBNET_P_NAME,
|
|
||||||
'address_scope': self.ADDRESS_SCOPE_ID,
|
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(json_output['id'])
|
self.assertIsNotNone(json_output['id'])
|
||||||
@ -57,12 +52,7 @@ class L3NDPProxyTests(common.NetworkTests):
|
|||||||
self.EXT_NET_ID = json_output['id']
|
self.EXT_NET_ID = json_output['id']
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'subnet create --ip-version 6 --subnet-pool '
|
'subnet create --ip-version 6 --subnet-pool '
|
||||||
'%(subnet_pool)s --network %(net_id)s %(sub_name)s'
|
f'{self.SUBNET_POOL_ID} --network {self.EXT_NET_ID} {self.EXT_SUB_NAME}',
|
||||||
% {
|
|
||||||
'subnet_pool': self.SUBNET_POOL_ID,
|
|
||||||
'net_id': self.EXT_NET_ID,
|
|
||||||
'sub_name': self.EXT_SUB_NAME,
|
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(json_output['id'])
|
self.assertIsNotNone(json_output['id'])
|
||||||
@ -74,8 +64,7 @@ class L3NDPProxyTests(common.NetworkTests):
|
|||||||
self.assertIsNotNone(json_output['id'])
|
self.assertIsNotNone(json_output['id'])
|
||||||
self.ROT_ID = json_output['id']
|
self.ROT_ID = json_output['id']
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'router set %(router_id)s --external-gateway %(net_id)s'
|
f'router set {self.ROT_ID} --external-gateway {self.EXT_NET_ID}'
|
||||||
% {'router_id': self.ROT_ID, 'net_id': self.EXT_NET_ID}
|
|
||||||
)
|
)
|
||||||
self.assertEqual('', output)
|
self.assertEqual('', output)
|
||||||
output = self.openstack('router set --enable-ndp-proxy ' + self.ROT_ID)
|
output = self.openstack('router set --enable-ndp-proxy ' + self.ROT_ID)
|
||||||
@ -93,23 +82,14 @@ class L3NDPProxyTests(common.NetworkTests):
|
|||||||
self.INT_NET_ID = json_output['id']
|
self.INT_NET_ID = json_output['id']
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'subnet create --ip-version 6 --subnet-pool '
|
'subnet create --ip-version 6 --subnet-pool '
|
||||||
'%(subnet_pool)s --network %(net_id)s %(sub_name)s'
|
f'{self.SUBNET_POOL_ID} --network {self.INT_NET_ID} {self.INT_SUB_NAME}',
|
||||||
% {
|
|
||||||
'subnet_pool': self.SUBNET_POOL_ID,
|
|
||||||
'net_id': self.INT_NET_ID,
|
|
||||||
'sub_name': self.INT_SUB_NAME,
|
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(json_output['id'])
|
self.assertIsNotNone(json_output['id'])
|
||||||
self.INT_SUB_ID = json_output['id']
|
self.INT_SUB_ID = json_output['id']
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port create --network %(net_id)s '
|
f'port create --network {self.INT_NET_ID} '
|
||||||
'%(port_name)s'
|
f'{self.INT_PORT_NAME}',
|
||||||
% {
|
|
||||||
'net_id': self.INT_NET_ID,
|
|
||||||
'port_name': self.INT_PORT_NAME,
|
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(json_output['id'])
|
self.assertIsNotNone(json_output['id'])
|
||||||
@ -161,14 +141,13 @@ class L3NDPProxyTests(common.NetworkTests):
|
|||||||
def _create_ndp_proxies(self, ndp_proxies):
|
def _create_ndp_proxies(self, ndp_proxies):
|
||||||
for ndp_proxy in ndp_proxies:
|
for ndp_proxy in ndp_proxies:
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'router ndp proxy create %(router)s --name %(name)s '
|
'router ndp proxy create {router} --name {name} '
|
||||||
'--port %(port)s --ip-address %(address)s'
|
'--port {port} --ip-address {address}'.format(
|
||||||
% {
|
router=ndp_proxy['router_id'],
|
||||||
'router': ndp_proxy['router_id'],
|
name=ndp_proxy['name'],
|
||||||
'name': ndp_proxy['name'],
|
port=ndp_proxy['port_id'],
|
||||||
'port': ndp_proxy['port_id'],
|
address=ndp_proxy['address'],
|
||||||
'address': ndp_proxy['address'],
|
),
|
||||||
},
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(ndp_proxy['router_id'], output['router_id'])
|
self.assertEqual(ndp_proxy['router_id'], output['router_id'])
|
||||||
@ -214,8 +193,7 @@ class L3NDPProxyTests(common.NetworkTests):
|
|||||||
self._create_ndp_proxies([ndp_proxies])
|
self._create_ndp_proxies([ndp_proxies])
|
||||||
ndp_proxy_id = self.created_ndp_proxies[0]['id']
|
ndp_proxy_id = self.created_ndp_proxies[0]['id']
|
||||||
output = self.openstack(
|
output = self.openstack(
|
||||||
'router ndp proxy set --description %s %s'
|
f'router ndp proxy set --description {description} {ndp_proxy_id}'
|
||||||
% (description, ndp_proxy_id)
|
|
||||||
)
|
)
|
||||||
self.assertEqual('', output)
|
self.assertEqual('', output)
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
|
@ -32,40 +32,39 @@ class NetworkQosRuleTestsMinimumBandwidth(NetworkQosTests):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.QOS_POLICY_NAME = 'qos_policy_%s' % uuid.uuid4().hex
|
self.QOS_POLICY_NAME = f'qos_policy_{uuid.uuid4().hex}'
|
||||||
|
|
||||||
self.openstack('network qos policy create %s' % self.QOS_POLICY_NAME)
|
self.openstack(f'network qos policy create {self.QOS_POLICY_NAME}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos policy delete %s' % self.QOS_POLICY_NAME,
|
f'network qos policy delete {self.QOS_POLICY_NAME}',
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type minimum-bandwidth '
|
'--type minimum-bandwidth '
|
||||||
'--min-kbps 2800 '
|
'--min-kbps 2800 '
|
||||||
'--egress %s' % self.QOS_POLICY_NAME,
|
f'--egress {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.RULE_ID = cmd_output['id']
|
self.RULE_ID = cmd_output['id']
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos rule delete %s %s'
|
f'network qos rule delete {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
)
|
)
|
||||||
self.assertTrue(self.RULE_ID)
|
self.assertTrue(self.RULE_ID)
|
||||||
|
|
||||||
def test_qos_rule_create_delete(self):
|
def test_qos_rule_create_delete(self):
|
||||||
# This is to check the output of qos rule delete
|
# This is to check the output of qos rule delete
|
||||||
policy_name = uuid.uuid4().hex
|
policy_name = uuid.uuid4().hex
|
||||||
self.openstack('network qos policy create %s' % policy_name)
|
self.openstack(f'network qos policy create {policy_name}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'network qos policy delete %s' % policy_name
|
self.openstack, f'network qos policy delete {policy_name}'
|
||||||
)
|
)
|
||||||
rule = self.openstack(
|
rule = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type minimum-bandwidth '
|
'--type minimum-bandwidth '
|
||||||
'--min-kbps 2800 '
|
'--min-kbps 2800 '
|
||||||
'--egress %s' % policy_name,
|
f'--egress {policy_name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -75,27 +74,24 @@ class NetworkQosRuleTestsMinimumBandwidth(NetworkQosTests):
|
|||||||
|
|
||||||
def test_qos_rule_list(self):
|
def test_qos_rule_list(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule list %s' % self.QOS_POLICY_NAME,
|
f'network qos rule list {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
||||||
|
|
||||||
def test_qos_rule_show(self):
|
def test_qos_rule_show(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
||||||
|
|
||||||
def test_qos_rule_set(self):
|
def test_qos_rule_set(self):
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network qos rule set --min-kbps 7500 %s %s'
|
f'network qos rule set --min-kbps 7500 {self.QOS_POLICY_NAME} {self.RULE_ID}'
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID)
|
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(7500, cmd_output['min_kbps'])
|
self.assertEqual(7500, cmd_output['min_kbps'])
|
||||||
@ -107,40 +103,39 @@ class NetworkQosRuleTestsMinimumPacketRate(NetworkQosTests):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.QOS_POLICY_NAME = 'qos_policy_%s' % uuid.uuid4().hex
|
self.QOS_POLICY_NAME = f'qos_policy_{uuid.uuid4().hex}'
|
||||||
|
|
||||||
self.openstack('network qos policy create %s' % self.QOS_POLICY_NAME)
|
self.openstack(f'network qos policy create {self.QOS_POLICY_NAME}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos policy delete %s' % self.QOS_POLICY_NAME,
|
f'network qos policy delete {self.QOS_POLICY_NAME}',
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type minimum-packet-rate '
|
'--type minimum-packet-rate '
|
||||||
'--min-kpps 2800 '
|
'--min-kpps 2800 '
|
||||||
'--egress %s' % self.QOS_POLICY_NAME,
|
f'--egress {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.RULE_ID = cmd_output['id']
|
self.RULE_ID = cmd_output['id']
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos rule delete %s %s'
|
f'network qos rule delete {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
)
|
)
|
||||||
self.assertTrue(self.RULE_ID)
|
self.assertTrue(self.RULE_ID)
|
||||||
|
|
||||||
def test_qos_rule_create_delete(self):
|
def test_qos_rule_create_delete(self):
|
||||||
# This is to check the output of qos rule delete
|
# This is to check the output of qos rule delete
|
||||||
policy_name = uuid.uuid4().hex
|
policy_name = uuid.uuid4().hex
|
||||||
self.openstack('network qos policy create %s' % policy_name)
|
self.openstack(f'network qos policy create {policy_name}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'network qos policy delete %s' % policy_name
|
self.openstack, f'network qos policy delete {policy_name}'
|
||||||
)
|
)
|
||||||
rule = self.openstack(
|
rule = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type minimum-packet-rate '
|
'--type minimum-packet-rate '
|
||||||
'--min-kpps 2800 '
|
'--min-kpps 2800 '
|
||||||
'--egress %s' % policy_name,
|
f'--egress {policy_name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -150,27 +145,24 @@ class NetworkQosRuleTestsMinimumPacketRate(NetworkQosTests):
|
|||||||
|
|
||||||
def test_qos_rule_list(self):
|
def test_qos_rule_list(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule list %s' % self.QOS_POLICY_NAME,
|
f'network qos rule list {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
||||||
|
|
||||||
def test_qos_rule_show(self):
|
def test_qos_rule_show(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
||||||
|
|
||||||
def test_qos_rule_set(self):
|
def test_qos_rule_set(self):
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network qos rule set --min-kpps 7500 --any %s %s'
|
f'network qos rule set --min-kpps 7500 --any {self.QOS_POLICY_NAME} {self.RULE_ID}'
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID)
|
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(7500, cmd_output['min_kpps'])
|
self.assertEqual(7500, cmd_output['min_kpps'])
|
||||||
@ -183,37 +175,36 @@ class NetworkQosRuleTestsDSCPMarking(NetworkQosTests):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.QOS_POLICY_NAME = 'qos_policy_%s' % uuid.uuid4().hex
|
self.QOS_POLICY_NAME = f'qos_policy_{uuid.uuid4().hex}'
|
||||||
self.openstack('network qos policy create %s' % self.QOS_POLICY_NAME)
|
self.openstack(f'network qos policy create {self.QOS_POLICY_NAME}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos policy delete %s' % self.QOS_POLICY_NAME,
|
f'network qos policy delete {self.QOS_POLICY_NAME}',
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type dscp-marking '
|
'--type dscp-marking '
|
||||||
'--dscp-mark 8 %s' % self.QOS_POLICY_NAME,
|
f'--dscp-mark 8 {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.RULE_ID = cmd_output['id']
|
self.RULE_ID = cmd_output['id']
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos rule delete %s %s'
|
f'network qos rule delete {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
)
|
)
|
||||||
self.assertTrue(self.RULE_ID)
|
self.assertTrue(self.RULE_ID)
|
||||||
|
|
||||||
def test_qos_rule_create_delete(self):
|
def test_qos_rule_create_delete(self):
|
||||||
# This is to check the output of qos rule delete
|
# This is to check the output of qos rule delete
|
||||||
policy_name = uuid.uuid4().hex
|
policy_name = uuid.uuid4().hex
|
||||||
self.openstack('network qos policy create %s' % policy_name)
|
self.openstack(f'network qos policy create {policy_name}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'network qos policy delete %s' % policy_name
|
self.openstack, f'network qos policy delete {policy_name}'
|
||||||
)
|
)
|
||||||
rule = self.openstack(
|
rule = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type dscp-marking '
|
'--type dscp-marking '
|
||||||
'--dscp-mark 8 %s' % policy_name,
|
f'--dscp-mark 8 {policy_name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -223,27 +214,24 @@ class NetworkQosRuleTestsDSCPMarking(NetworkQosTests):
|
|||||||
|
|
||||||
def test_qos_rule_list(self):
|
def test_qos_rule_list(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule list %s' % self.QOS_POLICY_NAME,
|
f'network qos rule list {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
||||||
|
|
||||||
def test_qos_rule_show(self):
|
def test_qos_rule_show(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
||||||
|
|
||||||
def test_qos_rule_set(self):
|
def test_qos_rule_set(self):
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network qos rule set --dscp-mark 32 %s %s'
|
f'network qos rule set --dscp-mark 32 {self.QOS_POLICY_NAME} {self.RULE_ID}'
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID)
|
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(32, cmd_output['dscp_mark'])
|
self.assertEqual(32, cmd_output['dscp_mark'])
|
||||||
@ -255,40 +243,39 @@ class NetworkQosRuleTestsBandwidthLimit(NetworkQosTests):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.QOS_POLICY_NAME = 'qos_policy_%s' % uuid.uuid4().hex
|
self.QOS_POLICY_NAME = f'qos_policy_{uuid.uuid4().hex}'
|
||||||
self.openstack('network qos policy create %s' % self.QOS_POLICY_NAME)
|
self.openstack(f'network qos policy create {self.QOS_POLICY_NAME}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos policy delete %s' % self.QOS_POLICY_NAME,
|
f'network qos policy delete {self.QOS_POLICY_NAME}',
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type bandwidth-limit '
|
'--type bandwidth-limit '
|
||||||
'--max-kbps 10000 '
|
'--max-kbps 10000 '
|
||||||
'--egress %s' % self.QOS_POLICY_NAME,
|
f'--egress {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.RULE_ID = cmd_output['id']
|
self.RULE_ID = cmd_output['id']
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'network qos rule delete %s %s'
|
f'network qos rule delete {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
)
|
)
|
||||||
self.assertTrue(self.RULE_ID)
|
self.assertTrue(self.RULE_ID)
|
||||||
|
|
||||||
def test_qos_rule_create_delete(self):
|
def test_qos_rule_create_delete(self):
|
||||||
# This is to check the output of qos rule delete
|
# This is to check the output of qos rule delete
|
||||||
policy_name = uuid.uuid4().hex
|
policy_name = uuid.uuid4().hex
|
||||||
self.openstack('network qos policy create %s' % policy_name)
|
self.openstack(f'network qos policy create {policy_name}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.openstack, 'network qos policy delete %s' % policy_name
|
self.openstack, f'network qos policy delete {policy_name}'
|
||||||
)
|
)
|
||||||
rule = self.openstack(
|
rule = self.openstack(
|
||||||
'network qos rule create '
|
'network qos rule create '
|
||||||
'--type bandwidth-limit '
|
'--type bandwidth-limit '
|
||||||
'--max-kbps 10000 '
|
'--max-kbps 10000 '
|
||||||
'--max-burst-kbits 1400 '
|
'--max-burst-kbits 1400 '
|
||||||
'--egress %s' % policy_name,
|
f'--egress {policy_name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -298,15 +285,14 @@ class NetworkQosRuleTestsBandwidthLimit(NetworkQosTests):
|
|||||||
|
|
||||||
def test_qos_rule_list(self):
|
def test_qos_rule_list(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule list %s' % self.QOS_POLICY_NAME,
|
f'network qos rule list {self.QOS_POLICY_NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
self.assertIn(self.RULE_ID, [rule['ID'] for rule in cmd_output])
|
||||||
|
|
||||||
def test_qos_rule_show(self):
|
def test_qos_rule_show(self):
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
self.assertEqual(self.RULE_ID, cmd_output['id'])
|
||||||
@ -315,11 +301,10 @@ class NetworkQosRuleTestsBandwidthLimit(NetworkQosTests):
|
|||||||
self.openstack(
|
self.openstack(
|
||||||
'network qos rule set --max-kbps 15000 '
|
'network qos rule set --max-kbps 15000 '
|
||||||
'--max-burst-kbits 1800 '
|
'--max-burst-kbits 1800 '
|
||||||
'--ingress %s %s' % (self.QOS_POLICY_NAME, self.RULE_ID)
|
f'--ingress {self.QOS_POLICY_NAME} {self.RULE_ID}'
|
||||||
)
|
)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule show %s %s'
|
f'network qos rule show {self.QOS_POLICY_NAME} {self.RULE_ID}',
|
||||||
% (self.QOS_POLICY_NAME, self.RULE_ID),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(15000, cmd_output['max_kbps'])
|
self.assertEqual(15000, cmd_output['max_kbps'])
|
||||||
|
@ -67,7 +67,7 @@ class NetworkQosRuleTypeTests(common.NetworkTests):
|
|||||||
def test_qos_rule_type_details(self):
|
def test_qos_rule_type_details(self):
|
||||||
for rule_type in self.AVAILABLE_RULE_TYPES:
|
for rule_type in self.AVAILABLE_RULE_TYPES:
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network qos rule type show %s -f json' % rule_type,
|
f'network qos rule type show {rule_type} -f json',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(rule_type, cmd_output['rule_type_name'])
|
self.assertEqual(rule_type, cmd_output['rule_type_name'])
|
||||||
|
@ -128,8 +128,8 @@ class NetworkSegmentRangeTests(common.NetworkTests):
|
|||||||
new_minimum = 2020
|
new_minimum = 2020
|
||||||
new_maximum = 2029
|
new_maximum = 2029
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'network segment range set --minimum {min} --maximum {max} '
|
f'network segment range set --minimum {new_minimum} --maximum {new_maximum} '
|
||||||
'{name}'.format(min=new_minimum, max=new_maximum, name=name)
|
f'{name}'
|
||||||
)
|
)
|
||||||
self.assertOutput('', cmd_output)
|
self.assertOutput('', cmd_output)
|
||||||
|
|
||||||
|
@ -32,33 +32,27 @@ class NetworkTrunkTests(common.NetworkTests):
|
|||||||
self.parent_port_name = uuid.uuid4().hex
|
self.parent_port_name = uuid.uuid4().hex
|
||||||
self.sub_port_name = uuid.uuid4().hex
|
self.sub_port_name = uuid.uuid4().hex
|
||||||
|
|
||||||
self.openstack('network create %s' % network_name)
|
self.openstack(f'network create {network_name}')
|
||||||
self.addCleanup(self.openstack, 'network delete %s' % network_name)
|
self.addCleanup(self.openstack, f'network delete {network_name}')
|
||||||
|
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'subnet create %s '
|
f'subnet create {subnet_name} '
|
||||||
'--network %s --subnet-range 10.0.0.0/24'
|
f'--network {network_name} --subnet-range 10.0.0.0/24'
|
||||||
% (subnet_name, network_name)
|
|
||||||
)
|
)
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'port create %s --network %s'
|
f'port create {self.parent_port_name} --network {network_name}'
|
||||||
% (self.parent_port_name, network_name)
|
|
||||||
)
|
|
||||||
self.addCleanup(
|
|
||||||
self.openstack, 'port delete %s' % self.parent_port_name
|
|
||||||
)
|
)
|
||||||
|
self.addCleanup(self.openstack, f'port delete {self.parent_port_name}')
|
||||||
json_out = self.openstack(
|
json_out = self.openstack(
|
||||||
'port create %s --network %s -f json'
|
f'port create {self.sub_port_name} --network {network_name} -f json'
|
||||||
% (self.sub_port_name, network_name)
|
|
||||||
)
|
)
|
||||||
self.sub_port_id = json.loads(json_out)['id']
|
self.sub_port_id = json.loads(json_out)['id']
|
||||||
self.addCleanup(self.openstack, 'port delete %s' % self.sub_port_name)
|
self.addCleanup(self.openstack, f'port delete {self.sub_port_name}')
|
||||||
|
|
||||||
def test_network_trunk_create_delete(self):
|
def test_network_trunk_create_delete(self):
|
||||||
trunk_name = uuid.uuid4().hex
|
trunk_name = uuid.uuid4().hex
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network trunk create %s --parent-port %s -f json '
|
f'network trunk create {trunk_name} --parent-port {self.parent_port_name} -f json '
|
||||||
% (trunk_name, self.parent_port_name)
|
|
||||||
)
|
)
|
||||||
raw_output = self.openstack('network trunk delete ' + trunk_name)
|
raw_output = self.openstack('network trunk delete ' + trunk_name)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
@ -67,8 +61,7 @@ class NetworkTrunkTests(common.NetworkTests):
|
|||||||
trunk_name = uuid.uuid4().hex
|
trunk_name = uuid.uuid4().hex
|
||||||
json_output = json.loads(
|
json_output = json.loads(
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network trunk create %s --parent-port %s -f json '
|
f'network trunk create {trunk_name} --parent-port {self.parent_port_name} -f json '
|
||||||
% (trunk_name, self.parent_port_name)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'network trunk delete ' + trunk_name)
|
self.addCleanup(self.openstack, 'network trunk delete ' + trunk_name)
|
||||||
@ -81,8 +74,7 @@ class NetworkTrunkTests(common.NetworkTests):
|
|||||||
trunk_name = uuid.uuid4().hex
|
trunk_name = uuid.uuid4().hex
|
||||||
json_output = json.loads(
|
json_output = json.loads(
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network trunk create %s --parent-port %s -f json '
|
f'network trunk create {trunk_name} --parent-port {self.parent_port_name} -f json '
|
||||||
% (trunk_name, self.parent_port_name)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'network trunk delete ' + trunk_name)
|
self.addCleanup(self.openstack, 'network trunk delete ' + trunk_name)
|
||||||
@ -98,8 +90,7 @@ class NetworkTrunkTests(common.NetworkTests):
|
|||||||
# Add subport to trunk
|
# Add subport to trunk
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network trunk set '
|
'network trunk set '
|
||||||
+ '--subport port=%s,segmentation-type=vlan,segmentation-id=42 '
|
+ f'--subport port={self.sub_port_name},segmentation-type=vlan,segmentation-id=42 '
|
||||||
% (self.sub_port_name)
|
|
||||||
+ trunk_name
|
+ trunk_name
|
||||||
)
|
)
|
||||||
json_output = json.loads(
|
json_output = json.loads(
|
||||||
@ -132,10 +123,9 @@ class NetworkTrunkTests(common.NetworkTests):
|
|||||||
trunk_name = uuid.uuid4().hex
|
trunk_name = uuid.uuid4().hex
|
||||||
json_output = json.loads(
|
json_output = json.loads(
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network trunk create %s --parent-port %s '
|
f'network trunk create {trunk_name} --parent-port {self.parent_port_name} '
|
||||||
'--subport port=%s,segmentation-type=vlan,segmentation-id=42 '
|
f'--subport port={self.sub_port_name},segmentation-type=vlan,segmentation-id=42 '
|
||||||
'-f json '
|
'-f json '
|
||||||
% (trunk_name, self.parent_port_name, self.sub_port_name)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'network trunk delete ' + trunk_name)
|
self.addCleanup(self.openstack, 'network trunk delete ' + trunk_name)
|
||||||
@ -143,7 +133,7 @@ class NetworkTrunkTests(common.NetworkTests):
|
|||||||
|
|
||||||
json_output = json.loads(
|
json_output = json.loads(
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'network subport list --trunk %s -f json' % trunk_name
|
f'network subport list --trunk {trunk_name} -f json'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -31,14 +31,14 @@ class PortTests(common.NetworkTagTests):
|
|||||||
cls.NETWORK_NAME = uuid.uuid4().hex
|
cls.NETWORK_NAME = uuid.uuid4().hex
|
||||||
|
|
||||||
# Create a network for the port tests
|
# Create a network for the port tests
|
||||||
cls.openstack('network create %s' % cls.NETWORK_NAME)
|
cls.openstack(f'network create {cls.NETWORK_NAME}')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
try:
|
try:
|
||||||
if cls.haz_network:
|
if cls.haz_network:
|
||||||
raw_output = cls.openstack(
|
raw_output = cls.openstack(
|
||||||
'network delete %s' % cls.NETWORK_NAME
|
f'network delete {cls.NETWORK_NAME}'
|
||||||
)
|
)
|
||||||
cls.assertOutput('', raw_output)
|
cls.assertOutput('', raw_output)
|
||||||
finally:
|
finally:
|
||||||
@ -56,9 +56,7 @@ class PortTests(common.NetworkTagTests):
|
|||||||
self.assertEqual(self.NAME, json_output.get('name'))
|
self.assertEqual(self.NAME, json_output.get('name'))
|
||||||
|
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port create --network {} {}x'.format(
|
f'port create --network {self.NETWORK_NAME} {self.NAME}x',
|
||||||
self.NETWORK_NAME, self.NAME
|
|
||||||
),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
id2 = json_output.get('id')
|
id2 = json_output.get('id')
|
||||||
@ -80,20 +78,18 @@ class PortTests(common.NetworkTagTests):
|
|||||||
self.assertIsNotNone(id1)
|
self.assertIsNotNone(id1)
|
||||||
mac1 = json_output.get('mac_address')
|
mac1 = json_output.get('mac_address')
|
||||||
self.assertIsNotNone(mac1)
|
self.assertIsNotNone(mac1)
|
||||||
self.addCleanup(self.openstack, 'port delete %s' % id1)
|
self.addCleanup(self.openstack, f'port delete {id1}')
|
||||||
self.assertEqual(self.NAME, json_output.get('name'))
|
self.assertEqual(self.NAME, json_output.get('name'))
|
||||||
|
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port create --network {} {}x'.format(
|
f'port create --network {self.NETWORK_NAME} {self.NAME}x',
|
||||||
self.NETWORK_NAME, self.NAME
|
|
||||||
),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
id2 = json_output.get('id')
|
id2 = json_output.get('id')
|
||||||
self.assertIsNotNone(id2)
|
self.assertIsNotNone(id2)
|
||||||
mac2 = json_output.get('mac_address')
|
mac2 = json_output.get('mac_address')
|
||||||
self.assertIsNotNone(mac2)
|
self.assertIsNotNone(mac2)
|
||||||
self.addCleanup(self.openstack, 'port delete %s' % id2)
|
self.addCleanup(self.openstack, f'port delete {id2}')
|
||||||
self.assertEqual(self.NAME + 'x', json_output.get('name'))
|
self.assertEqual(self.NAME + 'x', json_output.get('name'))
|
||||||
|
|
||||||
# Test list
|
# Test list
|
||||||
@ -120,7 +116,7 @@ class PortTests(common.NetworkTagTests):
|
|||||||
|
|
||||||
# Test list --mac-address
|
# Test list --mac-address
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port list --mac-address %s' % mac2,
|
f'port list --mac-address {mac2}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
item_map = {
|
item_map = {
|
||||||
@ -147,22 +143,22 @@ class PortTests(common.NetworkTagTests):
|
|||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port create '
|
'port create '
|
||||||
'--network %s '
|
f'--network {self.NETWORK_NAME} '
|
||||||
'--description xyzpdq '
|
'--description xyzpdq '
|
||||||
'--disable %s' % (self.NETWORK_NAME, name),
|
f'--disable {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
id1 = json_output.get('id')
|
id1 = json_output.get('id')
|
||||||
self.addCleanup(self.openstack, 'port delete %s' % id1)
|
self.addCleanup(self.openstack, f'port delete {id1}')
|
||||||
self.assertEqual(name, json_output.get('name'))
|
self.assertEqual(name, json_output.get('name'))
|
||||||
self.assertEqual('xyzpdq', json_output.get('description'))
|
self.assertEqual('xyzpdq', json_output.get('description'))
|
||||||
self.assertEqual(False, json_output.get('admin_state_up'))
|
self.assertEqual(False, json_output.get('admin_state_up'))
|
||||||
|
|
||||||
raw_output = self.openstack('port set --enable %s' % name)
|
raw_output = self.openstack(f'port set --enable {name}')
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port show %s' % name,
|
f'port show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
sg_id = json_output.get('security_group_ids')[0]
|
sg_id = json_output.get('security_group_ids')[0]
|
||||||
@ -178,7 +174,7 @@ class PortTests(common.NetworkTagTests):
|
|||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port show %s' % name,
|
f'port show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual([], json_output.get('security_group_ids'))
|
self.assertEqual([], json_output.get('security_group_ids'))
|
||||||
@ -186,19 +182,19 @@ class PortTests(common.NetworkTagTests):
|
|||||||
def test_port_admin_set(self):
|
def test_port_admin_set(self):
|
||||||
"""Test create, set (as admin), show, delete"""
|
"""Test create, set (as admin), show, delete"""
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port create ' '--network %s %s' % (self.NETWORK_NAME, self.NAME),
|
'port create ' f'--network {self.NETWORK_NAME} {self.NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
id_ = json_output.get('id')
|
id_ = json_output.get('id')
|
||||||
self.addCleanup(self.openstack, 'port delete %s' % id_)
|
self.addCleanup(self.openstack, f'port delete {id_}')
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'--os-username admin '
|
'--os-username admin '
|
||||||
'port set --mac-address 11:22:33:44:55:66 %s' % self.NAME
|
f'port set --mac-address 11:22:33:44:55:66 {self.NAME}'
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port show %s' % self.NAME,
|
f'port show {self.NAME}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(json_output.get('mac_address'), '11:22:33:44:55:66')
|
self.assertEqual(json_output.get('mac_address'), '11:22:33:44:55:66')
|
||||||
@ -207,39 +203,39 @@ class PortTests(common.NetworkTagTests):
|
|||||||
"""Test create, set, show, delete"""
|
"""Test create, set, show, delete"""
|
||||||
sg_name1 = uuid.uuid4().hex
|
sg_name1 = uuid.uuid4().hex
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'security group create %s' % sg_name1,
|
f'security group create {sg_name1}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
sg_id1 = json_output.get('id')
|
sg_id1 = json_output.get('id')
|
||||||
self.addCleanup(self.openstack, 'security group delete %s' % sg_id1)
|
self.addCleanup(self.openstack, f'security group delete {sg_id1}')
|
||||||
|
|
||||||
sg_name2 = uuid.uuid4().hex
|
sg_name2 = uuid.uuid4().hex
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'security group create %s' % sg_name2,
|
f'security group create {sg_name2}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
sg_id2 = json_output.get('id')
|
sg_id2 = json_output.get('id')
|
||||||
self.addCleanup(self.openstack, 'security group delete %s' % sg_id2)
|
self.addCleanup(self.openstack, f'security group delete {sg_id2}')
|
||||||
|
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port create '
|
'port create '
|
||||||
'--network %s '
|
f'--network {self.NETWORK_NAME} '
|
||||||
'--security-group %s %s' % (self.NETWORK_NAME, sg_name1, name),
|
f'--security-group {sg_name1} {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
id1 = json_output.get('id')
|
id1 = json_output.get('id')
|
||||||
self.addCleanup(self.openstack, 'port delete %s' % id1)
|
self.addCleanup(self.openstack, f'port delete {id1}')
|
||||||
self.assertEqual(name, json_output.get('name'))
|
self.assertEqual(name, json_output.get('name'))
|
||||||
self.assertEqual([sg_id1], json_output.get('security_group_ids'))
|
self.assertEqual([sg_id1], json_output.get('security_group_ids'))
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'port set ' '--security-group %s %s' % (sg_name2, name)
|
'port set ' f'--security-group {sg_name2} {name}'
|
||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port show %s' % name,
|
f'port show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(name, json_output.get('name'))
|
self.assertEqual(name, json_output.get('name'))
|
||||||
@ -256,15 +252,13 @@ class PortTests(common.NetworkTagTests):
|
|||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
json_output = self.openstack(
|
json_output = self.openstack(
|
||||||
'port show %s' % name,
|
f'port show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual([sg_id2], json_output.get('security_group_ids'))
|
self.assertEqual([sg_id2], json_output.get('security_group_ids'))
|
||||||
|
|
||||||
def _create_resource_for_tag_test(self, name, args):
|
def _create_resource_for_tag_test(self, name, args):
|
||||||
return self.openstack(
|
return self.openstack(
|
||||||
'{} create --network {} {} {}'.format(
|
f'{self.base_command} create --network {self.NETWORK_NAME} {args} {name}',
|
||||||
self.base_command, self.NETWORK_NAME, args, name
|
|
||||||
),
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
|
@ -275,17 +275,16 @@ class RouterTests(common.NetworkTagTests):
|
|||||||
subnet_name = uuid.uuid4().hex
|
subnet_name = uuid.uuid4().hex
|
||||||
router_name = uuid.uuid4().hex
|
router_name = uuid.uuid4().hex
|
||||||
|
|
||||||
self.openstack('network create %s' % network_name)
|
self.openstack(f'network create {network_name}')
|
||||||
self.addCleanup(self.openstack, 'network delete %s' % network_name)
|
self.addCleanup(self.openstack, f'network delete {network_name}')
|
||||||
|
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'subnet create %s '
|
f'subnet create {subnet_name} '
|
||||||
'--network %s --subnet-range 10.0.0.0/24'
|
f'--network {network_name} --subnet-range 10.0.0.0/24'
|
||||||
% (subnet_name, network_name)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.openstack('router create %s' % router_name)
|
self.openstack(f'router create {router_name}')
|
||||||
self.addCleanup(self.openstack, 'router delete %s' % router_name)
|
self.addCleanup(self.openstack, f'router delete {router_name}')
|
||||||
|
|
||||||
self.openstack(f'router add subnet {router_name} {subnet_name}')
|
self.openstack(f'router add subnet {router_name} {subnet_name}')
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
@ -295,24 +294,20 @@ class RouterTests(common.NetworkTagTests):
|
|||||||
|
|
||||||
out1 = (
|
out1 = (
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'router add route %s '
|
f'router add route {router_name} '
|
||||||
'--route destination=10.0.10.0/24,gateway=10.0.0.10'
|
'--route destination=10.0.10.0/24,gateway=10.0.0.10',
|
||||||
% router_name,
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.assertEqual(1, len(out1[0]['routes']))
|
self.assertEqual(1, len(out1[0]['routes']))
|
||||||
|
|
||||||
self.addCleanup(
|
self.addCleanup(self.openstack, f'router set {router_name} --no-route')
|
||||||
self.openstack, 'router set %s --no-route' % router_name
|
|
||||||
)
|
|
||||||
|
|
||||||
out2 = (
|
out2 = (
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'router add route %s '
|
f'router add route {router_name} '
|
||||||
'--route destination=10.0.10.0/24,gateway=10.0.0.10 '
|
'--route destination=10.0.10.0/24,gateway=10.0.0.10 '
|
||||||
'--route destination=10.0.11.0/24,gateway=10.0.0.11'
|
'--route destination=10.0.11.0/24,gateway=10.0.0.11',
|
||||||
% router_name,
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -320,10 +315,9 @@ class RouterTests(common.NetworkTagTests):
|
|||||||
|
|
||||||
out3 = (
|
out3 = (
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'router remove route %s '
|
f'router remove route {router_name} '
|
||||||
'--route destination=10.0.11.0/24,gateway=10.0.0.11 '
|
'--route destination=10.0.11.0/24,gateway=10.0.0.11 '
|
||||||
'--route destination=10.0.12.0/24,gateway=10.0.0.12'
|
'--route destination=10.0.12.0/24,gateway=10.0.0.12',
|
||||||
% router_name,
|
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -59,7 +59,7 @@ class ObjectTests(common.ObjectStoreTests):
|
|||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_show_fields(items, OBJECT_FIELDS)
|
self.assert_show_fields(items, OBJECT_FIELDS)
|
||||||
|
|
||||||
raw_output = self.openstack('object list %s' % self.CONTAINER_NAME)
|
raw_output = self.openstack(f'object list {self.CONTAINER_NAME}')
|
||||||
items = self.parse_listing(raw_output)
|
items = self.parse_listing(raw_output)
|
||||||
self.assert_table_structure(items, BASIC_LIST_HEADERS)
|
self.assert_table_structure(items, BASIC_LIST_HEADERS)
|
||||||
|
|
||||||
@ -69,15 +69,12 @@ class ObjectTests(common.ObjectStoreTests):
|
|||||||
tmp_file = 'tmp.txt'
|
tmp_file = 'tmp.txt'
|
||||||
self.addCleanup(os.remove, tmp_file)
|
self.addCleanup(os.remove, tmp_file)
|
||||||
self.openstack(
|
self.openstack(
|
||||||
'object save %s %s --file %s'
|
f'object save {self.CONTAINER_NAME} {object_file} --file {tmp_file}'
|
||||||
% (self.CONTAINER_NAME, object_file, tmp_file)
|
|
||||||
)
|
)
|
||||||
# TODO(stevemar): Assert returned fields
|
# TODO(stevemar): Assert returned fields
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'object save {} {} --file -'.format(
|
f'object save {self.CONTAINER_NAME} {object_file} --file -'
|
||||||
self.CONTAINER_NAME, object_file
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
self.assertEqual(raw_output, 'test content')
|
self.assertEqual(raw_output, 'test content')
|
||||||
|
|
||||||
@ -91,6 +88,6 @@ class ObjectTests(common.ObjectStoreTests):
|
|||||||
|
|
||||||
self.openstack(f'object create {self.CONTAINER_NAME} {object_file}')
|
self.openstack(f'object create {self.CONTAINER_NAME} {object_file}')
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'container delete -r %s' % self.CONTAINER_NAME
|
f'container delete -r {self.CONTAINER_NAME}'
|
||||||
)
|
)
|
||||||
self.assertEqual(0, len(raw_output))
|
self.assertEqual(0, len(raw_output))
|
||||||
|
@ -40,21 +40,15 @@ class BaseVolumeTests(base.TestCase):
|
|||||||
current_status = output['status']
|
current_status = output['status']
|
||||||
if current_status == desired_status:
|
if current_status == desired_status:
|
||||||
print(
|
print(
|
||||||
'{} {} now has status {}'.format(
|
f'{check_type} {check_name} now has status {current_status}'
|
||||||
check_type, check_name, current_status
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
print(
|
print(
|
||||||
'Checking {} {} Waiting for {} current status: {}'.format(
|
f'Checking {check_type} {check_name} Waiting for {desired_status} current status: {current_status}'
|
||||||
check_type, check_name, desired_status, current_status
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if current_status in failures:
|
if current_status in failures:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'Current status {} of {} {} is one of failures {}'.format(
|
f'Current status {current_status} of {check_type} {check_name} is one of failures {failures}'
|
||||||
current_status, check_type, check_name, failures
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
total_sleep += interval
|
total_sleep += interval
|
||||||
@ -72,15 +66,9 @@ class BaseVolumeTests(base.TestCase):
|
|||||||
if check_name not in names:
|
if check_name not in names:
|
||||||
print(f'{check_type} {check_name} is now deleted')
|
print(f'{check_type} {check_name} is now deleted')
|
||||||
return
|
return
|
||||||
print(
|
print(f'Checking {check_type} {check_name} Waiting for deleted')
|
||||||
'Checking {} {} Waiting for deleted'.format(
|
|
||||||
check_type, check_name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
total_sleep += interval
|
total_sleep += interval
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'Timeout: {} {} was not deleted in {} seconds'.format(
|
f'Timeout: {check_type} {check_name} was not deleted in {wait} seconds'
|
||||||
check_type, check_name, wait
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(self.NAME, cmd_output['name'])
|
self.assertEqual(self.NAME, cmd_output['name'])
|
||||||
@ -57,19 +57,19 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d %s' % name
|
f'volume type set --property a=b --property c=d {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack('volume type unset --property a %s' % name)
|
raw_output = self.openstack(f'volume type unset --property a {name}')
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
||||||
@ -84,21 +84,21 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d %s' % name
|
f'volume type set --property a=b --property c=d {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --property a --property c %s' % name
|
f'volume type unset --property a --property c {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({}, cmd_output['properties'])
|
self.assertEqual({}, cmd_output['properties'])
|
||||||
@ -106,9 +106,9 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
def test_multi_delete(self):
|
def test_multi_delete(self):
|
||||||
vol_type1 = uuid.uuid4().hex
|
vol_type1 = uuid.uuid4().hex
|
||||||
vol_type2 = uuid.uuid4().hex
|
vol_type2 = uuid.uuid4().hex
|
||||||
self.openstack('volume type create %s' % vol_type1)
|
self.openstack(f'volume type create {vol_type1}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
self.openstack('volume type create %s' % vol_type2)
|
self.openstack(f'volume type create {vol_type2}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cmd = f'volume type delete {vol_type1} {vol_type2}'
|
cmd = f'volume type delete {vol_type1} {vol_type2}'
|
||||||
raw_output = self.openstack(cmd)
|
raw_output = self.openstack(cmd)
|
||||||
|
@ -56,4 +56,4 @@ class VolumeBackupTests(common.BaseVolumeTests):
|
|||||||
self.wait_for_status(
|
self.wait_for_status(
|
||||||
"volume", backup_restored['volume_id'], "available"
|
"volume", backup_restored['volume_id'], "available"
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'volume delete %s' % vol_id)
|
self.addCleanup(self.openstack, f'volume delete {vol_id}')
|
||||||
|
@ -32,7 +32,7 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
@ -57,19 +57,19 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d %s' % name
|
f'volume type set --property a=b --property c=d {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack('volume type unset --property a %s' % name)
|
raw_output = self.openstack(f'volume type unset --property a {name}')
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
||||||
@ -84,21 +84,21 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d %s' % name
|
f'volume type set --property a=b --property c=d {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --property a --property c %s' % name
|
f'volume type unset --property a --property c {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({}, cmd_output['properties'])
|
self.assertEqual({}, cmd_output['properties'])
|
||||||
@ -112,22 +112,20 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.addCleanup(self.openstack, 'volume type delete ' + name)
|
self.addCleanup(self.openstack, 'volume type delete ' + name)
|
||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(f'volume type set --project admin {name}')
|
||||||
'volume type set --project admin %s' % name
|
|
||||||
)
|
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --project admin %s' % name
|
f'volume type unset --project admin {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
|
||||||
def test_multi_delete(self):
|
def test_multi_delete(self):
|
||||||
vol_type1 = uuid.uuid4().hex
|
vol_type1 = uuid.uuid4().hex
|
||||||
vol_type2 = uuid.uuid4().hex
|
vol_type2 = uuid.uuid4().hex
|
||||||
self.openstack('volume type create %s' % vol_type1)
|
self.openstack(f'volume type create {vol_type1}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
self.openstack('volume type create %s' % vol_type2)
|
self.openstack(f'volume type create {vol_type2}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cmd = f'volume type delete {vol_type1} {vol_type2}'
|
cmd = f'volume type delete {vol_type1} {vol_type2}'
|
||||||
raw_output = self.openstack(cmd)
|
raw_output = self.openstack(cmd)
|
||||||
|
@ -32,7 +32,7 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
@ -57,19 +57,19 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d %s' % name
|
f'volume type set --property a=b --property c=d {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack('volume type unset --property a %s' % name)
|
raw_output = self.openstack(f'volume type unset --property a {name}')
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
||||||
@ -84,21 +84,21 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type set --property a=b --property c=d %s' % name
|
f'volume type set --property a=b --property c=d {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --property a --property c %s' % name
|
f'volume type unset --property a --property c {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume type show %s' % name,
|
f'volume type show {name}',
|
||||||
parse_output=True,
|
parse_output=True,
|
||||||
)
|
)
|
||||||
self.assertEqual({}, cmd_output['properties'])
|
self.assertEqual({}, cmd_output['properties'])
|
||||||
@ -112,22 +112,20 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
|||||||
self.addCleanup(self.openstack, 'volume type delete ' + name)
|
self.addCleanup(self.openstack, 'volume type delete ' + name)
|
||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(f'volume type set --project admin {name}')
|
||||||
'volume type set --project admin %s' % name
|
|
||||||
)
|
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'volume type unset --project admin %s' % name
|
f'volume type unset --project admin {name}'
|
||||||
)
|
)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
|
|
||||||
def test_multi_delete(self):
|
def test_multi_delete(self):
|
||||||
vol_type1 = uuid.uuid4().hex
|
vol_type1 = uuid.uuid4().hex
|
||||||
vol_type2 = uuid.uuid4().hex
|
vol_type2 = uuid.uuid4().hex
|
||||||
self.openstack('volume type create %s' % vol_type1)
|
self.openstack(f'volume type create {vol_type1}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
self.openstack('volume type create %s' % vol_type2)
|
self.openstack(f'volume type create {vol_type2}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cmd = f'volume type delete {vol_type1} {vol_type2}'
|
cmd = f'volume type delete {vol_type1} {vol_type2}'
|
||||||
raw_output = self.openstack(cmd)
|
raw_output = self.openstack(cmd)
|
||||||
|
@ -135,16 +135,18 @@ class TestContainer(TestObjectAPIv1):
|
|||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
'GET',
|
'GET',
|
||||||
FAKE_URL
|
FAKE_URL
|
||||||
+ '?marker=%s&limit=1&format=json'
|
+ '?marker={}&limit=1&format=json'.format(
|
||||||
% LIST_CONTAINER_RESP[0]['name'],
|
LIST_CONTAINER_RESP[0]['name']
|
||||||
|
),
|
||||||
json=[LIST_CONTAINER_RESP[1]],
|
json=[LIST_CONTAINER_RESP[1]],
|
||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
'GET',
|
'GET',
|
||||||
FAKE_URL
|
FAKE_URL
|
||||||
+ '?marker=%s&limit=1&format=json'
|
+ '?marker={}&limit=1&format=json'.format(
|
||||||
% LIST_CONTAINER_RESP[1]['name'],
|
LIST_CONTAINER_RESP[1]['name']
|
||||||
|
),
|
||||||
json=[],
|
json=[],
|
||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
|
@ -109,12 +109,9 @@ class TestGroupAddUser(TestGroup):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.fail('CommandError should be raised.')
|
self.fail('CommandError should be raised.')
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
msg = "1 of 2 users not added to group %s." % self._group.name
|
msg = f"1 of 2 users not added to group {self._group.name}."
|
||||||
self.assertEqual(msg, str(e))
|
self.assertEqual(msg, str(e))
|
||||||
msg = ("%(user)s not added to group %(group)s: ") % {
|
msg = f"{self.users[0].name} not added to group {self._group.name}: "
|
||||||
'user': self.users[0].name,
|
|
||||||
'group': self._group.name,
|
|
||||||
}
|
|
||||||
mock_error.assert_called_once_with(msg)
|
mock_error.assert_called_once_with(msg)
|
||||||
|
|
||||||
|
|
||||||
@ -561,12 +558,9 @@ class TestGroupRemoveUser(TestGroup):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.fail('CommandError should be raised.')
|
self.fail('CommandError should be raised.')
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
msg = "1 of 2 users not removed from group %s." % self._group.id
|
msg = f"1 of 2 users not removed from group {self._group.id}."
|
||||||
self.assertEqual(msg, str(e))
|
self.assertEqual(msg, str(e))
|
||||||
msg = ("%(user)s not removed from group %(group)s: ") % {
|
msg = f"{self.users[0].id} not removed from group {self._group.id}: "
|
||||||
'user': self.users[0].id,
|
|
||||||
'group': self._group.id,
|
|
||||||
}
|
|
||||||
mock_error.assert_called_once_with(msg)
|
mock_error.assert_called_once_with(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,7 +256,6 @@ class TestMetadefObjectPropertyShow(fakes.TestImagev2):
|
|||||||
parsed_args,
|
parsed_args,
|
||||||
)
|
)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'Property %s not found in object %s.'
|
f'Property {parsed_args.property} not found in object {parsed_args.object}.',
|
||||||
% (parsed_args.property, parsed_args.object),
|
|
||||||
str(exc),
|
str(exc),
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@ from openstackclient.tests.unit import utils
|
|||||||
|
|
||||||
|
|
||||||
HOST = "192.168.5.41"
|
HOST = "192.168.5.41"
|
||||||
URL_BASE = "http://%s/identity" % HOST
|
URL_BASE = f"http://{HOST}/identity"
|
||||||
|
|
||||||
V2_AUTH_URL = URL_BASE + "/v2.0/"
|
V2_AUTH_URL = URL_BASE + "/v2.0/"
|
||||||
V2_VERSION_RESP = {
|
V2_VERSION_RESP = {
|
||||||
|
@ -903,9 +903,9 @@ class TestSetNetworkQosRuleMinimumBandwidth(TestNetworkQosRule):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
msg = (
|
msg = (
|
||||||
'Failed to set Network QoS rule ID "%(rule)s": Rule type '
|
f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
|
||||||
'"minimum-bandwidth" only requires arguments: direction, '
|
'"minimum-bandwidth" only requires arguments: direction, '
|
||||||
'min_kbps' % {'rule': self.new_rule.id}
|
'min_kbps'
|
||||||
)
|
)
|
||||||
self.assertEqual(msg, str(e))
|
self.assertEqual(msg, str(e))
|
||||||
|
|
||||||
@ -1007,9 +1007,9 @@ class TestSetNetworkQosRuleMinimumPacketRate(TestNetworkQosRule):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
msg = (
|
msg = (
|
||||||
'Failed to set Network QoS rule ID "%(rule)s": Rule type '
|
f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
|
||||||
'"minimum-packet-rate" only requires arguments: direction, '
|
'"minimum-packet-rate" only requires arguments: direction, '
|
||||||
'min_kpps' % {'rule': self.new_rule.id}
|
'min_kpps'
|
||||||
)
|
)
|
||||||
self.assertEqual(msg, str(e))
|
self.assertEqual(msg, str(e))
|
||||||
|
|
||||||
@ -1111,9 +1111,8 @@ class TestSetNetworkQosRuleDSCPMarking(TestNetworkQosRule):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
msg = (
|
msg = (
|
||||||
'Failed to set Network QoS rule ID "%(rule)s": Rule type '
|
f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
|
||||||
'"dscp-marking" only requires arguments: dscp_mark'
|
'"dscp-marking" only requires arguments: dscp_mark'
|
||||||
% {'rule': self.new_rule.id}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(msg, str(e))
|
self.assertEqual(msg, str(e))
|
||||||
|
|
||||||
@ -1249,7 +1248,7 @@ class TestSetNetworkQosRuleBandwidthLimit(TestNetworkQosRule):
|
|||||||
self.addCleanup(self._reset_direction, self.new_rule.direction)
|
self.addCleanup(self._reset_direction, self.new_rule.direction)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--%s' % direction,
|
f'--{direction}',
|
||||||
self.new_rule.qos_policy_id,
|
self.new_rule.qos_policy_id,
|
||||||
self.new_rule.id,
|
self.new_rule.id,
|
||||||
]
|
]
|
||||||
@ -1288,9 +1287,9 @@ class TestSetNetworkQosRuleBandwidthLimit(TestNetworkQosRule):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
msg = (
|
msg = (
|
||||||
'Failed to set Network QoS rule ID "%(rule)s": Rule type '
|
f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
|
||||||
'"bandwidth-limit" only requires arguments: direction, '
|
'"bandwidth-limit" only requires arguments: direction, '
|
||||||
'max_burst_kbps, max_kbps' % {'rule': self.new_rule.id}
|
'max_burst_kbps, max_kbps'
|
||||||
)
|
)
|
||||||
self.assertEqual(msg, str(e))
|
self.assertEqual(msg, str(e))
|
||||||
|
|
||||||
|
@ -143,13 +143,12 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
|
|||||||
"--parent-port",
|
"--parent-port",
|
||||||
self.new_trunk.port_id,
|
self.new_trunk.port_id,
|
||||||
"--subport",
|
"--subport",
|
||||||
'port=%(port)s,segmentation-type=%(seg_type)s,'
|
'port={port},segmentation-type={seg_type},'
|
||||||
'segmentation-id=%(seg_id)s'
|
'segmentation-id={seg_id}'.format(
|
||||||
% {
|
seg_id=subport['segmentation_id'],
|
||||||
'seg_id': subport['segmentation_id'],
|
seg_type=subport['segmentation_type'],
|
||||||
'seg_type': subport['segmentation_type'],
|
port=subport['port_id'],
|
||||||
'port': subport['port_id'],
|
),
|
||||||
},
|
|
||||||
self.new_trunk.name,
|
self.new_trunk.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -194,12 +193,11 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
|
|||||||
"--parent-port",
|
"--parent-port",
|
||||||
self.new_trunk.port_id,
|
self.new_trunk.port_id,
|
||||||
"--subport",
|
"--subport",
|
||||||
"port=%(port)s,segmentation-type=%(seg_type)s,"
|
"port={port},segmentation-type={seg_type},"
|
||||||
"segmentation-id=boom"
|
"segmentation-id=boom".format(
|
||||||
% {
|
seg_type=subport['segmentation_type'],
|
||||||
'seg_type': subport['segmentation_type'],
|
port=subport['port_id'],
|
||||||
'port': subport['port_id'],
|
),
|
||||||
},
|
|
||||||
self.new_trunk.name,
|
self.new_trunk.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -265,12 +263,10 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
|
|||||||
'--parent-port',
|
'--parent-port',
|
||||||
self.new_trunk.port_id,
|
self.new_trunk.port_id,
|
||||||
'--subport',
|
'--subport',
|
||||||
'segmentation-type=%(seg_type)s,'
|
'segmentation-type={seg_type},' 'segmentation-id={seg_id}'.format(
|
||||||
'segmentation-id=%(seg_id)s'
|
seg_id=subport['segmentation_id'],
|
||||||
% {
|
seg_type=subport['segmentation_type'],
|
||||||
'seg_id': subport['segmentation_id'],
|
),
|
||||||
'seg_type': subport['segmentation_type'],
|
|
||||||
},
|
|
||||||
self.new_trunk.name,
|
self.new_trunk.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -585,7 +581,7 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
|
|||||||
|
|
||||||
def _test_set_network_trunk_attr(self, attr, value):
|
def _test_set_network_trunk_attr(self, attr, value):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--%s' % attr,
|
f'--{attr}',
|
||||||
value,
|
value,
|
||||||
self._trunk[attr],
|
self._trunk[attr],
|
||||||
]
|
]
|
||||||
@ -674,13 +670,12 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
|
|||||||
subport = self._trunk['sub_ports'][0]
|
subport = self._trunk['sub_ports'][0]
|
||||||
arglist = [
|
arglist = [
|
||||||
'--subport',
|
'--subport',
|
||||||
'port=%(port)s,segmentation-type=%(seg_type)s,'
|
'port={port},segmentation-type={seg_type},'
|
||||||
'segmentation-id=%(seg_id)s'
|
'segmentation-id={seg_id}'.format(
|
||||||
% {
|
seg_id=subport['segmentation_id'],
|
||||||
'seg_id': subport['segmentation_id'],
|
seg_type=subport['segmentation_type'],
|
||||||
'seg_type': subport['segmentation_type'],
|
port=subport['port_id'],
|
||||||
'port': subport['port_id'],
|
),
|
||||||
},
|
|
||||||
self._trunk['name'],
|
self._trunk['name'],
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -732,12 +727,10 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
|
|||||||
subport = self._trunk['sub_ports'][0]
|
subport = self._trunk['sub_ports'][0]
|
||||||
arglist = [
|
arglist = [
|
||||||
'--subport',
|
'--subport',
|
||||||
'segmentation-type=%(seg_type)s,'
|
'segmentation-type={seg_type},' 'segmentation-id={seg_id}'.format(
|
||||||
'segmentation-id=%(seg_id)s'
|
seg_id=subport['segmentation_id'],
|
||||||
% {
|
seg_type=subport['segmentation_type'],
|
||||||
'seg_id': subport['segmentation_id'],
|
),
|
||||||
'seg_type': subport['segmentation_type'],
|
|
||||||
},
|
|
||||||
self._trunk['name'],
|
self._trunk['name'],
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -776,7 +769,8 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
|
|||||||
with testtools.ExpectedException(exceptions.CommandError) as e:
|
with testtools.ExpectedException(exceptions.CommandError) as e:
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Failed to set trunk '%s': " % self._trunk['name'], str(e)
|
"Failed to set trunk '{}': ".format(self._trunk['name']),
|
||||||
|
str(e),
|
||||||
)
|
)
|
||||||
attrs = {'name': 'reallylongname'}
|
attrs = {'name': 'reallylongname'}
|
||||||
self.network_client.update_trunk.assert_called_once_with(
|
self.network_client.update_trunk.assert_called_once_with(
|
||||||
@ -805,7 +799,9 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
|
|||||||
with testtools.ExpectedException(exceptions.CommandError) as e:
|
with testtools.ExpectedException(exceptions.CommandError) as e:
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Failed to add subports to trunk '%s': " % self._trunk['name'],
|
"Failed to add subports to trunk '{}': ".format(
|
||||||
|
self._trunk['name']
|
||||||
|
),
|
||||||
str(e),
|
str(e),
|
||||||
)
|
)
|
||||||
self.network_client.update_trunk.assert_called_once_with(self._trunk)
|
self.network_client.update_trunk.assert_called_once_with(self._trunk)
|
||||||
|
@ -179,7 +179,7 @@ class TestCreatePort(TestPort):
|
|||||||
'--mac-address',
|
'--mac-address',
|
||||||
'aa:aa:aa:aa:aa:aa',
|
'aa:aa:aa:aa:aa:aa',
|
||||||
'--fixed-ip',
|
'--fixed-ip',
|
||||||
'subnet=%s,ip-address=10.0.0.2' % self.fake_subnet.id,
|
f'subnet={self.fake_subnet.id},ip-address=10.0.0.2',
|
||||||
'--description',
|
'--description',
|
||||||
self._port.description,
|
self._port.description,
|
||||||
'--device',
|
'--device',
|
||||||
@ -866,7 +866,7 @@ class TestCreatePort(TestPort):
|
|||||||
'test-port',
|
'test-port',
|
||||||
]
|
]
|
||||||
if policy:
|
if policy:
|
||||||
arglist += ['--numa-policy-%s' % policy]
|
arglist += [f'--numa-policy-{policy}']
|
||||||
|
|
||||||
numa_affinity_policy = None if not policy else policy
|
numa_affinity_policy = None if not policy else policy
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -877,7 +877,7 @@ class TestCreatePort(TestPort):
|
|||||||
('name', 'test-port'),
|
('name', 'test-port'),
|
||||||
]
|
]
|
||||||
if policy:
|
if policy:
|
||||||
verifylist.append(('numa_policy_%s' % policy, True))
|
verifylist.append((f'numa_policy_{policy}', True))
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -1418,7 +1418,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
ip_address = self._ports[0].fixed_ips[0]['ip_address']
|
ip_address = self._ports[0].fixed_ips[0]['ip_address']
|
||||||
arglist = [
|
arglist = [
|
||||||
'--fixed-ip',
|
'--fixed-ip',
|
||||||
"ip-address=%s" % ip_address,
|
f"ip-address={ip_address}",
|
||||||
]
|
]
|
||||||
verifylist = [('fixed_ip', [{'ip-address': ip_address}])]
|
verifylist = [('fixed_ip', [{'ip-address': ip_address}])]
|
||||||
|
|
||||||
@ -1428,7 +1428,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
|
|
||||||
self.network_client.ports.assert_called_once_with(
|
self.network_client.ports.assert_called_once_with(
|
||||||
**{
|
**{
|
||||||
'fixed_ips': ['ip_address=%s' % ip_address],
|
'fixed_ips': [f'ip_address={ip_address}'],
|
||||||
'fields': LIST_FIELDS_TO_RETRIEVE,
|
'fields': LIST_FIELDS_TO_RETRIEVE,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -1439,7 +1439,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
ip_address_ss = self._ports[0].fixed_ips[0]['ip_address'][:-1]
|
ip_address_ss = self._ports[0].fixed_ips[0]['ip_address'][:-1]
|
||||||
arglist = [
|
arglist = [
|
||||||
'--fixed-ip',
|
'--fixed-ip',
|
||||||
"ip-substring=%s" % ip_address_ss,
|
f"ip-substring={ip_address_ss}",
|
||||||
]
|
]
|
||||||
verifylist = [('fixed_ip', [{'ip-substring': ip_address_ss}])]
|
verifylist = [('fixed_ip', [{'ip-substring': ip_address_ss}])]
|
||||||
|
|
||||||
@ -1449,7 +1449,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
|
|
||||||
self.network_client.ports.assert_called_once_with(
|
self.network_client.ports.assert_called_once_with(
|
||||||
**{
|
**{
|
||||||
'fixed_ips': ['ip_address_substr=%s' % ip_address_ss],
|
'fixed_ips': [f'ip_address_substr={ip_address_ss}'],
|
||||||
'fields': LIST_FIELDS_TO_RETRIEVE,
|
'fields': LIST_FIELDS_TO_RETRIEVE,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -1460,7 +1460,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
subnet_id = self._ports[0].fixed_ips[0]['subnet_id']
|
subnet_id = self._ports[0].fixed_ips[0]['subnet_id']
|
||||||
arglist = [
|
arglist = [
|
||||||
'--fixed-ip',
|
'--fixed-ip',
|
||||||
"subnet=%s" % subnet_id,
|
f"subnet={subnet_id}",
|
||||||
]
|
]
|
||||||
verifylist = [('fixed_ip', [{'subnet': subnet_id}])]
|
verifylist = [('fixed_ip', [{'subnet': subnet_id}])]
|
||||||
|
|
||||||
@ -1475,7 +1475,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
|
|
||||||
self.network_client.ports.assert_called_once_with(
|
self.network_client.ports.assert_called_once_with(
|
||||||
**{
|
**{
|
||||||
'fixed_ips': ['subnet_id=%s' % subnet_id],
|
'fixed_ips': [f'subnet_id={subnet_id}'],
|
||||||
'fields': LIST_FIELDS_TO_RETRIEVE,
|
'fields': LIST_FIELDS_TO_RETRIEVE,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -1505,8 +1505,8 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
self.network_client.ports.assert_called_once_with(
|
self.network_client.ports.assert_called_once_with(
|
||||||
**{
|
**{
|
||||||
'fixed_ips': [
|
'fixed_ips': [
|
||||||
'subnet_id=%s' % subnet_id,
|
f'subnet_id={subnet_id}',
|
||||||
'ip_address=%s' % ip_address,
|
f'ip_address={ip_address}',
|
||||||
],
|
],
|
||||||
'fields': LIST_FIELDS_TO_RETRIEVE,
|
'fields': LIST_FIELDS_TO_RETRIEVE,
|
||||||
}
|
}
|
||||||
@ -1519,9 +1519,9 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
ip_address = self._ports[0].fixed_ips[0]['ip_address']
|
ip_address = self._ports[0].fixed_ips[0]['ip_address']
|
||||||
arglist = [
|
arglist = [
|
||||||
'--fixed-ip',
|
'--fixed-ip',
|
||||||
"subnet=%s" % subnet_id,
|
f"subnet={subnet_id}",
|
||||||
'--fixed-ip',
|
'--fixed-ip',
|
||||||
"ip-address=%s" % ip_address,
|
f"ip-address={ip_address}",
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('fixed_ip', [{'subnet': subnet_id}, {'ip-address': ip_address}])
|
('fixed_ip', [{'subnet': subnet_id}, {'ip-address': ip_address}])
|
||||||
@ -1542,8 +1542,8 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
|
|||||||
self.network_client.ports.assert_called_once_with(
|
self.network_client.ports.assert_called_once_with(
|
||||||
**{
|
**{
|
||||||
'fixed_ips': [
|
'fixed_ips': [
|
||||||
'subnet_id=%s' % subnet_id,
|
f'subnet_id={subnet_id}',
|
||||||
'ip_address=%s' % ip_address,
|
f'ip_address={ip_address}',
|
||||||
],
|
],
|
||||||
'fields': LIST_FIELDS_TO_RETRIEVE,
|
'fields': LIST_FIELDS_TO_RETRIEVE,
|
||||||
}
|
}
|
||||||
@ -2360,11 +2360,11 @@ class TestSetPort(TestPort):
|
|||||||
|
|
||||||
def _test_create_with_numa_affinity_policy(self, policy):
|
def _test_create_with_numa_affinity_policy(self, policy):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--numa-policy-%s' % policy,
|
f'--numa-policy-{policy}',
|
||||||
self._port.id,
|
self._port.id,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('numa_policy_%s' % policy, True),
|
(f'numa_policy_{policy}', True),
|
||||||
(
|
(
|
||||||
'port',
|
'port',
|
||||||
self._port.id,
|
self._port.id,
|
||||||
|
@ -62,7 +62,7 @@ class TestCase(testtools.TestCase):
|
|||||||
|
|
||||||
if m.called:
|
if m.called:
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = 'method %s should not have been called' % m
|
msg = f'method {m} should not have been called'
|
||||||
self.fail(msg)
|
self.fail(msg)
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class TestCommand(TestCase):
|
|||||||
argparse.ArgumentError,
|
argparse.ArgumentError,
|
||||||
):
|
):
|
||||||
raise ParserException(
|
raise ParserException(
|
||||||
"Argument parse failed: %s" % stderr.getvalue()
|
f"Argument parse failed: {stderr.getvalue()}"
|
||||||
)
|
)
|
||||||
for av in verify_args:
|
for av in verify_args:
|
||||||
attr, value = av
|
attr, value = av
|
||||||
|
@ -6,7 +6,7 @@ quote-style = "preserve"
|
|||||||
docstring-code-format = true
|
docstring-code-format = true
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
select = ["E4", "E7", "E9", "F", "S"]
|
select = ["E4", "E7", "E9", "F", "S", "U"]
|
||||||
|
|
||||||
[tool.ruff.lint.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
"openstackclient/tests/*" = ["S"]
|
"openstackclient/tests/*" = ["S"]
|
||||||
|
Loading…
Reference in New Issue
Block a user