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


Python hookenv.config方法代码示例

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


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

示例1: __init__

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def __init__(self, *args):
        self.required_options = args
        self['config'] = hookenv.config()
        with open(os.path.join(hookenv.charm_dir(), 'config.yaml')) as fp:
            self.config = yaml.load(fp).get('options', {}) 
开发者ID:openstack,项目名称:charm-plumgrid-gateway,代码行数:7,代码来源:helpers.py

示例2: add_device

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def add_device(request, device_path, bucket=None):
    ceph.utils.osdize(dev, hookenv.config('osd-format'),
                      ceph_hooks.get_journal_devices(),
                      hookenv.config('osd-reformat'),
                      hookenv.config('ignore-device-errors'),
                      hookenv.config('osd-encrypt'),
                      hookenv.config('bluestore'))
    # Make it fast!
    if hookenv.config('autotune'):
        ceph.utils.tune_dev(dev)
    mounts = filter(lambda disk: device_path
                    in disk.device, psutil.disk_partitions())
    if mounts:
        osd = mounts[0]
        osd_id = osd.mountpoint.split('/')[-1].split('-')[-1]
        request.ops.append({
            'op': 'move-osd-to-bucket',
            'osd': "osd.{}".format(osd_id),
            'bucket': bucket})
    return request 
开发者ID:openstack,项目名称:charm-ceph-osd,代码行数:22,代码来源:add_disk.py

示例3: install_apparmor_profile

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def install_apparmor_profile():
    """
    Install ceph apparmor profiles and configure
    based on current setting of 'aa-profile-mode'
    configuration option.
    """
    log('Installing apparmor profile for ceph-osd')
    copy_profile_into_place()
    if config().changed('aa-profile-mode'):
        aa_context = CephOsdAppArmorContext()
        aa_context.setup_aa_profile()
        service_reload('apparmor')
        if ceph.systemd():
            for osd_id in ceph.get_local_osd_ids():
                service_restart('[email protected]{}'.format(osd_id))
        else:
            service_restart('ceph-osd-all') 
开发者ID:openstack,项目名称:charm-ceph-osd,代码行数:19,代码来源:ceph_hooks.py

示例4: az_info

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def az_info():
    az_info = ""
    config_az = config("availability_zone")
    juju_az_info = os.environ.get('JUJU_AVAILABILITY_ZONE')
    if juju_az_info:
        # NOTE(jamespage): avoid conflicting key with root
        #                  of crush hierarchy
        if juju_az_info == 'default':
            juju_az_info = 'default-rack'
        az_info = "{} rack={}".format(az_info, juju_az_info)
    if config_az:
        # NOTE(jamespage): avoid conflicting key with root
        #                  of crush hierarchy
        if config_az == 'default':
            config_az = 'default-row'
        az_info = "{} row={}".format(az_info, config_az)
    if az_info != "":
        log("AZ Info: " + az_info)
        return az_info 
开发者ID:openstack,项目名称:charm-ceph-osd,代码行数:21,代码来源:ceph_hooks.py

示例5: use_short_objects

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def use_short_objects():
    '''
    Determine whether OSD's should be configured with
    limited object name lengths.

    @return: boolean indicating whether OSD's should be limited
    '''
    if cmp_pkgrevno('ceph', "10.2.0") >= 0:
        if config('osd-format') in ('ext4'):
            return True
        for device in config('osd-devices'):
            if device and not device.startswith('/dev'):
                # TODO: determine format of directory based
                #       OSD location
                return True
    return False 
开发者ID:openstack,项目名称:charm-ceph-osd,代码行数:18,代码来源:ceph_hooks.py

