code: def get_service_instance_from_managed_object(mo_ref, name='<unnamed>'):
      '''
      Retrieves the service instance from a managed object.
  
      me_ref
          Reference to a managed object (of type vim.ManagedEntity).
  
      name
          Name of managed object. This field is optional.
      '''
      if not name:
          name = mo_ref.name
      log.trace('[%s] Retrieving service instance from managed object', name)
      si = vim.ServiceInstance('ServiceInstance')
      si._stub = mo_ref._stub
      return sf get_service_instance_from_managed_object(mo_ref, name='<unnamed>'):
      '''
      Retrieves the service instance from a managed object.
  
      me_ref
          Reference to a managed object (of type vim.ManagedEntity).
  
      name
          Name of managed object. This field is optional.
      '''
      if not name:
          name = mo_ref.name
      log.trace('[%s] Retrieving service instance from managed object', name)
      si = vim.ServiceInstance('ServiceInstance')
      si._stub = mo_ref._stub
      return si
docs: Retrieves the service instance from a managed object.
  
      me_ref
          Reference to a managed object (of type vim.ManagedEntity).
  
      name
          Name of managed object. This field is optional.