Created
March 3, 2017 15:19
-
-
Save dstanek/a8a343a3ab5ad4ad0862e3e1be332173 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Table structures: | |
limit_types: | |
id uuid | |
service string | |
name string | |
default int | |
project_limits: | |
id uuid | |
limit_type_id uuid | |
value integer | |
project uuid | |
Example data: | |
limit_types: | |
3134fdb, compute, vCPU, 10 | |
18d864ff79e445fc789cebb19 | |
project_limits | |
2234c2f, 3134fdb, 9, A | |
2645049, 3134fdb, 4, C | |
Example hierarchy: | |
A -> B | |
-> C | |
-> D | |
Example API: | |
>>> # project not explicitly defined gets the service default | |
>>> keystone.get_limits('compute', 'X') | |
{ | |
'limits': { | |
'vCPU': 10, | |
}, | |
} | |
>>> # root project get its limits | |
>>> keystone.get_limits('compute', 'A') | |
{ | |
'limits': { | |
'vCPU': 9, | |
}, | |
} | |
>>> # child gets a mini tree | |
>>> keystone.get_limits('compute', 'B') | |
{ | |
'limits': { | |
'vCPU': None, | |
}, | |
'parent': { | |
'name': 'A', | |
'limits': { | |
'vCPU': 9 | |
}, | |
}, | |
} | |
>>> # grandchild gets a bigger tree | |
>>> keystone.get_limits('compute', 'C') | |
{ | |
'limits': { | |
'vCPU': 4, | |
}, | |
'parent': | |
'name': 'B', | |
'limits': { | |
'vCPU': None, | |
}, | |
'parent': { | |
'name': 'A', | |
'limits': { | |
'vCPU': 9, | |
}, | |
}, | |
}, | |
} | |
Notes: | |
1. There are lots of possiblities to flatten the nested structure | |
2. We can add a `'siblings': []` at the same level as parent if we end up needing it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment