- headers = {'Content-Type': 'application/xml'}
- data = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
- <ops:alert-definition xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:ops="http://webservice.vmware.com/vRealizeOpsMgr/1.0/">
- <ops:name>{0:s}</ops:name>
- <ops:description>{1:s}</ops:description>
- <ops:adapterKindKey>{2:s}</ops:adapterKindKey>
- <ops:resourceKindKey>{3:s}</ops:resourceKindKey>
- <ops:waitCycles>1</ops:waitCycles>
- <ops:cancelCycles>1</ops:cancelCycles>
- <ops:type>{4:s}</ops:type>
- <ops:subType>{5:s}</ops:subType>
- <ops:states>
- <ops:state severity="{6:s}">
- <ops:symptom-set>
- <ops:symptomDefinitionIds>
- <ops:symptomDefinitionId>{7:s}</ops:symptomDefinitionId>
- </ops:symptomDefinitionIds>
- <ops:relation>SELF</ops:relation>
- <ops:aggregation>ALL</ops:aggregation>
- <ops:symptomSetOperator>AND</ops:symptomSetOperator>
- </ops:symptom-set>
- <ops:impact>
- <ops:impactType>BADGE</ops:impactType>
- <ops:detail>{8:s}</ops:detail>
- </ops:impact>
- </ops:state>
- </ops:states>
- </ops:alert-definition>"""\
- .format(alarm_params['name'],alarm_params['description'],
- alarm_params['adapterKindKey'],alarm_params['resourceKindKey'],
- str(alarm_params['type']),str(alarm_params['subType']),
- alarm_params['severity'],alarm_params['symptomDefinitionId'],
- alarm_params['impact'])
+ headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
+ data = {
+ "name": alarm_params['name'],
+ "description": alarm_params['description'],
+ "adapterKindKey": alarm_params['adapterKindKey'],
+ "resourceKindKey": alarm_params['resourceKindKey'],
+ "waitCycles": 1,
+ "cancelCycles": 1,
+ "type": alarm_params['type'],
+ "subType": alarm_params['subType'],
+ "states": [
+ {
+ "severity": alarm_params['severity'],
+ "base-symptom-set":
+ {
+ "type": "SYMPTOM_SET",
+ "relation": "SELF",
+ "aggregation": "ALL",
+ "symptomSetOperator": "AND",
+ "symptomDefinitionIds": [alarm_params['symptomDefinitionId']]
+ },
+ "impact": {
+ "impactType": "BADGE",
+ "detail": alarm_params['impact']
+ }
+ }
+ ]
+ }