Remove dashboard url from success actions messages for tasks
_success_action method of NailgunReceiver was modified so that is now not supply dashboard url for produced message. Tests was updated accordingly Change-Id: Idc3756b5ac7c2cbe5d890a22796cc5b0c74c8027 Closes-Bug: #1479414
This commit is contained in:
parent
999efffd19
commit
88db2a7cf4
|
@ -28,7 +28,6 @@ from sqlalchemy import or_
|
||||||
from nailgun import consts
|
from nailgun import consts
|
||||||
from nailgun import notifier
|
from nailgun import notifier
|
||||||
from nailgun import objects
|
from nailgun import objects
|
||||||
from nailgun.rpc import utils
|
|
||||||
from nailgun.settings import settings
|
from nailgun.settings import settings
|
||||||
|
|
||||||
from nailgun.consts import TASK_STATUSES
|
from nailgun.consts import TASK_STATUSES
|
||||||
|
@ -485,87 +484,22 @@ class NailgunReceiver(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
task_name = task.name.title()
|
task_name = task.name.title()
|
||||||
if task.cluster.mode in ('singlenode', 'multinode'):
|
try:
|
||||||
# determining horizon url - it's an IP
|
message = (
|
||||||
# of a first cluster controller
|
u"{0} of environment '{1}' is done. "
|
||||||
controller = db().query(Node).filter_by(
|
).format(
|
||||||
cluster_id=task.cluster_id
|
task_name,
|
||||||
).filter(
|
task.cluster.name,
|
||||||
Node.roles.any('controller')
|
)
|
||||||
).first()
|
except Exception as exc:
|
||||||
|
logger.error(": ".join([
|
||||||
if controller:
|
str(exc),
|
||||||
logger.debug(
|
traceback.format_exc()
|
||||||
u"Controller is found, node_id=%s, "
|
]))
|
||||||
"getting it's IP addresses",
|
message = u"{0} of environment '{1}' is done".format(
|
||||||
controller.id
|
task_name,
|
||||||
)
|
task.cluster.name
|
||||||
public_net = filter(
|
)
|
||||||
lambda n: n['name'] == 'public' and 'ip' in n,
|
|
||||||
objects.Cluster.get_network_manager(
|
|
||||||
controller.cluster
|
|
||||||
).get_node_networks(controller)
|
|
||||||
)
|
|
||||||
if public_net:
|
|
||||||
horizon_ip = public_net[0]['ip'].split('/')[0]
|
|
||||||
protocol = utils.get_protocol_for_horizon(task.cluster)
|
|
||||||
message = (
|
|
||||||
u"{task} of environment '{name}' is done. "
|
|
||||||
"Access the OpenStack dashboard (Horizon) at "
|
|
||||||
"{proto}://{horizon_address}/ or via internal "
|
|
||||||
"network at http://{controller_address}/"
|
|
||||||
).format(
|
|
||||||
task=task_name,
|
|
||||||
name=task.cluster.name,
|
|
||||||
proto=protocol,
|
|
||||||
horizon_address=horizon_ip,
|
|
||||||
controller_address=controller.ip
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
message = u"{0} of environment '{1}' is done".format(
|
|
||||||
task_name,
|
|
||||||
task.cluster.name
|
|
||||||
)
|
|
||||||
logger.warning(
|
|
||||||
u"Public ip for controller node "
|
|
||||||
"not found in '{0}'".format(task.cluster.name)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
message = u"{0} of environment '{1}' is done".format(
|
|
||||||
task_name,
|
|
||||||
task.cluster.name
|
|
||||||
)
|
|
||||||
logger.warning(u"Controller node not found in '{0}'".format(
|
|
||||||
task.cluster.name
|
|
||||||
))
|
|
||||||
elif task.cluster.is_ha_mode:
|
|
||||||
# determining horizon url in HA mode - it's vip
|
|
||||||
# from a public network saved in task cache
|
|
||||||
try:
|
|
||||||
message = (
|
|
||||||
u"{0} of environment '{1}' is done. "
|
|
||||||
"Access the OpenStack dashboard (Horizon) at {2}"
|
|
||||||
).format(
|
|
||||||
task_name,
|
|
||||||
task.cluster.name,
|
|
||||||
objects.Cluster.get_network_manager(
|
|
||||||
task.cluster
|
|
||||||
).get_horizon_url(task.cluster.id)
|
|
||||||
)
|
|
||||||
except Exception as exc:
|
|
||||||
logger.error(": ".join([
|
|
||||||
str(exc),
|
|
||||||
traceback.format_exc()
|
|
||||||
]))
|
|
||||||
message = u"{0} of environment '{1}' is done".format(
|
|
||||||
task_name,
|
|
||||||
task.cluster.name
|
|
||||||
)
|
|
||||||
logger.warning(
|
|
||||||
u"Cannot find virtual IP for '{0}'".format(
|
|
||||||
task.cluster.name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
zabbix_url = objects.Cluster.get_network_manager(
|
zabbix_url = objects.Cluster.get_network_manager(
|
||||||
task.cluster
|
task.cluster
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from nailgun import consts
|
|
||||||
from nailgun.logger import logger
|
from nailgun.logger import logger
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,12 +25,3 @@ def delete_entities(conn, *entities):
|
||||||
channel = conn.channel()
|
channel = conn.channel()
|
||||||
bound_entity = entity(channel)
|
bound_entity = entity(channel)
|
||||||
bound_entity.delete()
|
bound_entity.delete()
|
||||||
|
|
||||||
|
|
||||||
def get_protocol_for_horizon(cluster):
|
|
||||||
attr_value = cluster.attributes.editable.\
|
|
||||||
get('public_ssl', {}).get('horizon', {}).get('value')
|
|
||||||
if attr_value is True:
|
|
||||||
return consts.PROTOCOL.https
|
|
||||||
else:
|
|
||||||
return consts.PROTOCOL.http
|
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright 2013 Mirantis, Inc.
|
|
||||||
#
|
|
||||||
# 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 nailgun import consts
|
|
||||||
from nailgun import objects
|
|
||||||
|
|
||||||
from nailgun.db.sqlalchemy.models import IPAddr
|
|
||||||
from nailgun.db.sqlalchemy.models import NetworkGroup
|
|
||||||
from nailgun.test.base import BaseIntegrationTest
|
|
||||||
from nailgun.test.base import fake_tasks
|
|
||||||
|
|
||||||
|
|
||||||
class TestHorizonURL(BaseIntegrationTest):
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
self._wait_for_threads()
|
|
||||||
super(TestHorizonURL, self).tearDown()
|
|
||||||
|
|
||||||
@fake_tasks(override_state={"progress": 100, "status": "ready"})
|
|
||||||
def test_horizon_url_ha_mode(self):
|
|
||||||
self.env.create(
|
|
||||||
nodes_kwargs=[
|
|
||||||
{"pending_addition": True},
|
|
||||||
{"pending_addition": True},
|
|
||||||
{"pending_addition": True},
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
supertask = self.env.launch_deployment()
|
|
||||||
self.env.wait_ready(supertask, 60)
|
|
||||||
|
|
||||||
network = self.db.query(NetworkGroup).\
|
|
||||||
filter(NetworkGroup.group_id ==
|
|
||||||
objects.Cluster.get_default_group(
|
|
||||||
self.env.clusters[0]).id).\
|
|
||||||
filter_by(name="public").first()
|
|
||||||
lost_ips = self.db.query(IPAddr).filter_by(
|
|
||||||
network=network.id,
|
|
||||||
node=None,
|
|
||||||
vip_type=consts.NETWORK_VIP_TYPES.haproxy,
|
|
||||||
).all()
|
|
||||||
self.assertEqual(len(lost_ips), 1)
|
|
||||||
|
|
||||||
self.assertEqual(supertask.message, (
|
|
||||||
u"Deployment of environment '{0}' is done. "
|
|
||||||
"Access the OpenStack dashboard (Horizon) at http://{1}/"
|
|
||||||
).format(
|
|
||||||
self.env.clusters[0].name,
|
|
||||||
lost_ips[0].ip_addr
|
|
||||||
))
|
|
|
@ -53,9 +53,8 @@ class TestNailgunReceiver(base.BaseTestCase):
|
||||||
NailgunReceiver._success_action(self.task, 'ready', 100)
|
NailgunReceiver._success_action(self.task, 'ready', 100)
|
||||||
self.assertRegexpMatches(
|
self.assertRegexpMatches(
|
||||||
self.task.message,
|
self.task.message,
|
||||||
"Deployment of environment '[^\s]+' is done. Access the OpenStack "
|
"Deployment of environment '[^\s]+' is done. "
|
||||||
"dashboard \(Horizon\) at [^\s]+\n"
|
"\n\n"
|
||||||
"\n"
|
|
||||||
"Plugin name\d is deployed. description\d\n"
|
"Plugin name\d is deployed. description\d\n"
|
||||||
"Plugin name\d is deployed. description\d")
|
"Plugin name\d is deployed. description\d")
|
||||||
|
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright 2015 Mirantis, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
from nailgun import consts
|
|
||||||
from nailgun.rpc import utils
|
|
||||||
from nailgun.test import base
|
|
||||||
|
|
||||||
|
|
||||||
class TestRpcUtils(base.BaseTestCase):
|
|
||||||
|
|
||||||
def test_get_protocol_for_horizon(self):
|
|
||||||
self.env.create()
|
|
||||||
cluster = self.env.clusters[0]
|
|
||||||
|
|
||||||
self.assertIn(
|
|
||||||
cluster.attributes.editable['public_ssl']['horizon']['value'],
|
|
||||||
(True, True)
|
|
||||||
)
|
|
||||||
|
|
||||||
with mock.patch.dict(cluster.attributes.editable, {}):
|
|
||||||
self.assertEqual(consts.PROTOCOL.https,
|
|
||||||
utils.get_protocol_for_horizon(cluster))
|
|
||||||
|
|
||||||
with mock.patch.dict(cluster.attributes.editable, {'public_ssl': {}}):
|
|
||||||
self.assertEqual(consts.PROTOCOL.http,
|
|
||||||
utils.get_protocol_for_horizon(cluster))
|
|
||||||
|
|
||||||
with mock.patch.dict(cluster.attributes.editable,
|
|
||||||
{'public_ssl': {'horizon': {}}}):
|
|
||||||
self.assertEqual(consts.PROTOCOL.http,
|
|
||||||
utils.get_protocol_for_horizon(cluster))
|
|
||||||
|
|
||||||
with mock.patch.dict(cluster.attributes.editable,
|
|
||||||
{'public_ssl': {'horizon': {'value': False}}}):
|
|
||||||
self.assertEqual(consts.PROTOCOL.http,
|
|
||||||
utils.get_protocol_for_horizon(cluster))
|
|
||||||
|
|
||||||
with mock.patch.dict(cluster.attributes.editable,
|
|
||||||
{'public_ssl': {'horizon': {'value': None}}}):
|
|
||||||
self.assertEqual(consts.PROTOCOL.http,
|
|
||||||
utils.get_protocol_for_horizon(cluster))
|
|
||||||
|
|
||||||
with mock.patch.dict(cluster.attributes.editable,
|
|
||||||
{'public_ssl': {'horizon': {'value': True}}}):
|
|
||||||
self.assertEqual(consts.PROTOCOL.https,
|
|
||||||
utils.get_protocol_for_horizon(cluster))
|
|
Loading…
Reference in New Issue