(self, action, resource_uri, resource, option_set=None,
               selector_set=None, timeout=None)
return response_xml
Send a generic WSMan request to the host.

        :param action: The action to run, this relates to the wsa:Action header
            field.
        :param resource_uri: The resource URI that the action relates to, this
          relates to the wsman:ResourceURI header field.
        :param resource: This is an optional xml.etree.ElementTree Element to
            be added to the s:Body section.
        :param option_set: a wsman.OptionSet to add to the request
        :param selector_set: a wsman.SelectorSet to add to the request
        :param timeout: Override the default wsman:OperationTimeout value for
            the request, this should be an int in seconds.
        :return: The ET Element of the response XML from the server
Send a generic WSMan request to the host.
Send a generic WSMan request to the host .
def invoke(self, action, resource_uri, resource, option_set=None,
               selector_set=None, timeout=None):
        """
        Send a generic WSMan request to the host.

        :param action: The action to run, this relates to the wsa:Action header
            field.
        :param resource_uri: The resource URI that the action relates to, this
          relates to the wsman:ResourceURI header field.
        :param resource: This is an optional xml.etree.ElementTree Element to
            be added to the s:Body section.
        :param option_set: a wsman.OptionSet to add to the request
        :param selector_set: a wsman.SelectorSet to add to the request
        :param timeout: Override the default wsman:OperationTimeout value for
            the request, this should be an int in seconds.
        :return: The ET Element of the response XML from the server
        """
        s = NAMESPACES['s']
        envelope = ET.Element("{%s}Envelope" % s)

        header = self._create_header(action, resource_uri, option_set,
                                     selector_set, timeout)
        envelope.append(header)

        body = ET.SubElement(envelope, "{%s}Body" % s)
        if resource is not None:
            body.append(resource)

        message_id = header.find("wsa:MessageID", namespaces=NAMESPACES).text
        xml = ET.tostring(envelope, encoding='utf-8', method='xml')

        try:
            response = self.transport.send(xml)
        except WinRMTransportError as err:
            try:
                # try and parse the XML and get the WSManFault
                raise self._parse_wsman_fault(err.response_text)
            except ET.ParseError:
                # no XML message is present so not a WSManFault error
                log.error("Failed to parse WSManFault message on WinRM error"
                          " response, raising original WinRMTransportError")
                raise err

        response_xml = ET.fromstring(response)
        relates_to = response_xml.find("s:Header/wsa:RelatesTo",
                                       namespaces=NAMESPACES).text

        if message_id != relates_to:
            raise WinRMError("Received related id does not match related "
                             "expected message id: Sent: %s, Received: %s"
                             % (message_id, relates_to))
        return response_xml
def invoke ( self , action , resource_uri , resource , option_set = None , selector_set = None , timeout = None ) : s = NAMESPACES [ 's' ] envelope = ET . Element ( "{%s}Envelope" % s ) header = self . _create_header ( action , resource_uri , option_set , selector_set , timeout ) envelope . append ( header ) body = ET . SubElement ( envelope , "{%s}Body" % s ) if resource is not None : body . append ( resource ) message_id = header . find ( "wsa:MessageID" , namespaces = NAMESPACES ) . text xml = ET . tostring ( envelope , encoding = 'utf-8' , method = 'xml' ) try : response = self . transport . send ( xml ) except WinRMTransportError as err : try : # try and parse the XML and get the WSManFault raise self . _parse_wsman_fault ( err . response_text ) except ET . ParseError : # no XML message is present so not a WSManFault error log . error ( "Failed to parse WSManFault message on WinRM error" " response, raising original WinRMTransportError" ) raise err response_xml = ET . fromstring ( response ) relates_to = response_xml . find ( "s:Header/wsa:RelatesTo" , namespaces = NAMESPACES ) . text if message_id != relates_to : raise WinRMError ( "Received related id does not match related " "expected message id: Sent: %s, Received: %s" % ( message_id , relates_to ) ) return response_xml