A lot has changed since my last post. I drafted several posts over the past month and never ended up finishing and publishing them – too many distractions, both personally and professionally. But, my setup now has evolved to the point where I’m still running Ollama in a VM, but I’ve started deploying some other services on another VM.
Homepage: (https://gethomepage.dev/)
Gitlab: (https://about.gitlab.com/)
Open WebUI: (https://openwebui.com/#open-webui-community)
I’m going to redeploy these in a more permanent way once I get the new 2TB SSD that I ordered… and also now that Broadcom brought back the free version of ESXi and I can deploy an 8.x version rather than the old 6.7 version I currently had in my homelab.
What I’ve been experimenting with lately is not just different models, but RAG. Ollama makes this easy – basically, you populate a Knowledgebase with the contextural information you want it to use, and then create a custom model referencing that Knowledgebase, and then when you create a new chat, you can select your new model and it will automatically use whatever documents or data you added to your Knowledgebase.
To demonstrate, I used the following prompt, which is a very basic task a Storage Administrator of a NetApp ONTAP NAS cluster may want to perform, “Write a powershell script that connects to multiple clusters passed into the script via parameter at runtime as an array of hostnames, gets and sums the amount of space used by volume snapshots.”
So rather than start with something that has absolutely zero context, I decided to use deepseek-coder-v2:16b as the basemodel, submitted the prompt and basically it gave me this:
param (
[Parameter(Mandatory = $true)]
[array]$ClusterHosts
)
# Function to get the amount of space used by volume snapshots in a cluster
function Get-SnapshotSpaceUsage {
param (
[string]$ClusterHost
)
# Initialize the total space usage variable
$totalSpaceUsed = 0
try {
# Connect to the cluster using PowerShell Remoting
Invoke-Command -ComputerName $ClusterHost -ScriptBlock {
# Get all volume snapshots on the cluster node
$volumeSnapshots = Get-VMwareSnapshot -ErrorAction Stop | Where-Object { $_.State -eq "snapshot" }
foreach ($snapshot in $volumeSnapshots) {
# Sum up the space used by each snapshot
$totalSpaceUsed += [math]::Round($snapshot.Size, 2)
}
}
} catch {
Write-Error "Failed to connect to or execute commands on cluster host: $ClusterHost"
return -1
}
# Return the total space used by snapshots
return [math]::Round($totalSpaceUsed, 2)
}
# Loop through each cluster hostname and get the snapshot space usage
$results = @()
foreach ($host in $ClusterHosts) {
$spaceUsage = Get-SnapshotSpaceUsage -ClusterHost $host
if ($spaceUsage -ne -1) {
$results += [PSCustomObject]@{ Cluster = $host; SpaceUsedGB = $spaceUsage }
}
}
# Output the results
if ($results.Count -gt 0) {
Write-Output "Total space used by volume snapshots across all clusters:"
foreach ($result in $results) {
Write-Output "Cluster: $($result.Cluster), Space Used (GB): $($result.SpaceUsedGB)"
}
} else {
Write-Output "No valid data found."
}
Not bad… the logic is sound, but it clearly has no clue that NetApp has a PowerShell Toolkit. It’s even so confused it’s using cmdlets that are likely from VMware’s PowerShell module.
So, what happens when we give it some information about NetApp’s PowerShell Toolkit… in the next test, I’ve dumped the output of Get-Help -Full for every cmdlet in the toolkit to text files, and added them all to a Knowledgebase which is referenced in the custom model I built, using the same base model:
# Import the PSTK module for NetApp Data ONTAP cmdlets
Import-Module NetApp.ONTAP
# Function to get the snapshot space usage from a cluster
function Get-SnapshotSpaceUsage {
param (
[string]$ClusterHostname
)
# Connect to the cluster
Connect-NcController -Name $ClusterHostname
# Get all volumes in the cluster
$volumes = Get-NcVol
# Initialize a variable to hold the total snapshot space used
$totalSnapshotSpaceUsed = 0
foreach ($volume in $volumes) {
# Get snapshots for each volume
$snapshots = Get-NcSnapshot -Name $volume.Volume
foreach ($snapshot in $snapshots) {
# Add the size of the snapshot to the total space used
$totalSnapshotSpaceUsed += [math]::Round($snapshot.Size, 2)
}
}
# Return the total snapshot space used
return [math]::Round($totalSnapshotSpaceUsed, 2)
}
# Function to get and sum the snapshot space usage from multiple clusters
function Get-TotalSnapshotSpaceUsage {
param (
[string[]]$ClusterHostnames
)
# Initialize a variable to hold the total snapshot space used across all clusters
$totalSnapshotSpaceUsed = 0
foreach ($hostname in $ClusterHostnames) {
# Get the snapshot space usage for the current cluster
$snapshotSpaceUsage = Get-SnapshotSpaceUsage -ClusterHostname $hostname
# Add the snapshot space usage to the total
$totalSnapshotSpaceUsed += $snapshotSpaceUsage
}
return [math]::Round($totalSnapshotSpaceUsed, 2)
}
# Example usage:
# $clusterHostnames = @("cluster1.example.com", "cluster2.example.com")
# $totalSpaceUsed = Get-TotalSnapshotSpaceUsage -ClusterHostnames $clusterHostnames
# Write-Output "Total snapshot space used across all clusters: $totalSpaceUsed TB"
Now we’re getting somewhere… right off the bat, you can see it imported the NetApp.ONTAP module. Then it uses the Connect-NcController cmdlet… another success. It gets volumes, then gets snapshots for each volume and sums them for each cluster. Great!
For the next test I narrowed it’s field of knowledge so rather than hundreds of help documents, it only has acouple dozen, but they are more relevant to the task at hand:
param (
[Parameter(Mandatory = $true)]
[string[]]$ClusterHosts
)
# Import the NetApp PowerShell Toolkit module
Import-Module "NetApp.ONTAP"
foreach ($host in $ClusterHosts) {
try {
# Connect to each cluster
Write-Host "Connecting to cluster: $host"
Connect-NcController -Name $host -Credential (Get-Credential)
# Get all volumes and their snapshots
Write-Host "Getting volumes and snapshots for cluster: $host"
$volumes = Get-NcVol
$snapshotSpaceUsed = 0
foreach ($vol in $volumes) {
$snapshots = Get-NcSnapshot -Volume $vol.Name
foreach ($snap in $snapshots) {
# Sum the space used by each snapshot
$snapshotSpaceUsed += [math]::Round($snap.Used, 2)
}
}
Write-Host "Total space used by snapshots on cluster $host: $snapshotSpaceUsed GB"
# Disconnect from the current cluster
Write-Host "Disconnecting from cluster: $host"
Disconnect-NcController -PassThru
} catch {
Write-Error "Failed to connect or process snapshots on cluster $host. Error: $_"
}
}
Again – it imports the correct module, connects to the cluster properly, gets volumes, gets snapshots from each volume and sums them… for all intents and purposes, this looks like another successful piece of AI generated code.
Eventually I’ll get a NetApp ONTAP Simulator deployed to actually test things like this, but knowing what I know about NetApp clusters and PowerShell, these latter two scripts should work without much, if any, editing.
I’ll get back into a little more detailed and step-by-step information about how I’m going through this, I just wanted to get a post out there and provide an update on my progress.
Stay tuned for more updates on my experimentation with the big public LLMs like Gemini and ChatGPT, and also with fun tools like Replit and Firebase!
Leave a comment