Esempio n. 1
0
def delete_table(table_id):
    table = flush_table(table_id)
    for chain_id in table['chains']:
        chain_wrapper.delete_chain(chain_id)
    cmd = nft_utils.nft_command('delete table {family} {name}'.format(**table))
    cmd_result = cmd.wait()
    if cmd_result == 0:
        nft_utils.close_nft_command(cmd)
        table['id'] = '{family}:{name}'.format(**table)
        return table
    else:
        raise NFTError(Error(cmd.stdout.readlines()))
Esempio n. 2
0
def delete_table(table_id):
    table = flush_table(table_id)
    for chain_id in table['chains']:
        chain_wrapper.delete_chain(chain_id)
    cmd = nft_utils.nft_command('delete table {family} {name}'.format(**table))
    cmd_result = cmd.wait()
    if cmd_result == 0:
        nft_utils.close_nft_command(cmd)
        table['id'] = '{family}:{name}'.format(**table)
        return table
    else:
        raise NFTError(Error(cmd.stdout.readlines()))
Esempio n. 3
0
def chain(chain_id):
    '''
    GET:
      Get a chain by it's id
    DELETE:
      Delete the chain with the specified id
    '''
    if request.method == 'DELETE':
        try:
            chain = chain_validator.validate_chain_delete(chain_id)
            chain = chain_wrapper.delete_chain(chain_id)
            return jsonify(chain=chain)
        except NFTValidationError as e:
            return abort(400, e)
        except NFTError as e:
            return abort(500, e)
    else:
        return jsonify(chain=chain_wrapper.get_chain(chain_id))