Esempio n. 1
0
 def delete_cluster(
     cluster_id, host_id_list, user, delete_underlying_host=False
 ):
     if delete_underlying_host:
         for host_id in host_id_list:
             host_db.del_host(
                 host_id, True, True, user=user
             )
     cluster_db.del_cluster(
         cluster_id, True, True, user=user
     )
Esempio n. 2
0
    def delete_cluster(cluster_id,
                       host_id_list,
                       user,
                       delete_underlying_host=False):
        """Delete cluster.

        If delete_underlying_host is set, underlying hosts will also
        be deleted.
        """
        if delete_underlying_host:
            for host_id in host_id_list:
                host_db.del_host(host_id, True, True, user=user)
        cluster_db.del_cluster(cluster_id, True, True, user=user)
Esempio n. 3
0
    def delete_cluster(
        cluster_id, host_id_list, user, delete_underlying_host=False
    ):
        """Delete cluster.

        If delete_underlying_host is set, underlying hosts will also
        be deleted.
        """
        if delete_underlying_host:
            for host_id in host_id_list:
                host_db.del_host(
                    host_id, True, True, user=user
                )
        cluster_db.del_cluster(
            cluster_id, True, True, user=user
        )
Esempio n. 4
0
def delete_clusters():
    clusternames = [
        clustername for clustername in flags.OPTIONS.clusternames.split(',')
        if clustername
    ]
    user = user_api.get_user_object(setting.COMPASS_ADMIN_EMAIL)
    list_cluster_args = {}
    if clusternames:
        list_cluster_args['name'] = clusternames
    clusters = cluster_api.list_clusters(user=user, **list_cluster_args)
    delete_underlying_host = flags.OPTIONS.delete_hosts
    for cluster in clusters:
        cluster_id = cluster['id']
        cluster_api.del_cluster(cluster_id,
                                True,
                                False,
                                delete_underlying_host,
                                user=user)
Esempio n. 5
0
def delete_clusters():
    clusternames = [
        clustername
        for clustername in flags.OPTIONS.clusternames.split(',')
        if clustername
    ]
    user = user_api.get_user_object(setting.COMPASS_ADMIN_EMAIL)
    list_cluster_args = {}
    if clusternames:
        list_cluster_args['name'] = clusternames
    clusters = cluster_api.list_clusters(
        user=user, **list_cluster_args
    )
    delete_underlying_host = flags.OPTIONS.delete_hosts
    for cluster in clusters:
        cluster_id = cluster['id']
        cluster_api.del_cluster(
            cluster_id, True, False, delete_underlying_host, user=user
        )
Esempio n. 6
0
          default='')
flags.add_bool('delete_hosts',
               help='if all hosts related to the cluster will be deleted',
               default=False)


if __name__ == '__main__':
    flags.init()
    logsetting.init()
    database.init()
    clusternames = [
        clustername
        for clustername in flags.OPTIONS.clusternames.split(',')
        if clustername
    ]
    logging.info('delete clusters %s', clusternames)
    user = user_api.get_user_object(setting.COMPASS_ADMIN_EMAIL)
    clusters = cluster_api.list_clusters(
        user, name=clusternames
    )
    if flags.OPTIONS.delete_hosts:
        for cluster in clusters:
            hosts = cluster_api.list_cluster_hosts(
                user, cluster['id'])
            for host in hosts:
                logging.info('delete host %s', host['hostname'])
                host_api.del_host(user, host['id'])
    for cluster in clusters:
        logging.info('delete cluster %s', cluster['name'])
        cluster_api.del_cluster(user, cluster['id'])