Add region support
Now Heat is missing the region support for software deployment
and so did os-collect-config. This patch fixes it but keeps the
backward compatibility.
For changes in Heat pls refer Iec6f3606c9fdf8474f393b0990356f34d38bcf75
and https://review.openstack.org/580470
For changes in Heat agents please refer
I8e0518fa61e237ec055834dd4bebe0fc87cd6627
Story: 2002781
Change-Id: I88182a9a9af74e9760b2ec9b500971f06293f0b8
(cherry picked from commit 5bebbf1654
)
This commit is contained in:
parent
08bb3bd58f
commit
cad9d0fead
@ -37,6 +37,8 @@ opts = [
|
||||
help='ID of the stack this deployment belongs to'),
|
||||
cfg.StrOpt('resource-name',
|
||||
help='Name of resource in the stack to be polled'),
|
||||
cfg.StrOpt('region-name',
|
||||
help='Region Name for extracting Heat endpoint'),
|
||||
]
|
||||
name = 'heat'
|
||||
|
||||
@ -69,6 +71,8 @@ class Collector(object):
|
||||
if CONF.heat.resource_name is None:
|
||||
logger.info('No resource_name configured.')
|
||||
raise exc.HeatMetadataNotConfigured
|
||||
# NOTE(flwang): To be compatible with old versions, we won't throw
|
||||
# error here if there is no region name.
|
||||
|
||||
try:
|
||||
ks = keystone.Keystone(
|
||||
@ -78,8 +82,11 @@ class Collector(object):
|
||||
project_id=CONF.heat.project_id,
|
||||
keystoneclient=self.keystoneclient,
|
||||
discover_class=self.discover_class).client
|
||||
endpoint = ks.service_catalog.url_for(
|
||||
service_type='orchestration', endpoint_type='publicURL')
|
||||
kwargs = {'service_type': 'orchestration',
|
||||
'endpoint_type': 'publicURL'}
|
||||
if CONF.heat.region_name:
|
||||
kwargs['region_name'] = CONF.heat.region_name
|
||||
endpoint = ks.service_catalog.url_for(**kwargs)
|
||||
logger.debug('Fetching metadata from %s' % endpoint)
|
||||
heat = self.heatclient.Client(
|
||||
'1', endpoint, token=ks.auth_token)
|
||||
|
@ -43,6 +43,8 @@ opts = [
|
||||
cfg.BoolOpt('use-websockets',
|
||||
default=False,
|
||||
help='Use the websocket transport to connect to Zaqar.'),
|
||||
cfg.StrOpt('region-name',
|
||||
help='Region Name for extracting Zaqar endpoint'),
|
||||
]
|
||||
name = 'zaqar'
|
||||
|
||||
@ -59,23 +61,26 @@ class Collector(object):
|
||||
self.transport = transport
|
||||
|
||||
def get_data_wsgi(self, ks, conf):
|
||||
kwargs = {'service_type': 'messaging', 'endpoint_type': 'publicURL'}
|
||||
if CONF.zaqar.region_name:
|
||||
kwargs['region_name'] = CONF.zaqar.region_name
|
||||
endpoint = ks.service_catalog.url_for(**kwargs)
|
||||
logger.debug('Fetching metadata from %s' % endpoint)
|
||||
zaqar = self.zaqarclient.Client(endpoint, conf=conf, version=1.1)
|
||||
|
||||
endpoint = ks.service_catalog.url_for(
|
||||
service_type='messaging', endpoint_type='publicURL')
|
||||
logger.debug('Fetching metadata from %s' % endpoint)
|
||||
zaqar = self.zaqarclient.Client(endpoint, conf=conf, version=1.1)
|
||||
|
||||
queue = zaqar.queue(CONF.zaqar.queue_id)
|
||||
r = six.next(queue.pop())
|
||||
return r.body
|
||||
queue = zaqar.queue(CONF.zaqar.queue_id)
|
||||
r = six.next(queue.pop())
|
||||
return r.body
|
||||
|
||||
def _create_req(self, endpoint, action, body):
|
||||
return request.Request(endpoint, action, content=json.dumps(body))
|
||||
|
||||
def get_data_websocket(self, ks, conf):
|
||||
|
||||
endpoint = ks.service_catalog.url_for(
|
||||
service_type='messaging-websocket', endpoint_type='publicURL')
|
||||
kwargs = {'service_type': 'messaging-websocket',
|
||||
'endpoint_type': 'publicURL'}
|
||||
if CONF.zaqar.region_name:
|
||||
kwargs['region_name'] = CONF.zaqar.region_name
|
||||
endpoint = ks.service_catalog.url_for(**kwargs)
|
||||
|
||||
logger.debug('Fetching metadata from %s' % endpoint)
|
||||
|
||||
@ -129,6 +134,8 @@ class Collector(object):
|
||||
if CONF.zaqar.queue_id is None:
|
||||
logger.warn('No queue_id configured.')
|
||||
raise exc.ZaqarMetadataNotConfigured()
|
||||
# NOTE(flwang): To be compatible with old versions, we won't throw
|
||||
# error here if there is no region name.
|
||||
|
||||
try:
|
||||
ks = keystone.Keystone(
|
||||
|
Loading…
Reference in New Issue
Block a user