當前位置: 首頁>>代碼示例>>Python>>正文


Python config.AuroraConfig類代碼示例

本文整理匯總了Python中apache.aurora.config.AuroraConfig的典型用法代碼示例。如果您正苦於以下問題:Python AuroraConfig類的具體用法?Python AuroraConfig怎麽用?Python AuroraConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AuroraConfig類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_config_with_ports

def test_config_with_ports():
    hwc = HELLO_WORLD(
        task=HELLO_WORLD.task()(
            processes=[Process(name="hello_world", cmdline="echo {{thermos.ports[http]}} {{thermos.ports[admin]}}")]
        )
    )
    config = AuroraConfig(hwc)
    job = config.job()
    assert job.taskConfig.requestedPorts == set(["http", "admin"])
開發者ID:kevinburg,項目名稱:incubator-aurora,代碼行數:9,代碼來源:test_thrift.py

示例2: test_pick

def test_pick():
  env = AuroraConfigLoader.load(BytesIO(MESOS_CONFIG))

  hello_world = env['jobs'][0]
  assert AuroraConfig.pick(env, 'hello_world', None) == hello_world

  env['jobs'][0] = env['jobs'][0](name='something_{{else}}')
  assert str(AuroraConfig.pick(env, 'something_else', [{'else': 'else'}]).name()) == (
      'something_else')
開發者ID:AltanAlpay,項目名稱:aurora,代碼行數:9,代碼來源:test_loader.py

示例3: test_pick

def test_pick():
  with temporary_file() as fp:
    fp.write(MESOS_CONFIG)
    fp.flush()
    env = AuroraConfigLoader.load(fp.name)

  hello_world = env['jobs'][0]
  assert AuroraConfig.pick(env, 'hello_world', None) == hello_world

  env['jobs'][0] = env['jobs'][0](name='something_{{else}}')
  assert str(AuroraConfig.pick(env, 'something_else', [{'else': 'else'}]).name()) == (
      'something_else')
開發者ID:KancerEzeroglu,項目名稱:aurora,代碼行數:12,代碼來源:test_loader.py

示例4: test_simple_config

def test_simple_config():
    with temporary_file() as fp:
        fp.write(MESOS_CONFIG)
        fp.flush()
        proxy_config1 = AuroraConfig.load(fp.name)
        proxy_config2 = AuroraConfig.load(fp.name, name="hello_world")
        assert proxy_config1.job()
        assert proxy_config1._job == proxy_config2._job
        assert proxy_config1._job == REIFIED_CONFIG
        assert proxy_config1.name() == "hello_world"
        assert proxy_config1.role() == "john_doe"
        assert proxy_config1.cluster() == "smf1-test"
        assert proxy_config1.ports() == set()
開發者ID:kevinburg,項目名稱:incubator-aurora,代碼行數:13,代碼來源:test_base.py

示例5: test_config_with_ports

def test_config_with_ports():
  hwc = HELLO_WORLD(
    task=HELLO_WORLD.task()(
      processes=[
        Process(name='hello_world',
                cmdline='echo {{thermos.ports[http]}} {{thermos.ports[admin]}}')
      ]
    )
  )
  config = AuroraConfig(hwc)
  job = config.job()
  assert Resource(namedPort='http') in list(job.taskConfig.resources)
  assert Resource(namedPort='admin') in list(job.taskConfig.resources)
開發者ID:apache,項目名稱:aurora,代碼行數:13,代碼來源:test_thrift.py

示例6: test_inject_default_environment

def test_inject_default_environment():
  base_job = Job(
      name='hello_world', role='john_doe', cluster='smf1-test',
      task=Task(name='main', processes=[],
                resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)))

  no_env_config = AuroraConfig(base_job)
  config._inject_default_environment(no_env_config)
  assert no_env_config.environment() == DEFAULT_ENVIRONMENT

  test_env_config = AuroraConfig(base_job(environment='test'))
  config._inject_default_environment(test_env_config)
  assert test_env_config.environment() == 'test'
開發者ID:betepahos,項目名稱:incubator-aurora,代碼行數:13,代碼來源:test_config.py

示例7: test_config_with_task_links

def test_config_with_task_links():
    tl = Map(String, String)
    unresolved_tl = {
        "foo": "http://%host%:{{thermos.ports[foo]}}",
        "bar": "http://%host%:{{thermos.ports[bar]}}/{{mesos.instance}}",
    }
    resolved_tl = {"foo": "http://%host%:%port:foo%", "bar": "http://%host%:%port:bar%/%shard_id%"}
    aurora_config = AuroraConfig(HELLO_WORLD(task_links=tl(unresolved_tl)))
    assert aurora_config.task_links() == tl(resolved_tl)
    assert aurora_config.job().taskConfig.taskLinks == frozendict(resolved_tl)

    bad_tl = {"foo": "{{thermos.ports.bad}}"}
    with pytest.raises(AuroraConfig.InvalidConfig):
        AuroraConfig(HELLO_WORLD(task_links=tl(bad_tl))).job()
