<# This script collects cm_storage data by connecting directly to clusters. Only limited information is collected This script is not officially supported by NetApp, communities support only, report feedback to Tim.Kleingeld@netapp.com. WARNING: This datasource has been built against WFA 3.1RC1 and may not work correctly against future versions. Take care when upgrading WFA. Requirements: Credentials for clusters must be configured in credentials HostName should be a comma separated list of cluster names or cluster management addresses User name can contain a comma separated list of flags: - debug - log more verbosely into the log file - log= - Location of log - nostrict - don't abort on failure - strict - abort if there is any failure (by default failures other than missing credentials are ignored) Data *not* collected: resource_group, resource_group_member, resource_pool, resource_pool_member VERSION-HISTORY: 1.0.2 - DAK - applied labeled fixes to correct missing broadcast_domain_id in "failover_group" and "port" #> $ClusterList = Get-WfaRestParameter "host" $creds = Get-WfaCredentials $Flags = $creds.UserName $log = "..\..\log\direct_cm_storage.log" $debug = $False $strict = $False $timeout = 180000 $clusters = $ClusterList -split "," if ($clusters -eq $null -or $clusters.length -eq 0) { throw "Failed to get cluster list - have you added any clusters?" } if ($clusters.length -eq 1) { # Always be strict if there is only one cluster $strict = $True } $Flags -split "," | % { if ($_ -eq "debug") { $debug = $True } if ($_ -eq "strict") { $strict = $True } if ($_ -eq "nostrict") { $strict = $False } if ($_ -match '^log=(.*)$') { $log = $matches[1] } if ($_ -match '^timeout=(\d*)$') { $timeout = [int64]($matches[1]) } } # Ensure that dates are always returned in English [System.Threading.Thread]::CurrentThread.CurrentCulture="en-US" Function doLog ($logString, $debugFlag) { $global:lastlog = $logString if ($debugFlag -and -not $debug) { return } $date = Get-Date Add-Content $log "$($date): $logString" } doLog "Started with arrays='$ClusterList' flags='$Flags'" # Create the output files Function outputFile ($name, $data) { $file = "./$name.csv" New-Item -Path $file -type file -force $fields = $schemaFields[$name] $keys = @( $data.get_keys() ) # Add-Content $file ([byte[]][char[]] (($fields -join "`t")+"`n")) -Encoding Byte $keys | % { $key = $_ $row = $data[$_] $line = @() $fields | % { $d = $row[$_] if ($d -eq $null) { $line += '\N' } else { $val = $d -replace '\\', '\\' $line += $val -replace "`t", " " } } try { Add-Content $file ([byte[]][char[]] (($line -join "`t")+"`n")) -Encoding Byte } catch { doLog $("Failed to write entry to $file due to non-ascii character: $_ - content is: " + ($line -join "\t")) if ($strict) { throw $("Failed to write entry to $file due to non-ascii character: $_ - content is: " + ($line -join "\t")) } } } } Function getId ($type, $key) { $id = $currentIds[$type][$key] if (!$id) { $global:maxId++ $id = $global:maxId $currentIds[$type][$key] = $id } return $id } Function bool ($value) { if ($value -and "$value" -ne "false") { return 1 } return 0 } $schemaFields = @{ "aggregate" = @("id,node_id,name,size_mb,used_size_mb,available_size_mb,raid_type,raid_status,block_type,state,number_of_disks,volume_count,is_hybrid,hybrid_enabled,hybrid_cache_size_mb,snapshot_total_size_mb,snapshot_used_size_mb,has_local_root,has_partner_root,daily_growth_rate_mb,days_until_full" -split ","); "broadcast_domain" = @("id,name,ipspace_id,mtu" -split ","); "cifs_share" = @("id,name,path,vserver_id,comment,share_properties" -split ","); "cifs_share_acl" = @("id,cifs_share_id,user_or_group,access_level" -split ","); "cluster" = @("id,admin_vserver_id,name,location,primary_address,uuid,serial_number,version,is_metrocluster,mt_configuration_state,mt_mode" -split ","); "cluster_license" = @("id,cluster_id,license" -split ","); "cluster_peer" = @("id,primary_cluster_id,peer_cluster_id,cluster_uuid,peer_addresses,availability,active_addresses,serial_number,remote_cluster_nodes,is_cluster_healthy,unreachable_local_nodes,address_family,auth_status_admin,auth_status_operational,ipspace_id" -split ","); "disk" = @("id,name,uid,type,rpm,home_node_id,owner_node_id,model,serial_number,size_mb,shelf,shelf_bay,pool,vendor,raid_position,container_type,cluster_id" -split ","); "disk_aggregate" = @("id,disk_id,aggregate_id" -split ","); "efficiency_policy" = @("id,name,vserver_id,schedule_id,enabled,comment,duration,qos_policy" -split ","); "export_policy" = @("id,name,vserver_id" -split ","); "export_rule" = @("id,clientmatch,policy_id,protocol,ro_rule,rule_index,rw_rule,super_user" -split ","); "failover_group" = @("id,name,cluster_id,broadcast_domain_id" -split ","); "fcp_adapter" = @("id,name,world_wide_node_name,world_wide_port_name,max_speed,physical_protocol,media_type,switch_port,status,node_id" -split ","); "igroup" = @("id,initiators,name,os_type,portset_id,protocol,vserver_id" -split ","); "ipspace" = @("id,name,cluster_id" -split ","); "logical_interface" = @("id,vserver_id,name,role,home_port_id,current_port_id,status,address,netmask,protocols,failover_group,failover_policy,fcp_adapter_id,netmask_length,is_dns_update_enabled,listen_for_dns_query" -split ","); "lun" = @("id,name,os_type,prefix_size,size_mb,space_reserved,qtree_id,volume_id,vserver_id,full_path,is_online,space_alloc_enabled,serial_number,alignment,comment,qos_policy_group_id" -split ","); "lunmap" = @("id,lun_id,igroup_id,lun_map_value" -split ","); "node" = @("id,cluster_id,ha_partner_id,node_vserver_id,name,primary_address,model,serial_number,system_id,os_version,owner,location,product_type,failover_enabled,takeover_possible,failover_state,memory_size_mb,flash_device_count,is_flash_optimized" -split ","); "port" = @("id,name,node_id,type,role,operational_status,mtu,ifgrp_port_id,operational_speed,vlan_id,vlan_port_id,broadcast_domain_id" -split ","); "portset" = @("id,name,type,vserver_id" -split ","); "portset_member" = @("id,portset_id,logical_interface_id" -split ","); "qos_policy_group" = @("id,name,vserver_id,class,max_throughput_limit" -split ","); "qtree" = @("id,name,oplock_mode,path,security_style,volume_id,disk_limit_mb,disk_soft_limit_mb,files_limit,soft_files_limit,threshold_mb,disk_used_mb" -split ","); "resource_group" = @("id,dfm_name,name,parent_group_id,uuid" -split ","); "resource_group_member" = @("id,aggregate_id,cluster_id,group_id,uuid,volume_id,vserver_id" -split ","); "resource_pool" = @("id,name,description,uuid" -split ","); "resource_pool_member" = @("id,resource_pool_id,aggregate_id" -split ","); "schedule" = @("id,name,cluster_id,description,type,cron_days_of_month,cron_days_of_week,cron_hours,cron_minutes,cron_months,interval_days,interval_hours,interval_minutes,interval_seconds" -split ","); "snapmirror" = @("id,secondary_volume_id,tries,type,volume_id,max_transfer_rate,snapmirror_policy_id,schedule_id,state,relationship_identifier,vserver_snapmirror_id" -split ","); "snapmirror_policy" = @("id,name,vserver_id,comment,transfer_priority,restart,tries,ignore_atime,type" -split ","); "snapmirror_policy_rule" = @("id,snapmirror_label,snapmirror_policy_id,keep,preserve,warn" -split ","); "snapmirror_svm" = @("id,tries,type,destination_vserver_id,max_transfer_rate,snapmirror_policy_id,schedule_id,state,relationship_identifier,source_vserver_id" -split ","); "snapshot_policy" = @("id,cluster_id,vserver_id,comment,enabled,name" -split ","); "snapshot_policy_schedule" = @("id,schedule_id,snapshot_count,snapshot_prefix,snapmirror_label,snapshot_policy_id" -split ","); "storage_pool" = @("id,name,cluster_id,allocation_unit_size_mb,pool_usable_size_mb,pool_total_size_mb,storage_type,disk_count" -split ","); "storage_pool_aggregate" = @("id,storage_pool_id,aggregate_id,used_capacity_mb" -split ","); "storage_pool_available" = @("id,storage_pool_id,node_id,allocation_unit_count,available_size_mb" -split ","); "volume" = @("id,vserver_id,aggregate_id,parent_volume_id,name,size_mb,used_size_mb,available_size_mb,type,state,junction_path,space_guarantee,snapshot_used_mb,snapshot_reserved_percent,snapshot_enabled,style,max_autosize_mb,block_type,security_style,dedupe_enabled,auto_increment_size_mb,snapshot_policy_id,export_policy_id,autosize_enabled,compression,deduplication_space_saved_mb,compression_space_saved_mb,percent_deduplication_space_saved,percent_compression_space_saved,hybrid_cache_eligibility,inode_files_total,inode_files_used,auto_size_mode,sis_last_op_begin_timestamp,sis_last_op_end_timestamp,flexcache_origin_volume_id,flexcache_min_reserve_mb,constituent_role,is_managed_by_service,storage_class,snap_diff_enabled,max_namespace_constituent_size_mb,max_data_constituent_size_mb,efficiency_policy_id,qos_policy_group_id,language,data_daily_growth_rate_mb,data_days_until_full,auto_delete_enabled,auto_delete_commitment,auto_delete_delete_order,auto_delete_defer_delete,auto_delete_target_free_space,auto_delete_trigger,auto_delete_prefix,auto_delete_destroy_list" -split ","); "vserver" = @("id,cluster_id,root_volume_id,name,type,uuid,name_service_switch,nis_domain,language,comment,admin_state,nfs_allowed,cifs_allowed,fcp_allowed,iscsi_allowed,dns_domain,dns_servers,snapshot_policy_id,cifs_is_up,nfs_is_up,fcp_is_up,iscsi_is_up,max_volumes,restricted_aggregate_count,cifs_authentication_style,cifs_domain,nis_enabled,nis_servers,is_repository,dns_enabled,qos_policy_group_id,ipspace_id,operational_state,subtype,is_smb_encryption_required,is_ddns_enabled,is_ddns_use_secure,ddns_domain_name,ddns_ttl" -split ","); "vserver_allowed_aggregate" = @("id,aggregate_id,vserver_id" -split ","); "vserver_association" = @("id,source_vserver_id,destination_vserver_id,type,uuid" -split ","); "vserver_peer" = @("id,vserver_id,peer_vserver_id,peer_state,applications" -split ","); } $global:maxId = 0 $currentIds = @{} $currentIds["aggregate-by-cluster"] = @{} $out = @{ "cluster" = @{}; "node" = @{}; "vserver" = @{}; "aggregate" = @{}; "volume" = @{}; "qtree" = @{}; "lun" = @{}; "vserver_allowed_aggregate" = @{}; "export_policy" = @{}; "export_rule" = @{}; "portset" = @{}; "igroup" = @{}; "qos_policy_group" = @{}; "lunmap" = @{}; "port" = @{}; "fcp_adapter" = @{}; "logical_interface" = @{}; "cifs_share" = @{}; "cifs_share_acl" = @{}; "portset_member" = @{}; "schedule" = @{}; "cluster_license" = @{}; "snapmirror_policy" = @{}; "snapmirror_policy_rule" = @{}; "snapshot_policy" = @{}; "snapshot_policy_schedule" = @{}; "snapmirror" = @{}; "vserver_association" = @{}; "ipspace" = @{}; "broadcast_domain" = @{}; "failover_group" = @{}; "efficiency_policy" = @{}; "disk" = @{}; "disk_aggregate" = @{}; "storage_pool" = @{}; "storage_pool_aggregate" = @{}; "storage_pool_available" = @{}; "cluster_peer" = @{}; "snapmirror_svm" = @{}; "vserver_peer" = @{}; } Function importCurrent ($table, $fields) { $query = "select id, "+($fields -join ",")+" from cm_storage.$table" $data = @(Invoke-MysqlQuery -Query $query) $currentIds[$table] = @{} $First = $True $data | % { $row = $_ if ($First) { $First = $False return } $id = [int64]($row[0]) if ($id -gt $global:maxId) { $global:maxId = $id } $currentIds[$table][$row[1..2] -join "`t"] = $id if ($debug) { doLog $("table:$table '"+($row[1..2] -join "`t")+"' = $id") } } } try { importCurrent "cluster" @(,"name") importCurrent "node" @("cluster_id", "name") importCurrent "vserver" @("cluster_id", "name") importCurrent "aggregate" @("node_id", "name") importCurrent "volume" @("vserver_id", "name") importCurrent "qtree" @("volume_id", "name") importCurrent "lun" @("vserver_id", "full_path") importCurrent "vserver_allowed_aggregate" @("aggregate_id", "vserver_id") importCurrent "export_policy" @("vserver_id", "name") importCurrent "export_rule" @("policy_id", "rule_index") importCurrent "portset" @("vserver_id", "name") importCurrent "igroup" @("vserver_id", "name") importCurrent "qos_policy_group" @("vserver_id", "name") importCurrent "lunmap" @("lun_id", "igroup_id") importCurrent "port" @("node_id", "name") importCurrent "fcp_adapter" @("node_id", "name") importCurrent "logical_interface" @("vserver_id", "name") importCurrent "cifs_share" @("vserver_id", "name") importCurrent "cifs_share_acl" @("cifs_share_id", "user_or_group") importCurrent "portset_member" @("portset_id", "logical_interface_id") importCurrent "schedule" @("cluster_id", "name") importCurrent "cluster_license" @("cluster_id", "license") importCurrent "snapmirror_policy" @("vserver_id", "name") importCurrent "snapmirror_policy_rule" @("snapmirror_policy_id", "snapmirror_label") importCurrent "snapshot_policy" @("vserver_id", "name") importCurrent "snapshot_policy_schedule" @("snapshot_policy_id", "schedule_id") importCurrent "snapmirror" @("volume_id", "secondary_volume_id") importCurrent "vserver_association" @("source_vserver_id", "destination_vserver_id") importCurrent "vserver_peer" @("vserver_id", "peer_vserver_id") importCurrent "ipspace" @("cluster_id", "name") importCurrent "broadcast_domain" @("ipspace_id", "name") importCurrent "failover_group" @("cluster_id", "name") importCurrent "efficiency_policy" @("vserver_id", "name") importCurrent "disk" @("cluster_id", "name") importCurrent "disk_aggregate" @("disk_id", "aggregate_id") importCurrent "storage_pool" @("cluster_id", "name") importCurrent "storage_pool_aggregate" @("storage_pool_id", "aggregate_id") importCurrent "storage_pool_available" @("storage_pool_id", "node_id") importCurrent "cluster_peer" @("primary_cluster_id", "peer_cluster_id") importCurrent "vserver_peer" @("vserver_id", "peer_vserver_id") importCurrent "snapmirror_svm" @("source_vserver_id", "destination_vserver_id") } catch { # Ignore any errors for now doLog "Failed import: $_" } $clusters = $ClusterList -split "," if ($clusters -eq $null -or $clusters.length -eq 0) { throw "Failed to get cluster list - have you added any clusters?" } $clusters | % { $cluster = $_ $cred = Get-WfaCredentials -Host $cluster -EA Stop if ($cred -eq $null) { throw "No credentials found for $cluster" } try { doLog "Connecting to $cluster" $true Connect-WfaCluster $cluster -Timeout $timeout -EA Stop doLog "Get cluster info" $true $info = Get-NcCluster -EA Stop doLog "Find cluster id" $true $addr = $info.NcController.Address.IpAddressToString # $addr = $cluster $clusterid = getId "cluster" $info.ClusterName #"cluster" = @("#id,+admin_vserver_id,#name,#location,#primary_address,#uuid,#serial_number,+version" -split ","); $newcluster = @{ "id" = $clusterid; "name" = $info.ClusterName; "location" = $info.ClusterLocation; "primary_address" = $addr; "uuid" = $info.ClusterUuid; "serial_number" = $info.ClusterSerialNumber; } $version = Get-NcSystemVersion -EA Stop if ($version.Value -match 'Release (\S+\s+.*?):') { $newcluster["version"] = $matches[1] } else { $newcluster["version"] = $version.Value } $out["cluster"][$clusterid] = $newcluster # License table support is pretty poor - it doesn't appear to handle expiration, # node based licensing, etc. Just shove in any license we see. Duplicates will # be handled by using the same id @(Get-NcLicense -EA Stop) | % { $lic = $_ $licid = getId "cluster_license" "$clusterid`t$($lic.Package)" # "cluster_license" = @("id,cluster_id,license" -split ","); $newlic = @{ "id" = $licid; "cluster_id" = $clusterid; "license" = $lic.Package; } $out["cluster_license"][$licid] = $newlic } # "node" = @("#id,#cluster_id,+ha_partner_id,+node_vserver_id,#name,!primary_address,#model,#serial_number,#system_id,+os_version,#owner,#location,product_type,failover_enabled,takeover_possible,failover_state,memory_size_mb,flash_device_count" -split ","); doLog "Getting nodes" $true @(Get-NcNode -EA Stop) | % { $node = $_ doLog "Processing node $($node.Node)" $true $nodeid = getId "node" "$clusterid`t$($node.Node)" $if = @(Get-NcNetInterface -Vserver $node.Node -Role "node_mgmt" -EA Stop) $addr = $if[0].Address $newnode = @{ "id" = $nodeid; "cluster_id" = $clusterid; "name" = $node.Node; "model" = $node.NodeModel; "serial_number" = $node.NodeSerialNumber; "system_id" = $node.NodeSystemId; "owner" = $node.NodeOwner; "location" = $node.NodeLocation; "primary_address" = $addr; } if ($node.IsAllFlashOptimizedSpecified) { $newnode.is_flash_optimized = $(bool $node.IsAllFlashOptimized) } if ($node.ProductVersion -match 'Release (\S+\s+.*?):') { $newnode["os_version"] = $matches[1] } else { $newnode["os_version"] = $node.ProductVersion } $out["node"][$nodeid] = $newnode } doLog "Getting node info" $true # NcNodeInfo has easy access to partner name @(Get-NcNodeInfo -EA Stop) | % { $node = $_ $nodeid = $currentIds["node"]["$clusterid`t$($node.SystemName)"] if ($nodeid -eq $null) { doLog "Could not find node $($node.SystemName) in cluster $cluster" return } $n = $out["node"][$nodeid] if ($n -eq $null) { doLog "Could not find node data for $($node.SystemName) in cluster $cluster" return } $n["ha_partner_id"] = $currentIds["node"]["$clusterid`t$($node.PartnerSystemName)"] $n["memory_size_mb"] = $node.MemorySize } doLog "Getting aggregates" $true @(Get-NcAggr -EA Stop) | % { $aggr = $_ # "aggregate" = @("id,node_id,name,size_mb,used_size_mb,available_size_mb,raid_type,raid_status,block_type,state,number_of_disks,volume_count,is_hybrid,hybrid_enabled,hybrid_cache_size_mb,snapshot_total_size_mb,snapshot_used_size_mb,has_local_root,has_partner_root,daily_growth_rate_mb,days_until_full" -split ","); # key: node_id, name $nodeid = $currentIds["node"]["$clusterid`t$($aggr.Nodes[0])"] $aggrid = getId "aggregate" "$nodeid`t$($aggr.Name)" $currentIds["aggregate-by-cluster"]["$clusterid`t$($aggr.Name)"] = $aggrid $newaggr = @{ "id" = $aggrid; "node_id" = $nodeid; "name" = $aggr.Name; "size_mb" = [int64]($aggr.TotalSize / 1MB); "used_size_mb" = [int64]($aggr.AggrSpaceAttributes.SizeUsed / 1MB); "available_size_mb" = [int64]($aggr.Available / 1MB); "raid_type" = $aggr.AggrRaidAttributes.RaidType; "raid_status" = $aggr.AggrRaidAttributes.RaidStatus; "block_type" = $($aggr.AggrFsAttributes.BlockType -replace "_", "-"); "state" = $aggr.State; "number_of_disks" = $aggr.Disks; "volume_count" = $aggr.Volumes; "is_hybrid" = $(bool $aggr.AggrRaidAttributes.IsHybrid); "hybrid_enabled" = $(bool $aggr.AggrRaidAttributes.IsHybridEnabled); "hybrid_cache_size_mb" = [int64]($aggr.AggrSpaceAttributes.HybridCacheSizeTotal / 1MB); "snapshot_total_size_mb" = [int64]($aggr.AggrSnapshotAttributes.SizeTotal / 1MB); "snapshot_used_size_mb" = [int64]($aggr.AggrSnapshotAttributes.SizeUsed / 1MB); } $out["aggregate"][$aggrid] = $newaggr } $hasIpspaces = $false doLog "Getting ipspaces" $true try { $ipspaces = Get-NcNetIpspace -EA Stop foreach ($ipspace in $ipspaces) { $ipspaceid = getId "ipspace" "$clusterid`t$($ipspace.Ipspace)" # "ipspace" = @("id,name,cluster_id" -split ","); $newipspace = @{ "id" = $ipspaceid; "name" = $ipspace.Ipspace; "cluster_id" = $clusterid; } $out["ipspace"][$ipspaceid] = $newipspace } doLog "Getting broadcast domains" $true $broadcasts = Get-NcNetPortBroadcastDomain -EA Stop foreach ($broadcast in $broadcasts) { # "broadcast_domain" = @("id,name,ipspace_id,mtu" -split ","); $ipspaceid = $currentIds["ipspace"]["$clusterid`t$($broadcast.Ipspace)"] if ($ipspaceid -eq $null) { doLog "Could not find ipspace $($broadcast.Ipspace) for broadcast domain $($broadcast.BroadcastDomain) in cluster $cluster" return } $broadcastid = getId "broadcast_domain" "$ipspaceid`t$($broadcast.BroadcastDomain)" $newbroadcast = @{ "id" = $broadcastid; "name" = $broadcast.BroadcastDomain; "mtu" = $broadcast.MTU; "ipspace_id" = $ipspaceid; } $out["broadcast_domain"][$broadcastid] = $newbroadcast } $hasIpspaces = $true } catch { doLog "Getting ipspaces failed: $($_.Exception)" $true } doLog "Getting failover groups" $true $failovers = @(Get-NcNetFailoverGroup -EA Stop) doLog "Getting failover groups2" $true foreach ($failover in $failovers) { # "failover_group" = @("id,name,cluster_id,broadcast_domain_id" -split ","); $failoverid = getId "failover_group" "$clusterid`t$($failover.FailoverGroup)" $newfailover = @{ "id" = $failoverid; "name" = $failover.FailoverGroup; "cluster_id" = $clusterid; } if ($hasIpspaces -and $broadcast.BroadcastDomain -ne $null) { $newfailover.broadcast_domain_id = $currentIds["broadcast_domain"]["$ipspaceid`t$($broadcast.BroadcastDomain)"] ### Edit by DAK changed $clusterid t $ipspaceid ### } $out["failover_group"][$failoverid] = $newfailover } doLog "Getting disks" $true foreach ($disk in @(Get-NcDisk -EA Stop)) { #"disk" = @("id,name,uid,type,rpm,home_node_id,owner_node_id,model,serial_number,size_mb,shelf,shelf_bay,pool,vendor,raid_position,container_type,cluster_id" -split ","); $diskid = getId "disk" "$clusterid`t$($disk.Name)" $homenodeid = $currentIds["node"]["$clusterid`t$($disk.DiskOwnershipInfo.HomeNodeName)"] $ownernodeid = $currentIds["node"]["$clusterid`t$($disk.DiskOwnershipInfo.OwnerNodeName)"] $newdisk = @{ "id" = $diskid; "name" = $disk.Name; "uid" = $disk.DiskInventoryInfo.DiskUid; "rpm" = $disk.RPM; "home_node_id" = $homenodeid; "owner_node_id" = $ownernodeid; "model" = $disk.Model; "serial_number" = $disk.DiskInventoryInfo.SerialNumber; "size_mb" = [int64]($disk.Capacity / 1MB); "shelf" = $disk.DiskInventoryInfo.Shelf; "shelf_bay" = $disk.DiskInventoryInfo.ShelfBay; "pool" = $disk.DiskOwnershipInfo.Pool; "vendor" = $disk.DiskInventoryInfo.Vendor; "raid_position" = $disk.Position; "container_type" = $disk.DiskRaidInfo.ContainerType; "cluster_id" = $clusterid; }; $out["disk"][$diskid] = $newdisk #"disk_aggregate" = @("id,disk_id,aggregate_id" -split ","); if ($disk.DiskRaidInfo.ContainerType -eq "aggregate") { $aggrid = $currentIds["aggregate-by-cluster"]["$clusterid`t$($disk.DiskRaidInfo.DiskAggregateInfo.AggregateName)"] $daid = getId "disk_aggregate" "$diskid`t$aggrid" $newda = @{ "id" = $daid; "disk_id" = $diskid; "aggregate_id" = $aggrid; } $out["disk_aggregate"][$daid] = $newda } } doLog "Getting storage pools" $true $haveStoragePools = $false try { $pools = @(Get-NcStoragePool -EA Stop) $haveStoragePools = $true foreach ($pool in $pools) { $poolid = getId "storage_pool" "$clusterid`t$($pool.StoragePool)" # "storage_pool" = @("id,name,cluster_id,allocation_unit_size_mb,pool_usable_size_mb,pool_total_size_mb,storage_type,disk_count" -split ","); $newpool = @{ "id" = $poolid; "name" = $pool.StoragePool; "cluster_id" = $clusterid; "allocation_unit_size_mb" = [int64]($pool.AllocationUnitSize / 1MB); "pool_usable_size_mb" = [int64]($pool.PoolUsableSize / 1MB); "pool_total_size_mb" = [int64]($pool.PoolTotalSize / 1MB); "storage_type" = $pool.StorageType; "disk_count" = $pool.DiskCount; } $out["storage_pool"][$poolid] = $newpool; } doLog "Getting storage pool aggregates" $true foreach ($spa in @(Get-NcStoragePoolAggr -EA Stop)) { $poolid = $currentIds["storage_pool"]["$clusterid`t$($spa.StoragePool)"]; $aggrid = $currentIds["aggregate-by-cluster"]["$clusterid`t$($spa.Aggregate)"]; $spaid = getId "storage_pool_aggregate" "$poolid`t$aggrid" # "storage_pool_aggregate" = @("id,storage_pool_id,aggregate_id,used_capacity_mb" -split ","); $newspa = @{ "id" = $spaid; "storage_pool_id" = $poolid; "aggregate_id" = $aggrid; "used_capacity_mb" = [int64]($pa.UsedCapacity / 1MB); } $out["storage_pool_aggregate"][$spaid] = $newspa } doLog "Getting storage pool available" $true foreach ($spav in @(Get-NcStoragePoolAvailableCapacity -EA Stop)) { $spid = $currentIds["storage_pool"]["$clusterid`t$($spav.StoragePool)"] $nodeid = $currentIds["node"]["$clusterid`t$($spav.Node)"] $spavid = getId "storage_pool_available" "$spid`t$nodeid" # "storage_pool_available" = @("id,storage_pool_id,node_id,allocation_unit_count,available_size_mb" -split ","); $newspav = @{ "id" = $spavid; "storage_pool_id" = $spid; "node_id" = $nodeid; "allocation_unit_count" = $spav.AllocationUnitCount; "available_size_mb" = [int64]($spav.AvailableSize / 1MB); } $out["storage_pool_available"][$spavid] = $newspav } } catch { } $vserverQos = @{} doLog "Getting vservers" $true @(Get-NcVserver -EA Stop) | % { $vserver = $_ $vserverid = getId "vserver" "$clusterid`t$($vserver.VserverName)" # "vserver" = @("#id,#cluster_id,!root_volume_id,#name,#type,#uuid,#name_service_switch,#nis_domain,#language,#comment,#admin_state,#nfs_allowed,#cifs_allowed,#fcp_allowed,#iscsi_allowed,?dns_domain,?dns_servers,#snapshot_policy_id,?cifs_is_up,?nfs_is_up,?fcp_is_up,?iscsi_is_up,#max_volumes,?restricted_aggregate_count,?cifs_authentication_style,?cifs_domain,?nis_enabled,?nis_servers,#is_repository,?dns_enabled,#qos_policy_group_id,ipspace_id,operational_state,subtype" -split ","); # is_smb_encryption_required,is_ddns_enabled,is_ddns_use_secure,ddns_domain_name,ddns_ttl $protos = $vserver.AllowedProtocols $nsswitch = $null if ($vserver.NameServerSwitch -ne $null) { $nsswitch = $vserver.NameServerSwitch -join "," } if ($vserver.QosPolicyGroup -ne $null) { # Remember this for later when processing qos policy groups $vserverQos[$vserver.VserverName] = $vserver.QosPolicyGroup } $newvserver = @{ "id" = $vserverid; "cluster_id" = $clusterid; "name" = $vserver.VserverName; "type" = $vserver.VserverType; "uuid" = $vserver.Uuid; "name_service_switch" = $nsswitch; "nis_domain" = $vserver.NisDomain; "language" = $vserver.Language; "comment" = $vserver.Comment; "admin_state" = $vserver.State; "snapshot_policy" = $vserver.SnapshotPolicy; "max_volumes" = $(if ($vserver.MaxVolumes -eq "unlimited") { $null } else {$vserver.MaxVolumes}); "is_repository" = $(bool $vserver.IsRepositoryVserver); "nfs_allowed" = $(bool ($protos -contains "nfs")); "cifs_allowed" = $(bool ($protos -contains "cifs")); "fcp_allowed" = $(bool ($protos -contains "fcp")); "iscsi_allowed" = $(bool ($protos -contains "iscsi")); # If it's allowed, assume it's running for now... "nfs_is_up" = $(bool ($protos -contains "nfs")); "cifs_is_up" = $(bool $False); # Set later if it's administratively up "fcp_is_up" = $(bool ($protos -contains "fcp")); "iscsi_is_up" = $(bool ($protos -contains "iscsi")); "restricted_aggregate_count" = $(if ($vserver.VserverAggrInfoList -ne $null) {$vserver.VserverAggrInfoList.Length} else { 0 }); "operational_state" = $vserver.OperationalState; "subtype" = $vserver.VserverSubtype; } if ($vserver.Ipspace) { $ipspaceid = $currentIds["ipspace"]["$clusterid`t$($vserver.Ipspace)"] if ($ipspace -ne $null) { $newvserver.ipspace_id = $ipspaceid } } $out["vserver"][$vserverid] = $newvserver # Backfill vserverid in cluster and node if ($vserver.VserverType -eq "admin") { $newcluster.admin_vserver_id = $vserverid } elseif ($vserver.VserverType -eq "node") { $nodeid = $currentIds["node"]["$clusterid`t$($vserver.VserverName)"] $out["node"][$nodeid]["node_vserver_id"] = $vserverid } # "vserver_allowed_aggregate" = @("id,aggregate_id,vserver_id" -split ","); if ($vserver.AggrList -ne $null) { @($vserver.AggrList) | % { $aggr = $_ $aggrid = $currentIds["aggregate-by-cluster"]["$clusterid`t$aggr"] if (!$aggrid) { doLog "Could not find aggregate $aggr in cluster $cluster for vserver $vserver aggr list" return } $alid = getId "vserver_allowed_aggregate" "$aggrid`t$vserverid" $al = @{ "id" = $alid; "aggregate_id" = $aggrid; "vserver_id" = $vserverid; } $out["vserver_allowed_aggregate"][$alid] = $al } } } doLog "Fetch CIFS Server info" $true @(Get-NcCifsServer -EA Stop) | % { $cifs = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($cifs.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($cifs.Vserver) for cluster $cluster ($clusterid)" return } # "vserver" = @("id,cluster_id,root_volume_id,name,type,uuid,name_service_switch,nis_domain,language,comment,admin_state,nfs_allowed,cifs_allowed,fcp_allowed,iscsi_allowed,dns_domain,dns_servers,snapshot_policy_id,cifs_is_up,nfs_is_up,fcp_is_up,iscsi_is_up,max_volumes,restricted_aggregate_count,cifs_authentication_style,cifs_domain,nis_enabled,nis_servers,is_repository,dns_enabled,qos_policy_group_id,ipspace_id,operational_state,subtype,is_smb_encryption_required,is_ddns_enabled,is_ddns_use_secure,ddns_domain_name,ddns_ttl" -split ","); $vserver = $out["vserver"][$vserverid] $vserver.cifs_domain = $cifs.Domain $vserver.cifs_authentication_style = $cifs.AuthStyle $vserver.cifs_is_up = $(bool ($cifs.AdministrativeStatus -eq "up")) # Must be obtained on a per-vserver basis... grr. $sec = Get-NcCifsSecurity -VserverContext $cifs.Vserver if ($sec.IsSmbEncryptionRequiredSpecified) { $vserver.is_smb_encryption_required = $(bool $sec.IsSmbEncryptionRequired) } } doLog "Fetch ddns info" $true try { @(Get-NcNetDdns -EA Stop) | % { $ddns = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($ddns.VserverName)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($ddns.VserverName) for cluster $cluster ($clusterid)" return } $vserver = $out["vserver"][$vserverid] # is_smb_encryption_required,is_ddns_enabled,is_ddns_use_secure,ddns_domain_name,ddns_ttl if ($ddns.IsEnabledSpecified) { $vserver.is_ddns_enabled = $(bool $ddns.IsEnabled) } if ($ddns.UseSecureSpecified) { $vserver.is_ddns_use_secure = $(bool $ddns.UseSecure) } $vserver.ddns_domain_name = $ddns.DomainName $vserver.ddns_ttl = $ddns.Ttl } } catch { doLog "DDNS info not available" $true } doLog "Fetch ports" $true $ports = @(Get-NcNetPort -EA Stop) # First pass - create ids $ports | % { $port = $_ $nodeid = $currentIds["node"]["$clusterid`t$($port.Node)"] if ($nodeid -eq $null) { doLog "Failed to find node $($port.Node) for cluster $cluster ($clusterid)" return } $portid = getId "port" "$nodeid`t$($port.Name)" } # Second pass - create records $ports | % { $port = $_ $nodeid = $currentIds["node"]["$clusterid`t$($port.Node)"] if ($nodeid -eq $null) { doLog "Failed to find node $($port.Node) for cluster $cluster ($clusterid)" return } $portid = getId "port" "$nodeid`t$($port.Name)" $vlanportid = $null if ($port.VlanPort -ne $null) { $vlanportid = $currentIds["port"]["$nodeid`t$($port.VlanPort)"] if ($vlanportid -eq $null) { doLog "Failed to find port $($port.VlanPort) on node $($port.Node) for cluster $cluster (for $($port.Name))" return } } $ifgrpportid = $null if ($port.IfgrpPort -ne $null) { $ifgrpportid = $currentIds["port"]["$nodeid`t$($port.IfgrpPort)"] if ($ifgrpportid -eq $null) { doLog "Failed to find port $($port.IfgrpPort) on node $($port.Node) for cluster $cluster (for $($port.Name))" return } } $ipspaceid = $currentIds["ipspace"]["$clusterid`t$($port.Ipspace)"] ### Edit by DAK added ### $broadcastid = $currentIds["broadcast_domain"]["$ipspaceid`t$($broadcast.BroadcastDomain)"]; ### Edit by DAK added ### # "port" = @("id,name,node_id,type,role,operational_status,mtu,ifgrp_port_id,operational_speed,vlan_id,vlan_port_id,broadcast_domain_id" -split ","); ### Edit by DAK ### $newport = @{ "id" = $portid; "name" = $port.Name; "node_id" = $nodeid; "type" = $port.PortType; "role" = $port.Role; "operational_status" = $port.LinkStatus; "mtu" = $port.Mtu; "ifgrp_port_id" = $ifgrpportid; "operational_speed" = $port.OperationalSpeed; "vlan_id" = $port.VlanId; "vlan_port_id" = $vlanportid; "broadcast_domain_id" = $broadcastid; ### Edit by DAK added ### } $out["port"][$portid] = $newport } doLog "Collecting fcp port data" $true @(Get-NcFcpAdapter -EA Stop) | % { $fcp = $_ $nodeid = $currentIds["node"]["$clusterid`t$($fcp.Node)"] if ($nodeid -eq $null) { doLog "Failed to find node $($fcp.Node) for cluster $cluster ($clusterid)" return } $fcpid = getId "fcp_adapter" "$nodeid`t$($fcp.Adapter)" $status = $fcp.State if ($status -ne "online" -and $status -ne "offline") { $status = $null } # "fcp_adapter" = @("id,name,world_wide_node_name,world_wide_port_name,max_speed,physical_protocol,media_type,switch_port,status,node_id" -split ","); $newfcp = @{ "id" = $fcpid; "name" = $fcp.Adapter; "world_wide_port_name" = $fcp.PortName; "world_wide_node_name" = $fcp.NodeName; "max_speed" = $fcp.MaxSpeed; "physical_protocol" = $fcp.PhysicalProtocol; "media_type" = $fcp.MediaType; "switch_port" = $fcp.SwitchPort; "status" = $status; "node_id" = $nodeid; } $out["fcp_adapter"][$fcpid] = $newfcp } doLog "Collecting lif data" $true @(Get-NcNetInterface -EA Stop) | % { $lif = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($lif.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($lif.Vserver) for cluster $cluster" return } $homeportid = $null $currentportid = $null $fcpadapterid = $null $currentnodeid = $currentIds["node"]["$clusterid`t$($lif.CurrentNode)"] if ($currentnodeid -eq $null) { doLog "Could not find current node '$($lif.CurrentNode)' on cluster $cluster for lif $($lif.InterfaceName) on vserver $($lif.Vserver)" } elseif ($lif.CurrentPort -match '^\d') { $fcpadapterid = $currentIds["fcp_adapter"]["$currentnodeid`t$($lif.CurrentPort)"] if ($fcpadapterid -eq $null) { doLog "Could not find fcp adapter '$($lif.CurrentPort)' on node '$($lif.CurrentNode)' on cluster $cluster for lif $($lif.InterfaceName) on vserver $($lif.Vserver)" } } else { $currentportid = $currentIds["port"]["$currentnodeid`t$($lif.CurrentPort)"] if ($currentportid -eq $null) { doLog "Could not find port '$($lif.CurrentPort)' on node '$($lif.CurrentNode)' on cluster $cluster for lif $($lif.InterfaceName) on vserver $($lif.Vserver)" } } $homenodeid = $currentIds["node"]["$clusterid`t$($lif.HomeNode)"] if ($homenodeid -eq $null) { doLog "Could not find current node '$($lif.HomeNode)' on cluster $cluster for lif $($lif.InterfaceName) on vserver $($lif.Vserver)" } elseif (-not ($lif.CurrentPort -match '^\d')) { $homeportid = $currentIds["port"]["$homenodeid`t$($lif.HomePort)"] if ($homeportid -eq $null) { doLog "Could not find port '$($lif.HomePort)' on node '$($lif.CurrentNode)' on cluster $cluster for lif $($lif.InterfaceName) on vserver $($lif.Vserver)" } } $lifid = getId "logical_interface" "$vserverid`t$($lif.InterfaceName)" # "logical_interface" = @("id,vserver_id,name,role,home_port_id,current_port_id,status,address,netmask,protocols,failover_group,failover_policy,fcp_adapter_id" -split ","); # is_dns_update_enabled,listen_for_dns_query $newlif = @{ "id" = $lifid; "vserver_id" = $vserverid; "name" = $lif.InterfaceName; "role" = $lif.Role; "home_port_id" = $homeportid; "current_port_id" = $currentportid; "status" = $lif.OperationalStatus; "address" = $lif.Address; "netmask" = $lif.Netmask; "protocols" = $($lif.DataProtocols -join ","); "failover_group" = $lif.FailoverGroup; "failover_policy" = $lif.FailoverPolicy; "fcp_adapter_id" = $fcpadapterid; } if ($lif.ListenForDnsQuerySpecified) { $newlif.listen_for_dns_query = $(bool $lif.ListenForDnsQuery) } if ($lif.IsDnsUpdateEnabledSpecified) { $newlif.is_dns_update_enabled = $(bool $lif.IsDnsUpdateEnabled) } $out["logical_interface"][$lifid] = $newlif } doLog "Getting portset" $true @(Get-NcPortset -EA Stop) | % { $portset = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($portset.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($portset.Vserver) for cluster $cluster (for portset $($portset.PortsetName))" return } $portsetid = getId "portset" "$vserverid`t$($portset.PortsetName)" # "portset" = @("id,name,type,vserver_id" -split ","); $newportset = @{ "id" = $portsetid; "name" = $portset.PortsetName; "type" = $portset.PortsetType; "vserver_id" = $vserverid; } $out["portset"][$portsetid] = $newportset if ($portset.PortsetPortInfo -ne $null) { $portset.PortsetPortInfo | % { $port = $_ $lifid = $currentIds["logical_interface"]["$vserverid`t$port"] if ($lifid -eq $null) { doLog "Failed to find interface $port in vserver $($portset.Vserver) for cluster $cluster (for portset $($portset.PortsetName))" return } $memberid = getId "portset_member" "$portsetid`t$lifid" # "portset_member" = @("id,portset_id,logical_interface_id" -split ","); $newmember = @{ "id" = $memberid; "portset_id" = $portsetid; "logical_interface_id" = $lifid; } $out["portset_member"][$memberid] = $newmember } } } doLog "Getting interval schedules" $true @(Get-NcJobIntervalSchedule -EA Stop) | % { $sched = $_ $schedid = getId "schedule" "$clusterid`t$($sched.JobScheduleName)" # "schedule" = @("id,name,cluster_id,description,type,cron_days_of_month,cron_days_of_week,cron_hours,cron_minutes,cron_months,interval_days,interval_hours,interval_minutes,interval_seconds" -split ","); $newsched = @{ "id" = $schedid; "name" = $sched.JobScheduleName; "cluster_id" = $clusterid; "description" = $sched.JobScheduleDescription; "type" = "interval"; "interval_days" = $sched.JobScheduleIntervalDays; "interval_hours" = $sched.JobScheduleIntervalHours; "interval_minutes" = $sched.JobScheduleIntervalMinutes; "interval_seconds" = $sched.JobScheduleIntervalSeconds; } $out["schedule"][$schedid] = $newsched } doLog "Getting cron schedules" $true @(Get-NcJobCronSchedule -EA Stop) | % { $sched = $_ $schedid = getId "schedule" "$clusterid`t$($sched.JobScheduleName)" # "schedule" = @("id,name,cluster_id,description,type,cron_days_of_month,cron_days_of_week,cron_hours,cron_minutes,cron_months,interval_days,interval_hours,interval_minutes,interval_seconds" -split ","); $minutes = $null $hours = $null $months = $null $dow = $null $dom = $null if ($sched.Minute -ne $null) { $minutes = $($sched.Minute -join ",") } if ($sched.Hour -ne $null) { $hours = $($sched.Hour -join ",") } if ($sched.Month -ne $null) { $months = $($sched.Month -join ",") } if ($sched.Day -ne $null) { $dom = $($sched.Day -join ",") } if ($sched.DayOfWeek -ne $null) { $dow = $($sched.DayOfWeek -join ",") } $newsched = @{ "id" = $schedid; "name" = $sched.JobScheduleName; "cluster_id" = $clusterid; "description" = $sched.JobScheduleDescription; "type" = "cron"; "cron_days_of_month" = $dom; "cron_days_of_week" = $dow; "cron_hours" = $hours; "cron_minutes" = $minutes; "cron_months" = $months; } $out["schedule"][$schedid] = $newsched } doLog "Getting igroups" $true @(Get-NcIgroup -EA Stop) | % { $igroup = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($igroup.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($igroup.Vserver) for cluster $cluster (for igroup $($igroup.Name))" return } $portsetid = $null if ($igroup.Portset -ne $null) { $portsetid = $currentIds["portset"]["$vserverid`t$($igroup.Portset)"] if ($portsetid -eq $null) { doLog "Failed to find portset $($igroup.Portset) in vserver $($igroup.Vserver) for cluster $cluster (for igroup $($igroup.Name))" return } } $initiators = $null if ($igroup.Initiators -ne $null) { $inames = @() $igroup.Initiators | % { $inames += $_.InitiatorName } $initiators = $inames -join "," } # "igroup" = @("id,initiators,name,os_type,portset_id,protocol,vserver_id" -split ","); $igroupid = getId "igroup" "$vserverid`t$($igroup.Name)" $newigroup = @{ "id" = $igroupid; "initiators" = $initiators; "name" = $igroup.Name; "os_type" = $igroup.Type; "portset_id" = $portsetid; "protocol" = $igroup.Protocol; "vserver_id" = $vserverid; } $out["igroup"][$igroupid] = $newigroup } doLog "Getting qos policy groups" $true $query = Get-NcQosPolicyGroup -Template $query.PolicyGroupClass = "user_defined" @(Get-NcQosPolicyGroup -Query $query -EA Stop) | % { $qos = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($qos.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($qos.Vserver) for cluster $cluster (for qos policy group $($qos.PolicyGroup))" return } $qosid = getId "qos_policy_group" "$vserverid`t$($qos.PolicyGroup)" # "qos_policy_group" = @("id,name,vserver_id,class,max_throughput_limit" -split ","); $newqos = @{ "id" = $qosid; "name" = $qos.PolicyGroup; "vserver_id" = $vserverid; "class" = @($qos.PolicyGroupClass.toUpper()); "max_throughput_limit" = $qos.MaxThroughput; } $out["qos_policy_group"][$qosid] = $newqos # If the policy group is applied to the vserver, record that now. if ($vserverQos[$qos.Vserver] -eq $qos.PolicyGroup) { $out["vserver"][$vserverid].qos_policy_group_id = $qosid } } doLog "Getting export policies" $true @(Get-NcExportPolicy -EA Stop) | % { $policy = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($policy.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($policy.Vserver) for cluster $cluster (for export policy $($policy.PolicyName))" return } $policyid = getId "export_policy" "$vserverid`t$($policy.PolicyName)" #"export_policy" = @("id,name,vserver_id" -split ","); $newpolicy = @{ "id" = $policyid; "name" = $policy.PolicyName; "vserver_id" = $vserverid; } $out["export_policy"][$policyid] = $newpolicy } doLog "Getting export policie rules" $true @(Get-NcExportRule -EA Stop) | % { $rule = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($rule.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($rule.Vserver) for cluster $cluster" return } $policyid = $currentIds["export_policy"]["$vserverid`t$($rule.PolicyName)"] if ($policyid -eq $null) { doLog "Failed to find policy $($rule.PolicyName) for vserver $($rule.Vserver) for cluster $cluster" return } $ruleid = getId "export_rule" "$policyid`t$($rule.RuleIndex)" # "export_rule" = @("id,clientmatch,policy_id,protocol,ro_rule,rule_index,rw_rule,super_user" -split ","); $newrule = @{ "id" = $ruleid; "clientmatch" = $rule.ClientMatch; "policy_id" = $policyid; "protocol" = $($rule.Protocol -join ","); "ro_rule" = $($rule.RoRule -join ","); "rule_index" = $rule.RuleIndex; "rw_rule" = $($rule.RwRule -join ","); "super_user" = $($rule.SuperUserSecurity -join ","); } $out["export_rule"][$ruleid] = $newrule } doLog "Getting snapmirror policies" $true @(Get-NcSnapmirrorPolicy -EA Stop) | % { $smp = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($smp.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($smp.Vserver) for cluster $cluster" return } $smpid = getId "snapmirror_policy" "$vserverid`t$($smp.Name)" # "snapmirror_policy" = @("id,name,vserver_id,comment,transfer_priority" -split ","); $newsmp = @{ "id" = $smpid; "name" = $smp.Name; "vserver_id" = $vserverid; "comment" = $smp.Comment; "transfer_priority" = $smp.TransferPriority; } $out["snapmirror_policy"][$smpid] = $newsmp if ($smp.SnapmirrorPolicyRules -ne $null) { $smp.SnapmirrorPolicyRules | % { $rule = $_ $ruleid = getId "snapmirror_policy_rule" "$snapmirror_policy_id`t$($rule.SnapmirrorLabel)" # "snapmirror_policy_rule" = @("id,snapmirror_label,snapmirror_policy_id,keep,preserve,warn" -split ","); $newrule = @{ "id" = $ruleid; "snapmirror_label" = $rule.SnapmirrorLabel; "snapmirror_policy_id" = $smpid; "keep" = $rule.Keep; "preserve" = $(bool $rule.Preserve); "warn" = $rule.Warn; } $out["snapmirror_policy_rule"][$ruleid] = $newrule } } } doLog "Getting snapshot policies" $true @(Get-NcSnapshotPolicy -EA Stop) | % { $ssp = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($ssp.VserverName)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($ssp.VserverName) for cluster $cluster" return } $sspid = getId "snapshot_policy" "$vserverid`t$($ssp.Policy)" # "snapshot_policy" = @("id,cluster_id,vserver_id,comment,enabled,name" -split ","); $newssp = @{ "id" = $sspid; "cluster_id" = $clusterid; "vserver_id" = $vserverid; "comment" = $ssp.Comment; "enabled" = $(bool $ssp.Enabled); "name" = $ssp.Policy; } $out["snapshot_policy"][$sspid] = $newssp if ($ssp.SnapshotPolicySchedules -ne $null) { $ssp.SnapshotPolicySchedules | % { $sspsched = $_ $schedid = $currentIds["schedule"]["$clusterid`t$($sspsched.Schedule)"] if ($schedid -eq $null) { doLog "Failed to find schedule $($sspsched.Schedule) for cluster $cluster (for snapshot policy $($ssp.Policy) in vserver $($ssp.VserverName))" return } $sspschedid = getId "snapshot_policy_schedule" "$sspid`t$schedid" # "snapshot_policy_schedule" = @("id,schedule_id,snapshot_count,snapshot_prefix,snapmirror_label,snapshot_policy_id" -split ","); $newsspsched = @{ "id" = $sspschedid; "schedule_id" = $schedid; "snapshot_count" = $sspsched.Count; "snapshot_prefix" = $sspsched.Prefix; "snapmirror_label" = $sspsched.SnapmirrorLabel; "snapshot_policy_id" = $sspid; } $out["snapshot_policy_schedule"][$sspschedid] = $newsspsched } } } doLog "Getting efficiency policies" $true # "efficiency_policy" = @("id,name,vserver_id,schedule_id,enabled,comment,duration,qos_policy" -split ","); $effpolicys = @(Get-NcSisPolicy -EA Stop) foreach ($ep in $effpolicys) { $vserverid = $currentIds["vserver"]["$clusterid`t$($ep.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($ep.Vserver) for cluster $cluster" continue } $schedid = $null if ($ep.Schedule -ne $null) { $schedid = $currentIds["schedule"]["$clusterid`t$($ep.Schedule)"] if ($schedid -eq $null) { doLog "Failed to find schedule $($epsched.Schedule) for cluster $cluster for efficiency policy $($ep.PolicyName) in vserver $($ep.Vserver))" return } } $epid = getId "efficiency_policy" "$vserverid`t$($ep.PolicyName)" $newep = @{ "id" = $epid; "name" = $ep.PolicyName; "vserver_id" = $vserverid; "schedule_id" = $schedid; "enabled" = $(bool $ep.Enabled); "comment" = $ep.Comment; "qos_policy" = $ep.QosPolicy; } if ($ep.Duration -ne "-") { $newep.duration = $ep.Duration; } $out["efficiency_policy"][$epid] = $newep } doLog "Getting volumes" $true $cloneVols = @() @(Get-NcVol -EA Stop) | % { $vol = $_ # key: node_id, name $vserverid = $currentIds["vserver"]["$clusterid`t$($vol.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($vol.Vserver) for cluster $cluster" return } $aggrid = $currentIds["aggregate-by-cluster"]["$clusterid`t$($vol.Aggregate)"] if ($aggrid -eq $null) { doLog "Failed to find aggregate $($vol.Aggregate) for cluster $cluster (for volume $($vol.Name))" return } $volid = getId "volume" "$vserverid`t$($vol.Name)" $policyid = $null if ($vol.VolumeExportAttributes) { $policyid = $currentIds["export_policy"]["$vserverid`t$($vol.VolumeExportAttributes.Policy)"] if ($policyid -eq $null) { doLog "Failed to find policy $($vol.VolumeExportAttributes.Policy) for vserver $($vol.Vserver) in cluster $cluster (for volume $($vol.Name))" } } $qosid = $null if ($vol.VolumeQosAttributes -ne $null) { $qosid = $currentIds["qos_policy_group"]["$vserverid`t$($vol.VolumeQosAttributes.PolicyGroupName)"] if ($qosid -eq $null) { # doLog "Failed to find qos policy $($vol.VolumeQosAttributes.PolicyGroupName) for vserver $($vol.Vserver) in cluster $cluster (for volume $($vol.Name))" } } $snappolicyid = $null if ($vol.VolumeSnapshotAttributes -ne $null -and $vol.VolumeSnapshotAttributes.SnapshotPolicy -ne $null) { $snappolicyid = $currentIds["snapshot_policy"]["$vserverid`t$($vol.VolumeSnapshotAttributes.SnapshotPolicy)"] if ($snappolicyid -eq $null) { $snappolicyid = $currentIds["snapshot_policy"]["$($newcluster.admin_vserver_id)`t$($vol.VolumeSnapshotAttributes.SnapshotPolicy)"] } if ($snappolicyid -eq $null) { doLog "Failed to find snapshot policy $($vol.VolumeSnapshotAttributes.SnapshotPolicy) for vserver $($vol.Vserver) in cluster $cluster (for volume $($vol.Name))" } } $style = $vol.VolumeIdAttributes.Style if ($style -eq "infinitevol") { $style = "infinivol" } if ($vol.VolumeStateAttributes.IsConstituent) { $style = "constituent" } $newvol = @{ #"volume" = @("id,vserver_id,aggregate_id,parent_volume_id,name,size_mb,used_size_mb, "id" = $volid; "vserver_id" = $vserverid; "aggregate_id" = $aggrid; "name" = $vol.Name; "size_mb" = [int64]($vol.TotalSize / 1MB); "used_size_mb" = [int64]($vol.VolumeSpaceAttributes.SizeUsed / 1MB); # available_size_mb,type,state,junction_path,space_guarantee,snapshot_used_mb, "available_size_mb" = [int64]($vol.Available / 1MB); "type" = $vol.VolumeIdAttributes.Type; "state" = $vol.State; "junction_path" = $(if ($vol.JunctionPath -ne $null) {$vol.JunctionPath} else {"-"}); "space_guarantee" = $vol.VolumeSpaceAttributes.SpaceGuarantee; "snapshot_used_mb" = [int64]($vol.VolumeSpaceAttributes.SizeUsedBySnapshots / 1MB); # snapshot_reserved_percent,snapshot_enabled,style,max_autosize_mb,block_type,security_style, "snapshot_reserved_percent" = $vol.VolumeSpaceAttributes.PercentageSnapshotReserve; "snapshot_enabled" = $(bool $vol.VolumeSnapshotAttributes.AutoSnapshotsEnabled); "style" = $style; "max_autosize_mb" = [int64]($vol.VolumeAutosizeAttributes.MaximumSize / 1MB); "block_type" = $vol.VolumeInodeAttributes.BlockType; "security_style" = $vol.VolumeSecurityAttributes.Style; # dedupe_enabled,auto_increment_size_mb,!snapshot_policy_id,export_policy_id,autosize_enabled, "dedupe_enabled" = $(bool $vol.VolumeSisAttributes.IsSisVolume); "auto_increment_size_mb" = [int64]($vol.VolumeAutosizeAttributes.IncrementSize / 1MB); "snapshot_policy_id" = $snappolicyid; "export_policy_id" = $policyid; "autosize_enabled" = $(bool ($vol.VolumeAutoSizeAttributes.IsEnabled)); # compression,deduplication_space_saved_mb,compression_space_saved_mb,percent_deduplication_space_saved, "deduplication_space_saved_mb" = [int64]($vol.VolumeSisAttributes.DeduplicationSpaceSaved / 1MB); "compression_space_saved_mb" = [int64]($vol.VolumeSisAttributes.CompressionSpaceSaved / 1MB); "percent_deduplication_space_saved" = $vol.VolumeSisAttributes.PercentageDeduplicationSpaceSaved; # percent_compression_space_saved,hybrid_cache_eligibility,inode_files_total,inode_files_used, "percent_compression_space_saved" = $vol.VolumeSisAttributes.PercentageCompressionSpaceSaved; "hybrid_cache_eligibility" = $vol.VolumeHybridCacheAttributes.Eligibility; "inode_files_total" = $vol.VolumeInodeAttributes.FilesTotal; "inode_files_used" = $vol.VolumeInodeAttributes.FilesUsed; # auto_size_mode,sis_last_op_begin_timestamp,sis_last_op_end_timestamp,flexcache_origin_volume_id, "auto_size_mode" = $vol.VolumeAutoSizeAttributes.Mode; # flexcache_min_reserve_mb,constituent_role,is_managed_by_service,storage_class,snap_diff_enabled, # max_namespace_constituent_size_mb,max_data_constituent_size_mb,efficiency_policy_id,qos_policy_group_id, "qos_policy_group_id" = $qosid; # language,data_daily_growth_rate_mb,data_days_until_full,auto_delete_enabled,auto_delete_commitment, "language" = $vol.VolumeLanguageAttributes.LanguageCode; "auto_delete_enabled" = $(bool $vol.VolumeSnapshotAutodeleteAttributes.IsAutodeleteEnabled); "auto_delete_commitment" = $vol.VolumeSnapshotAutodeleteAttributes.Commitment; # auto_delete_delete_order,auto_delete_defer_delete,auto_delete_target_free_space,auto_delete_trigger, "auto_delete_delete_order" = $vol.VolumeSnapshotAutodeleteAttributes.DeleteOrder; "auto_delete_defer_delete" = $vol.VolumeSnapshotAutodeleteAttributes.DeferDelete; "auto_delete_target_free_space" = $vol.VolumeSnapshotAutodeleteAttributes.TargetFreeSpace; "auto_delete_trigger" = $vol.VolumeSnapshotAutodeleteAttributes.Trigger; #auto_delete_prefix,auto_delete_destroy_list" -split ",") "auto_delete_prefix" = $vol.VolumeSnapshotAutodeleteAttributes.Prefix; "auto_delete_destroy_list" = $vol.VolumeSnapshotAutodeleteAttributes.DestroyList; } if ($style -eq "constituent") { $newvol.constituent_role = $vol.VolumeInfinitevolAttributes.ConstituentRole } if ($style -eq "infinivol") { $newvol.is_managed_by_service = $(bool $vol.VolumeInfinitevolAttributes.IsManagedByService) $newvol.snap_diff_enabled = $(bool $vol.VolumeInfinitevolAttributes.EnableSnapdiff) if ($vol.VolumeInfinitevolAttributes.MaxNamespaceConstituentSize -ne $null) { $newvol.max_namespace_constituent_size_mb = [int64]($vol.VolumeInfinitevolAttributes.MaxNamespaceConstituentSize / 1MB) } if ($vol.VolumeInfinitevolAttributes.MaxDataConstituentSize -ne $null) { $newvol.max_data_constituent_size_mb = [int64]($vol.VolumeInfinitevolAttributes.MaxDataConstituentSize / 1MB) } } if ($newvol.snapshot_reserved_percent -eq $null) { $newvol.snapshot_reserved_percent = 0 } if ($vol.VolumeStateAttributes.IsVserverRoot) { if ($out["vserver"][$vserverid]) { $out["vserver"][$vserverid]["root_volume_id"] = $volid } else { doLog "Vserver root for unknown vserver $($vol.Vserver)" } } if ($vol.VolumeCloneAttributes -ne $null -and $vol.VolumeCloneAttributes.VolumeCloneParentAttributes -ne $null) { $cloneVols += $vol } $out["volume"][$volid] = $newvol } doLog "Processing clone volumes" $true @($cloneVols) | % { $vol = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($vol.Vserver)"] $volid = $currentIds["volume"]["$vserverid`t$($vol.Name)"] $parent = $vol.VolumeCloneAttributes.VolumeCloneParentAttributes.Name $parentid = $currentIds["volume"]["$vserverid`t$parent"] if ($volid -eq $null) { doLog "Failed to find volume $($vol.Name) in vserver $($vol.Vserver) for cluster $cluster (for volume $($vol.Name))" } elseif ($out["volume"][$volid] -eq $null) { doLog "Failed to find volume data for $($vol.Name) in vserver $($vol.Vserver) for cluster $cluster" } elseif ($parentid -eq $null) { doLog "Failed to find volume $parent in vserver $($vol.Vserver) for cluster $cluster (for volume $($vol.Name))" } else { $out["volume"][$volid]["parent_volume_id"] = $parentid } } doLog "Fetching sis data" $true foreach ($sis in @(Get-NcSis -EA Stop)) { if ($sis.Policy -ne $null) { if ($sis.Path -match "/vol/([^/]*)") { $volume = $matches[1] $vserverid = $currentIds["vserver"]["$clusterid`t$($sis.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($vol.Vserver) for cluster $cluster" continue } $volumeid = $currentIds["volume"]["$vserverid`t$volume"] if ($volumeid -eq $null) { doLog "Failed to find volume $volume in vserver $($sis.Vserver) for cluster $cluster" continue } $effid = $currentIds["efficiency_policy"]["$vserverid`t$($sis.Policy)"] if ($effid -eq $null) { doLog "Failed to find efficieny policy $($sis.Policy) in vserver $($sis.Vserver) for cluster $cluster" continue } # max_namespace_constituent_size_mb,max_data_constituent_size_mb,efficiency_policy_id,qos_policy_group_id, $out["volume"][$volumeid]["efficiency_policy_id"] = $effid # auto_size_mode,sis_last_op_begin_timestamp,sis_last_op_end_timestamp,flexcache_origin_volume_id, #$out["volume"][$volumeid]["sis_last_op_begin_timestamp"] = $sis.LastOperationBeginTimestampDT #$out["volume"][$volumeid]["sis_last_op_end_timestamp"] = $sis.LastOperationEndTimestampDT $compression = "disabled" if ($sis.IsCompressionEnabled) { $compression = "background" if ($sis.IsInlineCompressionEnabled) { $compression = "inline" } } $out["volume"][$volumeid]["compression"] = $compression } } } doLog "Fetching qtree data" $true @(Get-NcQtree -EA Stop) | % { $qtree = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($qtree.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($qtree.Vserver) for cluster $cluster" return } $volid = $currentIds["volume"]["$vserverid`t$($qtree.Volume)"] if ($volid -eq $null) { doLog "Failed to find volume $($qtree.Volume) from vserver $($qtree.Vserver) for cluster $cluster" return } $vol = $out["volume"][$volid] $path = $null if ($vol -ne $null -and $vol.junction_path -ne "-") { $path = $vol.junction_path + "/" + $qtree.Qtree if ($path -eq "//") { $path = "/" } } $qtreeid = getId "qtree" "$volid`t$($qtree.Qtree)" # "qtree" = @("id,name,oplock_mode,path,security_style,volume_id,disk_limit_mb,disk_soft_limit_mb,files_limit,soft_files_limit,threshold_mb,disk_used_mb" -split ","); $newqtree = @{ "id" = $qtreeid; "name" = "$($qtree.Qtree)"; "oplock_mode" = $qtree.Oplocks; "path" = $path "volume_id" = $volid; } $out["qtree"][$qtreeid] = $newqtree } doLog "Fetching quota data" $true @(Get-NcQuotaReport -EA Stop) | % { $quota = $_ if ($quota.QuotaType -ne "tree") { return } $vserverid = $currentIds["vserver"]["$clusterid`t$($quota.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($quota.Vserver) for cluster $cluster" return } $volid = $currentIds["volume"]["$vserverid`t$($quota.Volume)"] if ($volid -eq $null) { doLog "Failed to find volume $($quota.Volume) in vserver $($quota.Vserver) for cluster $cluster" return } $qtreeid = $currentIds["qtree"]["$volid`t$($quota.Qtree)"] if ($qtreeid -eq $null) { doLog "Failed to find qtree $($quota.Qtree) in volume $($quota.Volume) in vserver $($quota.Vserver) for cluster $cluster" return } $qt = $out["qtree"][$qtreeid] if ($qt -eq $null) { doLog "Failed to find qtree $($quota.Qtree) in volume $($quota.Volume) in vserver $($quota.Vserver) for cluster $cluster" return } # "qtree" = @("id,name,oplock_mode,path,security_style,volume_id,disk_limit_mb,disk_soft_limit_mb,files_limit,soft_files_limit,threshold_mb,disk_used_mb" -split ","); if ($quota.DiskLimit -ne $null -and $quota.DiskLimit -ne "-") { $qt["disk_limit_mb"] = [int64]($quota.DiskLimit / 1KB) } if ($quota.SoftDiskLimit -ne $null -and $quota.SoftDiskLimit -ne "-") { $qt["disk_soft_limit_mb"] = [int64]($quota.SoftDiskLimit / 1KB) } if ($quota.Threshold -ne $null -and $quota.Threshold -ne "-") { $qt["threshold_mb"] = [int64]($quota.Threshold / 1KB) } if ($quota.FileLimit -ne $null -and $quota.FileLimit -ne "-") { $qt["files_limit"] = $quota.FileLimit } if ($quota.SoftFileLimit -ne $null -and $quota.SoftFileLimit -ne "-") { $qt["soft_files_limit"] = $quota.SoftFileLimit } $qt["disk_used_mb"] = [int64]($quota.DiskUsed / 1KB) } doLog "Fetching lun data" $true @(Get-NcLun -EA Stop) | % { $lun = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($lun.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($lun.Vserver) for cluster $cluster" return } $volid = $currentIds["volume"]["$vserverid`t$($lun.Volume)"] if ($volid -eq $null) { doLog "Failed to find volume $($lun.Volume) from vserver $($lun.Vserver) for cluster $cluster" return } $qtreeid = $currentIds["qtree"]["$volid`t$($lun.Qtree)"] if ($qtreeid -eq $null) { doLog "Failed to find qtree '$($lun.Qtree)' in $($lun.Volume) from vserver $($lun.Vserver) for cluster $cluster" return } $name = $($lun.Path -replace "^.*/", ""); $fullpath = $($lun.Path -replace "^/vol/", ""); $lunid = getId "lun" "$vserverid`t$fullpath" $qosid = $null if ($lun.QosPolicyGroup -ne $null) { $qosid = $currentIds["qos_policy_group"]["$vserverid`t$($lun.QosPolicyGroup)"] if ($qosid -eq $null) { doLog "Failed to find qos policy $($lun.QosPolicyGroup) for vserver $($vol.Vserver) in cluster $cluster (for lun $($lun.Path))" } } # "lun" = @("id,name,os_type,prefix_size,size_mb,space_reserved,qtree_id,volume_id,vserver_id, $newlun = @{ "id" = $lunid; "name" = $name; "os_type" = $lun.Protocol; "size_mb" = [int64]($lun.Size / 1MB); "space_reserved" = $(bool $lun.IsSpaceReservationEnabled); "qtree_id" = $qtreeid; "volume_id" = $volid; "vserver_id" = $vserverid; # full_path,is_online,space_alloc_enabled,serial_number,alignment,comment,qos_policy_group_id "full_path" = $fullpath; "is_online" = $(bool $lun.Online); "space_alloc_enabled" = $(bool $lun.IsSpaceAllocEnabled); "serial_number" = $lun.SerialNumber; "alignment" = $lun.Alignment; "comment" = $lun.Comment; "qos_policy_group_id" = $qosid; }; $out["lun"][$lunid] = $newlun } doLog "Fetching lun mappings" @(Get-NcLunMap -EA Stop) | % { $map = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($map.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($map.Vserver) for cluster $cluster" return } $path = $map.Path -replace "^/vol/", "" $lunid = $currentIds["lun"]["$vserverid`t$path"] if ($lunid -eq $null) { doLog "Failed to find lun $path in vserver $($map.Vserver) for cluster $cluster" return } $igroupid = $currentIds["igroup"]["$vserverid`t$($map.InitiatorGroup)"] if ($igroupid -eq $null) { doLog "Failed to find igroup $($map.InitiatorGroup) in vserver $($map.Vserver) for cluster $cluster" return } $mapid = getId "lunmap" "$lunid`t$igroupid" # "lunmap" = @("id,lun_id,igroup_id,lun_map_value" -split ","); $newmap = @{ "id" = $mapid; "lun_id" = $lunid; "igroup_id" = $igroupid; "lun_map_value" = $map.LunId; } $out["lunmap"][$mapid] = $newmap } doLog "Fetching Cifs shares" $true @(Get-NcCifsShare -EA Stop) | % { $share = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($share.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($share.Vserver) for cluster $cluster" return } $shareid = getId "cifs_share" "$vserverid`t$($share.ShareName)" # "cifs_share" = @("id,name,path,vserver_id,comment,share_properties" -split ","); $newshare = @{ "id" = $shareid; "name" = $share.ShareName; "path" = $share.Path; "vserver_id" = $vserverid; "comment" = $share.Comment; "share_properties" = $($share.ShareProperties -join ","); } $out["cifs_share"][$shareid] = $newshare } doLog "Fetching Cifs share acls" $true @(Get-NcCifsShareAcl -EA Stop) | % { $acl = $_ $vserverid = $currentIds["vserver"]["$clusterid`t$($acl.Vserver)"] if ($vserverid -eq $null) { doLog "Failed to find vserver $($acl.Vserver) for cluster $cluster" return } $shareid = $currentIds["cifs_share"]["$vserverid`t$($acl.Share)"] if ($shareid -eq $null) { doLog "Failed to find share $($acl.Share) in vserver $($acl.Vserver) for cluster $cluster" return } $aclid = getId "cifs_share_acl" "$shareid`t$($acl.UserOrGroup)" # "cifs_share_acl" = @("id,cifs_share_id,user_or_group,access_level" -split ","); $newacl = @{ "id" = $aclid; "cifs_share_id" = $shareid; "user_or_group" = $acl.UserOrGroup; "access_level" = $acl.Permission; } $out["cifs_share_acl"][$aclid] = $newacl } } catch { doLog "Error on $cluster [last action '$global:lastlog']: $_" if ($strict) { throw "Error on $cluster [last action '$global:lastlog']: $_" } } } # Second iteration to handle peering $peerCluster = @{} $clusters | % { $cluster = $_ try { doLog "Connecting to $cluster" $true Connect-WfaCluster $cluster -Timeout $timeout -EA stop $info = Get-NcCluster -EA Stop $currentName = $info.ClusterName $currentId = $currentIds["cluster"][$currentName] if ($currentId -eq $null) { throw "Could not get cluster name for $cluster???" } doLog "Processing cluster peers" $true @(Get-NcClusterPeer -EA Stop) | % { # "cluster_peer" = @("id,primary_cluster_id,peer_cluster_id,cluster_uuid,peer_addresses,availability,active_addresses,serial_number,remote_cluster_nodes,is_cluster_healthy,unreachable_local_nodes,address_family,auth_status_admin,auth_status_operational,ipspace_id" -split ","); $peer = $_ $peerclusterid = $currentIds["cluster"][$peer.RemoteClusterName] if ($peerclusterid -eq $null) { doLog "Unable to find cluster $($peer.RemoteClusterName) for cluster peering of $($currentName)" return } $ipspaceid = $null if ($peer.IpspaceName -ne $null) { $ipspaceid = $currentIds["ipspace"]["$currentId`t$($peer.IpspaceName)"] } $peerid = getId "cluster_peer" "$currentId`t$peerclusterid" $newpeer = @{ "id" = $peerid; "primary_cluster_id" = $currentid; "peer_cluster_id" = $peerclusterid; "cluster_uuid" = $($peer.ClusterUuid); "peer_addresses" = $($peer.PeerAddresses -join ","); "availability" = $($peer.Availability); "active_addresses" = $($peer.ActiveAddresses -join ","); "serial_number" = $($peer.SerialNumber); "remote_cluster_nodes" = $($peer.RemoteClusterNodes -join ","); "unreachable_local_nodes" = $($peer.UnreachableLocalNodes -join ","); "address_family" = $($peer.AddressFamily); "auth_status_admin" = $($peer.AuthStatusAdmin); "auth_status_operational" = $($peer.AuthStatusOperational); "ipspace_id" = $ipspaceid; } if ($peer.IsClusterHealthySpecified) { $newpeer.is_cluster_healthy = $(bool $peer.IsClusterHealthy) } $out["cluster_peer"][$peerid] = $newpeer } doLog "Processing vserver peers" $true @(Get-NcVserverPeer -EA Stop) | % { $peer = $_ if ($peer.PeerCluster -eq $null) { return } $peerclusterid = $currentIds["cluster"][$peer.PeerCluster] if ($peerclusterid -eq $null) { doLog "Unable to find cluster $($peer.PeerCluster) for vserver peering of $($currentName):$($peer.Vserver)" return } $peervserverid = $currentIds["vserver"]["$peerclusterid`t$($peer.PeerVserver)"] if ($peervserverid -eq $null) { doLog "Unable to find vserver $($peer.PeerVserver) in cluster $($peer.PeerCluster) for vserver peering of $($currentName):$($peer.Vserver)" return } $vserverid = $currentIds["vserver"]["$currentId`t$($peer.Vserver)"] if ($vserverid -eq $null) { doLog "Unable to find vserver $($peer.Vserver) in cluster $currentName for vserver peering" return } $vserver = $out["vserver"][$vserverid] $peervserver = $out["vserver"][$peervserverid] if ($vserver -ne $null -and $peervserver -ne $null) { $uuid = $vserver.uuid + "_" + $peervserver.uuid + "_" + $($peer.Applications -join ",") } else { doLog "Unable to find uuid for vserver $($peer.Vserver) in cluster $currentName for vserver peering" return } $associd = getId "vserver_association" "$vserverid`t$peervserverid" $peerCluster["$currentId`t$($peer.Vserver)`t$($peer.PeerVserver)"] = $peerclusterid # Create vserver associations to correspond with vserver_peers. Associations are really a OCUM concept # But we'll create them anyway. # "vserver_association" = @("id,source_vserver_id,destination_vserver_id,type,uuid" -split ","); $newassoc = @{ "id" = $associd; "source_vserver_id" = $vserverid; "destination_vserver_id" = $peervserverid; "type" = $($peer.Applications -join ","); "uuid" = $uuid; } $out["vserver_association"][$associd] = $newassoc $peerid = getId "vserver_peer" "$vserverid`t$peervserverid" # "vserver_peer" = @("id,vserver_id,peer_vserver_id,peer_state,applications" -split ","); $newpeer = @{ "id" = $peerid; "vserver_id" = $vserverid; "peer_vserver_id" = $peervserverid; "peer_state" = $($peer.PeerState); "applications" = $($peer.Applications -join ","); } $out["vserver_peer"][$peerid] = $newpeer } } catch { doLog "Error on $cluster [last action '$global:lastlog']: $_" if ($strict) { throw "Error on $cluster [last action '$global:lastlog']: $_" } } } $clusters | % { $cluster = $_ try { doLog "Connecting to $cluster" $true Connect-WfaCluster $cluster -Timeout $timeout -EA stop $info = Get-NcCluster -EA Stop $currentName = $info.ClusterName $currentId = $currentIds["cluster"][$currentName] if ($currentId -eq $null) { throw "Could not get cluster name for $cluster???" } doLog "Processing snapmirror relationships" $true $sms = @(Get-NcSnapmirror -EA Stop) # First go through and find SVM DR snapmirror relationships $sms | % { $sm = $_ if ($sm.RelationshipGroupType -eq $null -or $sm.RelationshipGroupType -ne "vserver") { # Ignore everything except SVM DR here... return } if ($sm.DestinationCluster -ne $null -and $sm.DestinationCluster -ne $currentName) { doLog "Ignoring snapmirror for $($sm.DestinationCluster) which is not current cluster ($currentName)" return } if ($sm.SourceCluster -eq $null) { $sourceclusterid = $peerCluster["$currentId`t$($sm.DestinationVserver)`t$($sm.SourceVserver)"] if ($sourceclusterid -eq $null) { $sourceclusterid = $currentId } } else { $sourceclusterid = $currentIds["cluster"][$sm.SourceCluster] } if ($sourceclusterid -eq $null) { doLog "Could not find cluster '$($sm.SourceCluster)' for SVM DR to $($sm.DestinationCluster):$($sm.DestinationVserver)" return } $sourcevserverid = $currentIds["vserver"]["$sourceclusterid`t$($sm.SourceVserver)"] if ($sourcevserverid -eq $null) { doLog "Could not find vserver '$($sm.SourceVserver)' in cluster '$($sm.SourceCluster)' for SVM DR to $($sm.DestinationCluster):$($sm.DestinationVserver)" return } $destvserverid = $currentIds["vserver"]["$currentId`t$($sm.DestinationVserver)"] if ($destvserverid -eq $null) { doLog "Could not find vserver '$($sm.DestinationVserver)' in cluster '$($sm.DestinationVserver)' for snapmirror to $($sm.DestinationCluster):$($sm.DestinationVserver)" return } $smpolicyid = $null if ($sm.Policy -ne $null) { $smpolicyid = $currentIds["snapmirror_policy"]["$destvserverid`t$($sm.Policy)"] if ($smpolicyid -eq $null) { # Search for snapmirror policy in the cluster vserver $cvsid = $currentIds["vserver"]["$currentId`t$currentName"] if ($cvsid -ne $null) { $smpolicyid = $currentIds["snapmirror_policy"]["$cvsid`t$($sm.Policy)"] } } if ($smpolicyid -eq $null) { doLog "Could not find snapmirror policy '$($sm.Policy)' for SVM DR to $($sm.DestinationCluster):$($sm.DestinationVserver)" } } $schedid = $null if ($sm.Schedule -ne $null) { $schedid = $currentIds["schedule"]["$currentId`t$($sm.Schedule)"] if ($schedid -eq $null) { doLog "Could not find schedule '$($sm.Schedule)' for SVM DR to $($sm.DestinationCluster):$($sm.DestinationVserver)" } } $smid = getId "snapmirror_svm" "$sourcevserverid`t$destvserverid" # "snapmirror_svm" = @("id,tries,type,destination_vserver_id,max_transfer_rate,snapmirror_policy_id,schedule_id,state,relationship_identifier,source_vserver_id" $newsm = @{ "id" = $smid; "tries" = $sm.Tries; "type" = $sm.RelationshipType; "destination_vserver_id" = $destvserverid; "max_transfer_rate" = $sm.MaxTransferRate; "snapmirror_policy_id" = $smpolicyid; "schedule_id" = $schedid; "state" = $sm.MirrorState; "relationship_identifier" = $sm.RelationshipId; "source_vserver_id" = $sourcevserverid; } $out["snapmirror_svm"][$smid] = $newsm } # Look for regular snapmirrors now. $sms | % { $sm = $_ if ($sm.RelationshipType -eq "transition_data_protection") { # Ignore transition relationships return } if ($sm.RelationshipGroupType -eq "vserver") { # Ignore SVM DR here... it was handled above. return } if ($sm.DestinationCluster -ne $null -and $sm.DestinationCluster -ne $currentName) { doLog "Ignoring snapmirror for $($sm.DestinationCluster) which is not current cluster ($currentName)" return } if ($sm.SourceCluster -eq $null) { $sourceclusterid = $peerCluster["$currentId`t$($sm.DestinationVserver)`t$($sm.SourceVserver)"] if ($sourceclusterid -eq $null) { $sourceclusterid = $currentId } } else { $sourceclusterid = $currentIds["cluster"][$sm.SourceCluster] } if ($sourceclusterid -eq $null) { doLog "Could not find cluster '$($sm.SourceCluster)' for snapmirror to $($sm.DestinationCluster):$($sm.DestinationVserver)/$($sm.DestinationVolume)" return } $sourcevserverid = $currentIds["vserver"]["$sourceclusterid`t$($sm.SourceVserver)"] if ($sourcevserverid -eq $null) { doLog "Could not find vserver '$($sm.SourceVserver)' in cluster '$($sm.SourceCluster)' for snapmirror to $($sm.DestinationCluster):$($sm.DestinationVserver)/$($sm.DestinationVolume)" return } $destvserverid = $currentIds["vserver"]["$currentId`t$($sm.DestinationVserver)"] if ($destvserverid -eq $null) { doLog "Could not find vserver '$($sm.DestinationVserver) in cluster '$($sm.DestinationVserver)' for snapmirror to $($sm.DestinationCluster):$($sm.DestinationVserver)/$($sm.DestinationVolume)" return } $sourcevolumeid = $currentIds["volume"]["$sourcevserverid`t$($sm.SourceVolume)"] if ($sourcevolumeid -eq $null) { doLog "Could not find volume $($sm.SourceVolume) in vserver '$($sm.SourceVserver) in cluster '$($sm.SourceCluster)' for snapmirror to $($sm.DestinationCluster):$($sm.DestinationVserver)/$($sm.DestinationVolume)" return } $destvolumeid = $currentIds["volume"]["$destvserverid`t$($sm.DestinationVolume)"] if ($destvolumeid -eq $null) { doLog "Could not find snapmirror dest volume $($sm.DestinationCluster):$($sm.DestinationVserver)/$($sm.DestinationVolume)" return } $smpolicyid = $null if ($sm.Policy -ne $null) { $smpolicyid = $currentIds["snapmirror_policy"]["$destvserverid`t$($sm.Policy)"] if ($smpolicyid -eq $null) { # Search for snapmirror policy in the cluster vserver $cvsid = $currentIds["vserver"]["$currentId`t$currentName"] if ($cvsid -ne $null) { $smpolicyid = $currentIds["snapmirror_policy"]["$cvsid`t$($sm.Policy)"] } } if ($smpolicyid -eq $null) { doLog "Could not find snapmirror policy '$($sm.Policy) for dest volume $($sm.DestinationCluster):$($sm.DestinationVserver)/$($sm.DestinationVolume)" } } $schedid = $null if ($sm.Schedule -ne $null) { $schedid = $currentIds["schedule"]["$currentId`t$($sm.Schedule)"] if ($schedid -eq $null) { doLog "Could not find schedule '$($sm.Schedule) for dest volume $($sm.DestinationCluster):$($sm.DestinationVserver)/$($sm.DestinationVolume)" } } $svmsmid = $currentIds["snapmirror_svm"]["$sourcevserverid`t$destvserverid"] $smid = getId "snapmirror" "$sourcevolumeid`t$destvolumeid" # "snapmirror" = @("id,secondary_volume_id,tries,type,volume_id,max_transfer_rate,snapmirror_policy_id,schedule_id,state,relationship_identifier,vserver_snapmirror_id" -split ","); $newsm = @{ "id" = $smid; "secondary_volume_id" = $destvolumeid; "tries" = $sm.Tries; "type" = $sm.RelationshipType; "volume_id" = $sourcevolumeid; "max_transfer_rate" = $sm.MaxTransferRate; "snapmirror_policy_id" = $smpolicyid; "schedule_id" = $schedid; "state" = $sm.MirrorState; "relationship_identifier" = $sm.RelationshipId; "vserver_snapmirror_id" = $svmsmid; } $out["snapmirror"][$smid] = $newsm } } catch { doLog "Error on $cluster [last action '$global:lastlog']: $_" if ($strict) { throw "Error on $cluster [last action '$global:lastlog']: $_" } } } doLog "Outputting files" $true $tableList = "broadcast_domain, failover_group, ipspace, storage_pool, storage_pool_aggregate, storage_pool_available cluster_peer, snapmirror_svm, vserver_peer disk, disk_aggregate, efficiency_policy, resource_group, resource_group_member, resource_pool, resource_pool_member, cluster, node, vserver, aggregate, volume, qtree, lun, vserver_allowed_aggregate fcp_adapter, export_policy, export_rule, igroup, qos_policy_group, lunmap, portset, port, schedule, cifs_share, cifs_share_acl, portset_member, logical_interface, snapshot_policy, snapshot_policy_schedule, snapmirror, vserver_association, snapmirror_policy, snapmirror_policy_rule, cluster_license" $tableList -split "[,\s]+" | % { if ($out[$_] -ne $null) { outputFile $_ $out[$_] } else { outputFile $_ @{} } } doLog "Complete"