[29d5f7c] | 1 | #!/usr/local/bin/python |
---|
| 2 | |
---|
| 3 | import copy |
---|
| 4 | |
---|
| 5 | class allocation_info: |
---|
| 6 | """ |
---|
| 7 | An allocation identified by allocationID. It includes the local name |
---|
| 8 | of the testbed on which it was allocated and the uri on which to |
---|
| 9 | contact it. In addition, the proofs of access are included. |
---|
| 10 | """ |
---|
| 11 | def __init__(self, allocID, tb, uri, proof=None): |
---|
| 12 | self.allocID = allocID |
---|
| 13 | self.tb = tb |
---|
| 14 | self.uri = uri |
---|
| 15 | self.proof = proof |
---|
| 16 | |
---|
| 17 | class experiment_info: |
---|
| 18 | """ |
---|
| 19 | Information about an experiment in the eperiment controller. It includes |
---|
| 20 | the fedid and localnames, the identity the experiment acts as, current |
---|
| 21 | status, topology allocation logs and the allocations themselves. |
---|
| 22 | """ |
---|
| 23 | def __init__(self, fedid, localname, identity=None): |
---|
| 24 | self.fedid = fedid |
---|
| 25 | self.localname = localname |
---|
| 26 | self.identity = identity |
---|
| 27 | self.top = None |
---|
| 28 | self.status = 'empty' |
---|
| 29 | self.log = [] |
---|
| 30 | self.alloc = { } |
---|
| 31 | |
---|
| 32 | def add_allocation(self, a): |
---|
| 33 | self.alloc[a.tb] = a |
---|
| 34 | |
---|
| 35 | def get_allocation(self, tb): |
---|
| 36 | return self.alloc.get(tb,None) |
---|
| 37 | |
---|
| 38 | def get_all_allocations(self): |
---|
| 39 | return self.alloc.values() |
---|
| 40 | |
---|
| 41 | def get_info(self): |
---|
| 42 | """ |
---|
| 43 | Return the information as a dict suitable for a soap return value. |
---|
| 44 | This is an infoResponseType in fedd_types.xsd. |
---|
| 45 | """ |
---|
| 46 | # The state may be massaged by the service function that called |
---|
| 47 | # get_info (e.g., encoded for XMLRPC transport) so copy structured |
---|
| 48 | # fields. |
---|
| 49 | rv = { |
---|
| 50 | 'experimentID': [ |
---|
| 51 | { 'fedid': copy.deepcopy(self.fedid) }, |
---|
| 52 | {'localname': self.localname }, |
---|
| 53 | ], |
---|
| 54 | 'experimentStatus': self.status, |
---|
| 55 | } |
---|
| 56 | if self.log: |
---|
| 57 | rv['allocationLog'] = "".join(self.log) |
---|
| 58 | if self.identity is not None: |
---|
| 59 | rv['experimentAccess'] = {'X509': copy.deepcopy(self.identity)} |
---|
| 60 | if self.top is not None: |
---|
| 61 | rv['experimentdescription'] = \ |
---|
| 62 | { 'topdldescription': self.top.to_dict() } |
---|
| 63 | return rv |
---|
| 64 | |
---|