def _success_action(cls, task, status, progress): network_manager = NetworkManager() # 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, network_manager.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: netmanager = NetworkManager() message = ( u"Deployment of environment '{0}' is done. " "Access the OpenStack dashboard (Horizon) at {1}").format( task.cluster.name, netmanager.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)
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))
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)