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

Use __utils__ instead of salt.utils.cloud in opennebula driver #36070

Merged
merged 2 commits into from
Sep 8, 2016

Conversation

rallytime
Copy link
Contributor

What does this PR do?

In #35483, we switched to using __utils__['cloud.some_function'] instead of salt.utils.cloud.some_function. Some of the references were missed in the opennebula cloud driver. This PR fixes those references.

It also fixes up the from salt.utils import is_true references. Whenever we are using functions from salt.utils.__init__.py we need to import the whole module and reference functions explicitly. This PR changes the is_true references to salt.utils.is_true to match the salt.utils.fopen calls.

What issues does this PR fix or reference?

Fixes #36057

Previous Behavior

[ERROR   ] There was a profile error: global name '__opts__' is not defined
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/cloud/cli.py", line 284, in run
    self.config.get('names')
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1451, in run_profile
    ret[name] = self.create(vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1281, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/opennebula.py", line 956, in create
    ret = salt.utils.cloud.bootstrap(vm_, __opts__)
  File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 514, in bootstrap
    transport=opts.get('transport', 'zeromq')
  File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 1721, in fire_event
    sock_dir = os.path.join(__opts__['sock_dir'], 'master')
NameError: global name '__opts__' is not defined

New Behavior

Cleans up the stack trace and fixes the problem.

Tests written?

No

Please review Salt's Contributing Guide for best practices.

Also make sure to import salt.utils completely when using is_true and
fopen functions.
@rallytime
Copy link
Contributor Author

I need to backport this to 2015.8, too.

@rallytime rallytime added the bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch label Sep 6, 2016
@cachedout
Copy link
Contributor

@rallytime and @gtmanfred Could you please investigate the test failures here?

@cachedout cachedout added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Sep 7, 2016
@rallytime
Copy link
Contributor Author

The failing tests should be fixed now.

@rallytime rallytime removed the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Sep 7, 2016
@cachedout cachedout merged commit 70da628 into saltstack:2016.3 Sep 8, 2016
@cachedout
Copy link
Contributor

Thank you, @rallytime

@rallytime rallytime deleted the fix-36057 branch September 8, 2016 20:13
rallytime pushed a commit to rallytime/salt that referenced this pull request Sep 8, 2016
@rallytime rallytime added ZZZ[Done]-back-ported-bf RETIRED The pull request has been back-ported to an older branch. and removed bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch labels Sep 8, 2016
rallytime pushed a commit that referenced this pull request Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ZZZ[Done]-back-ported-bf RETIRED The pull request has been back-ported to an older branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants