Bump hacking

hacking 3.0.x is too old.

Change-Id: I24423a1524de2744c5bb96a0bd7b23d5592c97a0
This commit is contained in:
Takashi Kajinami 2024-01-17 01:31:30 +09:00
parent 167b07208d
commit c34fc8ae5d
8 changed files with 36 additions and 42 deletions

View File

@ -61,7 +61,7 @@ def get_hook_events(hc, stack_id, event_args, nested_depth=0,
resource_event_map[(e.stack_name, e.resource_name)] = e
elif e.resource_status_reason == hook_clear_event_reason:
if resource_event_map.get(stack_resource):
del(resource_event_map[(e.stack_name, e.resource_name)])
del resource_event_map[(e.stack_name, e.resource_name)]
return list(resource_event_map.values())
@ -84,9 +84,9 @@ def get_events(hc, stack_id, event_args, nested_depth=0,
return events
first_links = getattr(events[0], 'links', [])
root_stack_link = [l for l in first_links
if l.get('rel') == 'root_stack']
if root_stack_link:
root_stack_links = [link for link in first_links
if link.get('rel') == 'root_stack']
if root_stack_links:
# response has a root_stack link, indicating this is an API which
# supports nested_depth
return events
@ -152,8 +152,8 @@ def _get_nested_events(hc, nested_depth, stack_id, event_args):
def _get_stack_name_from_links(event):
links = dict((l.get('rel'),
l.get('href')) for l in getattr(event, 'links', []))
links = {link.get('rel'): link.get('href')
for link in getattr(event, 'links', [])}
href = links.get('stack')
if not href:
return
@ -197,8 +197,8 @@ def poll_for_events(hc, stack_name, action=None, poll_period=5, marker=None,
return False
phys_id = getattr(event, 'physical_resource_id', '')
links = dict((l.get('rel'),
l.get('href')) for l in getattr(event, 'links', []))
links = {link.get('rel'): link.get('href')
for link in getattr(event, 'links', [])}
stack_id = links.get('stack', phys_id).rsplit('/', 1)[-1]
return stack_id == phys_id

View File

@ -21,7 +21,7 @@ class ResourceDotInfo(object):
def __init__(self, res):
self.resource = res
links = {l['rel']: l['href'] for l in res.links}
links = {link['rel']: link['href'] for link in res.links}
self.nested_dot_id = self.dot_id(links.get('nested'), 'stack')
self.stack_dot_id = self.dot_id(links.get('stack'), 'stack')
self.res_dot_id = self.dot_id(links.get('self'))

View File

@ -126,17 +126,17 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
def link_formatter(links):
def format_link(l):
if 'rel' in l:
return "%s (%s)" % (l.get('href', ''), l.get('rel', ''))
def format_link(link):
if 'rel' in link:
return "%s (%s)" % (link.get('href', ''), link.get('rel', ''))
else:
return "%s" % (l.get('href', ''))
return '\n'.join(format_link(l) for l in links or [])
return "%s" % (link.get('href', ''))
return '\n'.join(format_link(link) for link in links or [])
def resource_nested_identifier(rsrc):
nested_link = [l for l in rsrc.links or []
if l.get('rel') == 'nested']
nested_link = [link for link in rsrc.links or []
if link.get('rel') == 'nested']
if nested_link:
nested_href = nested_link[0].get('href')
nested_identifier = nested_href.split("/")[-2:]
@ -204,11 +204,11 @@ class EventLogContext(object):
def get_stack_id():
if getattr(event, 'stack_id', None) is not None:
return event.stack_id
for l in getattr(event, 'links', []):
if l.get('rel') == 'stack':
if 'href' not in l:
for link in getattr(event, 'links', []):
if link.get('rel') == 'stack':
if 'href' not in link:
return None
stack_link = l['href']
stack_link = link['href']
return stack_link.split('/')[-1]
stack_id = get_stack_id()

View File

@ -64,26 +64,26 @@ class ListStackFailures(command.Command):
def _append_failed_resources(self, failures, resources, resource_path):
"""Recursively build list of failed resources."""
appended = False
for r in resources:
if not r.resource_status.endswith('FAILED'):
for rsc in resources:
if not rsc.resource_status.endswith('FAILED'):
continue
# determine if this resources is a nested stack
links_rel = list([l['rel'] for l in r.links])
links_rel = list([link['rel'] for link in rsc.links])
is_nested = 'nested' in links_rel
nested_appended = False
next_resource_path = list(resource_path)
next_resource_path.append(r.resource_name)
next_resource_path.append(rsc.resource_name)
if is_nested:
try:
nested_resources = self.heat_client.resources.list(
r.physical_resource_id)
rsc.physical_resource_id)
nested_appended = self._append_failed_resources(
failures, nested_resources, next_resource_path)
except exc.HTTPNotFound:
# there is a failed resource but no stack
pass
if not nested_appended:
failures['.'.join(next_resource_path)] = r
failures['.'.join(next_resource_path)] = rsc
appended = True
return appended

View File

@ -1051,7 +1051,7 @@ class ShellTestUserPass(ShellBase):
"resources": {'1': {'name': 'r1'}},
"creation_time": "2012-10-25T01:58:47Z",
"timeout_mins": timeout,
"disable_rollback": not(enable_rollback),
"disable_rollback": not enable_rollback,
"tags": tags
}}
self.mock_request_post('/stacks/preview', resp_dict,
@ -2729,11 +2729,9 @@ class ShellTestEventsNested(ShellBase):
def test_shell_nested_depth_invalid_value(self):
self.register_keystone_auth_fixture()
stack_id = 'teststack/1'
resource_name = 'aResource'
error = self.assertRaises(
exc.CommandError, self.shell,
'event-list {0} --nested-depth Z'.format(
stack_id, resource_name))
'event-list {0} --nested-depth Z'.format(stack_id))
self.assertIn('--nested-depth invalid value Z', str(error))
def test_shell_nested_depth_zero(self):

