<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def alloc_retrieve_subnet_info(self, tenant_id, direc):
 """Allocate and store Subnet. This function initially checks if subnet is allocated for a tenant for the in/out direction. If not, it calls routine to allocate a subnet and stores it on tenant object. """

        serv_obj = self.get_service_obj(tenant_id)
        subnet_dict = self.retrieve_dcnm_subnet_info(tenant_id, direc)
        if subnet_dict:
            return subnet_dict
        ip_subnet_dict = self.get_next_ip(tenant_id, direc)
        subnet_dict = self.fill_dcnm_subnet_info(
            tenant_id, ip_subnet_dict.get('subnet'),
            ip_subnet_dict.get('start'), ip_subnet_dict.get('end'),
            ip_subnet_dict.get('gateway'), ip_subnet_dict.get('sec_gateway'),
            direc)
        serv_obj.store_dcnm_subnet_dict(subnet_dict, direc)
        return subnet_dict