本文整理汇总了Python中nailgun.network.manager.NetworkManager.get_horizon_url方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.get_horizon_url方法的具体用法?Python NetworkManager.get_horizon_url怎么用?Python NetworkManager.get_horizon_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.network.manager.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.get_horizon_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_horizon_url [as 别名]
def GET(self, cluster_id):
try:
cluster = db().query(Cluster).get(cluster_id)
cluster_attrs = self.get_cluster_attrs(cluster)
network_manager = NetworkManager()
horizon_url = network_manager.get_horizon_url(cluster_id)
keystone_url = network_manager.get_keystone_url(cluster_id)
return {
"horizon_url": horizon_url,
"keystone_url": keystone_url,
"admin_username": cluster_attrs["user"],
"admin_password": cluster_attrs["password"],
"admin_tenant_name": cluster_attrs["tenant"],
"controller_nodes_ips": self.get_controller_nodes_ips(cluster),
"controller_nodes_names": self.get_controller_nodes_fqdns(cluster),
}
except Exception as exc:
logger.error(traceback.format_exc())
raise web.badrequest(message=str(exc))
示例2: _success_action
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_horizon_url [as 别名]
def _success_action(cls, task, status, progress):
# check if all nodes are ready
if any(map(lambda n: n.status == 'error',
task.cluster.nodes)):
cls._error_action(task, 'error', 100)
return
if task.cluster.mode in ('singlenode', 'multinode'):
# determining horizon url - it's an IP
# of a first cluster controller
controller = db().query(Node).filter_by(
cluster_id=task.cluster_id
).filter(Node.role_list.any(name='controller')).first()
if controller:
logger.debug(
u"Controller is found, node_id=%s, "
"getting it's IP addresses",
controller.id
)
public_net = filter(
lambda n: n['name'] == 'public' and 'ip' in n,
NetworkManager.get_node_networks(controller.id)
)
if public_net:
horizon_ip = public_net[0]['ip'].split('/')[0]
message = (
u"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at "
"http://{1}/ or via internal network at http://{2}/"
).format(
task.cluster.name,
horizon_ip,
controller.ip
)
else:
message = (
u"Deployment of environment '{0}' is done"
).format(task.cluster.name)
logger.warning(
u"Public ip for controller node "
"not found in '{0}'".format(task.cluster.name)
)
else:
message = (
u"Deployment of environment"
" '{0}' is done"
).format(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"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at {1}"
).format(
task.cluster.name,
NetworkManager.get_horizon_url(task.cluster.id)
)
except Exception as exc:
logger.error(": ".join([
str(exc),
traceback.format_exc()
]))
message = (
u"Deployment of environment"
" '{0}' is done"
).format(task.cluster.name)
logger.warning(
u"Cannot find virtual IP for '{0}'".format(
task.cluster.name
)
)
notifier.notify(
"done",
message,
task.cluster_id
)
TaskHelper.update_task_status(task.uuid, status, progress, message)