Merge pull request #5 from vmware/master

Update fork
This commit is contained in:
Kyle Ruddy
2019-11-18 19:06:54 -05:00
committed by GitHub
4 changed files with 111 additions and 12 deletions

View File

@@ -152,6 +152,8 @@ Function New-NSXTSegment {
This cmdlet creates a new NSX-T Segment (Logical Networks)
.EXAMPLE
New-NSXTSegment -Name "sddc-cgw-network-4" -Gateway "192.168.4.1/24" -DHCP -DHCPRange "192.168.4.2-192.168.4.254"
.EXAMPLE
New-NSXTSegment -Name "sddc-cgw-network-4" -Gateway "192.168.4.1/24" -DHCP -DHCPRange "192.168.4.2-192.168.4.254" -DomainName 'vmc.local'
.EXAMPLE
New-NSXTSegment -Name "sddc-cgw-network-5" -Gateway "192.168.5.1/24"
#>
@@ -159,6 +161,7 @@ Function New-NSXTSegment {
[Parameter(Mandatory=$True)]$Name,
[Parameter(Mandatory=$True)]$Gateway,
[Parameter(Mandatory=$False)]$DHCPRange,
[Parameter(Mandatory=$False)]$DomainName,
[Switch]$DHCP,
[Switch]$Troubleshoot
)
@@ -179,6 +182,11 @@ Function New-NSXTSegment {
display_name = $Name;
subnets = @($subnets)
}
if($DomainName) {
$payload.domain_name = $DomainName
}
$body = $payload | ConvertTo-Json -depth 4
$method = "PUT"
@@ -469,7 +477,7 @@ Function New-NSXTFirewall {
[Parameter(Mandatory=$False)]$SourceGroup,
[Parameter(Mandatory=$False)]$DestinationGroup,
[Parameter(Mandatory=$True)]$Service,
[Parameter(Mandatory=$True)][ValidateSet("ALLOW","DENY")]$Action,
[Parameter(Mandatory=$True)][ValidateSet("ALLOW","DROP")]$Action,
[Parameter(Mandatory=$false)]$InfraScope,
[Parameter(Mandatory=$false)]$SourceInfraGroup,
[Parameter(Mandatory=$false)]$DestinationInfraGroup,
@@ -746,18 +754,46 @@ Function New-NSXTGroup {
This cmdlet creates a new NSX-T Firewall Rule on MGW or CGW
.EXAMPLE
New-NSXTGroup -GatewayType MGW -Name Foo -IPAddress @("172.31.0.0/24")
.EXAMPLE
New-NSXTGroup -GatewayType CGW -Name Foo -Tag Bar
.EXAMPLE
New-NSXTGroup -GatewayType CGW -Name Foo -VmName Bar -Operator CONTAINS
.EXAMPLE
New-NSXTGroup -GatewayType CGW -Name Foo -VmName Bar -Operator STARTSWITH
#>
[CmdletBinding(DefaultParameterSetName = 'IPAddress')]
Param (
[Parameter(Mandatory=$True)]$Name,
[Parameter(Mandatory=$true)][ValidateSet("MGW","CGW")][String]$GatewayType,
[Parameter(Mandatory=$True)][String[]]$IPAddress,
[Parameter(Mandatory=$true, ParameterSetName='IPAddress')][String[]]$IPAddress,
[Parameter(Mandatory=$true, ParameterSetName='Tag')][String]$Tag,
[Parameter(Mandatory=$true, ParameterSetName='VmName')][String]$VmName,
[Parameter(Mandatory=$true, ParameterSetName='VmName')][ValidateSet('CONTAINS','STARTSWITH')][String]$Operator,
[Switch]$Troubleshoot
)
If (-Not $global:nsxtProxyConnection) { Write-error "No NSX-T Proxy Connection found, please use Connect-NSXTProxy" } Else {
$expression = @{
resource_type = "IPAddressExpression";
ip_addresses = $IPAddress;
if ($PSCmdlet.ParameterSetName -eq 'Tag') {
$expression = @{
resource_type = 'Condition'
member_type = 'VirtualMachine'
value = $Tag
key = 'Tag'
operator = 'EQUALS'
}
} elseif ($PSCmdlet.ParameterSetName -eq 'VmName') {
$expression = @{
resource_type = 'Condition'
member_type = 'VirtualMachine'
value = $VmName
key = 'Name'
operator = $Operator.ToUpper()
}
} else {
$expression = @{
resource_type = "IPAddressExpression";
ip_addresses = $IPAddress;
}
}
$payload = @{

View File

@@ -89,7 +89,7 @@ function Set-Title
$pcliModule = Get-Module -Name VMware.PowerCLI -ListAvailable |
Sort-Object -Property Version -Descending |
Select-Object -First 1
$pcli = " - PCLI: $($pcliModule.Version.ToString())"
$pcli = " - PCLI: $(if($pcliModule){$pcliModule.Version.ToString()}else{'na'})"
# If git is present and if in a git controlled folder, display repositoryname/current_branch
$gitStr = ''

View File

@@ -1,11 +1,11 @@
<#
.NOTES
===========================================================================
Created by: Alan Renouf
Organization: VMware
Blog: http://virtu-al.net
Twitter: @alanrenouf
===========================================================================
Created by: Alan Renouf
Organization: VMware
Blog: http://virtu-al.net
Twitter: @alanrenouf
===========================================================================
#>
Foreach ($vmhost in Get-VMHost) {
@@ -24,4 +24,4 @@ Foreach ($vmhost in Get-VMHost) {
$esxcli.nvme.device.feature.$feature.get.Invoke($currentfeature)
}
}
}
}

View File

@@ -0,0 +1,63 @@
<#
.NOTES
Script name: Set-ClusterDpm.ps1
Created on: 10/10/2019
Author: Doug Taliaferro, @virtually_doug
Description: Configures Distributed Power Management (DPM) on a cluster.
Dependencies: None known
===Tested Against Environment====
vSphere Version: 6.7
PowerCLI Version: 11.3.0
PowerShell Version: 5.1
OS Version: Windows 7, 10
Keyword: Cluster, DPM
.SYNOPSIS
Configures Distributed Power Management (DPM).
.DESCRIPTION
Enables/disables Distributed Power Management (DPM) for one or more clusters and optionally sets the automation level.
.PARAMETER Clusters
Specifies the name of the cluster(s) you want to configure.
.PARAMETER DpmEnabled
Indicates whether Distributed Power Management (DPM) should be enabled/disabled.
.PARAMETER DpmAutomationLevel
Specifies the Distributed Power Management (DPM) automation level. The valid values are 'automated' and 'manual'.
.EXAMPLE
Set-ClusterDpm -Cluster 'Cluster01' -DpmEnabled:$true
.EXAMPLE
Get-Cluster | Set-ClusterDpm -DpmEnabled:$true -DpmAutomationLevel 'automated'
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias('Name')]
[string[]]$Clusters,
[Parameter(Mandatory=$true)]
[bool]$DpmEnabled,
[Parameter(Mandatory = $false)]
[ValidateSet('automated','manual')]
[string]$DpmAutomationLevel
)
Begin {
# Create a configuration spec
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec.dpmConfig = New-Object VMware.Vim.ClusterDpmConfigInfo
$spec.dpmConfig.enabled = $DpmEnabled
if ($DpmAutomationLevel) {
$spec.dpmConfig.defaultDpmBehavior = $DpmAutomationLevel
}
}
Process {
ForEach ($cluster in $Clusters) {
# Configure the cluster
(Get-Cluster $cluster).ExtensionData.ReconfigureComputeResource_Task($spec, $true)
}
}