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


Python hookenv.service_name方法代码示例

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


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

示例1: update_prometheus_targets

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def update_prometheus_targets(target):
    services = target.services()
    related_targets = []
    for service in services:
        targets = []
        for unit in service['hosts']:
            hookenv.log('{} has a unit {}:{}'.format(
                service['service_name'],
                unit['hostname'],
                unit['port']))
            targets.append('{hostname}:{port}'.format(**unit))
        related_targets.append({'job_name': service['service_name'],
                                'targets': targets})

    unitdata.kv().set('target_jobs', related_targets)
    set_state('prometheus.do-check-reconfig') 
开发者ID:tasdomas,项目名称:juju-charm-prometheus,代码行数:18,代码来源:prometheus.py

示例2: _get_address_override

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def _get_address_override(endpoint_type=PUBLIC):
    """Returns any address overrides that the user has defined based on the
    endpoint type.

    Note: this function allows for the service name to be inserted into the
    address if the user specifies {service_name}.somehost.org.

    :param endpoint_type: the type of endpoint to retrieve the override
                          value for.
    :returns: any endpoint address or hostname that the user has overridden
              or None if an override is not present.
    """
    override_key = ADDRESS_MAP[endpoint_type]['override']
    addr_override = hookenv.config(override_key)
    if not addr_override:
        return None
    else:
        return addr_override.format(service_name=hookenv.service_name()) 
开发者ID:openstack,项目名称:charms.openstack,代码行数:20,代码来源:ip.py

示例3: storage_ceph_connected

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def storage_ceph_connected(ceph):
    ceph.create_pool(hookenv.service_name()) 
开发者ID:openstack,项目名称:charm-gnocchi,代码行数:4,代码来源:gnocchi_handlers.py

示例4: configure_ceph

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def configure_ceph(ceph):
    with charm.provide_charm_instance() as charm_class:
        # TODO(jamespage): refactor to avoid massaging helper
        ceph_helper.KEYRING = charm_class.ceph_keyring
        host.mkdir(os.path.dirname(charm_class.ceph_keyring))
        ceph_helper.ensure_ceph_keyring(service=hookenv.service_name(),
                                        key=ceph.key(),
                                        user=charm_class.gnocchi_user,
                                        group=charm_class.gnocchi_group) 
开发者ID:openstack,项目名称:charm-gnocchi,代码行数:11,代码来源:gnocchi_handlers.py

示例5: storage_ceph_disconnected

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def storage_ceph_disconnected():
    with charm.provide_charm_instance() as charm_class:
        # TODO(jamespage): refactor to avoid massaging helper
        ceph_helper.KEYRING = charm_class.ceph_keyring
        ceph_helper.delete_keyring(hookenv.service_name()) 
开发者ID:openstack,项目名称:charm-gnocchi,代码行数:7,代码来源:gnocchi_handlers.py

示例6: write_prometheus_config_yml

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def write_prometheus_config_yml():
    config = hookenv.config()
    target_jobs = unitdata.kv().get('target_jobs', [])
    scrape_jobs = unitdata.kv().get('scrape_jobs', [])

    # transform eg. 'h1:p1 ,  h2:p2' (string), to ['h1:p1', 'h2:p2'] (list)
    static_targets = None
    if config.get('static-targets'):
        static_targets = [x.strip()
                          for x in config.get('static-targets', '').split(',')]

    default_monitor_name = '{}-monitor'.format(hookenv.service_name())
    options = {
        'scrape_interval': config['scrape-interval'],
        'evaluation_interval': config['evaluation-interval'],
        'static_targets': static_targets,
        'private_address': hookenv.unit_get('private-address'),
        'monitor_name': config.get('monitor_name', default_monitor_name),
        'jobs': target_jobs,
        'scrape_jobs': scrape_jobs,
    }

    # custom-rules content must be passed verbatim with e.g.
    #   juju set prometheus custom-rules @my.rules
    if config.get('custom-rules'):
        custom_rules = config['custom-rules']
        with open(CUSTOM_RULES_PATH, 'w') as fh:
            fh.write(custom_rules)
        options['custom_rules_file'] = CUSTOM_RULES_PATH

    render(source=PROMETHEUS_YML_TMPL,
           target=PROMETHEUS_YML,
           context=options
           )
    validate_config()
    set_state('prometheus.do-restart')
    remove_state('prometheus.do-reconfig-yml') 
