<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _resolve_ondemand(self, macro, data):
 # pylint: disable=too-many-locals """Get on demand macro value If the macro cannot be resolved, this function will return 'n/a' rather than an empty string, this to alert the caller of a potential problem. :param macro: macro to parse :type macro: :param data: data to get value from :type data: :return: macro value :rtype: str """

        elts = macro.split(':')
        nb_parts = len(elts)
        macro_name = elts[0]
        # 3 parts for a service, 2 for all others types...
        if nb_parts == 3:
            val = ''
            (host_name, service_description) = (elts[1], elts[2])
            # host_name can be void, so it's the host in data
            # that is important. We use our self.host_class to
            # find the host in the data :)
            if host_name == '':
                for elt in data:
                    if elt is not None and elt.__class__ == self.host_class:
                        host_name = elt.host_name
            # Ok now we get service
            serv = self.services.find_srv_by_name_and_hostname(host_name, service_description)
            if serv is not None:
                cls = serv.__class__
                prop = cls.macros[macro_name]
                val = self._get_value_from_element(serv, prop)
                return val
        # Ok, service was easy, now hard part
        else:
            val = ''
            elt_name = elts[1]
            # Special case: elt_name can be void
            # so it's the host where it apply
            if elt_name == '':
                for elt in data:
                    if elt is not None and elt.__class__ == self.host_class:
                        elt_name = elt.host_name
            for od_list in self.lists_on_demand:
                cls = od_list.inner_class
                # We search our type by looking at the macro
                if macro_name in cls.macros:
                    prop = cls.macros[macro_name]
                    i = od_list.find_by_name(elt_name)
                    if i is not None:
                        val = self._get_value_from_element(i, prop)
                        # Ok we got our value :)
                        break
            return val

        # Return a strange value in this case rather than an empty string
        return 'n/a'