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


Python reactive.when方法代码示例

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


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

示例1: render_config

# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import when [as 别名]
def render_config(*args):
    """Render the configuration for charm when all the interfaces are
    available.
    """
    with charm.provide_charm_instance() as charm_class:
        charm_class.render_with_interfaces(args)
        charm_class.assess_status()
    reactive.set_state('config.rendered')


# db_sync checks if sync has been done so rerunning is a noop 
开发者ID:openstack,项目名称:charm-murano,代码行数:13,代码来源:murano_handlers.py

示例2: render_config

# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import when [as 别名]
def render_config(*args):
    """Render the configuration for charm when all the interfaces are
    available.
    """
    with charm.provide_charm_instance() as charm_class:
        charm_class.upgrade_if_available(args)
        charm_class.enable_services()
        charm_class.render_with_interfaces(args)
        charm_class.enable_webserver_site()
        charm_class.assess_status()
    reactive.set_state('config.rendered')


# db_sync checks if sync has been done so rerunning is a noop 
开发者ID:openstack,项目名称:charm-gnocchi,代码行数:16,代码来源:gnocchi_handlers.py

示例3: install_sandvine_pts_proxy

# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import when [as 别名]
def install_sandvine_pts_proxy():
    status_set('maintenance','Installing')
    # Do your setup here.
    #
    # If your charm has other dependencies before it can install,
    # add those as @when() clauses above., or as additional @when()
    # decorated handlers below
    #
    # See the following for information about reactive charms:
    #
    #  * https://jujucharms.com/docs/devel/developer-getting-started
    #  * https://github.com/juju-solutions/layer-basic#overview
    #
    set_state('sandvine-pts-proxy.installed')
    status_set('active','ready') 
开发者ID:sandvine,项目名称:sandvine-nfv-descriptors,代码行数:17,代码来源:svforwarding.py

示例4: render_config

# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import when [as 别名]
def render_config(*args):
    """Render the configuration for charm when all the interfaces are
    available.
    """
    horrible_hack_to_workaround_missing_package_files()
    with charm.provide_charm_instance() as charm_class:
        charm_class.render_with_interfaces(args)
        charm_class.db_sync()
        charm_class.upgrade_if_available(args)
        charm_class.assess_status()
    reactive.set_state('config.rendered') 
开发者ID:openstack,项目名称:charm-mistral,代码行数:13,代码来源:mistral_handlers.py

示例5: render_stuff

# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import when [as 别名]
def render_stuff(*args):
    """Render the configuration for Barbican when all the interfaces are
    available.

    Note that the HSM interface is optional and thus is only used if it is
    available.
    """
    hookenv.log("about to call the render_configs with {}".format(args))
    with charm.provide_charm_instance() as barbican_charm:
        barbican_charm.render_with_interfaces(
            charm.optional_interfaces(args, 'hsm.available'))
        barbican_charm.assess_status() 
开发者ID:openstack,项目名称:charm-barbican,代码行数:14,代码来源:barbican_handlers.py

示例6: setup_sync_target_alone

# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import when [as 别名]
def setup_sync_target_alone():
    '''If this is the only unit in the application then setup a sync target.
    This will likely by empty as zones.initialised is only unset when a unit
    frst comes up but the presence of the target allows subsequent units to
    bootstrap if leadership flips to them as they come up'''
    if hookenv.is_leader():
        designate_bind.setup_sync()
        reactive.set_state('zones.initialised') 
开发者ID:openstack,项目名称:charm-designate-bind,代码行数:10,代码来源:designate_bind_handlers.py

示例7: server_connected

# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import when [as 别名]
def server_connected(peer) -> None:
    """
    The peer.available state is set when there are one or more peer units
    that have joined.
    :return:
    """
    update_status()
    bricks = check_for_new_devices()
    if bricks.is_ok():
        log('Reporting my bricks {} to the leader'.format(bricks.value))
        peer.set_bricks(bricks=bricks.value)
    if not is_leader():
        log('Reporting my public address {} to the leader'.format(
            unit_public_ip()))
        peer.set_address(address_type='public', address=unit_public_ip())
        return

    # I am the leader
    log('Leader probing peers')
    probed_units = []
    try:
        p = hookenv.leader_get('probed-units')
        if p:
            probed_units = json.loads(p)
    except json.decoder.JSONDecodeError as e:
        log("json decoder failed for {}: {}".format(e.doc, e.msg))

    log("probed_units: {}".format(probed_units))
    peer_info = peer.get_peer_info()
    for unit in peer_info:
        if unit in probed_units:
            continue
        address = peer_info[unit]['address']
        log('probing host {} at {}'.format(unit, address))
        status_set('maintenance', 'Probing peer {}'.format(unit))
        try:
            peer_probe(address)
            probed_units.append(unit)
        except (GlusterCmdException, GlusterCmdOutputParseError):
            log('Error probing host {}: {}'.format(unit, address), ERROR)
            continue
        log('successfully probed {}: {}'.format(unit, address), DEBUG)
    settings = {'probed-units': json.dumps(probed_units)}
    hookenv.leader_set(settings)
    status_set('maintenance', '') 
开发者ID:openstack,项目名称:charm-glusterfs,代码行数:47,代码来源:main.py


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