summaryrefslogtreecommitdiffstats
path: root/api/resources/v2
diff options
context:
space:
mode:
Diffstat (limited to 'api/resources/v2')
-rw-r--r--api/resources/v2/environments.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/api/resources/v2/environments.py b/api/resources/v2/environments.py
index dc6eac725..4b27c45b8 100644
--- a/api/resources/v2/environments.py
+++ b/api/resources/v2/environments.py
@@ -1,9 +1,12 @@
import uuid
import logging
+from oslo_serialization import jsonutils
+
from api import ApiResource
from api.database.v2.handlers import V2EnvironmentHandler
from yardstick.common.utils import result_handler
+from yardstick.common.utils import change_obj_to_dict
from yardstick.common import constants as consts
LOG = logging.getLogger(__name__)
@@ -12,6 +15,20 @@ LOG.setLevel(logging.DEBUG)
class V2Environments(ApiResource):
+ def get(self):
+ environment_handler = V2EnvironmentHandler()
+ environments = [change_obj_to_dict(e) for e in environment_handler.list_all()]
+
+ for e in environments:
+ container_info = e['container_id']
+ e['container_id'] = jsonutils.loads(container_info) if container_info else {}
+
+ data = {
+ 'environments': environments
+ }
+
+ return result_handler(consts.API_SUCCESS, data)
+
def post(self):
return self._dispatch_post()
@@ -24,6 +41,7 @@ class V2Environments(ApiResource):
env_id = str(uuid.uuid4())
environment_handler = V2EnvironmentHandler()
+
env_init_data = {
'name': name,
'uuid': env_id