本文整理汇总了Python中API.addVNFTemplateV2方法的典型用法代码示例。如果您正苦于以下问题:Python API.addVNFTemplateV2方法的具体用法?Python API.addVNFTemplateV2怎么用?Python API.addVNFTemplateV2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API.addVNFTemplateV2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: import API [as 别名]
# 或者: from API import addVNFTemplateV2 [as 别名]
def put(self, request):
"""
Create a new VNF template. The 'vnf_id' assigned by the datastore is contained in the response.
"""
if request.META['CONTENT_TYPE'] != 'application/json':
return HttpResponse(status=415)
if 'image-upload-status' not in request.data.keys():
try:
if 'functional-capability' not in request.data.keys():
return HttpResponse("Missing functional-capability field", status=400)
capability = request.data['functional-capability']
ValidateTemplate().validate(request.data)
template = json.dumps(request.data)
image_upload_status = VNF.REMOTE
except:
return HttpResponse(status=400)
elif all(request.data['image-upload-status'] not in state for state in VNF.IMAGE_UPLOAD_STATUS):
return HttpResponse("Wrong value of image-upload-status field", status=400)
elif 'template' not in request.data.keys():
return HttpResponse("Missing template field", status=400)
else:
try:
if 'functional-capability' not in request.data['template'].keys():
return HttpResponse("Missing functional-capability field", status=400)
capability = request.data['template']['functional-capability']
ValidateTemplate().validate(request.data['template'])
template = json.dumps(request.data['template'])
image_upload_status = request.data['image-upload-status']
except:
return HttpResponse(status=400)
vnf_id = API.addVNFTemplateV2(template, capability, image_upload_status)
return HttpResponse(vnf_id, status=200)