

def _build_payload(**kwargs):
    '\n    Builds a SOAP envelope to send to the vCenter hidden API\n\n    :param entity_moref:\n    :param alarm_moref:\n    :param entity_type:\n    :return:\n    '
    entity_moref = kwargs.get('entity_moref')
    entity_type = kwargs.get('entity_type')
    alarm_moref = kwargs.get('alarm_moref')
    if ((not entity_moref) or (not entity_type) or (not alarm_moref)):
        raise ValueError('entity_moref, entity_type, and alarm_moref must be set')
    attribs = {
        'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
        'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
        'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/',
    }
    root = Element('soap:Envelope', attribs)
    body = SubElement(root, 'soap:Body')
    alarm_status = SubElement(body, 'SetAlarmStatus', {
        'xmlns': 'urn:vim25',
    })
    this = SubElement(alarm_status, '_this', {
        'xsi:type': 'ManagedObjectReference',
        'type': 'AlarmManager',
    })
    this.text = 'AlarmManager'
    alarm = SubElement(alarm_status, 'alarm', {
        'type': 'Alarm',
    })
    alarm.text = alarm_moref
    entity = SubElement(alarm_status, 'entity', {
        'xsi:type': 'ManagedObjectReference',
        'type': entity_type,
    })
    entity.text = entity_moref
    status = SubElement(alarm_status, 'status')
    status.text = 'green'
    return '<?xml version="1.0" encoding="UTF-8"?>{0}'.format(tostring(root))

dataset/ETHPy150Open vmware/pyvmomi-community-samples/samples/tools/alarm.py _build_payload/original