Exporting VSC Alignment Scan reports

by Frequent Contributor on ‎2014-03-14 10:00 PM

Hi,

I was recently asked if they is any way to export VSC alignment scan information via an API as there is no export function in the VSC GUI. The information is available in the logs but i wanted to export it via an API rather than parsing the log file.

As it took some time to find the solution I thought i'd share it (credit to Jeremy Maness for providing the API solution). An example of the log looks like this:

"C:\Program Files\NetApp\Virtual Storage Console\log\caster.log"

2014-03-14 13:58:12,690 (pool-3-thread-1) INFO  [AlignmentScanManager] - Scanning datastores with the following morefs: [Datastore:datastore-144]

2014-03-14 13:58:12,690 (pool-3-thread-1) INFO  [ControllerUtil] - logging level 6 to EMS: Scanning datastores with the following morefs: [Datastore:datastore-144]

2014-03-14 13:58:12,955 (pool-3-thread-1) INFO  [ControllerUtil] - logging level 6 to EMS: Scanning datastores with the following morefs: [Datastore:datastore-144]

2014-03-14 13:58:13,455 (pool-3-thread-1) INFO  [DatastoreUtil] - getDSVolumeQtreeName: testns01 does not have the address 192.168.100.23

2014-03-14 13:58:13,455 (pool-3-thread-1) INFO  [DatastoreUtil] - getDSVolumeQtreeName: testnv01 has the ip address 192.168.100.23 on interface e0b

2014-03-14 13:58:13,455 (pool-3-thread-1) INFO  [DatastoreUtil] - getDSVolumeQtreeName: /vol/vol2 replaced with /vol/vol2

2014-03-14 13:58:15,530 (pool-3-thread-1) INFO  [DatastoreUtil] - getDSVolumeQtreeName: testnv01 has the ip address 192.168.100.23 on interface e0b

2014-03-14 13:58:15,530 (pool-3-thread-1) INFO  [DatastoreUtil] - getDSVolumeQtreeName: /vol/vol2 replaced with /vol/vol2

2014-03-14 13:58:15,530 (pool-3-thread-1) ERROR [AlignmentScanManager] - Invalid suffix detected for an NFS-shimmed volume:

2014-03-14 13:58:15,842 (pool-3-thread-1) INFO  [CasterPreferences] - default.option.scanthreads=4

2014-03-14 13:58:15,842 (pool-3-thread-1) INFO  [CasterPreferences] - default.option.scantimeout_mins.vms=1440

2014-03-14 13:58:15,842 (pool-3-thread-1) INFO  [CasterPreferences] - default.option.migratethreads=4

2014-03-14 13:58:15,889 (VMExaminer-testxp10-1394765895842) INFO  [VMExaminerService] - Scanning virtual machine: testxp10 (5021e732-9bcc-f68d-8a64-1c99a4b50867)

2014-03-14 13:58:16,606 (VMExaminer-testxp10-1394765895842) INFO  [VMExaminerService] - Cleaning up any remaining snapshots

2014-03-14 13:58:16,638 (VMExaminer-testxp10-1394765895842) INFO  [VMExaminerService] - Finished scanning virtual machine: testxp10 (5021e732-9bcc-f68d-8a64-1c99a4b50867)

2014-03-14 13:58:16,669 (pool-3-thread-1) INFO  [AlignmentScanManager] - AlignmentScanManager is done

2014-03-14 13:58:16,669 (pool-3-thread-1) INFO  [AlignmentScanManager] - Scan initiation ended

Its possible to list of all virtual machines that have been scanned by parsing the log. EG:

C:\Program Files\NetApp\Virtual Storage Console\log>find /i "[VMExaminerService] - Finished scanning virtual machine:" caster.log

 

---------- CASTER.LOG

2014-03-14 13:58:16,638 (VMExaminer-testxp10-1394765895842) INFO  [VMExaminerService] - Finished scanning virtual machine: testxp10 (5021e732-9bcc-f68d-8a64-1c99a4b50867)

A better approach is to use the "getAlignmentReport" API. Here is an example of how to invoke it using powershell:

#'------------------------------------------------------------------------------

