00047_update.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:kuberdock-platform 作者: cloudlinux 项目源码 文件源码
def update_node_ceph_flags():
    hosts_query = text("SELECT hostname from nodes")
    hosts = [item[0] for item in db.session.execute(hosts_query).fetchall()]
    hosts_with_ceph = []
    for host in hosts:
        if not tasks.is_ceph_installed_on_node(host):
            continue
        hosts_with_ceph.append(host)
    if not hosts_with_ceph:
        return
    flags_query =\
        "INSERT INTO node_flags (node_id, created, deleted, flag_name, flag_value) "\
        "SELECT id, NOW() at time zone 'utc', NULL, 'ceph_installed', 'true' FROM nodes "\
        "WHERE hostname IN ({})".format(
            ', '.join("'" + host + "'" for host in hosts_with_ceph)
        )
    db.session.execute(text(flags_query))
    db.session.commit()
    for host in hosts_with_ceph:
        tasks.add_k8s_node_labels(
            host, {NODE_CEPH_AWARE_KUBERDOCK_LABEL: "True"})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号