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

Get-/Set-DbaNetworkConfiguration - New commands for managing network configuration of instance #7376

Merged
merged 23 commits into from
May 31, 2021

Conversation

andreasjordan
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes Set-dbatcpport static port incorrect #3170, fixes Enable/Disable Client/Server Protocol #5327 )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

General commands that get or set the network configuration like SQL Server Configuration Manager does.

At the moment, this is just a first concept and I would like to have feedback about it.

@andreasjordan
Copy link
Contributor Author

How to use the commands:

$netconf = Get-DbaNetworkConfiguration -SqlInstance SRV1\SQL2017 
$netconf.SharedMemoryEnabled = $false
$netconf.TCPIPProtokoll.KeepAlive = 20000
$netconf.TCPIPIPAddresses.Where({$_.Name -eq 'IPAll'})[0].TCPDynamicPorts = ''
$netconf.TCPIPIPAddresses.Where({$_.Name -eq 'IPAll'})[0].TCPPort = '12345' 
$netconf | Set-DbaNetworkConfiguration

@potatoqualitee
Copy link
Member

I like it! Can we cover 1-3 common scenarios in the params for Set-DbaNetworkConfiguration? Like -TCPPort or something? Open to the answer being no.

@potatoqualitee
Copy link
Member

Oh, I just realized this has the .Where( method. That is only PS4+ compat and we support 3+.

@andreasjordan
Copy link
Contributor Author

I can rewrite this - just wanted to play a bit with that syntax style.
Will think about some common scenarios, already some in mind.

@andreasjordan
Copy link
Contributor Author

Hooray, all tests are green!
@potatoqualitee Please have a look if this is the functionality you have been looking for. And then please have a look at the documentation and all the messages - you know, I'm not a nativ english speaking person.

@andreasjordan andreasjordan marked this pull request as ready for review May 27, 2021 20:41
Copy link
Member

@wsmelton wsmelton left a comment

Choose a reason for hiding this comment

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

@jpomfret the test for these commands should be included in the service_restart list so they do not adversely affect the other test groups since they change the network configuration of the instance in Appveyor.

functions/Set-DbaNetworkConfiguration.ps1 Outdated Show resolved Hide resolved
functions/Set-DbaNetworkConfiguration.ps1 Outdated Show resolved Hide resolved
functions/Set-DbaNetworkConfiguration.ps1 Outdated Show resolved Hide resolved
functions/Set-DbaNetworkConfiguration.ps1 Outdated Show resolved Hide resolved
functions/Set-DbaNetworkConfiguration.ps1 Outdated Show resolved Hide resolved
tests/Set-DbaNetworkConfiguration.Tests.ps1 Outdated Show resolved Hide resolved
tests/Set-DbaNetworkConfiguration.Tests.ps1 Outdated Show resolved Hide resolved
tests/Set-DbaNetworkConfiguration.Tests.ps1 Outdated Show resolved Hide resolved
tests/Set-DbaNetworkConfiguration.Tests.ps1 Outdated Show resolved Hide resolved
tests/Set-DbaNetworkConfiguration.Tests.ps1 Outdated Show resolved Hide resolved
@andreasjordan
Copy link
Contributor Author

Hi @wsmelton : Thanks for the review. Next time you can just say: "Grab a dictionary and have a look at protocol" - would save you a lot of time. I accepted all of you changes, thank you very much.

@andreasjordan
Copy link
Contributor Author

andreasjordan commented May 30, 2021

Let me copy that here:

These commands use Invoke-ManagedComputerCommand with -ArgumentList, so we have to make sure that the change from [string[]] to [object[]] has no negative effect.
Marked commands have been tested and alle commands have been code reviewed for only using strings in -ArgumentList:
[x] Enable-DbaAgHadr
[x] Disable-DbaAgHadr
[x] Get-DbaStartupParameter
[ ] Set-DbaStartupParameter
[x] Get-DbaTcpPort
[x] Test-DbaSpn
[ ] Update-DbaServiceAccount
[ ] Get-WmiHadr

This command needed to be changed, see next commit:
Set-DbaTcpPort

@andreasjordan
Copy link
Contributor Author

Thanks again Shawn for the hint, good we found this before the rollout.
Shall we rewrite Set-DbaTcpPort to use Set-DbaNetworkConfiguration within this pull request?
And maybe even rewrite Get-DbaTcpPort? The first approch is a bit strange, I would prefer to use Get-DbaNetworkConfiguration.
But it would be ok for me to first release DbaNetworkConfiguration and let some people use it and then later rewrite DbaTcpPort.

@wsmelton
Copy link
Member

wsmelton commented May 30, 2021

No problems from me for reusing code for network config in other commands. I'd say rewrite them all to use the get network command if it fits and simplifies the other commands; gives us one place to manage it instead of across all of them.

This PR can be released first though, and then PR(s) the changes for the other commands.

// @potatoqualitee @jpomfret

@potatoqualitee
Copy link
Member

agreed, will be able to merge then can create another PR 🙇🏼 Thank you both!

@andreasjordan
Copy link
Contributor Author

So yes, this PR can be merged, I have stopped working on this.

@potatoqualitee potatoqualitee merged commit 8eb88e6 into development May 31, 2021
@potatoqualitee potatoqualitee deleted the DbaNetworkConnection branch May 31, 2021 09:21
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.

Enable/Disable Client/Server Protocol Set-dbatcpport static port incorrect
3 participants