コード例 #1
0
def config_changed():
    # Determine whether vaultlocker is required and install
    if use_vaultlocker():
        installed = len(filter_installed_packages(['vaultlocker'])) == 0
        if not installed:
            apt_install('vaultlocker', fatal=True)

    # Check if an upgrade was requested
    check_for_upgrade()

    # Pre-flight checks
    if config('osd-format') not in ceph.DISK_FORMATS:
        log('Invalid OSD disk format configuration specified', level=ERROR)
        sys.exit(1)

    if config('prefer-ipv6'):
        assert_charm_supports_ipv6()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-osd-charm.conf')

    e_mountpoint = config('ephemeral-unmount')
    if e_mountpoint and ceph.filesystem_mounted(e_mountpoint):
        umount(e_mountpoint)
    prepare_disks_and_activate()
    install_apparmor_profile()
    add_to_updatedb_prunepath(STORAGE_MOUNT_PATH)
コード例 #2
0
def config_changed():
    # Determine whether vaultlocker is required and install
    if use_vaultlocker():
        installed = len(filter_installed_packages(['vaultlocker'])) == 0
        if not installed:
            apt_install('vaultlocker', fatal=True)

    # Check if an upgrade was requested
    check_for_upgrade()

    # Pre-flight checks
    if config('osd-format') not in ceph.DISK_FORMATS:
        log('Invalid OSD disk format configuration specified', level=ERROR)
        sys.exit(1)

    if config('prefer-ipv6'):
        assert_charm_supports_ipv6()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-osd-charm.conf')

    e_mountpoint = config('ephemeral-unmount')
    if e_mountpoint and ceph.filesystem_mounted(e_mountpoint):
        umount(e_mountpoint)
    prepare_disks_and_activate()
    install_apparmor_profile()
    add_to_updatedb_prunepath(STORAGE_MOUNT_PATH)
コード例 #3
0
def config_changed():
    if config('prefer-ipv6'):
        status_set('maintenance', 'Configuring ipv6')
        assert_charm_supports_ipv6()

    ensure_swift_directories()
    setup_rsync()

    if not config('action-managed-upgrade') and \
            openstack_upgrade_available('swift'):
        status_set('maintenance', 'Running openstack upgrade')
        do_openstack_upgrade(configs=CONFIGS)

    setup_storage()

    for rid in relation_ids('swift-storage'):
        swift_storage_relation_joined(rid=rid)

    CONFIGS.write_all()

    save_script_rc()
    if relations_of_type('nrpe-external-master'):
        update_nrpe_config()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-swift-storage-charm.conf')

    add_to_updatedb_prunepath(STORAGE_MOUNT_PATH)
コード例 #4
0
def finish_initialization(device_path: os.path) -> Result:
    """
    Once devices have been formatted this is called to run fstab entry setup,
    updatedb exclusion, weekly defrags, etc.
    :param device_path:  os.path to device
    :return: Result with Ok or Err
    """
    filesystem_config_value = config("filesystem_type")
    defrag_interval = config("defragmentation_interval")
    disk_elevator = config("disk_elevator")
    scheduler = Scheduler(disk_elevator)
    filesystem_type = FilesystemType(filesystem_config_value)
    mount_path = "/mnt/{}".format(device_path.file_name().unwrap())
    unit_storage = kv()
    device_info = get_device_info(device_path)
    if device_info.is_err():
        return Err(device_info.value)
    log("device_info: {}".format(device_info), INFO)

    # Zfs automatically handles mounting the device
    if filesystem_type != Zfs:
        log("Mounting block device {} at {}".format(device_path, mount_path),
            INFO)
        status_set(workload_state="maintenance",
                   message="Mounting block device {} at {}".format(
                       device_path, mount_path))

        if not os.path.exists(mount_path):
            log("Creating mount directory: {}".format(mount_path), INFO)
            os.makedirs(mount_path)

        mount_device(device_info.value, mount_path)
        fstab_entry = FsEntry(fs_spec="UUID={}".format(device_info.value.id),
                              mountpoint=os.path.join(mount_path),
                              vfs_type=device_info.value.fs_type,
                              mount_options=["noatime", "inode64"],
                              dump=False,
                              fsck_order=2)
        log("Adding {} to fstab".format(fstab_entry))
        fstab = FsTab(os.path.join("/etc/fstab"))
        fstab.add_entry(fstab_entry)
    unit_storage.set(device_path, True)
    log("Removing mount path from updatedb {}".format(mount_path), INFO)
    add_to_updatedb_prunepath(mount_path, os.path.join("/etc/updatedb.conf"))
    weekly_defrag(mount_path, filesystem_type, defrag_interval)
    set_elevator(device_path, scheduler)
    return Ok(())
コード例 #5
0
def config_changed():
    # Check if an upgrade was requested
    check_for_upgrade()

    # Pre-flight checks
    if config('osd-format') not in ceph.DISK_FORMATS:
        log('Invalid OSD disk format configuration specified', level=ERROR)
        sys.exit(1)

    if config('prefer-ipv6'):
        assert_charm_supports_ipv6()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-osd-charm.conf')

    e_mountpoint = config('ephemeral-unmount')
    if e_mountpoint and ceph.filesystem_mounted(e_mountpoint):
        umount(e_mountpoint)
    prepare_disks_and_activate()
    install_apparmor_profile()
    add_to_updatedb_prunepath(STORAGE_MOUNT_PATH)
コード例 #6
0
def mount_cluster() -> Result:
    """
    Mount the cluster at /mnt/glusterfs using fuse

    :return: Result.  Ok or Err depending on the outcome of mount
    """
    volume_name = config('volume_name')
    if not os.path.exists("/mnt/glusterfs"):
        os.makedirs("/mnt/glusterfs")
    if not filesystem_mounted("/mnt/glusterfs"):
        cmd = [
            "-t", "glusterfs", "localhost:/{}".format(volume_name),
            "/mnt/glusterfs"
        ]
        output = run_command("mount", cmd, True, False)
        if output.is_ok():
            log("Removing /mnt/glusterfs from updatedb", INFO)
            add_to_updatedb_prunepath("/mnt/glusterfs")
            set_state("glusterfs.mounted")
            return Ok(())
        else:
            return Err(output.value)
    return Ok(())
コード例 #7
0
def config_changed():
    if config('enable-firewall'):
        initialize_ufw()
    else:
        ufw.disable()

    if config('ephemeral-unmount'):
        umount(config('ephemeral-unmount'), persist=True)

    if config('prefer-ipv6'):
        status_set('maintenance', 'Configuring ipv6')
        assert_charm_supports_ipv6()

    ensure_swift_directories()
    setup_rsync()

    if not config('action-managed-upgrade') and \
            openstack_upgrade_available('swift'):
        status_set('maintenance', 'Running openstack upgrade')
        do_openstack_upgrade(configs=CONFIGS)

    install_vaultlocker()

    configure_storage()

    CONFIGS.write_all()

    save_script_rc()
    if relations_of_type('nrpe-external-master'):
        update_nrpe_config()

    sysctl_dict = config('sysctl')
    if sysctl_dict:
        create_sysctl(sysctl_dict, '/etc/sysctl.d/50-swift-storage-charm.conf')

    add_to_updatedb_prunepath(STORAGE_MOUNT_PATH)