Get watch_url via get_heat_cfn_url
Options heat_metadata_server_url and heat_waitcondition_server_url for getting correct url uses method get_heat_cfn_url, which gets cfn_url. This approach can be used also for getting heat_watch_server_url option. Closes-Bug: #1552379 Change-Id: I7c159f4d41c1b9546d4c78843e3a6cec08c78eee
This commit is contained in:
parent
edeae75de4
commit
29d6c8e1bf
|
@ -12,6 +12,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from heatclient import client as hc
|
||||
from heatclient import exc
|
||||
|
@ -96,3 +97,12 @@ class HeatClientPlugin(client_plugin.ClientPlugin):
|
|||
if config_url and config_url[-1] != "/":
|
||||
config_url += '/'
|
||||
return config_url
|
||||
|
||||
def get_watch_server_url(self):
|
||||
cfn_url = self.get_heat_cfn_url()
|
||||
url_parts = cfn_url.split(':')
|
||||
port_and_version = url_parts[-1].split('/')
|
||||
port_and_version[0] = (
|
||||
six.text_type(cfg.CONF.heat_api_cloudwatch.bind_port))
|
||||
url_parts[-1] = '/'.join(port_and_version)
|
||||
return ':'.join(url_parts)
|
||||
|
|
|
@ -372,11 +372,14 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
|||
attachments.append((jsonutils.dumps(metadata),
|
||||
'cfn-init-data', 'x-cfninitdata'))
|
||||
|
||||
attachments.append((cfg.CONF.heat_watch_server_url,
|
||||
'cfn-watch-server', 'x-cfninitdata'))
|
||||
heat_client_plugin = self.context.clients.client_plugin('heat')
|
||||
watch_url = cfg.CONF.heat_watch_server_url
|
||||
if not watch_url:
|
||||
watch_url = heat_client_plugin.get_watch_server_url()
|
||||
|
||||
attachments.append((watch_url, 'cfn-watch-server', 'x-cfninitdata'))
|
||||
|
||||
if is_cfntools:
|
||||
heat_client_plugin = self.context.clients.client_plugin('heat')
|
||||
cfn_md_url = heat_client_plugin.get_cfn_metadata_server_url()
|
||||
attachments.append((cfn_md_url,
|
||||
'cfn-metadata-server', 'x-cfninitdata'))
|
||||
|
@ -384,7 +387,7 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
|||
# Create a boto config which the cfntools on the host use to know
|
||||
# where the cfn and cw API's are to be accessed
|
||||
cfn_url = urlparse.urlparse(cfn_md_url)
|
||||
cw_url = urlparse.urlparse(cfg.CONF.heat_watch_server_url)
|
||||
cw_url = urlparse.urlparse(watch_url)
|
||||
is_secure = cfg.CONF.instance_connection_is_secure
|
||||
vcerts = cfg.CONF.instance_connection_https_validate_certificates
|
||||
boto_cfg = "\n".join(["[Boto]",
|
||||
|
|
|
@ -89,6 +89,10 @@ class ClientsTest(common.HeatTestCase):
|
|||
obj = self._client_cfn_url()
|
||||
self.assertEqual("http://0.0.0.0:8000/v1/", obj.get_heat_cfn_url())
|
||||
|
||||
def test_clients_get_watch_server_url(self):
|
||||
obj = self._client_cfn_url()
|
||||
self.assertEqual("http://0.0.0.0:8003/v1/", obj.get_watch_server_url())
|
||||
|
||||
def test_clients_get_heat_cfn_metadata_url(self):
|
||||
obj = self._client_cfn_url()
|
||||
self.assertEqual("http://0.0.0.0:8000/v1/",
|
||||
|
|
Loading…
Reference in New Issue