Enable Magnum to send notifications via RPC

Initialize RPC notification transport on starting magnum-api and
magnum-conductor. Here is the initialization sequence:
1. magnum.cmd.api.main()/magnum.cmd.conductor.main()
2. magnum.common.service.prepare_service()
3. magnum.common.config.parse_args()
4. magnum.common.rpc.init()
The last call setup a notifier that can be used to send notifications
via message queue.

Change-Id: Ibcc88d74a933d55ff33fad55e603786f9b4a3906
Partially-Implements: blueprint autoscale-bay
This commit is contained in:
Hongbin Lu 2015-08-18 21:37:34 -04:00
parent 8719df3b99
commit aeb401e5a5
4 changed files with 29 additions and 3 deletions

View File

@ -35,6 +35,12 @@
# (integer value)
#periodic_interval_max = 60
# Name of this node. This can be an opaque identifier. It is not
# necessarily a hostname, FQDN, or IP address. However, the node name
# must be valid within an AMQP key, and if using ZeroMQ, a valid
# hostname, FQDN, or IP address. (string value)
#host = localhost
#
# From oslo.log
#

View File

@ -141,7 +141,7 @@ def get_server(target, endpoints, serializer=None):
serializer=serializer)
def get_notifier(service=None, host=None, publisher_id=None):
def get_notifier(service='container', host=None, publisher_id=None):
assert NOTIFIER is not None
if not publisher_id:
publisher_id = "%s.%s" % (service, host or CONF.host)

View File

@ -12,13 +12,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import socket
from oslo_config import cfg
from oslo_log import log as logging
from magnum.common import config
from magnum.i18n import _
service_opts = [
cfg.StrOpt('host',
default=socket.getfqdn(),
help=_('Name of this node. This can be an opaque identifier. '
'It is not necessarily a hostname, FQDN, or IP address. '
'However, the node name must be valid within '
'an AMQP key, and if using ZeroMQ, a valid '
'hostname, FQDN, or IP address.')),
]
cfg.CONF.register_opts(service_opts)
def prepare_service(argv=None):
if argv is None:
argv = []
logging.register_options(cfg.CONF)
cfg.CONF(argv[1:], project='magnum')
config.parse_args(argv)
logging.setup(cfg.CONF, 'magnum')

View File

@ -20,6 +20,7 @@ import magnum.api.auth
import magnum.common.clients
import magnum.common.exception
import magnum.common.magnum_keystoneclient
import magnum.common.service
import magnum.conductor.config
import magnum.conductor.handlers.bay_conductor
import magnum.conductor.handlers.docker_conductor
@ -35,7 +36,8 @@ def list_opts():
magnum.common.magnum_keystoneclient.trust_opts,
magnum.common.paths.PATH_OPTS,
magnum.common.utils.UTILS_OPTS,
magnum.common.rpc_service.periodic_opts
magnum.common.rpc_service.periodic_opts,
magnum.common.service.service_opts,
)),
('api', magnum.api.app.API_SERVICE_OPTS),
('bay', magnum.conductor.template_definition.template_def_opts),