From 3c29a80e90dbe9e9763a2eda0db108ec21ef38c7 Mon Sep 17 00:00:00 2001 From: xinhuili Date: Wed, 29 Mar 2017 07:03:05 -0700 Subject: Fix create image issue This patch is to fix create image pending. Change-Id: I03fbf6d46e020fe55da55885110619bfa7f026b1 Issue-ids: MULTIVIM-36 Signed-off-by: xinhuili --- vio/vio/pub/vim/vimapi/glance/OperateImage.py | 1 + vio/vio/swagger/views/flavor/views.py | 7 +------ vio/vio/swagger/views/image/views.py | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) (limited to 'vio') diff --git a/vio/vio/pub/vim/vimapi/glance/OperateImage.py b/vio/vio/pub/vim/vimapi/glance/OperateImage.py index 2b08359..ce9ae75 100644 --- a/vio/vio/pub/vim/vimapi/glance/OperateImage.py +++ b/vio/vio/pub/vim/vimapi/glance/OperateImage.py @@ -50,6 +50,7 @@ class imageThread(threading.Thread): logger.debug("Image----transfer_image") vim_info = extsys.get_vim_by_id(vimid) + vim_info['tenant'] = tenantid param = image_utils.sdk_param_formatter(vim_info) data = imagefd.read() diff --git a/vio/vio/swagger/views/flavor/views.py b/vio/vio/swagger/views/flavor/views.py index c774f90..b6bc437 100644 --- a/vio/vio/swagger/views/flavor/views.py +++ b/vio/vio/swagger/views/flavor/views.py @@ -45,7 +45,6 @@ class FlavorsView(APIView): flavor_name = create_req.get('name', None) flavor_id = create_req.get('id', None) flavors_op = OperateFlavors.OperateFlavors() - exist = False try: target = flavor_id or flavor_name flavor = flavors_op.find_flavor(data, tenantid, target) @@ -53,7 +52,6 @@ class FlavorsView(APIView): flavor, extra_specs = flavors_op.get_flavor( data, tenantid, flavor.id) rsp['returnCode'] = 0 - exist = True else: rsp['returnCode'] = 1 flavor, extra_specs = flavors_op.create_flavor( @@ -66,10 +64,7 @@ class FlavorsView(APIView): return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) rsp.update(flavor_dict) - if exist: - return Response(data=rsp, status=status.HTTP_200_OK) - else: - return Response(data=rsp, status=status.HTTP_202_ACCEPTED) + return Response(data=rsp, status=status.HTTP_200_OK) def get(self, request, vimid, tenantid): try: diff --git a/vio/vio/swagger/views/image/views.py b/vio/vio/swagger/views/image/views.py index 43ed3c5..edc3873 100644 --- a/vio/vio/swagger/views/image/views.py +++ b/vio/vio/swagger/views/image/views.py @@ -125,7 +125,7 @@ class CreateListImagesView(APIView): rsp = image_utils.image_formatter(image) rsp.update(vim_rsp) rsp['returnCode'] = '1' - return Response(data=rsp, status=status.HTTP_201_ACCEPTED) + return Response(data=rsp, status=status.HTTP_201_CREATED) except Exception as e: if hasattr(e, "http_status"): return Response(data={'error': str(e)}, status=e.http_status) -- cgit 1.2.3-korg