示例6: prepare_disks_and_activate

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def prepare_disks_and_activate():
    osd_journal = get_journal_devices()
    check_overlap(osd_journal, set(get_devices()))
    log("got journal devs: {}".format(osd_journal), level=DEBUG)
    already_zapped = read_zapped_journals()
    non_zapped = osd_journal - already_zapped
    for journ in non_zapped:
        ceph.maybe_zap_journal(journ)
    write_zapped_journals(osd_journal)

    if ceph.is_bootstrapped():
        log('ceph bootstrapped, rescanning disks')
        emit_cephconf()
        for dev in get_devices():
            ceph.osdize(dev, config('osd-format'),
                        osd_journal, config('osd-reformat'),
                        config('ignore-device-errors'),
                        config('osd-encrypt'),
                        config('bluestore'))
            # Make it fast!
            if config('autotune'):
                ceph.tune_dev(dev)
        ceph.start_osds(get_devices()) 
开发者ID:openstack,项目名称:charm-ceph-osd,代码行数:25,代码来源:ceph_hooks.py

示例7: get_devices

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def get_devices():
    devices = []
    if config('osd-devices'):
        for path in config('osd-devices').split(' '):
            path = path.strip()
            # Make sure its a device which is specified using an
            # absolute path so that the current working directory
            # or any relative path under this directory is not used
            if os.path.isabs(path):
                devices.append(os.path.realpath(path))

    # List storage instances for the 'osd-devices'
    # store declared for this charm too, and add
    # their block device paths to the list.
    storage_ids = storage_list('osd-devices')
    devices.extend((storage_get('location', s) for s in storage_ids))

    # Filter out any devices in the action managed unit-local device blacklist
    _blacklist = get_blacklist()
    return [device for device in devices if device not in _blacklist] 
开发者ID:openstack,项目名称:charm-ceph-osd,代码行数:22,代码来源:ceph_hooks.py

示例8: get_mon_hosts

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def get_mon_hosts():
    hosts = []
    addr = get_public_addr()
    hosts.append('{}:6789'.format(format_ipv6_addr(addr) or addr))

    rel_ids = relation_ids('mon')
    if config('no-bootstrap'):
        rel_ids += relation_ids('bootstrap-source')

    for relid in rel_ids:
        for unit in related_units(relid):
            addr = relation_get('ceph-public-address', unit, relid)
            if addr is not None:
                hosts.append('{}:6789'.format(
                    format_ipv6_addr(addr) or addr))

    return sorted(hosts) 
开发者ID:openstack,项目名称:charm-ceph-mon,代码行数:19,代码来源:ceph_hooks.py

示例9: admin_relation_joined

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def admin_relation_joined(relid=None):
    if ceph.is_quorum():
        name = relation_get('keyring-name')
        if name is None:
            name = 'admin'
        log('mon cluster in quorum - providing client with keys')
        mon_hosts = config('monitor-hosts') or ' '.join(get_mon_hosts())
        data = {'key': ceph.get_named_key(name=name, caps=ceph.admin_caps),
                'fsid': leader_get('fsid'),
                'auth': config('auth-supported'),
                'mon_hosts': mon_hosts,
                }
        relation_set(relation_id=relid,
                     relation_settings=data)
    else:
        log('mon cluster not in quorum - deferring key provision') 
开发者ID:openstack,项目名称:charm-ceph-mon,代码行数:18,代码来源:ceph_hooks.py

示例10: client_relation_joined

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def client_relation_joined(relid=None):
    if ceph.is_quorum():
        log('mon cluster in quorum - providing client with keys')
        service_name = None
        if relid is None:
            units = [remote_unit()]
            service_name = units[0].split('/')[0]
        else:
            units = related_units(relid)
            if len(units) > 0:
                service_name = units[0].split('/')[0]

        if service_name is not None:
            public_addr = get_public_addr()
            data = {'key': ceph.get_named_key(service_name),
                    'auth': config('auth-supported'),
                    'ceph-public-address': public_addr}
            if config('default-rbd-features'):
                data['rbd-features'] = config('default-rbd-features')
            relation_set(relation_id=relid,
                         relation_settings=data)
    else:
        log('mon cluster not in quorum - deferring key provision') 
开发者ID:openstack,项目名称:charm-ceph-mon,代码行数:25,代码来源:ceph_hooks.py

