Esempio n. 1
0
def review_cluster(reviewer, cluster_id):
    """review cluster."""
    with database.session() as session:
        user_api.check_user_permission_internal(
            session, getter, permission.PERMISSION_REVIEW_CLUSTER)
        cluster = utils.get_db_object(
            session, models.Cluster, id=cluster_id
        )
        os_config = cluster.os_config
        if os_config:
            metadata_api.validate_os_config(
                os_config, cluster.apdater_id, True
            )
            for clusterhost in cluster.clusterhosts:
                host = clusterhost.host
                host_os_config = host.os_config
                host.deployed_os_config = util.merge_dict(
                    os_config, host_os_config
                )
                metadata_api.validate_os_config(
                    host.deployed_os_config, cluster.apdater_id, True
                )
        package_config = cluster.package_config
        if package_config:
            metadata_api.validate_package_config(
                package_config, cluster.adapter_id, True
            )
            for clusterhost in cluster.clusterhosts:
                clusterhost_package_config = clusterhost.package_config
                clusterhost.deployed_package_config = util.mrege_dict(
                    package_config, clusterhost_package_config
                )
                metadata_api.validate_os_config(
                    clusterhost.deployed_package_config,
                    cluster.apdater_id, True
                )
        return {
            'cluster': cluster.to_dict(),
            'clusterhosts': [
                clusterhost.to_dict()
                for clusterhost in cluster.clusterhosts
            ]
        }
Esempio n. 2
0
def update_cluster_config(updater, cluster_id, **kwargs):
    """Update a cluster config."""
    with database.session() as session:
        user_api.check_user_permission_internal(
            session, updater, permission.PERMISSION_ADD_CLUSTER)
        cluster = utils.get_db_object(
            session, models.Cluster, id=cluster_id
        )
        utils.update_db_object(session, cluster, **kwargs)
        os_config = cluster.os_config
        if os_config:
            metadata_api.validate_os_config(
                os_config, cluster.adapter_id
            )
        package_config = cluster.package_config
        if package_config:
            metadata_api.validate_package_config(
                package_config, cluster.adapter_id
            )
        return cluster.to_dict()