开发者ID:tasdomas,项目名称:juju-charm-prometheus,代码行数:39,代码来源:prometheus.py

示例7: update_prometheus_alertmanager

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def update_prometheus_alertmanager(alertmanager):
    services = alertmanager.services()
    if not (data_changed('alertmanager-service.related_services', services)):
        return
    # XXX: as of prometheus 0.17, it can only point to a single alertmanager,
    #      last one from below loop will be used.
    for service in services:
        for unit in service['hosts']:
            hookenv.log('{} has a unit {}:{}'.format(
                service['service_name'],
                unit['hostname'],
                unit['port']))
            runtime_args('-alertmanager.url',
                         'http://{hostname}:{port}'.format(**unit))
    set_state('prometheus.do-check-reconfig') 
开发者ID:tasdomas,项目名称:juju-charm-prometheus,代码行数:17,代码来源:prometheus.py

示例8: domain_name

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def domain_name(self):
        """Domain name for the running application

        :returns: string: containing the current domain name for the
                          application
        """
        return hookenv.config('domain-name') or hookenv.service_name() 
开发者ID:openstack,项目名称:charm-keystone-ldap,代码行数:9,代码来源:keystone_ldap.py

示例9: configure_domain_name

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def configure_domain_name(domain):
    keystone_ldap.render_config(domain.trigger_restart)
    domain.domain_name(hookenv.config('domain-name') or
                       hookenv.service_name())
    reactive.set_state('domain-name-configured') 
开发者ID:openstack,项目名称:charm-keystone-ldap,代码行数:7,代码来源:keystone_ldap_handlers.py

示例10: ssl_ca_file

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def ssl_ca_file(self):
        return '/var/lib/charm/{}/rabbit-client-ca.pem'.format(
            hookenv.service_name()) 
开发者ID:openstack,项目名称:charms.openstack,代码行数:5,代码来源:adapters.py

示例11: application_name

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def application_name(self):
        """Return the name of the deployed charm"""
        return hookenv.service_name() 
开发者ID:openstack,项目名称:charms.openstack,代码行数:5,代码来源:adapters.py

示例12: rabbit_client_cert_dir

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def rabbit_client_cert_dir(self):
        return '/var/lib/charm/{}'.format(hookenv.service_name()) 
开发者ID:openstack,项目名称:charms.openstack,代码行数:4,代码来源:classes.py

示例13: test_gets_service_name

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def test_gets_service_name(self, _unit):
        _unit.return_value = 'mysql/3'
        self.assertEqual(hookenv.service_name(), 'mysql') 
开发者ID:juju,项目名称:charm-helpers,代码行数:5,代码来源:test_hookenv.py

示例14: __init__

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import service_name [as 别名]
def __init__(self, port_map=None, service_name=None, charm_instance=None):
        """
        Note passing port_map and service_name is deprecated, but supported for
        backwards compatibility.  The port_map and service_name can be obtained
        from the self.charm_instance weak reference.
        :param  port_map: Map containing service names and the ports used e.g.
                port_map = {
                        'svc1': {
                        'admin': 9001,
                        'public': 9001,
                        'int': 9001,
                    },
                        'svc2': {
                        'admin': 9002,
                        'public': 9002,
                        'int': 9002,
                    },
                }
        :param service_name: Name of service being deployed
        :param charm_instance: a charm instance that will be passed to the base
            constructor
        """
        super(APIConfigurationAdapter, self).__init__(
            charm_instance=charm_instance)
        if port_map is not None:
            hookenv.log(
                "DEPRECATION: should not use port_map parameter in "
                "APIConfigurationAdapter.__init__()", level=hookenv.WARNING)
            self.port_map = port_map
        elif self.charm_instance is not None:
            self.port_map = self.charm_instance.api_ports
        else:
            self.port_map = None
        if service_name is not None:
            hookenv.log(
                "DEPRECATION: should not use service_name parameter in "
                "APIConfigurationAdapter.__init__()", level=hookenv.WARNING)
            self.service_name = service_name
        elif self.charm_instance is not None:
            self.service_name = self.charm_instance.name
        else:
            self.service_name = None
        self.__network_addresses = None 
开发者ID:openstack,项目名称:charms.openstack,代码行数:45,代码来源:adapters.py


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