Tacker internal server error while creating VNF via REST API
Hi all.
I'm developing a Python script that consumes Tacker API with Requests library. I'm using devstack and tacker's stable/pike branch. For testing purposes, i'm using identity v2.
Some requests (e.g., create vnfd, list vnfd, list vnfs) works fine, but when i try to create a vnf, it gives me:
"{u'TackerError': {u'message': u'Request Failed: internal server error while processing your request.', u'type': u'HTTPInternalServerError', u'detail': u''}}"
It is important to note that vnf create with CLI command with YAML descriptor works fine, which i believe it could be a problem in my JSON VNF Descriptor (since Tacker REST API expects a JSON descriptor).
Anyone know's what i am doing wrong? Thanks!
Here's a minimal example of my script:
#!/usr/bin/env python3
import requests
data = """{
"auth": {
"tenantName": "demo",
"passwordCredentials": {
"username": "admin",
"password": "devstack"
}
}
}"""
header = {
'Content-type' : 'application/json',
'Accept' : 'application/json'
}
url = 'http://a.b.c.d/identity/v2.0/tokens'
response = requests.post(url, data=data, headers=header).json()
token = response['access']['token']['id']
header = {
'Content-type' : 'application/json',
'Accept' : 'application/json',
'X-Auth-Token' : token
}
url = 'http://a.b.c.d:9890/v1.0/vnfds'
# This request works!
response = requests.get(url, headers=header)
print(response.json())
data = """{
"vnf": {
"vnfd_id": "ba14f8bd-1eee-41f8-8e3a-f74c709ef388",
"name": "my_vnf"
}
}"""
url = 'http://a.b.c.d:9890/v1.0/vnfs'
# This request doesn't work!
response = requests.post(url, headers=header, data=data)
print(response.json())
and the JSON VNF Descriptor:
{
"vnfd": {
"name": "vnfd-sample",
"description": "some vnfd description here",
"service_types": [
{
"service_type": "vnfd"
}
],
"attributes": {
"vnfd": {
"tosca_definitions_version": "tosca_simple_profile_for_nfv_1_0_0",
"description": "Demo example",
"metadata": {
"template_name": "sample-tosca-vnfd"
},
"topology_template": {
"node_templates": {
"VDU1": {
"type": "tosca.nodes.nfv.VDU.Tacker",
"capabilities": {
"nfv_compute": {
"properties": {
"num_cpus": 1,
"mem_size": "768 MB",
"disk_size": "12 GB"
}
}
},
"properties": {
"image": "vnf-server",
"availability_zone": "nova",
"mgmt_driver": "noop"
}
},
"CP1": {
"type": "tosca.nodes.nfv.CP.Tacker",
"properties": {
"order": 0,
"management": true,
"anti_spoofing_protection": false
},
"requirements": [
{
"virtualLink": {
"node": "VL1"
}
},
{
"virtualBinding": {
"node": "VDU1"
}
}
]
},
"CP2": {
"type": "tosca.nodes.nfv.CP.Tacker",
"properties": {
"order": 1,
"anti_spoofing_protection": false
},
"requirements": [
{
"virtualLink": {
"node": "VL2"
}
},
{
"virtualBinding": {
"node": "VDU1"
}
}
]
},
"VL1": {
"type": "tosca.nodes.nfv.VL",
"properties": {
"vendor": "Tacker",
"network_name": "net_mgmt"
}
},
"VL2": {
"type": "tosca.nodes.nfv.VL",
"properties": {
"vendor": "Tacker",
"network_name": "net0"
}
}
}
}
}
}
}
}