def _get_soap_headers(self, soap_action, message_id): headers = [ element.Element('Action', ns=self.NS_WSA).setText( soap_action.replace('"', '')).append(self.MUST_UNDERSTAND), element.Element('To', ns=self.NS_WSA).setText( self.WSA_ANONYMOUS).append(self.MUST_UNDERSTAND), element.Element('MessageID', ns=self.NS_WSA).setText(message_id), element.Element('ReplyTo', ns=self.NS_WSA).insert( element.Element('Address', ns=self.NS_WSA).setText(self.WSA_ANONYMOUS)), ] return headers
def set_soap_cookie(self, cookie): """Set the specified vCenter session cookie in the SOAP header :param cookie: cookie to set """ elem = element.Element('vcSessionCookie').setText(cookie) self.client.set_options(soapheaders=elem)
def _set_soap_headers(self, op_id): """Set SOAP headers for the next remote call to vCenter. SOAP headers may include operation ID and vcSessionCookie. The operation ID is a random string which allows to correlate log messages across different systems (OpenStack, vCenter, ESX). vcSessionCookie is needed when making PBM calls. """ headers = [] if self._vc_session_cookie: elem = element.Element('vcSessionCookie').setText( self._vc_session_cookie) headers.append(elem) if op_id: elem = element.Element('operationID').setText(op_id) headers.append(elem) if headers: self.client.set_options(soapheaders=headers)
def _copy_client_cookie(vimSession, pbmClient): """Copy the vim session cookie to pbm client soap header. :param vimSession: an vim session authenticated with VC/ESX :param pbmClient: a PBMClient object to set the session cookie """ vcSessionCookie = PBMClient._get_vc_session_cookie(vimSession) vcc = element.Element('vcSessionCookie').setText(vcSessionCookie) pbmClient.set_options(soapheaders=vcc)
def soap_header(): request_header = suds_element.Element('RequestHeader', ns=AdxService.ns0) context = suds_element.Element('context').setText('default') request_header.append(context) return request_header