diff --git a/pynsot/commands/cmd_interfaces.py b/pynsot/commands/cmd_interfaces.py index 4b88c6d..0c95bb1 100644 --- a/pynsot/commands/cmd_interfaces.py +++ b/pynsot/commands/cmd_interfaces.py @@ -343,6 +343,58 @@ def addresses(ctx, *args, **kwargs): ) +@list.command() +@click.pass_context +def parent(ctx, *args, **kwargs): + """Get the parent Interface of an Interface.""" + callbacks.list_subcommand( + ctx, display_fields=VERBOSE_FIELDS, my_name=ctx.info_name + ) + + +@list.command() +@click.pass_context +def ancestors(ctx, *args, **kwargs): + """Recursively get all parents of an Interface.""" + callbacks.list_subcommand( + ctx, display_fields=DISPLAY_FIELDS, my_name=ctx.info_name + ) + + +@list.command() +@click.pass_context +def children(ctx, *args, **kwargs): + """Get immediate children of an Interface.""" + callbacks.list_subcommand( + ctx, display_fields=DISPLAY_FIELDS, my_name=ctx.info_name + ) + + +@list.command() +@click.pass_context +def descendants(ctx, *args, **kwargs): + """Recursively get all children of an Interface.""" + callbacks.list_subcommand( + ctx, display_fields=DISPLAY_FIELDS, my_name=ctx.info_name + ) + + +@list.command() +@click.pass_context +def root(ctx, *args, **kwargs): + """Get parent of all ancestors of an Interface.""" + callbacks.list_subcommand( + ctx, display_fields=VERBOSE_FIELDS, my_name=ctx.info_name + ) + +@list.command() +@click.pass_context +def siblings(ctx, *args, **kwargs): + """Get Interfaces with the same parent and device id as an Interface.""" + callbacks.list_subcommand( + ctx, display_fields=VERBOSE_FIELDS, my_name=ctx.info_name + ) + ASSIGNMENT_FIELDS = ( ('id', 'ID'), ('hostname', 'Device'),