Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Added storage group connection report #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions zhmccli/_cmd_storagegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,27 @@ def storagegroup_discover_fcp(cmd_ctx, storagegroup, **options):
lambda: cmd_storagegroup_discover_fcp(cmd_ctx, storagegroup, options))


@storagegroup_group.command(
'show_connections', options_metavar=COMMAND_OPTIONS_METAVAR)
@click.argument('STORAGEGROUP', type=str, metavar='STORAGEGROUP')
@click.pass_obj
def storagegroup_show_connections(cmd_ctx, storagegroup):
"""
Show the connection report for a storage group.

The connection report is updated when LUN discovery is performed. LUN
discovery for FCP storage groups is performed automatically based on
certain triggers, regularly every 10 minutes, and can manually be
triggered with the 'storagegroup dicover_fcp' command.

In addition to the command-specific options shown in this help text, the
general options (see 'zhmc --help') can also be specified right after the
'zhmc' command name.
"""
cmd_ctx.execute_cmd(
lambda: cmd_storagegroup_show_connections(cmd_ctx, storagegroup))


def cmd_storagegroup_list(cmd_ctx, options):
# pylint: disable=missing-function-docstring

Expand Down Expand Up @@ -748,3 +769,32 @@ def cmd_storagegroup_discover_fcp(cmd_ctx, stogrp_name, options):
cmd_ctx.spinner.stop()
click.echo("LUN discovery has been completed for FCP storage group '{sg}'.".
format(sg=stogrp_name))


def cmd_storagegroup_show_connections(cmd_ctx, stogrp_name):
# pylint: disable=missing-function-docstring

client = zhmcclient.Client(cmd_ctx.session)
stogrp = find_storagegroup(cmd_ctx, client, stogrp_name)

try:
report = stogrp.get_connection_report()
except zhmcclient.Error as exc:
raise click_exception(exc, cmd_ctx.error_format)

fabrics_report = report['fcp-fabrics']
subsystems_report = report['fcp-storage-subsystems']
scanned_dt = zhmcclient.datetime_from_timestamp(report['last-scan-time'])

cmd_ctx.spinner.stop()
click.echo("Connection report for storage group {sg}:".
format(sg=stogrp_name))
click.echo("Last scanned: {dt}".format(dt=scanned_dt))

for fabric in fabrics_report:
click.echo("\nFabric with ID {n}:".format(n=fabric['fabric-id']))
print_properties(cmd_ctx, fabric, cmd_ctx.output_format)

for subsystem in subsystems_report:
click.echo("\nStorage subsystem:")
print_properties(cmd_ctx, subsystem, cmd_ctx.output_format)