3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
10 Resources to handle environment related requests
13 from flask import jsonify
15 from functest.api.base import ApiResource
16 from functest.cli.commands.cli_env import Env
17 from functest.api.common import api_utils
18 import functest.utils.functest_utils as ft_utils
21 class V1Envs(ApiResource):
22 """ V1Envs Resource class"""
24 def get(self): # pylint: disable=no-self-use
25 """ Get environment """
26 environment_show = Env().show()
27 return jsonify(environment_show)
30 """ Used to handle post request """
31 return self._dispatch_post()
33 def prepare(self, args): # pylint: disable=no-self-use, unused-argument
34 """ Prepare environment """
36 ft_utils.execute_command("prepare_env start")
37 except Exception as err: # pylint: disable=broad-except
38 return api_utils.result_handler(status=1, data=str(err))
39 return api_utils.result_handler(
40 status=0, data="Prepare env successfully")