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

Added support for retrievel of firmware from an FTP server #519

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

andy-maier
Copy link
Member

@andy-maier andy-maier commented Nov 17, 2023

For details, see the commit message.
This PR has not been tested so far.

To try this version, install it from its branch:

pip install zhmccli@git+https://github.com/zhmcclient/zhmccli.git@andy/upgrade-ftp-retrieval

@andy-maier andy-maier self-assigned this Nov 17, 2023
@andy-maier andy-maier added this to the 1.10.0 milestone Nov 17, 2023
@andy-maier andy-maier force-pushed the andy/upgrade-ftp-retrieval branch from 9544fc0 to 8ab22fd Compare November 17, 2023 16:25
@coveralls
Copy link

coveralls commented Nov 17, 2023

Coverage Status

coverage: 37.054% (-0.09%) from 37.143%
when pulling 67f82f2 on andy/upgrade-ftp-retrieval
into 4fc2a3a on master.

zhmccli/_cmd_console.py Show resolved Hide resolved
zhmccli/_cmd_console.py Outdated Show resolved Hide resolved
format(c=cpc_name, bl=bundle_level, t=timeout))
format(c=cpc_name, bl=bundle_level, fw=fw_str, t=timeout))

kwargs = dict(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code duplication? could the two ifs go into a utility method?

Copy link
Member Author

@andy-maier andy-maier Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this comment is about the one "if" 5 lines down from the location you commented on, and the same "if" in the console module:

    if ftp_host:
        kwargs['ftp_host'] = ftp_host
        kwargs['ftp_protocol'] = options['ftp_protocol']
        kwargs['ftp_user'] = ftp_user
        kwargs['ftp_password'] = ftp_password
        kwargs['ftp_directory'] = options['ftp_directory']

I'm not enthusiastic about introducing a cross-module utility function in the helper module just for these 5 updates. It makes it more difficult to see what is going on.

Also, if you suspect a maintenance problem because these properties might change, then what makes you think that they could not change differently between HMC and CPC?

Finally, with 5 rather similar input parameters, the utility function would likely be invoked with keyword args to make sure there is no unintentional misordering of positional parameters, so the 6 lines shown above would become something like this:

    kwargs.update(ftp_kwargs(
        ftp_host=ftp_host,
        ftp_protocol=options['ftp_protocol'],
        ftp_user=ftp_user,
        ftp_password=ftp_password,
        ftp_directory=options['ftp_directory']))

And this hides the fact that the kwargs are only updated if ftp_host is set (which is what I meant when I said it is more difficult to see what is going on).

Also, even if a new parameter gets added to both the CPC and Console case in the future, both invocations need to be adjusted. The only small advantage of a utility function would be that the second adjustment could not be forgotten, if (!) the new parameter to the utility function has no default. And I'm not sure that's worth it.

PS: Would these 6 identical lines between the CPC and Console modules still count as a code duplication ? ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is "duplicated code" if there is a realistic chance that future changes would affect all those "copies".
In the end, it is your call to make ;-)

@andy-maier
Copy link
Member Author

andy-maier commented Nov 24, 2023

The bundle-level parameter is now optional. Support for this needs to be added.

Update: DONE

@andy-maier andy-maier force-pushed the andy/upgrade-ftp-retrieval branch from 8ab22fd to 3931bb6 Compare November 24, 2023 14:28
@andy-maier andy-maier force-pushed the andy/upgrade-ftp-retrieval branch 2 times, most recently from 44594c7 to 2edcd1a Compare November 24, 2023 15:26
@andy-maier andy-maier requested a review from EdGue42 November 24, 2023 15:31
Details:

* Added support for retrievel of firmware from an FTP server to the
  'cpc/console upgrade' commands. (issue #518)

Signed-off-by: Andreas Maier <[email protected]>
@andy-maier andy-maier force-pushed the andy/upgrade-ftp-retrieval branch from 2edcd1a to 67f82f2 Compare November 27, 2023 11:54
format(c=cpc_name, bl=bundle_level, t=timeout))
format(c=cpc_name, bl=bundle_level, fw=fw_str, t=timeout))

kwargs = dict(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is "duplicated code" if there is a realistic chance that future changes would affect all those "copies".
In the end, it is your call to make ;-)

@andy-maier andy-maier merged commit 3cca72e into master Dec 7, 2023
12 checks passed
@andy-maier andy-maier deleted the andy/upgrade-ftp-retrieval branch December 7, 2023 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for ftp retrieval parameters on console/CPC single step install operation
4 participants