def clean_deployment(cluster_hosts):
    """Clean deployment of clusters.

    :param cluster_hosts: clusters and hosts in each cluster to clean.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
        The function should be called out of database session.
    """
    with util.lock('serialized_action'):
        logging.debug('clean cluster_hosts: %s', cluster_hosts)
        with database.session():
            cluster_hosts, os_versions, target_systems = (
                util.update_cluster_hosts(cluster_hosts))
            manager = ConfigManager()
            manager.clean_cluster_and_hosts(
                cluster_hosts, os_versions, target_systems)
            manager.sync()
Example #2
0
def deploy(cluster_hosts):
    """Deploy clusters.

    :param cluster_hosts: clusters and hosts in each cluster to deploy.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
        The function should be called out of database session.
    """
    with util.lock('serialized_action') as lock:
        if not lock:
            raise Exception('failed to acquire lock to deploy')

        logging.debug('deploy cluster_hosts: %s', cluster_hosts)
        with database.session():
            cluster_hosts, os_versions, target_systems = (
                util.update_cluster_hosts(cluster_hosts))
            manager = ConfigManager()
            manager.install_cluster_and_hosts(cluster_hosts, os_versions,
                                              target_systems)
            manager.sync()
def deploy(cluster_hosts):
    """Deploy clusters.

    :param cluster_hosts: clusters and hosts in each cluster to deploy.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
        The function should be called out of database session.
    """
    with util.lock('serialized_action') as lock:
        if not lock:
            raise Exception('failed to acquire lock to deploy')

        logging.debug('deploy cluster_hosts: %s', cluster_hosts)
        with database.session():
            cluster_hosts, os_versions, target_systems = (
                util.update_cluster_hosts(cluster_hosts))
            manager = ConfigManager()
            manager.install_cluster_and_hosts(
                cluster_hosts, os_versions, target_systems)
            manager.sync()
Example #4
0
def search(cluster_hosts, cluster_propreties_match,
           cluster_properties_name, host_properties_match,
           host_properties_name):
    """search clusters.

    :param cluster_hosts: clusters and hosts in each cluster to search.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
        The function should be called out of database session.
    """
    logging.debug('search cluster_hosts: %s', cluster_hosts)
    with database.session():
        cluster_hosts, os_versions, target_systems = (
            util.update_cluster_hosts(cluster_hosts))
        manager = ConfigManager()
        return manager.filter_cluster_and_hosts(
            cluster_hosts, os_versions,
            target_systems, cluster_propreties_match,
            cluster_properties_name, host_properties_match,
            host_properties_name)
Example #5
0
def search(cluster_hosts, cluster_propreties_match,
           cluster_properties_name, host_properties_match,
           host_properties_name):
    """search clusters.

    :param cluster_hosts: clusters and hosts in each cluster to search.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
        The function should be called out of database session.
    """
    logging.debug('search cluster_hosts: %s', cluster_hosts)
    with database.session():
        cluster_hosts, os_versions, target_systems = (
            util.update_cluster_hosts(cluster_hosts))
        manager = ConfigManager()
        return manager.filter_cluster_and_hosts(
            cluster_hosts, os_versions,
            target_systems, cluster_propreties_match,
            cluster_properties_name, host_properties_match,
            host_properties_name)
def update_progress(cluster_hosts):
    """Update status and installing progress of the given cluster.

    :param cluster_hosts: clusters and hosts in each cluster to update.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
       The function should be called out of the database session scope.
       In the function, it will update the database cluster_state and
       host_state table for the deploying cluster and hosts.

       The function will also query log_progressing_history table to get
       the lastest installing progress and the position of log it has
       processed in the last run. The function uses these information to
       avoid recalculate the progress from the beginning of the log file.
       After the progress got updated, these information will be stored back
       to the log_progressing_history for next time run.
    """
    with util.lock('log_progressing', blocking=False) as lock:
        if not lock:
            logging.error(
                'failed to acquire lock to calculate installation progress')
            return

        logging.info('update installing progress of cluster_hosts: %s',
                     cluster_hosts)
        os_versions = {}
        target_systems = {}
        with database.session():
            cluster_hosts, os_versions, target_systems = (
                util.update_cluster_hosts(
                    cluster_hosts, _cluster_filter, _host_filter))

        progress_calculator.update_progress(
            setting.OS_INSTALLER,
            os_versions,
            setting.PACKAGE_INSTALLER,
            target_systems,
            cluster_hosts)
Example #7
0
def clean_installing_progress(cluster_hosts):
    """Clean installing progress of clusters.

    :param cluster_hosts: clusters and hosts in each cluster to clean.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
        The function should be called out of database session.
    """
    with util.lock('serialized_action') as lock:
        if not lock:
            raise Exception(
                'failed to acquire lock to clean installation progress')

        logging.info('clean installing progress of cluster_hosts: %s',
                     cluster_hosts)
        with database.session():
            cluster_hosts, os_versions, target_systems = (
                util.update_cluster_hosts(cluster_hosts))
            manager = ConfigManager()
            manager.clean_cluster_and_hosts_installing_progress(
                cluster_hosts, os_versions, target_systems)
            manager.sync()
def clean_installing_progress(cluster_hosts):
    """Clean installing progress of clusters.

    :param cluster_hosts: clusters and hosts in each cluster to clean.
    :type cluster_hosts: dict of int or str to list of int or str

    .. note::
        The function should be called out of database session.
    """
    with util.lock('serialized_action') as lock:
        if not lock:
            raise Exception(
                'failed to acquire lock to clean installation progress')

        logging.info(
            'clean installing progress of cluster_hosts: %s',
            cluster_hosts)
        with database.session():
            cluster_hosts, os_versions, target_systems = (
                util.update_cluster_hosts(cluster_hosts))
            manager = ConfigManager()
            manager.clean_cluster_and_hosts_installing_progress(
                cluster_hosts, os_versions, target_systems)
            manager.sync()