I needed to create ALOT of vservers in my lab based off of engineer phone extensions.
Engineers have 3 digit extensions, 123 for example. All engineers have extensions between 192-254 so this works as a lazy mans tool.
They get network vlans for their own use of 1230-1239. They are locked into 10.###.[0-9].0/24 for their network segments, so each engineer has plenty of network addresses to play with.
Im basically pre-injecting gateways and datastores into their network for the non-storage engineers.
They get vservers (SVM) on ###8 and ###9, with IPs 10.XXX.8.232 and 10.XXX.9.232.
So, this is my very quick, very ugly, powershell to do it.
It gets some SVM settings (which aggr the root vol is in) from an existing svm called “svm_lab_infra”.
I may or may not update this for iscsi, fc, and other junk. Or as a full svm cloner.
Also, many of these commandlets had no good examples searchable online, so I am helping this helps.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
param( [Parameter(Mandatory=$True)][UInt16] $eng_phone_ext, [Parameter(Mandatory=$True)][String] $eng_initials,[Bool]$make_vlans=$true, [String]$cluster_ip = "192.168.1.232", [String] $base_clone = "svm_lab_infra", [String] $ParentInterface="e1b" ) Import-module DataOnTap; "" connect-ncController $cluster_ip $ClusterNodes= get-ncClusterNode $new_vserver="svm_lab_"+$eng_initials+"_"+$eng_phone_ext ##//------- Create Vlans on clusters $Vlan_Eng8=($eng_phone_ext*10)+8 $Vlan_Eng9=($eng_phone_ext*10)+9 if($make_vlans){ ForEach ($Node in $ClusterNodes){ New-NcNetPortVlan -ParentInterface $ParentInterface -Node $Node.NodeName -VlanId $Vlan_Eng8 -ErrorAction Stop New-NcNetPortVlan -ParentInterface $ParentInterface -Node $Node.NodeName -VlanId $Vlan_Eng9 -ErrorAction Stop } } $base_vserver = get-ncvserver -vserver $base_clone $base_vol= $base_vserver | Get-NcVol -Name *_root $base_aggr= $base_vol.Aggregate $base_vserver_template = Get-NcVserver -Template $base_vserver_template.vserver = $base_vserver $base_vserver_query = get-ncvserver -Query $base_vserver_template $new_vserver_root=$new_vserver+"_root" new-ncvserver -name $new_vserver -RootVolume $new_vserver_root -RootVolumeAggregate $base_aggr -NameServerSwitch "file" -RootVolumeSecurityStyle "UNIX" -NameMappingSwitch "file" -Language "en_us.utf_8" Set-NcVserver $new_vserver -AllowedProtocols $base_vserver_query.AllowedProtocols get-ncvserver -Name $new_vserver | Add-ncnfsservice #//------- #Set context to new vserver $base_ds_vol_template = Get-NcVol -Template -Fill -VserverContext $base_vserver Initialize-NcObjectProperty $base_ds_vol_template VolumeStateAttributes $base_ds_vol_template.name="*svm_lab_infra_datastore*" $base_ds_vol=Get-NcVol -Query $base_ds_vol_template ##//------- Switch to vserver context $global:CurrentNcController.Vserver = $new_vserver #//------- Make new NFS Vol $new_vol_name=$new_vserver+"_datastore1" $new_vol_junction="/"+$new_vol_name Get-Ncvserver -Name $new_vserver | new-ncvol $new_vol_name -Aggregate $base_ds_vol.Aggregate -Size $base_ds_vol.TotalSize -JunctionPath $new_vol_junction #Enable DeDupe Enable-NcSis $new_vol_name | Out-Null #Thin Provision it. Set-ncVolOption $new_vol_name guarantee none | Out-Null #Snap Management Set-ncSnapshotAutodelete $new_vol_name state on | Out-Null Set-ncVolOption $new_vol_name try_first volume_grow | Out-Null #// ----- Add NFS export policy rule to allow everything (yeah, a security hole in my lab...) New-NcExportRule default -ClientMatch 0.0.0.0/0 -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor sys -SuperUserSecurityFlavor any -protocol NFS #Make Data LIFs for Engineers. Put it on a random node, just because it's lab and I don't care where they are put. Basically spread out my throughput. $LifNode=$ClusterNodes | Get-Random $Lif8Name=$new_vserver+"_"+$Vlan_Eng8+"_lif1" $Lif8Port=$ParentInterface+"-"+$Vlan_Eng8 $Lif8Address="10."+$eng_phone_ext+".8.232" New-NcNetInterface -Name $Lif8Name -Vserver $new_vserver -Role data -Node $LifNode.NodeName -Port $Lif8Port -Address $Lif8Address -Netmask 255.255.255.0 $Lif9Name=$new_vserver+"_"+$Vlan_Eng9+"_lif1" $Lif9Port=$ParentInterface+"-"+$Vlan_Eng9 $Lif9Address="10."+$eng_phone_ext+".9.232" New-NcNetInterface -Name $Lif9Name -Vserver $new_vserver -Role data -Node $LifNode.NodeName -Port $Lif9Port -Address $Lif9Address -Netmask 255.255.255.0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
PowerCLI Z:\u01\projects\NetApp> .\create_lab_svm.ps1 99 xyz Name Address Vserver Version ---- ------- ------- ------- 192.168.1.232 192.168.1.232 NetApp Release 8.2.1 Cluster-Mode: Fri Mar 21 18:39:00 PDT 2014 GvrpEnabled : InterfaceName : e1b-998 NcController : 192.168.1.232 Node : ha-cluster-01 ParentInterface : e1b Vlanid : 998 GvrpEnabledSpecified : False GvrpEnabled : InterfaceName : e1b-999 NcController : 192.168.1.232 Node : ha-cluster-01 ParentInterface : e1b Vlanid : 999 GvrpEnabledSpecified : False GvrpEnabled : InterfaceName : e1b-998 NcController : 192.168.1.232 Node : ha-cluster-02 ParentInterface : e1b Vlanid : 998 GvrpEnabledSpecified : False GvrpEnabled : InterfaceName : e1b-999 NcController : 192.168.1.232 Node : ha-cluster-02 ParentInterface : e1b Vlanid : 999 GvrpEnabledSpecified : False AggrList : AllowedProtocols : {nfs, cifs, fcp, iscsi...} AntivirusOnAccessPolicy : default Comment : DisallowedProtocols : IsRepositoryVserver : False Language : en_us.utf_8 LdapDomain : MaxVolumes : unlimited NameMappingSwitch : {file} NameServerSwitch : {file} NcController : 192.168.1.232 NisDomain : QosPolicyGroup : QuotaPolicy : default RootVolume : svm_lab_xyz_99_root RootVolumeAggregate : aggr1_c2_2tb_fp RootVolumeSecurityStyle : unix SnapshotPolicy : default State : running Uuid : 0b98dc23-32c4-11e4-92bf-123478563412 VserverAggrInfoList : VserverName : svm_lab_xyz_99 VserverType : data IsRepositoryVserverSpecified : True MaxVolumesSpecified : True Vserver : svm_lab_xyz_99 AggrList : AllowedProtocols : {nfs, cifs, fcp, iscsi...} AntivirusOnAccessPolicy : default Comment : DisallowedProtocols : IsRepositoryVserver : False Language : en_us.utf_8 LdapDomain : MaxVolumes : unlimited NameMappingSwitch : {file} NameServerSwitch : {file} NcController : 192.168.1.232 NisDomain : QosPolicyGroup : QuotaPolicy : default RootVolume : svm_lab_xyz_99_root RootVolumeAggregate : aggr1_c2_2tb_fp RootVolumeSecurityStyle : unix SnapshotPolicy : default State : running Uuid : 0b98dc23-32c4-11e4-92bf-123478563412 VserverAggrInfoList : VserverName : svm_lab_xyz_99 VserverType : data IsRepositoryVserverSpecified : True MaxVolumesSpecified : True Vserver : svm_lab_xyz_99 ChownMode : use_export_policy DefaultWindowsGroup : DefaultWindowsUser : EnableEjukebox : True IsMountRootonlyEnabled : True IsNfsAccessEnabled : True IsNfsRootonlyEnabled : False IsNfsv2Enabled : False IsNfsv3ConnectionDropEnabled : True IsNfsv3Enabled : True IsNfsv3FsidChangeEnabled : True IsNfsv40AclEnabled : False IsNfsv40Enabled : False IsNfsv40MigrationEnabled : False IsNfsv40ReadDelegationEnabled : False IsNfsv40ReferralsEnabled : False IsNfsv40ReqOpenConfirmEnabled : False IsNfsv40WriteDelegationEnabled : False IsNfsv41AclEnabled : False IsNfsv41AclPreserveEnabled : True IsNfsv41Enabled : False IsNfsv41MigrationEnabled : False IsNfsv41PnfsEnabled : True IsNfsv41PnfsStripedVolumesEnabled : False IsNfsv41ReadDelegationEnabled : False IsNfsv41ReferralsEnabled : False IsNfsv41StateProtectionEnabled : True IsNfsv41WriteDelegationEnabled : False IsNfsv4FsidChangeEnabled : True IsNfsv4NumericIdsEnabled : True IsQtreeExportEnabled : False IsValidateQtreeExportEnabled : True IsVstorageEnabled : False NcController : 192.168.1.232 Nfsv41ImplementationIdDomain : netapp.com Nfsv41ImplementationIdName : NetApp Release 8.2.1 Cluster-Mode Nfsv41ImplementationIdTime : 1395427140 Nfsv4AclMaxAces : 400 Nfsv4GraceSeconds : 45 Nfsv4IdDomain : defaultv4iddomain.com Nfsv4LeaseSeconds : 30 Nfsv4xSessionNumSlots : 180 Nfsv4xSessionSlotReplyCacheSize : 640 NtfsUnixSecurityOps : use_export_policy RpcsecCtxHigh : 0 RpcsecCtxIdle : 0 Vserver : svm_lab_xyz_99 EnableEjukeboxSpecified : True IsMountRootonlyEnabledSpecified : True IsNfsAccessEnabledSpecified : True IsNfsRootonlyEnabledSpecified : True IsNfsv2EnabledSpecified : True IsNfsv3ConnectionDropEnabledSpecified : True IsNfsv3EnabledSpecified : True IsNfsv3FsidChangeEnabledSpecified : True IsNfsv40AclEnabledSpecified : True IsNfsv40EnabledSpecified : True IsNfsv40MigrationEnabledSpecified : True IsNfsv40ReadDelegationEnabledSpecified : True IsNfsv40ReferralsEnabledSpecified : True IsNfsv40ReqOpenConfirmEnabledSpecified : True IsNfsv40WriteDelegationEnabledSpecified : True IsNfsv41AclEnabledSpecified : True IsNfsv41AclPreserveEnabledSpecified : True IsNfsv41EnabledSpecified : True IsNfsv41MigrationEnabledSpecified : True IsNfsv41PnfsEnabledSpecified : True IsNfsv41PnfsStripedVolumesEnabledSpecified : True IsNfsv41ReadDelegationEnabledSpecified : True IsNfsv41ReferralsEnabledSpecified : True IsNfsv41StateProtectionEnabledSpecified : True IsNfsv41WriteDelegationEnabledSpecified : True IsNfsv4FsidChangeEnabledSpecified : True IsNfsv4NumericIdsEnabledSpecified : True IsQtreeExportEnabledSpecified : True IsValidateQtreeExportEnabledSpecified : True IsVstorageEnabledSpecified : True Nfsv4AclMaxAcesSpecified : True Nfsv4GraceSecondsSpecified : True Nfsv4LeaseSecondsSpecified : True Nfsv4xSessionNumSlotsSpecified : True Nfsv4xSessionSlotReplyCacheSizeSpecified : True RpcsecCtxHighSpecified : True RpcsecCtxIdleSpecified : True GeneralAccess : True IsNfsv3 : True IsNfsv4 : False IsNfsv41 : False Name : svm_lab_xyz_99_datastore1 NcController : 192.168.1.232 Volume64bitUpgradeAttributes : VolumeAntivirusAttributes : DataONTAP.C.Types.Volume.VolumeAntivirusAttributes VolumeAutosizeAttributes : DataONTAP.C.Types.Volume.VolumeAutosizeAttributes VolumeCloneAttributes : VolumeDirectoryAttributes : DataONTAP.C.Types.Volume.VolumeDirectoryAttributes VolumeExportAttributes : DataONTAP.C.Types.Volume.VolumeExportAttributes VolumeFlexcacheAttributes : VolumeHybridCacheAttributes : DataONTAP.C.Types.Volume.VolumeHybridCacheAttributes VolumeIdAttributes : DataONTAP.C.Types.Volume.VolumeIdAttributes VolumeInfinitevolAttributes : VolumeInodeAttributes : DataONTAP.C.Types.Volume.VolumeInodeAttributes VolumeLanguageAttributes : DataONTAP.C.Types.Volume.VolumeLanguageAttributes VolumeMirrorAttributes : DataONTAP.C.Types.Volume.VolumeMirrorAttributes VolumePerformanceAttributes : DataONTAP.C.Types.Volume.VolumePerformanceAttributes VolumeQosAttributes : VolumeSecurityAttributes : DataONTAP.C.Types.Volume.VolumeSecurityAttributes VolumeSisAttributes : DataONTAP.C.Types.Volume.VolumeSisAttributes VolumeSnapshotAttributes : DataONTAP.C.Types.Volume.VolumeSnapshotAttributes VolumeSnapshotAutodeleteAttributes : DataONTAP.C.Types.Volume.VolumeSnapshotAutodeleteAttributes VolumeSpaceAttributes : DataONTAP.C.Types.Volume.VolumeSpaceAttributes VolumeStateAttributes : DataONTAP.C.Types.Volume.VolumeStateAttributes VolumeStripingAttributes : VolumeTransitionAttributes : DataONTAP.C.Types.Volume.VolumeTransitionAttributes VolumeVmAlignAttributes : Vserver : svm_lab_xyz_99 State : online TotalSize : 1099511627776 Used : 5 Available : 1044535898112 Dedupe : False FilesUsed : 96 FilesTotal : 31876689 Aggregate : aggr1_c2_2tb_fp JunctionPath : /svm_lab_xyz_99_datastore1 IsInfiniteVolume : False Address : 10.99.8.232 AddressFamily : ipv4 AdministrativeStatus : up Comment : CurrentNode : ha-cluster-01 CurrentPort : e1b-998 DataProtocols : {nfs, cifs, fcache} DnsDomainName : none FailoverGroup : system-defined FailoverPolicy : nextavail FirewallPolicy : data HomeNode : ha-cluster-01 HomePort : e1b-998 InterfaceName : svm_lab_xyz_99_998_lif1 IsAutoRevert : False IsHome : True IsIpv4LinkLocal : LifUuid : 126d0efd-32c4-11e4-92bf-123478563412 ListenForDnsQuery : False NcController : 192.168.1.232 Netmask : 255.255.255.0 NetmaskLength : 24 OperationalStatus : up Role : data RoutingGroupName : d10.99.8.0/24 UseFailoverGroup : system_defined Vserver : svm_lab_xyz_99 IsAutoRevertSpecified : True IsHomeSpecified : True IsIpv4LinkLocalSpecified : False ListenForDnsQuerySpecified : True NetmaskLengthSpecified : True OpStatus : up Address : 10.99.9.232 AddressFamily : ipv4 AdministrativeStatus : up Comment : CurrentNode : ha-cluster-01 CurrentPort : e1b-999 DataProtocols : {nfs, cifs, fcache} DnsDomainName : none FailoverGroup : system-defined FailoverPolicy : nextavail FirewallPolicy : data HomeNode : ha-cluster-01 HomePort : e1b-999 InterfaceName : svm_lab_xyz_99_999_lif1 IsAutoRevert : False IsHome : True IsIpv4LinkLocal : LifUuid : 129594bd-32c4-11e4-92bf-123478563412 ListenForDnsQuery : False NcController : 192.168.1.232 Netmask : 255.255.255.0 NetmaskLength : 24 OperationalStatus : up Role : data RoutingGroupName : d10.99.9.0/24 UseFailoverGroup : system_defined Vserver : svm_lab_xyz_99 IsAutoRevertSpecified : True IsHomeSpecified : True IsIpv4LinkLocalSpecified : False ListenForDnsQuerySpecified : True NetmaskLengthSpecified : True OpStatus : up #---------------------------- PowerCLI Z:\u01\projects\NetApp> Get-NcVserver Vserver State VserverType Comment ------- ----- ----------- ------- ha-cluster admin The administrative vserver. svm_lab_bmc_220 running data svm_lab_bvo_208 running data svm_lab_cve_222 running data svm_lab_infra running data svm_lab_jal_205 running data svm_lab_jke_210 running data svm_lab_jku_213 running data svm_lab_jpr_219 running data svm_lab_mfi_207 running data svm_lab_mlo_201 running data svm_lab_rbe_225 running data svm_lab_ron_214 running data svm_lab_ttt_253 running data svm_lab_xyz_99 running data TestVserver123 running data |
[asa]0735681007[/asa]