GENI-NSF / geni-ch

GENI clearinghouse services
Other
3 stars 6 forks source link

create_request seems to ignore my request text #538

Closed nbastin closed 7 years ago

nbastin commented 7 years ago

I dug around a bit in the project schema to figure out what the values of these arguments should be, and it does seem to work:

>>> CH2.create_request(context.cf._sa, *context._chargs, project_id=project.uid, desc="Because I wanna!")
{'output': '', 'code': 0, 'value': 7069}

The innards of that request are:

def create_request (url, root_bundle, cert, key, cred_strings, project_id, desc):
  JOIN = 0
  DUMMY_ATTRS = {}
  req_data = xmlrpclib.dumps((REQCTX.PROJECT, project_id, JOIN, desc, DUMMY_ATTRS, cred_strings, {}),
                             methodname="create_request")

It does actually make the request for me to act on, but the text is the default dummy text:

>>> PP(context.cf.getPendingProjectRequests(context))
[{'context_id': '10c88fc8-9d57-4971-8820-5b14323557f5',
  'context_type': 1,
  'creation_timestamp': '2017-01-18T11:04:47Z',
  'id': 7069,
  'request_details': '',
  'request_text': "May I join GENI project 'vts-infra'?\nI think I need to do GENI research in your project.\n",
  'request_type': 0,
  'requestor': '2d8ff6b0-ee1f-4c09-a986-088dbf058867',
  'resolution_description': None,
  'resolution_timestamp': None,
  'resolver': None,
  'status': 0}]

This is not a deal breaker at the moment, but I didn't see any obvious reason why it was broken in a quick perusal of the SAv1PersistentImplementation code.

tcmitchell commented 7 years ago

I'm suspicious that something else has gone wrong. The default text is part of the portal code, not part of the clearinghouse code. Is it possible that you're looking at a different request when you look it up?

@nbastin could you run another test? I could be missing something, but I don't see how that request_text could have been added by the clearinghouse code.

nbastin commented 7 years ago

Apparently I already had a request pending, and it just kept giving it back to me (id 7069). After I rejected that request now I try to make a new one and get an error that makes me think perhaps it never worked:

CH2.create_request(context.cf._sa, *context._chargs, project_id = uid, desc="Foo!")
Out[34]:
{'code': 101,
 'output': "[SERVER] SERVER_ERROR (ProgrammingError: (ProgrammingError) can't adapt type 'dict' 'INSERT INTO pa_project_member_request (context_type, context_id, request_text, request_type, request_details, requestor, status, creation_timestamp) VALUES (%(context_type)s, %(context_id)s, %(request_text)s, %(request_type)s, %(request_details)s, %(requestor)s, %(status)s, %(creation_timestamp)s) RETURNING pa_project_member_request.id' {'status': 0, 'request_text': 'Foo!', 'context_type': 1, 'context_id': '10c88fc8-9d57-4971-8820-5b14323557f5', 'requestor': '2d8ff6b0-ee1f-4c09-a986-088dbf058867', 'request_type': 0, 'request_details': {}, 'creation_timestamp': datetime.datetime(2017, 2, 1, 19, 14, 54, 312146)})",
 'value': None}

Seems that possibly the problem is that request_details is a dict, so maybe I need to change the datatype I'm giving you (I feel like I was led to do whatever I did from the docs, but maybe not...)

nbastin commented 7 years ago

Ah so the docs just have ? for request_details...what should I put in there? :-)

tcmitchell commented 7 years ago

The portal passes an empty string for request_details. I recommend you do the same (for better or worse). I've updated the doc locally for now. I imagine there will be other changes needed as well.

nbastin commented 7 years ago

Huzzah! Victoire!

CH2.create_request(context.cf._sa, *context._chargs, project_id = uid, desc="Foo!")
Out[9]:
{'code': 0, 'output': '', 'value': 7222}
>>> PP(context.cf.getPendingProjectRequests(context))
[{'context_id': '10c88fc8-9d57-4971-8820-5b14323557f5',
  'context_type': 1,
  'creation_timestamp': '2017-02-01T20:42:20Z',
  'id': 7222,
  'request_details': '',
  'request_text': 'Foo!',
  'request_type': 0,
  'requestor': '2d8ff6b0-ee1f-4c09-a986-088dbf058867',
  'resolution_description': None,
  'resolution_timestamp': None,
  'resolver': None,
  'status': 0}]