deb-manila/contrib/share_driver_hooks/zaqarclientwrapper.py
Valeriy Ponomaryov 2f4795f7fe Add mount automation example based on Zaqar
This example consists of three parts:
- Server side hook module
'contrib.share_driver_hooks.zaqar_notification' that can be enabled in Manila
- Client side consumer module
'contrib.share_driver_hooks.zaqar_notification_example_consumer' that can be
used in any user machine.
- Common module 'contrib.share_driver_hooks.zaqarclientwrapper' that is used
by server and client side modules for initialization of Zaqar client.

Details of its usage are described in file
'contrib/share_driver_hooks/README.rst'

Change-Id: I5e802ee2e2a4dd36db92865b0ba82e73c1fa86d4
2015-11-06 23:41:40 +00:00

87 lines
2.7 KiB
Python

# Copyright (c) 2015 Mirantis, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from zaqarclient.queues import client as zaqar
zaqar_notification_opts = [
cfg.StrOpt(
"zaqar_username",
help="Username that should be used for init of zaqar client.",
),
cfg.StrOpt(
"zaqar_password",
secret=True,
help="Password for user specified in opt 'zaqar_username'.",
),
cfg.StrOpt(
"zaqar_project_name",
help=("Project/Tenant name that is owns user specified "
"in opt 'zaqar_username'."),
),
cfg.StrOpt(
"zaqar_auth_url",
default="http://127.0.0.1:35357/v2.0/",
help="Auth url to be used by Zaqar client.",
),
cfg.StrOpt(
"zaqar_region_name",
help="Name of the region that should be used. Optional.",
),
cfg.StrOpt(
"zaqar_service_type",
default="messaging",
help="Service type for Zaqar. Optional.",
),
cfg.StrOpt(
"zaqar_endpoint_type",
default="publicURL",
help="Type of endpoint to be used for init of Zaqar client. Optional.",
),
cfg.FloatOpt(
"zaqar_api_version",
default=1.1,
help="Version of Zaqar API to use. Optional.",
),
cfg.ListOpt(
"zaqar_queues",
default=["manila_notification_qeueue"],
help=("List of queues names to be used for sending Manila "
"notifications. Optional."),
),
]
CONF = cfg.CONF
CONF.register_opts(zaqar_notification_opts, group='zaqar')
ZAQARCLIENT = zaqar.Client(
version=CONF.zaqar.zaqar_api_version,
conf={
"auth_opts": {
"backend": "keystone",
"options": {
"os_username": CONF.zaqar.zaqar_username,
"os_password": CONF.zaqar.zaqar_password,
"os_project_name": CONF.zaqar.zaqar_project_name,
"os_auth_url": CONF.zaqar.zaqar_auth_url,
"os_region_name": CONF.zaqar.zaqar_region_name,
"os_service_type": CONF.zaqar.zaqar_service_type,
"os_endpoint_type": CONF.zaqar.zaqar_endpoint_type,
"insecure": True,
},
},
},
)