VMware Cloud Community
KInjal_Patel
Contributor
Contributor

Getting Web Fault error for Session (Session has been deleted or has not been completely created')

When We are destroying PropertyCollector using API function (destroyPropertyCollector) it is throwing below error:

WebFault: Server raised fault: 'The object 'vmodl.query.PropertyCollector:session[52f35b59-95f8-56ba-ba32-39c0ef193881]52ec5ed4-5b68-6569-221a-29a71c8c5831' has already been deleted or has not been completely created'.

Can you please help when do we get this error? Is this any issue related to vCenter? vCenter version is 6.5. What do we check on vCenter to troubleshoot this?

Thanks!

Reply
0 Kudos
3 Replies
msripada
Virtuoso
Virtuoso

can you share the complete actions performed through the API. Based on that, we can try to see the service you are hitting and check the relevant logs to identify.

Thanks,

MS

Reply
0 Kudos
KInjal_Patel
Contributor
Contributor

I am trying to collect VMware Virtual Machine Inventory data and for that first of all I am creating property collector and will use retrieveProperties() function to get inventory data.

As my script is called at every 15th minutes I am using mor[in our case: session[52f35b59-95f8-56ba-ba32-39c0ef193881]52ec5ed4-5b68-6569-221a-29a71c8c5831] created by createPropertyCollector to get only updates using waitForUpdatesEx() fuction. Now after 4 hours I would destroy that property collector and create a new one to get all data and cycle would be continued.

It is working properly but while destroying that proper collector it is throwing the above error.

To check above workflow I want to create an independent script using SOAP request.

The below script for destroying property collector throws internal Server error.

import urllib2

import cookielib

from xml.dom import minidom

from xml.sax.saxutils import escape, quoteattr

service_url="https://<vc>/sdk"
url="<vc_fqdn>"
username = "<user_name>"
password = "<passwod>"

cj = cookielib.LWPCookieJar()

#First we assume the server is 5.x
def _get_service_instance():

   cj = cookielib.LWPCookieJar()

   #this opener is used for all requests to ensure that cookies are handled properly
   opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

   #First we assume the server is 5.x
   request_body = """<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <ns0:Body>
  <ns1:RetrieveServiceContent>
  <ns1:_this xsi:type="ServiceInstance">ServiceInstance</ns1:_this>
  </ns1:RetrieveServiceContent>
  </ns0:Body>
  </SOAP-ENV:Envelope>
  """
   request = urllib2.Request(service_url, data=request_body)

   request = urllib2.Request(url, data=request_body)

   try:

  handle = opener.open(request, timeout=15)

   if handle.code != 200:

   return False
  else:

  version = "4.1"
   except:

   return False

   #Determine if we are an unmanaged host by inspecting the service instance
   service_instance_xml = handle.read()

  service_instance_dom = minidom.parseString(service_instance_xml)

  session_manager_node = service_instance_dom.getElementsByTagName("sessionManager")[0]

  session_manager_moid = session_manager_node.firstChild.data

   return opener, version, session_manager_moid

def _login(session_manager_moid, username, password, headers, opener):

   request_body = """<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <ns0:Body>
  <ns1:Login>
  <ns1:_this type="SessionManager">""" + escape(session_manager_moid) + """</ns1:_this>
  <ns1:userName>""" + escape(username) + """</ns1:userName>
  <ns1:password>""" + escape(password) + """</ns1:password>
  </ns1:Login>
  </ns0:Body>
  </SOAP-ENV:Envelope>
  """
   request = urllib2.Request(service_url, data=request_body, headers=headers)

   try:

  handle = opener.open(request)

   print(handle.read())

   if handle.code == 200:

   return True
  else:

   return False
  except urllib2.HTTPError as e:

   print(e)

   return False
opener, version, session_manager_moid = _get_service_instance()

if version == "5.x":

  headers = {'SOAPAction': u'"urn:vim25/5.1"', 'Soapaction': u'"urn:vim25/5.1"', 'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8'}

else:

  headers = {'SOAPAction': u'"urn:vim25/4.1"', 'Soapaction': u'"urn:vim25/4.1"', 'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8'}

_login(session_manager_moid, username, password, headers, opener)

try:

  request_body = """<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <ns0:Body>
  <ns1:DestroyPropertyCollector>
  <ns1:_this type="PropertyCollector">session[52f35b59-95f8-56ba-ba32-39c0ef193881]52ec5ed4-5b68-6569-221a-29a71c8c5831</ns1:_this>
  </ns1:DestroyPropertyCollector>
  </ns0:Body>
  </SOAP-ENV:Envelope>
  """
   request = urllib2.Request(service_url, data=request_body, headers=headers)

  handle = opener.open(request)

   print(handle.read())

except Exception as e:

   print(e)

Please help me to create SOAP request for creating property collector and destroying it.

Reply
0 Kudos
msripada
Virtuoso
Virtuoso

I am not good with the sdk part but you can post in the below forum for help. Please check the inventory service log for more details when you are performing this activity

Forums

Forums - VMware {code}

Thanks,

MS

Reply
0 Kudos