View File

@ -40,9 +40,9 @@ class Resource(base.Resource):
def stack_name(self):
if not hasattr(self, 'links'):
return
for l in self.links:
if l['rel'] == 'stack':
return l['href'].split('/')[-2]
for link in self.links:
if link['rel'] == 'stack':
return link['href'].split('/')[-2]
class ResourceManager(stacks.StackChildManager):

View File

@ -113,7 +113,7 @@ def do_stack_create(hc, args):
fields = {
'stack_name': args.name,
'disable_rollback': not(args.enable_rollback),
'disable_rollback': not args.enable_rollback,
'parameters': utils.format_all_parameters(args.parameters,
args.parameter_file,
args.template_file,
@ -201,7 +201,7 @@ def do_stack_adopt(hc, args):
fields = {
'stack_name': args.name,
'disable_rollback': not(args.enable_rollback),
'disable_rollback': not args.enable_rollback,
'adopt_stack_data': adopt_data,
'parameters': utils.format_parameters(args.parameters),
'files': files,
@ -262,7 +262,7 @@ def do_stack_preview(hc, args):
fields = {
'stack_name': args.name,
'disable_rollback': not(args.enable_rollback),
'disable_rollback': not args.enable_rollback,
'timeout_mins': args.timeout,
'parameters': utils.format_all_parameters(args.parameters,
args.parameter_file,
@ -543,7 +543,7 @@ def do_stack_update(hc, args):
except ValueError as ex:
raise exc.CommandError(str(ex))
else:
fields['disable_rollback'] = not(rollback)
fields['disable_rollback'] = not rollback
# TODO(pshchelo): remove the following 'else' clause after deprecation
# period of --enable-rollback switch and assign -r shortcut to --rollback
else:

View File

@ -1,9 +1,5 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8
hacking>=3.0.1,<3.1.0 # Apache-2.0
hacking>=6.1.0,<6.2.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
requests-mock>=1.2.0 # Apache-2.0