def delete_cluster_host( cluster_id, host_id, user, delete_underlying_host=False ): if delete_underlying_host: host_db.del_host( host_id, True, True, user=user ) cluster_db.del_cluster_host( cluster_id, host_id, True, True, user=user )
def delete_cluster_host(cluster_id, host_id, user, delete_underlying_host=False): """Delete clusterhost. If delete_underlying_host set, also delete underlying host. """ if delete_underlying_host: host_db.del_host(host_id, True, True, user=user) cluster_db.del_cluster_host(cluster_id, host_id, True, True, user=user)
def test_del_host(self): host.del_host( self.user_object, self.host_ids[0] ) del_host = host.list_hosts( self.user_object ) ids = [] for item in del_host: ids.append(item['id']) self.assertNotIn(self.host_ids[0], ids)
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)
def delete_cluster_host( cluster_id, host_id, user, delete_underlying_host=False ): """Delete clusterhost. If delete_underlying_host set, also delete underlying host. """ if delete_underlying_host: host_db.del_host( host_id, True, True, user=user ) cluster_db.del_cluster_host( cluster_id, host_id, True, True, user=user )
def test_get_machine(self): host.del_host( self.host_ids[0], user=self.user_object, ) get_machine = host.get_machine_or_host( self.host_ids[0], user=self.user_object, ) name = [] for k, v in get_machine.items(): if k == 'name': name.append(v) self.assertEqual(name, []) self.assertEqual(get_machine['mac'], '28:6e:d4:46:c4:25')
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 )
def test_del_host(self): from compass.tasks import client as celery_client celery_client.celery.send_task = mock.Mock() del_host = host.del_host( self.host_ids[0], user=self.user_object, ) self.assertIsNotNone(del_host)
def test_list_machines(self): host.del_host( self.host_ids[0], user=self.user_object, ) host.del_host( self.host_ids[1], user=self.user_object, ) list_hosts = host.list_machines_or_hosts( user=self.user_object ) macs = [] names = [] for list_host in list_hosts: for k, v in list_host.iteritems(): if k == 'mac': macs.append(v) if k == 'name': names.append(v) for mac in macs: self.assertIn(mac, ['28:6e:d4:46:c4:25', '00:0c:29:bf:eb:1d']) self.assertEqual(names, [])
def delete_host(host_id, user): host_db.del_host( host_id, True, True, user=user )
def delete_host(host_id, user): host_db.del_host(host_id, True, True, user=user)
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'])