Hi,
I am trying to create an alarm on the powerState of the VM using the gSOAP C++ generated interfaces. while running the code, I get the soap fault:
The code I've written is as follows:
/*
* Function to create alarm on the power state
* of the VM
*
* @param managed_obj_ref of the VM
*/
vSphereStatus vSphereUserAPI::create_power_state_alarm(ns1__ManagedObjectReference *vm_mor) {
/* Creates State Alarm Expression */
ns1__StateAlarmExpression state_alarm;
string red_state = "poweredOff";
state_alarm.operator_ = ns1__StateAlarmOperator__isEqual;
state_alarm.type = "VirtualMachine";
state_alarm.statePath = "runtime.powerState";
//state_alarm.yellow =
state_alarm.red = &red_state;
ns1__AlarmExpression alarm_expression = (ns1__AlarmExpression) state_alarm;
/* Creates Alarm Setting */
ns1__AlarmSetting alarm_setting;
alarm_setting.toleranceRange = 0;
alarm_setting.reportingFrequency = 0;
/* Creates the Alarm Spec */
ns1__AlarmSpec alarm_spec;
alarm_spec.name = "alarm123";
alarm_spec.description = "Alarm to detect the powered off state of the VM";
alarm_spec.enabled = true;
alarm_spec.expression = &alarm_expression;
//alarm_spec.action =
//alarm_spec.actionFrequency =
alarm_spec.setting = &alarm_setting;
/* Creates the Alarm */
ns1__CreateAlarmRequestType create_alarm_req;
create_alarm_req._USCOREthis = new ns1__ManagedObjectReference();
create_alarm_req._USCOREthis = service_content->alarmManager;
create_alarm_req.entity = vm_mor;
create_alarm_req.spec = &alarm_spec;
_ns1__CreateAlarmResponse create_alarm_res;
if (binding_proxy.CreateAlarm(&create_alarm_req, &create_alarm_res) == SOAP_OK) {
cout << "\nCreateAlarm successful!" << endl;
} else {
binding_proxy.soap_stream_fault(std::cerr);
return SOAP_ERROR;
}
delete create_alarm_req._USCOREthis;
return STATUS_OK;
}
Kindly guide me into this.
Thanks in advance.
Thread moved to the Developer Community
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference