Exemplo n.º 1
0
def main():
    print("Pools ********************")
    created_pools = set()
    for pool in pools:
        name = pool["name"]
        print(f"Create: {name}")
        create_pool(**pool)
        created_pools.add(name)
    for pool in get_pools():
        name = pool.pool
        if name == default_pool_name or name in created_pools:
            continue
        if name not in created_pools:
            print(f"Delete: {name}")
            delete_pool(name)
    return
Exemplo n.º 2
0
def delete_pool(name):
    """Delete pool."""
    try:
        pool = pool_api.delete_pool(name=name)
    except AirflowException as err:
        log.error(err)
        response = jsonify(error="{}".format(err))
        response.status_code = err.status_code
        return response
    else:
        return jsonify(pool.to_json())
Exemplo n.º 3
0
def delete_pool(name):
    """Delete pool."""
    try:
        pool = pool_api.delete_pool(name=name)
    except AirflowException as e:
        _log.error(e)
        response = jsonify(error="{}".format(e))
        response.status_code = getattr(e, 'status', 500)
        return response
    else:
        return jsonify(pool.to_json())
Exemplo n.º 4
0
 def test_delete_default_pool_not_allowed(self):
     with pytest.raises(AirflowBadRequest,
                        match="^default_pool cannot be deleted$"):
         pool_api.delete_pool(Pool.DEFAULT_POOL_NAME)
Exemplo n.º 5
0
 def test_delete_pool_bad_name(self):
     for name in ('', '    '):
         with pytest.raises(AirflowBadRequest,
                            match="^Pool name shouldn't be empty$"):
             pool_api.delete_pool(name=name)
Exemplo n.º 6
0
 def test_delete_pool_non_existing(self):
     with pytest.raises(pool_api.PoolNotFound,
                        match="^Pool 'test' doesn't exist$"):
         pool_api.delete_pool(name='test')
Exemplo n.º 7
0
 def test_delete_pool(self):
     pool = pool_api.delete_pool(name=self.pools[-1].pool)
     assert pool.pool == self.pools[-1].pool
     with create_session() as session:
         assert session.query(
             models.Pool).count() == self.TOTAL_POOL_COUNT - 1
Exemplo n.º 8
0
 def delete_pool(self, name):
     the_pool = pool.delete_pool(name=name)
     return the_pool.pool, the_pool.slots, the_pool.description
 def test_delete_default_pool_not_allowed(self):
     with self.assertRaisesRegex(AirflowBadRequest,
                                 "^default_pool cannot be deleted$"):
         pool_api.delete_pool(Pool.DEFAULT_POOL_NAME)
Exemplo n.º 10
0
 def test_delete_pool(self):
     pool = pool_api.delete_pool(name=self.pools[-1].pool)
     self.assertEqual(pool.pool, self.pools[-1].pool)
     with create_session() as session:
         self.assertEqual(
             session.query(models.Pool).count(), self.TOTAL_POOL_COUNT - 1)
Exemplo n.º 11
0
 def delete_pool(self, name):
     p = pool.delete_pool(name=name)
     return p.pool, p.slots, p.description
Exemplo n.º 12
0
 def test_delete_pool(self):
     pool = pool_api.delete_pool(name=self.pools[0].pool,
                                 session=self.session)
     self.assertEqual(pool.pool, self.pools[0].pool)
     self.assertEqual(self.session.query(models.Pool).count(), 1)
Exemplo n.º 13
0
 def test_delete_pool(self):
     pool = pool_api.delete_pool(name=self.pools[0].pool,
                                 session=self.session)
     self.assertEqual(pool.pool, self.pools[0].pool)
     self.assertEqual(self.session.query(models.Pool).count(), 1)
Exemplo n.º 14
0
 def delete_pool(self, name):
     p = pool.delete_pool(name=name)
     return p.pool, p.slots, p.description