<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi Michael:<br>
    <br>
    tosca-parser expects that the input values will be defined already
    and passed to the ToscaTemplate object in the parsed_params
    argument.<br>
    <br>
    If you change:<br>
    <br>
    tosca = ToscaTemplate(sys.argv[1])<br>
    <br>
    to:<br>
    <br>
    tosca = ToscaTemplate(sys.argv[1], parsed_params={'cpus': 4})<br>
    <br>
    the output becomes:<br>
    <br>
    Processing node template server<br>
      disk_size: 10 GB<br>
      num_cpus: 4<br>
      mem_size: 4096 MB<br>
      architecture: x86_64<br>
      type: Linux<br>
      distribution: Fedora<br>
      version: 18.0<br>
      min_instances: 1<br>
      max_instances: 1<br>
      secure: True<br>
    <br>
    <br>
    Hope this helps.<br>
    <br>
    Bob<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 12/17/18 3:25 AM, Michael Still
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAEd1pt5qnfHWAeJFVSO3+ocsXD7U-dgQ6rgHW4aypQS9tHytiw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">Hi,
            <div><br>
            </div>
            <div>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.</div>
            <div><br>
              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.</div>
            <div><br>
            </div>
            <div>Here's a snippet of example code:</div>
            <div><br>
            </div>
            <div>
              <div>#!/usr/bin/python</div>
              <div><br>
              </div>
              <div>import sys</div>
              <div><br>
              </div>
              <div>from jinja2 import Template</div>
              <div>import toscaparser.functions</div>
              <div>from toscaparser.tosca_template import ToscaTemplate</div>
              <div><br>
              </div>
              <div>tosca = ToscaTemplate(sys.argv[1])</div>
              <div><br>
              </div>
              <div>for nodetemplate in tosca.nodetemplates:</div>
              <div>    print</div>
              <div>    print('Processing node template %s'% <a
                  href="http://nodetemplate.name" moz-do-not-send="true">nodetemplate.name</a>)</div>
              <div><br>
              </div>
              <div>    capabilities =
                nodetemplate.get_capabilities_objects()</div>
              <div>    for cap in capabilities:</div>
              <div>        propobjs = cap.get_properties_objects()</div>
              <div>        if not propobjs:</div>
              <div>            continue</div>
              <div><br>
              </div>
              <div>        for po in propobjs:</div>
              <div>            print('  %s: %s' %(<a
                  href="http://po.name" moz-do-not-send="true">po.name</a>,
                po.value))</div>
            </div>
            <div><br>
            </div>
            <div>Which returns this:</div>
            <div><br>
            </div>
            <div>
              <div>$ python _capabilities.py csar_wordpress.zip </div>
              <div>No handlers could be found for logger "tosca.model"</div>
              <div><br>
              </div>
              <div>Processing node template wordpress</div>
              <div>  network_name: PRIVATE</div>
              <div>  initiator: source</div>
              <div>  protocol: tcp</div>
              <div>  secure: False</div>
              <div><br>
              </div>
              <div>Processing node template webserver</div>
              <div>  network_name: PRIVATE</div>
              <div>  initiator: source</div>
              <div>  protocol: tcp</div>
              <div>  secure: False</div>
              <div>  secure: True</div>
              <div><br>
              </div>
              <div>Processing node template mysql_dbms</div>
              <div><br>
              </div>
              <div>Processing node template mysql_database</div>
              <div><br>
              </div>
              <div>Processing node template server</div>
              <div>  secure: True</div>
              <div>  min_instances: 1</div>
              <div>  max_instances: 1</div>
              <div>  mem_size: 4096 MB</div>
              <div>  num_cpus: None</div>
              <div>  disk_size: 10 GB</div>
              <div>  distribution: Fedora</div>
              <div>  version: 18.0</div>
              <div>  type: Linux</div>
              <div>  architecture: x86_64</div>
            </div>
            <div><br>
            </div>
            <div>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.</div>
            <div><br>
            </div>
            <div>Is there an example somewhere of how to correctly
              access functions for capabilities?</div>
            <div><br>
            </div>
            <div>Thanks,</div>
            <div>Michael</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>