def deploy_clusters(): """Deploy hosts in clusters. .. note:: The hosts are defined in --clusters. The clusters flag is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS.async: celery.send_task('compass.tasks.deploy', (cluster_hosts,)) else: deploy.deploy(cluster_hosts)
def deploy_clusters(): """Deploy hosts in clusters. .. note:: The hosts are defined in --clusters. The clusters flag is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS. async: celery.send_task('compass.tasks.deploy', (cluster_hosts, )) else: deploy.deploy(cluster_hosts)
def reinstall_clusters(): """Reinstall hosts in clusters. .. note:: The hosts are defined in --clusters. The clusters flag is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS.async: celery.send_task('compass.tasks.reinstall', (cluster_hosts,)) else: reinstall.reinstall(cluster_hosts)
def clean_clusters(): """Delete clusters and hosts. .. note:: The clusters and hosts are defined in --clusters. the clusters flag is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS.async: celery.send_task('compass.tasks.clean_deployment', (cluster_hosts,)) else: clean_deployment.clean_deployment(cluster_hosts)
def reinstall_clusters(): """Reinstall hosts in clusters. .. note:: The hosts are defined in --clusters. The clusters flag is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS. async: celery.send_task('compass.tasks.reinstall', (cluster_hosts, )) else: reinstall.reinstall(cluster_hosts)
def clean_clusters(): """Delete clusters and hosts. .. note:: The clusters and hosts are defined in --clusters. the clusters flag is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS. async: celery.send_task('compass.tasks.clean_deployment', (cluster_hosts, )) else: clean_deployment.clean_deployment(cluster_hosts)
def clean_installation_progress(): """Clean clusters and hosts installation progress. .. note:: The cluster and hosts is defined in --clusters. The clusters flags is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS.async: celery.send_task('compass.tasks.clean_installing_progress', (cluster_hosts,)) else: clean_installing_progress.clean_installing_progress(cluster_hosts)
def clean_installation_progress(): """Clean clusters and hosts installation progress. .. note:: The cluster and hosts is defined in --clusters. The clusters flags is as clusterid:hostname1,hostname2,...;... """ cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) if flags.OPTIONS. async: celery.send_task('compass.tasks.clean_installing_progress', (cluster_hosts, )) else: clean_installing_progress.clean_installing_progress(cluster_hosts)
def search_cluster_hosts(): """Search cluster hosts by properties. .. note:: --search_cluster_properties defines what properties are used to search. the format of search_cluster_properties is as <property_name>=<property_value>;... If no search properties are set, It will returns properties of all hosts. --print_cluster_properties defines what properties to print. the format of print_cluster_properties is as <property_name>;... --search_host_properties defines what properties are used to search. the format of search_host_properties is as <property_name>=<property_value>;... If no search properties are set, It will returns properties of all hosts. --print_host_properties defines what properties to print. the format of print_host_properties is as <property_name>;... """ cluster_properties = util.get_properties_from_str( flags.OPTIONS.search_cluster_properties) cluster_properties_name = util.get_properties_name_from_str( flags.OPTIONS.print_cluster_properties) host_properties = util.get_properties_from_str( flags.OPTIONS.search_host_properties) host_properties_name = util.get_properties_name_from_str( flags.OPTIONS.print_host_properties) cluster_hosts = util.get_clusters_from_str(flags.OPTIONS.clusters) cluster_properties, cluster_host_properties = search.search( cluster_hosts, cluster_properties, cluster_properties_name, host_properties, host_properties_name) print 'clusters properties:' util.print_properties(cluster_properties) for clusterid, host_properties in cluster_host_properties.items(): print 'hosts properties under cluster %s' % clusterid util.print_properties(host_properties)
flags.add('run_interval', help='run interval in seconds', default=setting.PROGRESS_UPDATE_INTERVAL) def progress_update(cluster_hosts): """entry function.""" if flags.OPTIONS.async: celery.send_task('compass.tasks.update_progress', (cluster_hosts,)) else: try: update_progress.update_progress(cluster_hosts) except Exception as error: logging.error('failed to update progress for cluster_hosts: %s', cluster_hosts) logging.exception(error) if __name__ == '__main__': flags.init() logsetting.init() logging.info('run progress update') daemonize.daemonize( functools.partial( progress_update, util.get_clusters_from_str(flags.OPTIONS.clusters)), flags.OPTIONS.run_interval, pidfile=lockfile.FileLock('/var/run/progress_update.pid'), stderr=open('/tmp/progress_update_err.log', 'w+'), stdout=open('/tmp/progress_update_out.log', 'w+'))
flags.add_bool('async', help='run in async mode', default=True) flags.add('run_interval', help='run interval in seconds', default=setting.PROGRESS_UPDATE_INTERVAL) def progress_update(cluster_hosts): """entry function.""" if flags.OPTIONS. async: celery.send_task('compass.tasks.update_progress', (cluster_hosts, )) else: try: update_progress.update_progress(cluster_hosts) except Exception as error: logging.error('failed to update progress for cluster_hosts: %s', cluster_hosts) logging.exception(error) if __name__ == '__main__': flags.init() logsetting.init() logging.info('run progress update') daemonize.daemonize( functools.partial(progress_update, util.get_clusters_from_str(flags.OPTIONS.clusters)), flags.OPTIONS.run_interval, pidfile=lockfile.FileLock('/var/run/progress_update.pid'), stderr=open('/tmp/progress_update_err.log', 'w+'), stdout=open('/tmp/progress_update_out.log', 'w+'))