開發者ID:kevinburg,項目名稱:incubator-aurora,代碼行數:14,代碼來源:test_thrift.py

示例8: test_inject_default_environment

def test_inject_default_environment():
    base_job = Job(
        name="hello_world",
        role="john_doe",
        cluster="test-cluster",
        task=Task(name="main", processes=[], resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)),
    )

    no_env_config = AuroraConfig(base_job)
    config._inject_default_environment(no_env_config)
    assert no_env_config.environment() == DEFAULT_ENVIRONMENT

    test_env_config = AuroraConfig(base_job(environment="test"))
    config._inject_default_environment(test_env_config)
    assert test_env_config.environment() == "test"
開發者ID:kevinburg,項目名稱:incubator-aurora,代碼行數:15,代碼來源:test_config.py

示例9: _start_release

  def _start_release(self, api, context):
    package, config_content = get_config(
        context.options.jobspec, context.options.version or 'latest')

    config = AuroraConfig.loads_json(config_content)
    resp = api.start_job_update(config, message='Release started by %s.' % getpass.getuser())

    if not resp.result:
      return package, None

    return package, resp.result.startJobUpdateResult.key.id
開發者ID:pombredanne,項目名稱:sacker,代碼行數:11,代碼來源:deploy_noun.py

示例10: test_docker_binding_throws

  def test_docker_binding_throws(self, mock_resolve):
    mock_resolve.side_effect = Exception('mock resolve failure')

    binding_helper.unregister_all()
    BindingHelper.register(DockerBindingHelper())

    with temporary_file() as fp:
      fp.write(DOCKER_BINDING_CONFIG)
      fp.flush()
      with CLUSTERS.patch(TEST_CLUSTERS):
        cfg = AuroraConfig.load(fp.name)
        with pytest.raises(Exception):
          binding_helper.apply_all(cfg)
          assert mock_resolve.mock_calls == [call(TEST_CLUSTER, 'some/name', 'some.tag')]
開發者ID:apache,項目名稱:aurora,代碼行數:14,代碼來源:test_docker_helper.py

示例11: test_docker_binding

  def test_docker_binding(self, mock_resolve):
    image_reference = 'registry.example.com/some/[email protected]:digest'

    mock_resolve.return_value = image_reference

    binding_helper.unregister_all()
    BindingHelper.register(DockerBindingHelper())

    with temporary_file() as fp:
      fp.write(DOCKER_BINDING_CONFIG)
      fp.flush()
      with CLUSTERS.patch(TEST_CLUSTERS):
        cfg = AuroraConfig.load(fp.name)
        binding_helper.apply_all(cfg)
        assert cfg.job().taskConfig.container.docker.image == image_reference
        assert mock_resolve.mock_calls == [call(TEST_CLUSTER, 'some/name', 'some.tag')]
開發者ID:apache,項目名稱:aurora,代碼行數:16,代碼來源:test_docker_helper.py

示例12: _job_diff

 def _job_diff(self, api, context, config_content):
   # return true if jobs are diff, false if not
   config = AuroraConfig.loads_json(config_content)
   role, env, name = config.role(), config.environment(), config.name()
   resp = api.query(api.build_query(role, name, env=env, statuses=ACTIVE_STATES))
   context.log_response_and_raise(resp, err_code=EXIT_INVALID_PARAMETER,
       err_msg="Could not find job to diff against")
   if resp.result.scheduleStatusResult.tasks is None:
     context.print_err("No tasks found for job %s" % context.options.jobspec)
     return True
   else:
     remote_tasks = [t.assignedTask.task for t in resp.result.scheduleStatusResult.tasks]
   resp = api.populate_job_config(config)
   context.log_response_and_raise(resp, err_code=EXIT_INVALID_CONFIGURATION,
         err_msg="Error loading configuration")
   local_tasks = [resp.result.populateJobResult.taskConfig] * config.instances()
   if len(remote_tasks) != len(local_tasks):
     return True
   for task1, task2 in zip(remote_tasks, local_tasks):
     if task1 != task2:
       return True
   return False
開發者ID:pombredanne,項目名稱:sacker,代碼行數:22,代碼來源:deploy_noun.py

示例13: test_empty_config

def test_empty_config():
    with pytest.raises(AuroraConfig.InvalidConfig):
        with temporary_file() as fp:
            fp.write(UNDERSPECIFIED_MESOS_CONFIG)
            fp.flush()
            AuroraConfig.load(fp.name)
開發者ID:kevinburg,項目名稱:incubator-aurora,代碼行數:6,代碼來源:test_base.py

示例14: write_and_load_config

def write_and_load_config(role):
  with temporary_file() as fp:
    fp.write(GENERIC_CONFIG)
    fp.flush()
    return AuroraConfig.load(fp.name, name='hello_world', select_role=role)
開發者ID:MustafaOrkunAcar,項目名稱:incubator-aurora,代碼行數:5,代碼來源:test_binding_helper.py


注:本文中的apache.aurora.config.AuroraConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。