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

Adding 'dist-upgrade' support to the zypper module #37088

Merged
merged 4 commits into from
Oct 20, 2016

Conversation

meaksh
Copy link
Contributor

@meaksh meaksh commented Oct 19, 2016

What does this PR do?

This PR adds dist-upgrade support for zypper pkg.upgrade. It allows you to perform dryrun upgrades, and also set fromrepo and novendorchange options when you're performing a system dist-upgrade.

If possible, this changes should also go everywhere 😄
Thanks!

Tests written?

Yes

/cc @isbm

# Creates a solver test case for debugging.
log.info('Executing debugsolver and performing a dry-run dist-upgrade')
cmd_debugsolver = cmd_update + ['--debug-solver']
__zypper__.noraise.call(*cmd_debugsolver)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not introduce another variable here just for sake to have it.

__zypper__.noraise.call(*cmd_update + ['--debug-solver'])

Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand this is an extra-call in case of dry-run, additionally to that one below, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's an extra call in case of dry-run.

if fromrepo:
fromrepoopt = ['--from', fromrepo]
log.info('Targeting repo {0!r}'.format(fromrepo))
cmd_update.extend(fromrepoopt)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer logger after everything. So after cmd_update....

cmd_update.extend(fromrepoopt)

if novendorchange:
log.info('Disabling changes of vendor')
Copy link
Contributor

Choose a reason for hiding this comment

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

This log message would be better after the cmd_update.

'''
ret = {'changes': {},
'result': True,
'comment': '',
}

cmd_update = ['dist-upgrade'] if dist_upgrade else ['update']
cmd_update.extend(['--auto-agree-with-licenses'])
Copy link
Contributor

Choose a reason for hiding this comment

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

No need in extra brackets and it can be shorter. This is sufficient:

cmd_update = (['dist-upgrade'] if dist_upgrade else ['update']) + ['--auto-agree-with-licenses']

if refresh:
refresh_db()

if dryrun:
cmd_update.extend(['--dry-run'])
Copy link
Contributor

Choose a reason for hiding this comment

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

No need extra brackets and .append() is just sufficient here.

Copy link
Contributor

@isbm isbm left a comment

Choose a reason for hiding this comment

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

Additionally to the above, please also take a look at this one.

self.assertFalse(ret['result'])
self.assertEqual(ret['comment'], zypper_out.strip())
self.assertDictEqual(ret['changes'], {})
zypper_mock.noraise.call.assert_called_with('dist-upgrade', '--auto-agree-with-licenses', '--from', 'DUMMY')
Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally to the previous things, I have no idea what had happened to your editor so the indentation went nuts. :-)

Copy link
Contributor

@isbm isbm left a comment

Choose a reason for hiding this comment

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

Seems OK now. Thanks!

@meaksh
Copy link
Contributor Author

meaksh commented Oct 19, 2016

Thanks for your suggestions @isbm !

Copy link
Contributor

@isbm isbm left a comment

Choose a reason for hiding this comment

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

Sorry. One more. :-)


if novendorchange:
cmd_update.append('--no-allow-vendor-change')
log.info('Disabling changes of vendor')
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, missed this one. "Disabling vendor changes" is probably more correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! Adding.. :-)

Copy link
Contributor

@isbm isbm left a comment

Choose a reason for hiding this comment

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

Cool, thanks!

@cachedout
Copy link
Contributor

Thanks to you both as always @meaksh and @isbm . You two are great!

@cachedout cachedout merged commit 3a37a22 into saltstack:2015.8 Oct 20, 2016
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.

None yet

3 participants