diff options
| author | termie <github@anarkystic.com> | 2011-03-24 12:42:47 -0700 |
|---|---|---|
| committer | termie <github@anarkystic.com> | 2011-03-24 12:42:47 -0700 |
| commit | a1bde64e91a8b76fd0e69c3bdfc51e4e85adf6f0 (patch) | |
| tree | eac8457e1871416fbbf075efe6b12057a72f80e1 /bin | |
| parent | a7863c026819a9369cecaa42778a10ab54e798ba (diff) | |
add some more docs and make it more obvious which parts are examples
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/nova-direct-api | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/nova-direct-api b/bin/nova-direct-api index 0f7589871..bb3aa8ae7 100755 --- a/bin/nova-direct-api +++ b/bin/nova-direct-api @@ -54,12 +54,19 @@ flags.DEFINE_flag(flags.HelpXMLFlag()) # An example of an API that only exposes read-only methods. +# In this case we're just limiting which methods are exposed. class ReadOnlyCompute(direct.Limited): """Read-only Compute API.""" _allowed = ['get', 'get_all', 'get_console_output'] + # An example of an API that provides a backwards compatibility layer. +# In this case we're overwriting the implementation to ensure +# compatibility with an older version. In reality we would want the +# "description=None" to be part of the actual API so that code +# like this isn't even necessary, but this example shows what one can +# do if that isn't the situation. class VolumeVersionOne(direct.Limited): _allowed = ['create', 'delete', 'update', 'get'] @@ -76,8 +83,12 @@ if __name__ == '__main__': direct.register_service('volume', volume.API()) direct.register_service('network', network.API()) direct.register_service('reflect', direct.Reflection()) - direct.register_service('compute-readonly', ReadOnlyCompute(compute.API())) - direct.register_service('volume-v1', VolumeVersionOne(volume.API())) + + # Here is how we could expose the code in the examples above. + #direct.register_service('compute-readonly', + # ReadOnlyCompute(compute.API())) + #direct.register_service('volume-v1', VolumeVersionOne(volume.API())) + router = direct.Router() with_json = direct.JsonParamsMiddleware(router) with_req = direct.PostParamsMiddleware(with_json) |
