b72d57c6c7
etcd service must be disabled in devstack environment. Change-Id: I327653fb81e408d33327e56dbbc9770a7593f966
2.0 KiB
2.0 KiB
Interact with other OpenStack services
It's very easy to interact with other OpenStack services in your function. Let's take Python programming language and integration with Swift service for an example.
At the time you create a function, you specify an entry, which is a function in your code module that Qinling can invoke when the service executes your code. Use the following general syntax structure when creating a function in Python which will interact with Swift service in OpenStack.
import swiftclient
def main(region_name, container, object, context=None, **kwargs):
= swiftclient.Connection(
conn =context['os_session'],
session={'region_name': region_name},
os_options
)
= conn.head_object(container, object)
obj_info return obj_info
In the above code, note the following:
- Qinling supports most of OpenStack service clients, so you don't
need to install
python-swiftclient
in your code package. - There is a parameter named
context
, this is a parameter provided by Qinling that is usually of the Python dict type. You can easily get a valid Keystone session object from it. As a result, you don't need to pass any sensitive data to Qinling in order to interact with OpenStack services.
Note
Please avoid using context
as your own parameter in the
code.