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

Test all parameters #11

Merged
merged 7 commits into from
Aug 21, 2015
Merged

Conversation

lorengordon
Copy link
Contributor

Previously, xIPAddress only checked whether the configured IP Address matched the IPAddress parameter. This pull request checks all parameters against the existing configuration.

Fixes #9

@msftclas
Copy link

msftclas commented Aug 7, 2015

Hi @lorengordon, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas
Copy link

msftclas commented Aug 7, 2015

@lorengordon, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@@ -134,48 +130,162 @@ function ValidateProperties

if(!([System.Net.Ipaddress]::TryParse($ip, [ref]0)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be changed to $IPAddress and the line above it $ip = $IPAddress should just be removed.

@tysonjhayes
Copy link
Collaborator

I'm not going to lie the more I dive into this the more frustrated I am with this resource. Your commits are great in that they are targeted to what you wanted to add in the given context, but it's making me believe a more fundemental rewrite is needed of this resource.

One of the things I would look to address is handling more then one IP address being returned. Even if it's just to throw and bail out.

@lorengordon
Copy link
Contributor Author

Sigh. I was really trying to scope my edits just enough to deal with my use case (plus compliance with style guide). Several of your comments are on bits that were in place previously. I can take a stab at a larger rewrite, but I won't be able to get to it for another week or two.

}

try
{
Write-Verbose -Message "Checking the IPAddress ..."
#Get the current IP Address based on the parameters given.
$currentIP = Get-NetIPAddress -InterfaceAlias $InterfaceAlias -AddressFamily $AddressFamily -ErrorAction Stop
$currentIP = Get-NetIPAddress -InterfaceAlias $InterfaceAlias -AddressFamily `
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually to fix the multiple IP addresses that could come back why don't we just add the IPAddress Parameter to this call? This would filter down to the one address that we're looking to manage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to break the use case where this resource is trying to change the IP address. Scoping only to the IP address we receive as a parameter will cause this call to return nothing. Which might be fine. I'll look at the subsequent checks and think about it some more.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In theory if the IP address doesn't exist are we actually in compliance? In theory we could design this resource to accept one IP and only one IP. If the IP doesn't exist, add it. If we're trying to change the IP we could call this resource twice (once with the Ensure = 'Absent') to remove the IP address we are looking to "change."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may be misunderstanding the comment, but this raises and interesting issue with state design. I don't always know the prior state, only what I want the state to be. I'm not necessarily intentionally changing the IP, I'm simply specifying the interface configuration I want, and I expect the resource to do all the work to make it so. If I have to know the prior state, then to me there's little benefit to using the stateful functions--I might as well just use the regular PowerShell commandlets.

@tysonjhayes
Copy link
Collaborator

I think it's fantastic that you are trying to scope your edits. That's really what we actually want. I'm frustrated at the design of this resource and think it might make more sense to take a step back and rethink it. You've done good work so far, don't let my comments disuade you of that!

@lorengordon
Copy link
Contributor Author

I can easily take care of the nits and add tests to make sure the mocks are called. Probably knock that out tomorrow afternoon.

I don't mind taking a stab at a larger rewrite of the resource, but I'd prefer to do that in another pull request, if that's alright with you.

@tysonjhayes
Copy link
Collaborator

That's great to me, if we're doing a larger rewrite we'll want more eyes on it anyway. 👍

@lorengordon
Copy link
Contributor Author

Alright, I fixed the nits, added tests to ensure the mocks are called, and I studied the data model for Get-NetIPAddress and Get-NetRoute to try to better support cases where multiple IP addresses or default gateways are present. The behavior currently only supports managing a single IP and gateway -- meaning that any other IP or gateway associated with that interface will be removed. However, I added a switch $NoReset that is internal only for now (pending the larger rewrite), which we can expose later to support managing multiple IP addresses or gateways on one interface. If $NoReset=$true, then other IP addresses or gateways should be left alone.

@tysonjhayes
Copy link
Collaborator

@lorengordon This looks pretty good to me, they've given me merge powers, any objections to merging this? I'm going to open some discussions on where we want to take this resource with some of my ideas early next week so let's hold off on any major rewrites.

@lorengordon
Copy link
Contributor Author

@tysonjhayes, no objections. :shipit: 😁

@lorengordon
Copy link
Contributor Author

Oh geez, this is embarrassing, I left a few write-verbose statements in there from when I was checking the behavior around the NoReset flag. I'll clean that up really quick...

@lorengordon
Copy link
Contributor Author

Ok, all better.

@tysonjhayes
Copy link
Collaborator

haha. Totally missed those when I looked. Good catch. 🚢

tysonjhayes pushed a commit that referenced this pull request Aug 21, 2015
@tysonjhayes tysonjhayes merged commit d45a86c into dsccommunity:dev Aug 21, 2015
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.

3 participants