'Adds and index an item into the `items` container.
This implementation takes into account that a service has two naming
attribute: `host_name` and `service_description`.
:param item:    The item to add
:param index:   Flag indicating if the item should be indexed'

def add_item(self, item, index=True):

    objcls = self.inner_class.my_type
    hname = getattr(item, 'host_name', '')
    hgname = getattr(item, 'hostgroup_name', '')
    sdesc = getattr(item, 'service_description', '')
    source = getattr(item, 'imported_from', 'unknown')
    if source:
        in_file = ('    in    %s' % source)
    else:
        in_file = ''
    if ((not hname) and (not hgname)):
        mesg = ('a    %s    has    been    defined    without    host_name    nor    hostgroups%s' % (objcls, in_file))
        item.configuration_errors.append(mesg)
    if (index is True):
        if (hname and sdesc):
            item = self.index_item(item)
        else:
            mesg = ('a    %s    has    been    defined    without    host_name    nor    service_description%s' % (objcls, in_file))
            item.configuration_errors.append(mesg)
            return
    self.items[item.id] = item
