Jun 022011
 

I started playing with the Cisco UCSM Toolkit recently (currently in Beta) and with its 70 Cmdlets I have been able to automate quite a few actions in UCS that can often take up a fair amount of administrative effort. For me its extremely useful to be able to automate those initial configuration tasks that would be  repeated on every UCS instillation. Working for a solutions provider I often have to install multiple UCS deployments and find allot of repetition.

Using UCSM’s XML API for all commination between the toolkit and UCSM instance. By creating the appropriate XML document for the API call it can then send it to the Web Service on all the UCSM instances.

So why is this UCSM ToolKit of interest?

Well not everyone can afford tools like UIM and EMC Bladelogic to automate the provisioning of the UCS components within a single UCS environment and also (more importantly) with multiple UCSM instances. By adopting the XML API, UCSM opens up the API to almost any scripting language in the future. Utilising the VMware PowerCli and the UCSM Toolkit, it is now possible to automate a huge chunk of a VMware on UCS deployment which has not been easy to achieve previously.

You don’t need a real UCS system.

Download the UCSM Toolkit here (you will need to register with Cisco) and follow the instructions in the user guide.

Using the UCS emulator you can perform pretty much every cmdlet that is in the Toolkit. The emulator runs as a VM and presents a small UCS B-Series environment that critically contains the XML API.

You can download the emulator here.

 

Here’s a really basic script that will connect to the UCSM server and create a new service profile then configure it with a description

# the bellow module contains the cmdlets
import-module <filepath>\CiscoUCSPS.dll
# connect to UCSM
connect-ucsm -Name 192.168.70.128
# Add a masic service profile and configure it.
add-serviceprofile -spname davetest | set-serviceprofile -Desc vmackem
# disconnect all UCSM Sessions
Disconnect-AllUCSM

 

Before – image

 

After –image

Post to Twitter

Oct 182010
 

I have been investigating using Microsoft Chart Controls for Microsoft .NET Framework 3.5 to create some nice looking images in my Powershell reporting script. I am in the early stage but here is an initial snip-it of how powerful this can be.

Once I finish my report script I will post it for everyone to enjoy.

# -----------------------------------------------------------------------------------------------------------
###
### Script Name - charting for vcenter object demo
###
### Author - David Owen
###
### Description - this script gathers the VM objects and displays them in graph format.
###
 
# connect to you VC or ESX server
Connect-VIServer -Server "your server"
 
# gather statistics to be used in the graph
$vms = Get-VM -Name *io*
$vms1 = Get-VM -Name *4
 
# create chart object
$Chart = New-object System.Windows.Forms.DataVisualization.Charting.Chart
$Chart.Width = 350
$Chart.Height = 250
$Chart.Left = 25
$Chart.Top = 15
 
# create a chart area to draw on and add to chart
$ChartArea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
$Chart.ChartAreas.Add($ChartArea)
 
# add data to chart
$conts = @{"Total of vms with io in the name" = $vms.count; "number of VMs with 4 in the name" = $vms1.count}
[void]$Chart.Series.Add("Data")
$Chart.Series["Data"].Points.DataBindXY($conts.Keys, $conts.Values)
 
# set chart type
$Chart.Series["Data"].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]::Pie
 
# set chart options
$Chart.Series["Data"]["PieLabelStyle"] = "Outside"
$Chart.Series["Data"]["PieLineColor"] = "Black"
$Chart.Series["Data"]["PieDrawingStyle"] = "Concave"
($Chart.Series["Data"].Points.FindMaxByValue())["Exploded"] = $true
 
$Chart.SaveImage("$pwd\myChart1.gif",[System.Windows.Forms.DataVisualization.Charting.ChartImageFormat]::Gif)
 
invoke-item "$pwd\myChart1.gif"
 
Disconnect-VIServer -Force -WarningAction SilentlyContinue

Here are some example charts.

I produced the pie chard just using get-vm as the data source.

As you can see you can do some real cool treading stats with this .net extension. I’m not a .net developer and all the examples are in .net so its a slow process but the basic charts I am producing are relay cool and will fit nicely into reports.

Things like up-time statistics and resource processes easy accessible through the VMware APIs that normally you can only get from the viclient are now totally customizable into you own format etc to fit your needs.

Post to Twitter

Sep 172010
 
 
I had to write a script that ran a SQL SP this week and found that this was not the most straight forward thing to do.
 
This was how I managed do it.
 
 

    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "UID=”DBUID”;PWD=”password”;Server=”IP”;Database=”DB”;Integrated Security=False"
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = "sp_name"
    $SqlCmd.Connection = $SqlConnection
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet) | Out-Null
    $SqlConnection.Close()
    $DataSet.Tables[0]

All you Powershell gurus are more than welcome to suggest a better way…..

Post to Twitter

Twitter links powered by Tweet This v1.8.3, a WordPress plugin for Twitter.