当前位置: 首页>>代码示例>>Python>>正文


Python CloudHost.get_cluster_average_stats方法代码示例

本文整理汇总了Python中cloud.aws.CloudHost.get_cluster_average_stats方法的典型用法代码示例。如果您正苦于以下问题:Python CloudHost.get_cluster_average_stats方法的具体用法?Python CloudHost.get_cluster_average_stats怎么用?Python CloudHost.get_cluster_average_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloud.aws.CloudHost的用法示例。


在下文中一共展示了CloudHost.get_cluster_average_stats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_if_instance_info

# 需要导入模块: from cloud.aws import CloudHost [as 别名]
# 或者: from cloud.aws.CloudHost import get_cluster_average_stats [as 别名]
    def handle_if_instance_info(self, is_allowed):
        stats = self.get_argument('instance_info', None)
        if stats is None:
            return False

        if not is_allowed:
            AdminHandler.log_error("Show instance info not allowed for user")
            response = {'code': -1, 'data': 'You do not have permissions to view these stats'}
        else:
            try:
                if stats == 'load':
                    stats = {}
                    # get cluster loads
                    average_load = CloudHost.get_cluster_average_stats('Load')
                    if None != average_load:
                        stats['Average Load'] = average_load;

                    machine_loads = CloudHost.get_cluster_stats('Load')
                    if None != machine_loads:
                        for n, v in machine_loads.iteritems():
                            stats['Instance ' + n] = v

                response = {'code': 0, 'data': stats} if stats is not None else {'code': 1, 'data': {}}
            except:
                AdminHandler.log_error("exception while getting stats")
                response = {'code': -1, 'data': 'error getting stats'}

        self.write(response)
        return True
开发者ID:arshak,项目名称:JuliaBox,代码行数:31,代码来源:admin.py

示例2: handle_if_instance_info

# 需要导入模块: from cloud.aws import CloudHost [as 别名]
# 或者: from cloud.aws.CloudHost import get_cluster_average_stats [as 别名]
    def handle_if_instance_info(self, is_allowed):
        stats = self.get_argument('instance_info', None)
        if stats is None:
            return False

        if not is_allowed:
            AdminHandler.log_error("Show instance info not allowed for user")
            response = {'code': -1, 'data': 'You do not have permissions to view these stats'}
        else:
            try:
                if stats == 'load':
                    result = {}
                    # get cluster loads
                    average_load = CloudHost.get_cluster_average_stats('Load')
                    if None != average_load:
                        result['Average Load'] = average_load;

                    machine_loads = CloudHost.get_cluster_stats('Load')
                    if None != machine_loads:
                        for n, v in machine_loads.iteritems():
                            result['Instance ' + n] = v
                elif stats == 'sessions':
                    result = {}
                    if CloudHost.ENABLED['autoscale']:
                        instances = CloudHost.get_autoscaled_instances()
                    else:
                        instances = ['localhost']

                    for idx in range(0, len(instances)):
                        inst = instances[idx]
                        result[inst] = JBoxContainer.sync_session_status(inst)['data']
                else:
                    raise Exception("unknown command %s" % (stats,))

                response = {'code': 0, 'data': result}
            except:
                AdminHandler.log_error("exception while getting stats")
                AdminHandler._get_logger().exception("exception while getting stats")
                response = {'code': -1, 'data': 'error getting stats'}

        self.write(response)
        return True
开发者ID:barrygolden,项目名称:JuliaBox,代码行数:44,代码来源:admin.py


注:本文中的cloud.aws.CloudHost.get_cluster_average_stats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。