Ask Your Question
0

Tacker internal server error while creating VNF via REST API

asked 2017-12-12 13:40:50 -0500

Giovanni gravatar image

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"
          }
        }
      }
    }
   }
  }
 }
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-14 06:16:18 -0500

Giovanni gravatar image

I've managed to solve the problem. It was actually quite simple. The credentials i was using to generate the auth token were from a different project. Then, the default VIM (VIM0) could not resolve the request.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-12-12 13:40:50 -0500

Seen: 237 times

Last updated: Dec 14 '17