How to retrieve xenstore parameters from WMI interface

1.1k views Asked by At

I'm trying to retrieve some parameters from xenstore using WMI (specifically, I was hoping to use this script to change a VM IP address after it's created).

According to this article, it seems like I should just be able to do something like:

From the xenserver CLI:

xe vm-param-set uuid=e66660e9-85e1-1f99-3229-1dfa7d1065a8 xenstore-data:data/TempValue=test

then in a powershell script:

$base = gwmi -n root\wmi -cl CitrixXenStoreBase 
$sid = $base.AddSession("MyNewSession") 
$session = gwmi -n root\wmi -q "select * from CitrixXenStoreSession where SessionId=$($sid.SessionId)" 
$output = $session.GetValue("data/TempValue").value
log "$output"

But that doesn't seem to retrieve the value that I expect.

One thing I noticed was if I set the value from a powershell script, it seems to consistently retrieve the value when I run the previous script:

$base = gwmi -n root\wmi -cl CitrixXenStoreBase 
$sid = $base.AddSession("MyNewSession") 
$session = gwmi -n root\wmi -q "select * from CitrixXenStoreSession where SessionId=$($sid.SessionId)" 
$session.SetValue("data/TempValue","This is a string")

It seems to retain the set value across sessions, but when I go back to the CLI and attempt to find the value, I get nothing:

xe vm-param-list uuid=e66660e9-85e1-1f99-3229-1dfa7d1065a8 | grep TempValue

So what it boils down to is that I'd like to either:

  1. Know how to retrieve a xenstore parameter in a WMI script after executing the xe vm-param-set command.
  2. Know how to set a parameter in the xenserver CLI in the same way that $session.SetValue works in the above example.
1

There are 1 answers

0
user949286 On

Nevermind, looks like this was user error on my end. I was setting the values after the VM was already started. Looks like the parameters have to be set before the VM starts (or the VM should be restarted).