RSS .92| RSS 2.0| ATOM 0.3
  • Home
  •  

    Connecting to the Nutanix PrismAPI with vCenter Orchestrator – Part 3

    March 4th, 2014

    Part 1 covered pointing the vCO HTTP-REST plugin to a PrismAPI endpoint.

    Part 2 covered building a workflow and consuming the bulk data output from the PrismAPI.

    Part 3 will cover consuming the data, and in this case displaying values from Nutanix Protection Domains.

    Add a Scriptable Task

    Right click on the workflow created in Part 2, and click Edit.  In my case, the workflow is called Nutanix PrismAPI – protection_domains.

    1. Drag a Scriptable Task to the blue line that connects Invoke a REST operation and the end ball.add parseJSON scriptable task
    2. Switch to the Info tab, and name it parseJSON.
    3. Switch to the IN tab, hit the single dumb bell, and select contentAsString  scriptable task input
    4. Change to the Scripting tab.  Plug in the following code:
    // built in JSON parser to vCO via javascript
    var jsonResponse = JSON.parse(contentAsString);
    
    System.log("\n\n--------\n\n");
    
    // get the length of the JSON array that is returned
    length=jsonResponse.length;
    
    // iterate through the array and look for particular values we want to use
    for(var i=0;i<length;i++) {
     for(obj in jsonResponse[i]) {
     if(obj == "name") {
     foundName=obj;
     //System.log("object: "+obj);
     System.log("---> Protection_domain: "+jsonResponse[i][obj]);
     }
     if(obj == "pendingReplicationCount") {
     foundReplicationCount=obj;
     System.log("---> pendingReplicationCount: "+jsonResponse[i][obj]);
     }
     if(obj == "ongoingReplicationCount") {
     foundOngoingReplicationCount=obj;
     System.log("---> ongoingReplicationCount: "+jsonResponse[i][obj]);
     }
     if(obj == "totalUserWrittenBytes") {
     foundTotalUserWrittenBytes=obj;
     System.log("---> foundTotalUserWrittenBytes: "+jsonResponse[i][obj]);
     }
    
     }
     System.log("\n");
     }
    

    Validate the workflow and fix any errors.  Right click and run.  My example output looks like this:

    [2014-03-04 15:50:20.402] [I] —> Protection_domain: WANPD2
    [2014-03-04 15:50:20.402] [I] —> pendingReplicationCount: 0
    [2014-03-04 15:50:20.403] [I] —> ongoingReplicationCount: 0
    [2014-03-04 15:50:20.403] [I] —> foundTotalUserWrittenBytes: null
    [2014-03-04 15:50:20.404] [I]

    [2014-03-04 15:50:20.404] [I] —> Protection_domain: WANPD
    [2014-03-04 15:50:20.405] [I] —> pendingReplicationCount: 0
    [2014-03-04 15:50:20.405] [I] —> ongoingReplicationCount: 0
    [2014-03-04 15:50:20.406] [I] —> foundTotalUserWrittenBytes: null
    [2014-03-04 15:50:20.406] [I]

    In my code, I am specifically looking for Protection Domains, and three values:

    • pendingReplicationCount
    •  ongoingReplicationCount
    • foundTotalUserWrittenBytes

    With code such as this, it could be possible to create a scheduled task, and send an alert email if the pendingRelicationCount hits a certain threshold.

    Enjoy!

    Editors note: Mobile shout-out to Ryan Swenson for code assist.


    Connecting to the Nutanix PrismAPI with vCenter Orchestrator – Part 2

    March 3rd, 2014

    Part 1 covered pointing the vCO HTTP-REST plugin to a PrismAPI endpoint.

    Part 3 will cover consuming the data, and in this case displaying values from Nutanix Protection Domains.

    Continuing on, we need to first Add a REST operation.  This, in short, defines an API endpoint we are going to conduct GET operations.  You can also configure endpoints to do POST operations, among others.

    We are going to create a generic endpoint that allows for variable substitution, which we will pass in.  The current PrismAPI endpoint allows for the following resources:

    • /alerts
    • /authconfig
    • /cluster
    • /containers
    • /disks
    • /events
    • /hosts
    • /http_proxies
    • /protection_domains
    • /remote_sites
    • /service_centers
    • /snmp
    • /storage_pools
    • /vdisks
    • /vms
    • /vstores

    I am going to pick /protection_domains, for no other reason than it will probably be a totally fun thing to build workflows against (such as monitoring in-flow replication).

    Add a REST operation

    We will consume the REST host we populated in the first tutorial.

    1. Expand Library->HTTP-REST.  Right-click on Add a REST Operation Add a REST Operation
    2. Select the Parent Host created in the 1st tutorial.  Mine is called “Nutanix PrismAPI”
    3. The REST Workflow leaves an entry for Name.  This can be specific a specific resource, in my case, I want to keep it generic and pass in a resource at runtime.  The PrismAPI is currently constructed thusly: /PrismGateway/services/rest/v1/<resource>/ .. vCO allows for variable substitution, so enter the following string: /PrismGateway/services/rest/v1/{endPoint}/
    4. The HTTP method is GET.  Click submit, and hopefully you have a green response.
    5. Now we get to the fun stuff.  Create a new folder somewhere in your vCO tree.  I called mine Nutanix PrismAPI
    6. Right click on the folder and select New Workflow.  I named mine: Nutanix PrismAPI – protection_domains.  I chose the naming to denote this WF (workflow) will be directly calling the protection_domains resource.
    7. In the general tab, create a new Attribute by clicking on the A+.  Name it restOperation (as so, it makes things easier in a bit).  Select the value, and  drill to the HTTP-REST host you have created for this.  Expand and select the red ball for the Operation.
    8. Create another Attribute and enter the value as protection_domains (again as thus, it is a hard requirement as it is called the REST resource).
    9. Create a final Attribute called contentAsString and leave the value blank.
    10. Great, now click on the Schema tab.  Drag a Workflow element from the left pain to the blue error between the green “Go” ball and the end ball.  In the filter field, type: “Invoke a REST Operation.”  Hit Select.Invoke RestOP WF
    11. Hover over and hit the pencil.  You will now edit the specifics of that WF element.  Hit Pencil
    12. Click the In tab.  For restOperation, click the Source paramenter field and select the restOperation that we created.input to null
    13. Click the Source Parameter for param_0, select the endPoint attribute we created.
    14. Set the rest to NULL.
    15. Click on the Out tab.  Set the contentAsString to the contentAsString attribute we created.output to content as string
    16. The other three Local Parameters can be set to NULL, or you can create attributes for each and wire them.  Hit OK.
    17. Click on the Validate button with the green check.  Hopefully everything is wired properly.  If not, investigate the fix.  Save and close.

    Run the Workflow

    1. Right click on the Workflow that was just created.  With any luck you should see the workflow run, step through and complete.  We will receive the following output (I prettied it up, just a little bit):

    [2014-03-03 20:29:57.546] [I] Request: DynamicWrapper (Instance) : [RESTRequest]-[class com.vmware.o11n.plugin.rest.Request] — VALUE : [email protected]
    [2014-03-03 20:29:57.546] [I] Request URL: https://<URL>/PrismGateway/services/rest/v1/protection_domains/
    [2014-03-03 20:29:57.586] [I] Response: DynamicWrapper (Instance) : [RESTResponse]-[class com.vmware.o11n.plugin.rest.Response] — VALUE : [email protected]
    [2014-03-03 20:29:57.587] [I] Status code: 200
    [2014-03-03 20:29:57.588] [I] Content as string: <A very long string in JSON format>

    We see awesome metrics such as:

    “pendingReplicationCount”:0,

    “ongoingReplicationCount”:0,

    “totalUserWrittenBytes”:null

    With this, we can theoretically build a workflow that monitors replication status and alerts us with progress and/or completion.  Parsing and using the data will be in Part 3!


    PowerCLI – Report on Organization Resource usage in vCloud Director

    December 6th, 2012

    It is important to monitor Organization resource usage in vCloud Director.  There is a view in the Monitor area but what if you want a quick look?  Voila, here it is!

    You will need PowerCLI installed with the vCloud cmdlets.  You will also need to be connected to the cell.  This will walk through all of your configured Organizations and display the percentage usage.  Very useful when you are using the Allocation model.

    (get-orgvdc) | %{
     $orgvdc = $_
     $cpuAlloc = $orgvdc.CpuAllocationGhz
     $ramAlloc = $orgvdc.MemoryAllocationGB
     $storAlloc = $orgvdc.StorageAllocationGB
    
     if ($orgvdc.CpuUsedGhz -ne 0 -and $orgvdc.CpuAllocationGhz -ne 0) {
     $orgcpuspc = (($orgvdc.CpuUsedGhz * 100) / $orgvdc.CpuAllocationGB) }
    
     if ($orgvdc.MemoryUsedGB -ne 0 -and $orgvdc.MemoryAllocationGB -ne 0) {
     $orgramuspc = (($orgvdc.MemoryUsedGB * 100) / $orgvdc.MemoryAllocationGB) }
    
     if ($orgvdc.StorageUsedGB -ne 0 -and $orgvdc.StorageAllocationGB -ne 0) {
     $orgstoruspc = (($orgvdc.StorageUsedGB * 100) / $orgvdc.StorageAllocationGB) }
     $orgram = [System.math]::round($orgramuspc,1)
     $orgcpu = [System.math]::round($orgcpuspc,1)
     $orgstor = [System.math]::round($orgstoruspc,1)
    
     write-host `n"Org vDC: $orgvdc"
     write-host "CPU: $orgcpu% of $cpuAlloc Ghz, MEM: $orgram% of $ramAlloc GB, Storage: $orgstor% of $storAlloc GB"`n
     }
    
    

    The output will be:

    OvDC: My Org vDC, CPU: 25.3%, MEM: 18.6%, Storage: 60.1%


    Reporting of baseline compliance with PowerCLI and Update Manager cmdlets

    April 11th, 2012

    The following code will generate a lovely excel spreadsheet to report compliance of ESX(i) hosts against their current baseline as applied from Update Manager.

    You will need Excel, Powershell, PowerCLI and the Update Manager cmdlets installed.  The framework is borrowed from an excellent Powershell script at http://ict-freak.nl/2009/07/01/powercli-generate-an-excel-sheet-with-vm-info/

    $xlCSV = 6
    $xlXLS = 56
    $csvfile = "compliance.csv"
    $xlsfile = "compliance.xls"
    
    $Excel = New-Object -ComObject Excel.Application
    $Excel.visible = $True
    $Excel = $Excel.Workbooks.Add()
    
    $Sheet = $Excel.Worksheets.Item(1)
    $Sheet.Cells.Item(1,1) = "Server"
    $Sheet.Cells.Item(1,2) = "Release"
    $Sheet.Cells.Item(1,3) = "Version"
    $Sheet.Cells.Item(1,4) = "Build"
    $Sheet.Cells.Item(1,5) = "Baseline"
    $Sheet.Cells.Item(1,6) = "Status"
    
    $intRow = 2
    
    $WorkBook = $Sheet.UsedRange
    $WorkBook.Interior.ColorIndex = 19
    $WorkBook.Font.ColorIndex = 11
    $WorkBook.Font.Bold = $True
    
    $compliant = "Compliant"
    $notcompliant = "Not Compliant"
    $unknown = "Unknown Status"
    
    $vmhosts = get-vmhost
    foreach ($vmhost in $vmhosts) {
    
      $vmhostview = get-vmhost $vmhost | get-view
      $compliance = get-compliance -entity $vmhost
    
      $Sheet.Cells.Item($intRow, 1) = [String]$vmhost
      $Sheet.Cells.Item($intRow, 2) = $vmhostview.Config.Product.name
      $Sheet.Cells.Item($intRow, 3) = $vmhostview.Config.Product.version
      $Sheet.Cells.Item($intRow, 4) = $vmhostview.Config.Product.build
      $Sheet.Cells.Item($intRow, 5) = $compliance.baseline.name
    
      if($compliance.status -eq 0) {
        $Sheet.Cells.Item($intRow, 6) = [String]$compliant
        $Sheet.Cells.Item($intRow, 6).Interior.ColorIndex = 4
        $Sheet.Cells.Item($intRow, 1).Interior.ColorIndex = 4
      }
      elseif($compliance.status -eq 1) {
        $Sheet.Cells.Item($intRow, 6) = [String]$notcompliant
        $Sheet.Cells.Item($intRow, 6).Interior.ColorIndex = 3
        $Sheet.Cells.Item($intRow, 1).Interior.ColorIndex = 3
      }
      else {
        $Sheet.Cells.Item($intRow, 6) = [String]$unknown
        $Sheet.Cells.Item($intRow, 6).Interior.ColorIndex = 48
        $Sheet.Cells.Item($intRow, 1).Interior.ColorIndex = 48
      }
    
      $intRow = $intRow + 1
    }
    $WorkBook.EntireColumn.AutoFit()
    
    sleep 5
    
    $Sheet.SaveAs($xlsfile,$xlXLS)
    $Sheet.SaveAs($csvfile,$xlCSV)
    

    The output will show:
    Server | Release (ESX or ESXi) | Version of ESX(i) | Build Number | Attached Baseline | Status (Compliant, Not, or Unknown


    Place ESXi in to Maintenance Mode from vCloud Director

    February 21st, 2012

    So you have your handy dandy cloud built on top of VMware vSphere and vCloud Director. And then you find out you need to conduct maintenance on the host.  What to do?

    Easy!  Browse to:

    • System-> Manage & Monitor
    • vSphere Resources -> Hosts
    1. Find the host you need to place in to maintenance mode, right click and select Disable Host.
    2.  At that point, the status will turn from a green circle with a check, to a red circle.
    3. Right click on the host again and select Redeploy All VMs.
    4. The ESXi host will go in to maintenance mode in the vCenter server and evacuate all virtual machines as usual.
    5. (Optional!) If you see vsla errors (such as the screenshot), issues with deleting vApps, Unprepare the host which removes the vCloud agent from ESXi
    6. (Optional!) Prepare the host for vCloud by pushing the vCloud agent to ESXi
    7. When maintenance is complete, right click and Enable Host.
    8. And your work is complete!

    Storage vMotion and RDM

    August 16th, 2011

    I just conducted a Storage vMotion of a virutal machine that had multiple very small RDM.  To my surprise each of the RDM became a thick-provisioned vmdk.  VMware KB 1005241 discusses this situation in particular, however I am left scratching my head because I do believe the RDM was configured for physical mode, which goes against the KB article.  VMware Communities has a nice little discussion as well.


    Thoughts on Facebook’s ability to bring on new datacenters

    May 17th, 2011

    GigaOM has a very interesting article detailing how Facebook spun up a virtual data center inside of one of their production data centers in the Virginia (I assume Northern) area.  The direct link to the engineering blog can be found here.

    I found the content regarding their provisioning system named Kobold the most interesting.  Their ability to provision (tens of) thousands of servers in a 30 day window is impressive.  When I worked in RSA Security‘s SaaS group, we had a few different infrastructure silos that made up our hosting solution.  We created, for the most part, a build system that allowed us to get servers available in a matter of minutes after basic infrastructure was configured (power, cabling and kickstart VLAN).  While we were able to stand up infrastructure on the quicker side of things, we may have been able to scale to a few hundred (if it ever came to that) in 30 days, but nowhere near thousands or tens of thousands.  We just weren’t able to get the full boot-strap of the app layer in play.

    The promise of cloud to allow for quick scaling is based on the premise of boot-strapping.  Each machine needs to have logic to check in and get marching orders.  Without that, you are stuck with a whole lot of machines, and a whole lot of work to do to get them in to production.

    Two other interesting sites about data center boot-strapping:

    Twitter created Murder to conduct code deployments via BitTorrent.

    SmugMug created SkyNet to scale and boot-strap their infrastructure.