Function Get-AlignmentReport{

   <#

   .SYNOPSIS

      Get-AlignmentReport retrieves an alignment status report from a previous alignment scan

   .DESCRIPTION

      Get-AlignmentReport retrieves an alignment status report from a previous alignment scan.

      The alignment scan should be initiated through the VSC user interface.

   .PARAMETER VscHostName

      Specifies the hostname or IP address of the vCenter Server

   .PARAMETER PortNumber

      Specifies the VSC Port Number

   .PARAMETER Credentials

      Specifies the credential object to connect to VSC

   .INPUTS

      None. You cannot pipe objects to Get-AlignmentReport.

   .OUTPUTS

      A scannedVirtualMachine object for each virtual machine, containing the following properties:

      alignmentStatus          alignmentStatus (Enum: FUNCTIONALLY_ALIGNED, ACTUALLY_ALIGNED,

                                                     ONLINE_MIGRATION, OFFLINE_ALIGNMENT, OTHER)

      alignmentStatusSpecified System.Boolean

      datastoreName            System.String

      hosts                    System.String

      instanceUuid             System.String

      moref                    System.String

      name                     System.String

      offset                   System.Int32

      offsetSpecified          System.Boolean

   .EXAMPLE

      C:\PS> Get-AlignmentReport -VscHostName "testvc01" -PortNumber 8143 -Credentials $credentials

   .LINK

      http://www.netapp.com/us/products/management-software/vsc/

   #>

   [CmdletBinding()]

   Param(

      [Parameter(Position=0,

         Mandatory=$True,

         ValueFromPipeLine=$True,

         ValueFromPipeLineByPropertyName=$True)]

      [String]$VscHostName,

      [Parameter(Position=1,

         Mandatory=$True,

         ValueFromPipeLine=$True,

         ValueFromPipeLineByPropertyName=$True)]

      [Int]$PortNumber,

      [Parameter(Position=2,

         Mandatory=$True,

         ValueFromPipeLine=$True,

         ValueFromPipeLineByPropertyName=$True)]

      [System.Management.Automation.PSCredential]$Credentials

   )

   #'---------------------------------------------------------------------------

   #'Bypass SSL certificate confirmation

   #'---------------------------------------------------------------------------

   [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$True}

   #'---------------------------------------------------------------------------

   #'Create a web service connection to VSC

   #'---------------------------------------------------------------------------

   [String]$uri = "https://$VscHostName`:$PortNumber/caster/public/api?wsdl"

   Try{

      [System.Web.Services.Protocols.SoapHttpClientProtocol]$connection = `

      New-WebServiceProxy -uri $uri -Credential $Credentials -ErrorAction Stop

      Write-Host "Connected to VSC on ""$uri"""

   }Catch{

      Write-Host ("Error """ + $Error[0] + """ Connecting to ""$uri""")

      Break;

   }

   #'---------------------------------------------------------------------------

   #'Enumerate the VSC namespace

   #'---------------------------------------------------------------------------

   [System.Object]$namespace = $connection.GetType().Namespace  

   #'---------------------------------------------------------------------------

   #'Enumerate the VSC username and password from the Credential object

   #'---------------------------------------------------------------------------

   [String]$vscDomain   = $Credentials.GetNetworkCredential().domain

   [String]$vscUser     = $Credentials.GetNetworkCredential().username

   [String]$vscPassword = $Credentials.GetNetworkCredential().password

   [String]$vscUsername = "$vscDomain\$vscUser"

   #'---------------------------------------------------------------------------

   #'Create a requestSpec object and set credentials.

   #'---------------------------------------------------------------------------

   [System.Object]$requestSpecType        = ($namespace + '.requestSpec')

   [System.Object]$requestSpec            = New-Object ($requestSpecType)

   [System.Object]$requestSpec.serviceUrl = "https://" + $vscHostName + "/sdk"

   [System.Object]$requestSpec.vcUser     = $vscUsername

   [System.Object]$requestSpec.vcPassword = $vscPassword

   #'---------------------------------------------------------------------------

   #'Invoke the GetAlignmentReport API and return the results.

   #'---------------------------------------------------------------------------

   Try{

      $results = $connection.getAlignmentReport($requestSpec)

   }Catch{

      Write-Host ("Error """ + $Error[0] + """ invoking the ""GetAlignmentReport"" Method")

      Break;     

   }

   Return $results;

}#End Function

#'------------------------------------------------------------------------------

#'Prompt for VSC credentials.

#'------------------------------------------------------------------------------

[String]$username = "testlab\administrator"

[System.Security.SecureString]$password = Read-Host "Please enter the password for user ""$username""" -AsSecureString

[System.Management.Automation.PSCredential]$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password

#'------------------------------------------------------------------------------

#'Enumerate the VSC alignment report and display the results.

#'------------------------------------------------------------------------------

$results = Get-AlignmentReport -VscHostName "testvc01" -PortNumber 8143 -Credentials $Credentials

$results | Where-Object {$_.alignmentStatus -eq "ONLINE_MIGRATION"}

#'------------------------------------------------------------------------------

Example output:

PS C:\Scripts\PowerShell\Projects\VSC> .\GetAlignmentReport.ps1
Please enter the password for user "testlab\administrator": *************
Connected to VSC on "https://testvc01:8143/caster/public/api?wsdl"

alignmentStatus          : ONLINE_MIGRATION

alignmentStatusSpecified : True

datastoreName            : datastore1

instanceUuid             : 5021e732-9bcc-f68d-8a64-1c99a4b50867

moref                    : VirtualMachine:vm-411

name                     : testxp10

offset                   : 7

offsetSpecified          : True

GUI View:

Hope that helps

Cheers Matt

Comments

Hi

I try to use the scripts but have no results and no errors

...

PS C:\Support\Scripts> .\GetAlignmentReport.ps1

Please enter the password for user "domain\user": *********

Connected to VSC on "https://192.168.1.XXX:8143/caster/public/api?wsdl"

Try to open the link via browser:

<?xml version="1.0" encoding="UTF-8" ?>

- <!--

 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. 

-->  - <!--

 Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. 
-->

 

- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://server.caster.netapp.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://server.caster.netapp.com/" name="CasterApiWS">

- <types>

- <xsd:schema>

</xsd:schema>

</types>

- <message name="getVmFiles">

<part name="parameters" element="tns:getVmFiles" />

</message>

- <message name="getVmFilesResponse">

<part name="parameters" element="tns:getVmFilesResponse" />

</message>

- <message name="getMoref">

<part name="parameters" element="tns:getMoref" />

</message>

- <message name="getMorefResponse">

<part name="parameters" element="tns:getMorefResponse" />

</message>

- <message name="migrateVirtualMachines">

<part name="parameters" element="tns:migrateVirtualMachines" />

</message>

- <message name="migrateVirtualMachinesResponse">

<part name="parameters" element="tns:migrateVirtualMachinesResponse" />

</message>

- <message name="runAlignmentScan">

<part name="parameters" element="tns:runAlignmentScan" />

</message>

- <message name="runAlignmentScanResponse">

<part name="parameters" element="tns:runAlignmentScanResponse" />

</message>

- <message name="getAlignmentReport">

<part name="parameters" element="tns:getAlignmentReport" />

</message>

- <message name="getAlignmentReportResponse">

<part name="parameters" element="tns:getAlignmentReportResponse" />

</message>

- <portType name="Api">

- <operation name="getVmFiles">

<input message="tns:getVmFiles" />

<output message="tns:getVmFilesResponse" />

</operation>

- <operation name="getMoref">

<input message="tns:getMoref" />

<output message="tns:getMorefResponse" />

</operation>

- <operation name="migrateVirtualMachines">

<input message="tns:migrateVirtualMachines" />

<output message="tns:migrateVirtualMachinesResponse" />

</operation>

- <operation name="runAlignmentScan">

<input message="tns:runAlignmentScan" />

<output message="tns:runAlignmentScanResponse" />

</operation>

- <operation name="getAlignmentReport">

<input message="tns:getAlignmentReport" />

<output message="tns:getAlignmentReportResponse" />

</operation>

</portType>

- <binding name="ApiImplPortBinding" type="tns:Api">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />

- <operation name="getVmFiles">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" />

</input>

- <output>

<soap:body use="literal" />

</output>

</operation>

- <operation name="getMoref">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" />

</input>

- <output>

<soap:body use="literal" />

</output>

</operation>

- <operation name="migrateVirtualMachines">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" />

</input>

- <output>

<soap:body use="literal" />

</output>

</operation>

- <operation name="runAlignmentScan">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" />

</input>

- <output>

<soap:body use="literal" />

</output>

</operation>

- <operation name="getAlignmentReport">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" />

</input>

- <output>

<soap:body use="literal" />

</output>

</operation>

</binding>

- <service name="CasterApiWS">

- <port name="ApiImplPort" binding="tns:ApiImplPortBinding">

<soap:address location="https://192.168.1.XXX:8143/caster/public/api" />

</port>

</service>

</definitions>

Thank's

Frequent Contributor

Hi Daniele,

Can you try the following code (modifying varabile names to match your environment) and display the "requestSpec" values to ensure the credentials are correct?

Run the following code from a powershell prompt:

================================================================================

$vscHostName = "testvc01"
$portNumber  = 8143
$username    = "testlab\administrator"
$password    = Read-Host "Please enter the password for user ""$username""" -AsSecureString
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$True}
$uri         = "https://$VscHostName`:$PortNumber/caster/public/api?wsdl"
$connection  = New-WebServiceProxy -uri $uri -Credential $Credentials
$namespace   = $connection.GetType().Namespace
$vscDomain   = $Credentials.GetNetworkCredential().domain
$vscUser     = $Credentials.GetNetworkCredential().username
$vscPassword = $Credentials.GetNetworkCredential().password
$vscUsername = "$vscDomain\$vscUser"
$requestSpecType        = ($namespace + '.requestSpec')
$requestSpec            = New-Object ($requestSpecType)
$requestSpec.serviceUrl = "https://" + $vscHostName + "/sdk"
$requestSpec.vcUser     = $vscUsername
$requestSpec.vcPassword = $vscPassword
$results                = $connection.getAlignmentReport($requestSpec)

$requestSpec | fl

$results

================================================================================

Example Output:

================================================================================
serviceUrl : https://testvc01/sdk
vcPassword : p@ssw0rd
vcSession  :
vcUser     : testlab\administrator


alignmentStatus          : ONLINE_MIGRATION
alignmentStatusSpecified : True
datastoreName            : datastore1
instanceUuid             : 5021e732-9bcc-f68d-8a64-1c99a4b50867
moref                    : VirtualMachine:vm-411
name                     : testxp10
offset                   : 7
offsetSpecified          : True

================================================================================

Please let me know if that works. Thanks

Matt

Hi

Try the new scripts the results it’s the same.

On screen appear :

PS C:\Support\Scripts> .\GetAlignmentReport2.ps1

Please enter the password for user "domain\user": *********

serviceUrl : https://192.168.1.xxx/sdk

vcPassword : password ß (correct password)

vcSession :

vcUser : domain\user

I have VSC 4.2.1 Installed on other system of Virtual Center.

Da: mbeattie

Inviato: giovedì 20 marzo 2014 05:34

A: Daniele Vincon

Oggetto: Re: - Exporting VSC Alignment Scan reports

<https://communities.netapp.com/index.jspa> NetApp Online Community

<http://media.netapp.com/images/divider-600x3.jpg>

Exporting VSC Alignment Scan reports

new comment by mbeattie <https://communities.netapp.com/people/mbeattie> View all comments on this document <https://communities.netapp.com/docs/DOC-33049#comment-19983>

I've been using this script for some time now.  It works great.

Is there anyway to get per vmdk alignment stats from this?  I see there is "getVmFiles" but my attempts to use it have failed.

Frequent Contributor

Hi,

The "getVmFiles" method returns a list of "VmFileSpec" objects which has a diskID property but there does not appear to be any alignment property associated with individual VMDK files.
You can easily filter the results to determine the overall alignment status of a VM but I don't think it's possible to determine which disk associated with that VM is the misaligned disk.

This is unfortunate, as you can see it has the data i need just not from the api i guess:

VSC-per-vmdk-alignment.PNG

Is anyone aware of any changes to the api in VSC 5.0?  Specifically, the ability to get per vmdk alignment reports?

New Contributor

Guys have you  try to use oncommand balance? it helps with many  reports  that i find  helpfull  for me, and you can find the report that you are looking  for remember you can  get a evaluation license for this tool in the support.netapp.com page

I am Ram from india  did my MBA pass out in 2014 itself i am very interest in netapp storeage  any problem come in join for company itslef pls sir clarification ( My UG Also BBA and MBA Accounting and Finance )

 

Thanks sir

 I really hope I can get this to work so please respond if you have the time.

 

   #'Create a requestSpec object and set credentials.

   #'---------------------------------------------------------------------------

   [System.Object]$requestSpecType        = ($namespace + '.requestSpec')

   [System.Object]$requestSpec            = New-Object ($requestSpecType)

   [System.Object]$requestSpec.serviceUrl = "https://" + $vscHostName + "/sdk"

   [System.Object]$requestSpec.vcUser     = $vscUsername

   [System.Object]$requestSpec.vcPassword = $vscPassword

 

For this item, do we want the server name of our vCenter Web Client or the server name of the Virtual Storage Console server?  I didn't install the VSC on the same server as my vCenter Server or vCenter Server Web Client (don't ask - inherited this environment)

 

Also, receiving this error:

Error "Exception calling "getAlignmentReport" with "1" argument(s): "org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean$TargetBeanObjectFactory cannot be cast to com.ne
tapp.caster.server.VSphereSessionContext"" invoking the "GetAlignmentReport" Method

 

Any thoughts?

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.