Change-Id: I8ea9ea41925ade445c92ab3402575a97d9aeb000
Issue-Id: VFC-469
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import threading
import traceback
import logging
import threading
import traceback
logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
class ResCreateThread(threading.Thread):
"""
Create resource
class ResCreateThread(threading.Thread):
"""
Create resource
except:
logger.error(traceback.format_exc())
logger.error(str(sys.exc_info()))
except:
logger.error(traceback.format_exc())
logger.error(str(sys.exc_info()))
def do_notify(self, res_type, ret):
logger.debug('ret of [%s] is %s', res_type, ret)
def do_notify(self, res_type, ret):
logger.debug('ret of [%s] is %s', res_type, ret)
class ResDeleteThread(threading.Thread):
"""
Delete resource
class ResDeleteThread(threading.Thread):
"""
Delete resource
except:
logger.error(traceback.format_exc())
logger.error(str(sys.exc_info()))
except:
logger.error(traceback.format_exc())
logger.error(str(sys.exc_info()))
def do_notify(self, res_type, res_id):
logger.debug('Delete %s(%s)', res_type, res_id)
def do_notify(self, res_type, res_id):
logger.debug('Delete %s(%s)', res_type, res_id)
import unittest
import json
import unittest
import json
from django.test import Client
from rest_framework import status
from django.test import Client
from rest_framework import status
-from lcm.pub.vimapi import api
-
inst_res_url = "/api/vnflcm/v1/resources/inst"
term_res_url = "/api/vnflcm/v1/resources/term"
inst_res_data = {
inst_res_url = "/api/vnflcm/v1/resources/inst"
term_res_url = "/api/vnflcm/v1/resources/term"
inst_res_data = {
"vm": [{"vim_id": "6", "tenant_id": "7", "res_id": "8"}]
}
"vm": [{"vim_id": "6", "tenant_id": "7", "res_id": "8"}]
}
class SampleViewTest(unittest.TestCase):
def setUp(self):
self.client = Client()
class SampleViewTest(unittest.TestCase):
def setUp(self):
self.client = Client()
self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
resp_data = json.loads(response.content)
self.assertEqual({"status": "active"}, resp_data)
self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
resp_data = json.loads(response.content)
self.assertEqual({"status": "active"}, resp_data)
def test_inst_res(self):
resp = self.client.post(inst_res_url, data=json.dumps(inst_res_data), content_type='application/json')
self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)
def test_inst_res(self):
resp = self.client.post(inst_res_url, data=json.dumps(inst_res_data), content_type='application/json')
self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)
def test_term_res(self):
resp = self.client.post(term_res_url, data=json.dumps(term_res_data), content_type='application/json')
self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)
def test_term_res(self):
resp = self.client.post(term_res_url, data=json.dumps(term_res_data), content_type='application/json')
self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)
-
\ No newline at end of file
logger.debug("get")
return Response({"status": "active"})
logger.debug("get")
return Response({"status": "active"})
class ResourceList(APIView):
"""
Instantiate/Terminate resource.
class ResourceList(APIView):
"""
Instantiate/Terminate resource.