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

Dev/cloud vultr #58547

Merged
merged 9 commits into from Feb 9, 2021
Merged

Dev/cloud vultr #58547

merged 9 commits into from Feb 9, 2021

Conversation

richardsimko
Copy link
Contributor

@richardsimko richardsimko commented Sep 25, 2020

What does this PR do?

Improves the Vultr provider for Salt Cloud by adding options for firewallgroupid (#53677) and SSH keys.

What issues does this PR fix or reference?

Fixes: #53677

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

@richardsimko richardsimko marked this pull request as ready for review September 25, 2020 08:32
@richardsimko richardsimko requested a review from a team as a code owner September 25, 2020 08:32
@richardsimko richardsimko requested review from Ch3LL and removed request for a team September 25, 2020 08:32
@ghost ghost requested a review from twangboy September 25, 2020 08:32
Copy link
Contributor

@Ch3LL Ch3LL left a comment

Choose a reason for hiding this comment

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

Just a question and one change request. We will also need some test coverage for this change.

salt/cloud/clouds/vultrpy.py Outdated Show resolved Hide resolved
salt/cloud/clouds/vultrpy.py Outdated Show resolved Hide resolved
@richardsimko
Copy link
Contributor Author

Thanks for the feedback. As there are no test cases at all for the Vultr client and I don't feel comfortable taking full ownership over writing those it would be very hard to write tests exclusively covering this small change, which is why I left it out.

@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 7, 2020

Here's a test to help get you started:

(salt-3.7) ➜  salt git:(dev/cloud-vultr) ✗ cat tests/unit/cloud/clouds/test_vultr.py
# -*- coding: utf-8 -*-

# Import Salt Libs
from salt.cloud.clouds import vultrpy as vultr

# Import Salt Testing Libs
from tests.support.unit import TestCase
from tests.support.helpers import TstSuiteLoggingHandler


class VultrTestCase(TestCase):
    """
    Unit TestCase for salt.cloud.clouds.vultr module.
    """
    def test_show_keypair_no_keyname(self):
        """
        test salt.cloud.clouds.vultr.show_keypair
        when keyname is not in kwargs
        """
        kwargs = {}
        with TstSuiteLoggingHandler() as handler:
            assert not vultr.show_keypair(kwargs)
            assert "ERROR:A keyname is required." in handler.messages

Let me know if you need more direction to add test coverage for the rest of the code. Thanks :)

@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 7, 2020

Also to be clear you only need to add coverage for your change, not for the entire module.

@richardsimko
Copy link
Contributor Author

Thanks for the guidance. I added that and another test, however most of the added logic is in the create function which is not very testable, I don't see any of the other test providers having test coverage for this function either, probably due to the heavy coupling to other parts and the amount of mocking which would be required. Unless we completely rewrite it that will remain quite a challenge to be tested.

@richardsimko richardsimko force-pushed the dev/cloud-vultr branch 2 times, most recently from 7749c57 to cc69931 Compare October 9, 2020 11:39
@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 12, 2020

I can definitely help in writing a test for create. Can you just paste here what kind of information you would expect to find in ssh_key_names and firewall_group_id

@richardsimko
Copy link
Contributor Author

Thanks! Sure thing, ssh_key_names is a comma separated list like dev1,dev2,salt-master each representing an SSH public key which has been uploaded to Vultr and is installed on the VM when created. firewall_group_id is a string representing an ID of a firewall configuration in Vultr.

@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 20, 2020

Thanks, I've added this to my backlog. should be able to get to it by next week :)

@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 30, 2020

I will need to bump this to next week, apologies.

@richardsimko
Copy link
Contributor Author

No worries! We're not really using Vultr any more so this is more in the interest of getting it merged in case someone else uses it (Which I somewhat doubt since it's nigh on unusable without using SSH keys 😅 )

@Ch3LL
Copy link
Contributor

Ch3LL commented Nov 5, 2020

@richardsimko i went ahead and added a couple tests. Can you review and make sure the returns and args are all correct?

@richardsimko
Copy link
Contributor Author

@Ch3LL Sorry for the late reply, everything looks good to me! 🎉

Ch3LL
Ch3LL previously approved these changes Dec 4, 2020
@sagetherage sagetherage added Aluminium Release Post Mg and Pre Si Feature new functionality including changes to functionality and code refactors, etc. labels Dec 15, 2020
@sagetherage
Copy link
Contributor

Since this is feature can you also add a Release Notes, please?

s0undt3ch
s0undt3ch previously approved these changes Feb 9, 2021
@s0undt3ch s0undt3ch dismissed stale reviews from Ch3LL and themself via 55290cd February 9, 2021 07:00
@Ch3LL Ch3LL merged commit 43421f8 into saltstack:master Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aluminium Release Post Mg and Pre Si Feature new functionality including changes to functionality and code refactors, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

salt-cloud: vultr provider doesn't support "firewallgroupid" functionality
4 participants