VMware Cloud Community
svneswar
Enthusiast
Enthusiast

Need help in importing alarms from xml file with tag "system Name" by modifying ConvertFromDeserialized function

Hi All,

I followed the discussion Re: Script to export/import Alarms between VC or synchronize alarms between 2 Virtual Centers

And came up with the scripts attached below.

 

  1. ExportAlarmsToXml.ps1- to export alarms to a singlexml file
  2. ImportAlarmsFromXml.ps1- to import alarms from the xml file generated using the above script.

   

I am able to export the alarms succesfully.

But while importing, script is working fine for vcenter version 5.0.0 and build 755629. But, failing for build 913577.

After going through the discussions, I found that the reason is "SystemName"

 

for example,In old version, the system name tag is like <Nil N="SystemName"/> [same for every alarm]

For example, In new version[ build 913577], the system name tag is <S N="SystemName">alarm.VmTimedoutStartingSecondaryAlarm</S> [changes value for each default alarms]

So, while running the script, Iam getting error like :

 

Exception calling "CreateAlarm" with "2" argument(s): "A specified parameter was not correct."

At E:\scripts\ImportAlarmsFromXmlFile.ps1:145 char:31

   
$alarmManager.CreateAlarm <<<< ($entity.Id, $importedAlarmInfo) | Out-Null

CategoryInfo          :NotSpecified: (:) [], MethodInvocationException

FullyQualifiedErrorId : DotNetMethodException


Could some one please help me in modifying the ImportAlarmsFromXmlfile.ps1 to work with the new system name tag xml file.[ Upto my knowledge, we may need to modify the function
ConvertFromDeserialized]

0 Kudos
0 Replies