示例11: get_manual_bricks

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def get_manual_bricks() -> Result:
    """
    Get the list of bricks from the config.yaml
    :return: Result with Ok or Err
    """
    log("Gathering list of manually specified brick devices")
    brick_list = []
    manual_config_brick_devices = config("brick_devices")
    if manual_config_brick_devices:
        for brick in manual_config_brick_devices.split(" "):
            if brick is not None:
                brick_list.append(brick)
    log("List of manual storage brick devices: {}".format(brick_list))
    bricks = scan_devices(brick_list)
    if bricks.is_err():
        return Err(bricks.value)
    return Ok(bricks.value) 
开发者ID:openstack,项目名称:charm-glusterfs,代码行数:19,代码来源:block.py

示例12: render_samba_configuration

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def render_samba_configuration(f: TextIOBase, volume_name: str) -> int:
    """
    Write the samba configuration file out to disk

    :param f: TextIOBase handle to the sambe config file
    :param volume_name: str
    :return: int of bytes written
    """
    bytes_written = 0
    bytes_written += f.write("[{}]\n".format(volume_name))
    bytes_written += f.write(b"path = /mnt/glusterfs\n"
                             b"read only = no\n"
                             b"guest ok = yes\n"
                             b"kernel share modes = no\n"
                             b"kernel oplocks = no\n"
                             b"map archive = no\n"
                             b"map hidden = no\n"
                             b"map read only = no\n"
                             b"map system = no\n"
                             b"store dos attributes = yes\n")
    return bytes_written 
开发者ID:openstack,项目名称:charm-glusterfs,代码行数:23,代码来源:samba.py

示例13: samba_config_changed

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def samba_config_changed() -> bool:
    """
    Checks whether a samba config file has changed or not.
    :param volume_name: str.
    :return: True or False
    """
    volume_name = config("volume_name")
    samba_path = os.path.join(os.sep, 'etc', 'samba', 'smb.conf')
    if os.path.exists(samba_path):
        # Lets check if the smb.conf matches what we're going to write.
        # If so then it was already setup and there's nothing to do
        with open(samba_path) as existing_config:
            old_config = existing_config.readlines()
            new_config = io.StringIO()
            render_samba_configuration(new_config, volume_name)
            if "".join(new_config) == "".join(old_config):
                # configs are identical
                return False
            else:
                return True
    # Config doesn't exist.
    return True 
开发者ID:openstack,项目名称:charm-glusterfs,代码行数:24,代码来源:samba.py

示例14: setup_samba

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def setup_samba():
    """
    Installs and starts up samba
    :param volume_name: str. Gluster volume to start samba on
    """
    volume_name = config("volume_name")
    cifs_config = config("cifs")
    if cifs_config is None:
        # Samba isn't enabled
        return
    if not samba_config_changed(volume_name):
        # log!("Samba is already setup.  Not reinstalling")
        return
    status_set("Maintenance", "Installing Samba")
    apt_install(["samba"])
    status_set("Maintenance", "Configuring Samba")
    with open(os.path.join(os.sep, 'etc', 'samba', 'smb.conf')) as samba_conf:
        bytes_written = render_samba_configuration(samba_conf, volume_name)
        log("Wrote {} bytes to /etc/samba/smb.conf", bytes_written)
        log("Starting Samba service")
        status_set("Maintenance", "Starting Samba")
        service_start("smbd")
        set_state('samba.installed') 
开发者ID:openstack,项目名称:charm-glusterfs,代码行数:25,代码来源:samba.py

示例15: use_short_objects

# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import config [as 别名]
def use_short_objects():
    '''
    Determine whether OSD's should be configured with
    limited object name lengths.

    @return: boolean indicating whether OSD's should be limited
    '''
    if cmp_pkgrevno('ceph', "10.2.0") >= 0:
        if config('osd-format') in ('ext4'):
            return True
        for device in config('osd-devices'):
            if not device.startswith('/dev'):
                # TODO: determine format of directory based
                #       OSD location
                return True
    return False 
开发者ID:openstack,项目名称:charm-ceph,代码行数:18,代码来源:ceph_hooks.py


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