def _hook_poll(args, heat_client): """List resources with pending hook for a stack.""" # There are a few steps to determining if a stack has pending hooks # 1. The stack is IN_PROGRESS status (otherwise, by definition no hooks # can be pending # 2. There is an event for a resource associated with hitting a hook # 3. There is not an event associated with clearing the hook in step(2) # # So, essentially, this ends up being a specially filtered type of event # listing, because all hook status is exposed via events. In future # we might consider exposing some more efficient interface via the API # to reduce the expense of this brute-force polling approach columns = ['ID', 'Resource Status Reason', 'Resource Status', 'Event Time'] if args.nested_depth: try: nested_depth = int(args.nested_depth) except ValueError: msg = _("--nested-depth invalid value %s") % args.nested_depth raise exc.CommandError(msg) columns.append('Stack Name') else: nested_depth = 0 hook_type = hook_utils.get_hook_type_via_status(heat_client, args.stack) event_args = {'sort_dir': 'asc'} hook_events = event_utils.get_hook_events(heat_client, stack_id=args.stack, event_args=event_args, nested_depth=nested_depth, hook_type=hook_type) if len(hook_events) >= 1: if hasattr(hook_events[0], 'resource_name'): columns.insert(0, 'Resource Name') else: columns.insert(0, 'Logical Resource ID') rows = (utils.get_item_properties(h, columns) for h in hook_events) return (columns, rows)
def _hook_poll(args, heat_client): """List resources with pending hook for a stack.""" # There are a few steps to determining if a stack has pending hooks # 1. The stack is IN_PROGRESS status (otherwise, by definition no hooks # can be pending # 2. There is an event for a resource associated with hitting a hook # 3. There is not an event associated with clearing the hook in step(2) # # So, essentially, this ends up being a specially filtered type of event # listing, because all hook status is exposed via events. In future # we might consider exposing some more efficient interface via the API # to reduce the expense of this brute-force polling approach columns = ['ID', 'Resource Status Reason', 'Resource Status', 'Event Time'] if args.nested_depth: try: nested_depth = int(args.nested_depth) except ValueError: msg = _("--nested-depth invalid value %s") % args.nested_depth raise exc.CommandError(msg) columns.append('Stack Name') else: nested_depth = 0 hook_type = hook_utils.get_hook_type_via_status(heat_client, args.stack) event_args = {'sort_dir': 'asc'} hook_events = event_utils.get_hook_events( heat_client, stack_id=args.stack, event_args=event_args, nested_depth=nested_depth, hook_type=hook_type) if len(hook_events) >= 1: if hasattr(hook_events[0], 'resource_name'): columns.insert(0, 'Resource Name') else: columns.insert(0, 'Logical Resource ID') rows = (utils.get_item_properties(h, columns) for h in hook_events) return (columns, rows)