<div dir="ltr">Hi Paul,<div><br></div><div><span style="font-size:12.8px">> Here both key and value appear to be a string (note, I can't confirm this as the typeinfo function doesn't appear to be available in Instance.yaml for some reason... perhaps I'm using it wrong)</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">They are not strings. Reporter converts everything that is passed to it into string by doing unicode(obj). What you see is the Python string representation of lists and dicts, where every unicode string is prefixed with "u".</span></div><div><span style="font-size:12.8px">Typinfo function works on objects (instances of MuranoPL classes), not on primitive types like strings, dicts and lists.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">> 1) Why is the content of this 'get_attr' coming from heat being stored in the stack outputs as a string,</span><br></div><div><span style="font-size:12.8px">it is stored exactly as it comes from Heat. In theory conversion to string could happen on Heat side, but most likely it just the output of reporter made it look like this</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">> </span><span style="font-size:12.8px">2) Is there a way I can cast this to a list of dicts or similar structure so it can be iterated as expected?</span></div><div><span style="font-size:12.8px">It's hard to answer without seeing your code and how you got the results that you provided. </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">> </span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">when I access this from a sample app, I end up with a list of strings, shown by $reporter as: ...</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Curly braces in the output indicate that this is not a list of strings but rather the single dict converted to a string by reporter. So what you see is the value of that </span><span style="font-size:12.8px">'vol-7c8ee61f-a444-46a1-ad70-</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">fc6fce6a7b56-attachments' output, which sounds like what you're wanted it to be. In MuranoPL you can have very detailed contracts: not just [] (any list) but something like</span></div><div><span style="font-size:12.8px">Contract:</span></div><div><span style="font-size:12.8px">  - key1: string().notNull()</span></div><div><span style="font-size:12.8px">    key2: int()</span><span style="font-size:12.8px">.notNull()</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">which is a list of dicts with contract on each dict entry. If you don't get contract violation exception, you can be sure that the list contains list of dicts with appropriate keys/values rather than list of strings or anything else  </span></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span style="border-collapse:separate;color:rgb(0,0,0);font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="font-family:arial;font-size:small">Sincerely yours,<br>Stan Lagun<br>Principal Software Engineer @ Mirantis</span></span><br><span style="border-collapse:separate;color:rgb(0,0,0);font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="font-family:arial;font-size:small"><br><a href="mailto:slagun@mirantis.com" target="_blank"></a></span></span></div></div></div>
<br><div class="gmail_quote">On Thu, Mar 30, 2017 at 10:17 AM, Paul Bourke <span dir="ltr"><<a href="mailto:paul.bourke@oracle.com" target="_blank">paul.bourke@oracle.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Stan,<br>
<br>
I had a quick(hopefully) question about MuranoPL that I hope you might be able to help with, Felipe had mentioned you are very knowledgeable in this area. If you don't have time please disregard!<br>
<br>
I'm working on a patch for the Murano core library to make volume attachment info available, which is available at <a href="https://review.openstack.org/451909" rel="noreferrer" target="_blank">https://review.openstack.org/4<wbr>51909</a>. It's mostly working, but I'm having some issues getting the types correct in MuranoPL to make this info consumable by end users.<br>
<br>
The attachment info from a sample run in the stack $outputs looks like this (taken from the dashboard using $reporter)<br>
<br>
u'vol-7c8ee61f-a444-46a1-ad70-<wbr>fc6fce6a7b56-attachments': u"[{u'server_id': u'2891067b-e7bb-4ab9-a759-9e81<wbr>096c0682', u'attachment_id': u'7456a4b0-3abd-48a0-a0cb-f3fa<wbr>0f2706bb', u'attached_at': u'2017-03-30T16:51:57.000000', u'host_name': None, u'volume_id': u'373e4a5a-46b6-4091-82d6-b3db<wbr>a62d552b', u'device': u'/dev/vda', u'id': u'373e4a5a-46b6-4091-82d6-b3db<wbr>a62d552b'}]"<br>
<br>
Here both key and value appear to be a string (note, I can't confirm this as the typeinfo function doesn't appear to be available in Instance.yaml for some reason... perhaps I'm using it wrong)<br>
<br>
My goal is to then set this into a property of CinderVolume.yaml, with a Contract of '[]'. However, when I access this from a sample app, I end up with a list of strings, shown by $reporter as:<br>
<br>
(u"[{u'server_id': u'2891067b-e7bb-4ab9-a759-9e81<wbr>096c0682', u'attachment_id': u'f5bd50ab-4040-4e2b-8b50-7907<wbr>81d9bc37', u'attached_at': u'2017-03-30T16:51:59.000000', u'host_name': None, u'volume_id': u'ed7eb535-9e81-4c97-b063-8693<wbr>6d4ee306', u'device': u'/dev/vdb', u'id': u'ed7eb535-9e81-4c97-b063-8693<wbr>6d4ee306'}]",)<br>
<br>
So my question is:<br>
<br>
1) Why is the content of this 'get_attr' coming from heat being stored in the stack outputs as a string, and<br>
<br>
2) Is there a way I can cast this to a list of dicts or similar structure so it can be iterated as expected?<br>
<br>
Any tips much appreciated.<br>
<br>
Thanks,<br>
-Paul<br>
</blockquote></div><br></div>