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


Python AppScaleTools.print_cluster_status方法代码示例

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


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

示例1: status

# 需要导入模块: from appscale.tools.appscale_tools import AppScaleTools [as 别名]
# 或者: from appscale.tools.appscale_tools.AppScaleTools import print_cluster_status [as 别名]
  def status(self, extra_options_list=None):
    """ 'status' is a more accessible way to query the state of the AppScale
    deployment than 'appscale-describe-instances', and calls it with the
    parameters in the user's AppScalefile.

    Raises:
      AppScalefileException: If there is no AppScalefile in the current
      directory.
    """
    contents = self.read_appscalefile()

    # Construct a describe-instances command from the file's contents
    command = extra_options_list or []
    contents_as_yaml = yaml.safe_load(contents)
    if 'keyname' in contents_as_yaml:
      command.append("--keyname")
      command.append(contents_as_yaml['keyname'])

    # Finally, exec the command. Don't worry about validating it -
    # appscale-describe-instances will do that for us.
    options = ParseArgs(command, "appscale-describe-instances").args
    AppScaleTools.print_cluster_status(options)
开发者ID:tmarballi,项目名称:appscale-tools,代码行数:24,代码来源:appscale.py

示例2: test_started_two_nodes

# 需要导入模块: from appscale.tools.appscale_tools import AppScaleTools [as 别名]
# 或者: from appscale.tools.appscale_tools.AppScaleTools import print_cluster_status [as 别名]
  def test_started_two_nodes(self):
    # Mock functions which provides inputs for print_cluster_status
    flexmock(LocalState).should_receive("get_host_with_role").\
      and_return("1.1.1.1")
    flexmock(LocalState).should_receive("get_secret_key").and_return("xxxxxxx")
    fake_ac_client = flexmock()
    (flexmock(appscale_tools)
       .should_receive("AppControllerClient")
       .and_return(fake_ac_client))
    (fake_ac_client.should_receive("get_all_private_ips")
       .and_return(["10.10.4.220", "10.10.7.12"]))
    # This huge list is the most valuable input for the function
    cluster_stats = [
      # HEAD node
      {
        'private_ip': '10.10.4.220',
        'public_ip': '1.1.1.1',
        'roles': ['load_balancer', 'taskqueue_master', 'zookeeper',
                  'db_master','taskqueue', 'shadow'],
        'is_initialized': True,
        'is_loaded': True,
        'apps': {
          'appscaledashboard_default_v1': {
            'http': 1080, 'language': 'python', 'total_reqs': 24, 'appservers': 3,
            'pending_appservers': 0, 'https': 1443, 'reqs_enqueued': 0}},
        'memory': {'available': 1117507584, 'total': 3839168512, 'used': 3400077312},
        'disk': [{'/': {'total': 9687113728, 'free': 4895760384, 'used': 4364763136}}],
        'cpu': {'count': 2, 'idle': 66.7, 'system': 9.5, 'user': 19.0},
        'loadavg': {'last_1_min': 0.64, 'last_5_min': 1.04, 'last_15_min': 0.95,
                    'scheduling_entities': 381, 'runnable_entities': 3},
        # Irrelevant for status bellow
        'state': 'Done starting up AppScale, now in heartbeat mode',
        'swap': {'used': 0, 'free': 0},
        'services': {},
      },

      # AppEngine node
      {
        'private_ip': '10.10.7.12',
        'public_ip': '2.2.2.2',
        'roles': ['memcache', 'appengine'],
        'is_initialized': True,
        'is_loaded': True,
        'apps': {},
        'loadavg': {'last_1_min': 1.05, 'last_5_min': 0.92, 'last_15_min': 0.95,
                    'scheduling_entities': 312, 'runnable_entities': 2},
        'memory': {'available': 2891546624, 'total': 3839168512, 'used': 1951600640},
        'disk': [{'/': {'total': 9687113728, 'free': 5160316928, 'used': 4100206592}}],
        'cpu': {'count': 2, 'idle': 100.0, 'system': 0.0, 'user': 0.0},

        # Irrelevant for status bellow
        'state': 'Done starting up AppScale, now in heartbeat mode',
        'swap': {'used': 0, 'free': 0},
        'services': {},
      }
    ]
    fake_ac_client.should_receive('get_property').\
      and_return({'login': '1.1.1.1'})
    (fake_ac_client.should_receive("get_cluster_stats")
       .and_return(cluster_stats))

    # Configure catching of all logged messages
    fake_logger = LogsCollector()
    flexmock(appscale_tools.AppScaleLogger,
             log=fake_logger.log, warn=fake_logger.warn,
             success=fake_logger.success)

    # Do actual call to tested function
    options = flexmock(keyname="bla-bla", verbose=False)
    AppScaleTools.print_cluster_status(options)

    # Verify if output matches expectation
    self.assertRegexpMatches(
      fake_logger.info_buf,
      r"-+\n\n"
      r"PROJECT ID +SERVICE ID +HTTP/HTTPS +APPSERVERS/PENDING "
      r"+REQS\. ENQUEUED/TOTAL +STATE *\n"
      r"appscaledashboard +default +1080/1443 +3/0 +0/24 +Ready *\n"
    )
    self.assertEqual(fake_logger.warn_buf, "")
    self.assertEqual(fake_logger.success_buf,
                     "\nAppScale is up. All 2 nodes are loaded\n"
                     "\nView more about your AppScale deployment at "
                     "http://1.1.1.1:1080/status\n")
开发者ID:AppScale,项目名称:appscale-tools,代码行数:86,代码来源:test_appscale_describe_instances.py


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