[tosca-parser] Failing to get functions from capabilities

Michael Still mikal at stillhq.com
Mon Dec 17 09:25:52 UTC 2018


Hi,

I'm trying to use tosca-parser to parse CSAR files. Its working quite well,
until I hit a wall with capabilities today. Specifically I am testing with
the single instance wordpress example CSAR, which uses a get_input for the
num_cpus argument for host capabilities for the server.

Based on how properties work, I would expect to get a function back for
anything which requires referencing another value, but in the case of
capabilities I either get the hardcoded value (strings, ints etc), or a
None for values which would be functions if we were talking about
prototypes.

Here's a snippet of example code:

#!/usr/bin/python

import sys

from jinja2 import Template
import toscaparser.functions
from toscaparser.tosca_template import ToscaTemplate

tosca = ToscaTemplate(sys.argv[1])

for nodetemplate in tosca.nodetemplates:
    print
    print('Processing node template %s'% nodetemplate.name)

    capabilities = nodetemplate.get_capabilities_objects()
    for cap in capabilities:
        propobjs = cap.get_properties_objects()
        if not propobjs:
            continue

        for po in propobjs:
            print('  %s: %s' %(po.name, po.value))

Which returns this:

$ python _capabilities.py csar_wordpress.zip
No handlers could be found for logger "tosca.model"

Processing node template wordpress
  network_name: PRIVATE
  initiator: source
  protocol: tcp
  secure: False

Processing node template webserver
  network_name: PRIVATE
  initiator: source
  protocol: tcp
  secure: False
  secure: True

Processing node template mysql_dbms

Processing node template mysql_database

Processing node template server
  secure: True
  min_instances: 1
  max_instances: 1
  mem_size: 4096 MB
  num_cpus: None
  disk_size: 10 GB
  distribution: Fedora
  version: 18.0
  type: Linux
  architecture: x86_64

I would expect num_cpus for the "server" node_template to be a GetInput()
function based on its definition in the CSAR, but instead I get None.

Is there an example somewhere of how to correctly access functions for
capabilities?

Thanks,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-discuss/attachments/20181217/c203da62/attachment-0001.html>


More information about the openstack-discuss mailing list