<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} .ms-cui-menu {background-color:#ffffff;border:1px rgb(171, 171, 171) solid;font-family:'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif;font-size:11pt;color:rgb(51, 51, 51);} .ms-cui-menusection-title {display:none;} .ms-cui-ctl {vertical-align:text-top;text-decoration:none;color:rgb(51, 51, 51);} .ms-cui-ctl-on {background-color:rgb(223, 237, 250);opacity: 0.8;} .ms-cui-img-cont-float {display:inline-block;margin-top:2px} .ms-cui-smenu-inner {padding-top:0px;} .ms-owa-paste-option-icon {margin: 2px 4px 0px 4px;vertical-align:sub;padding-bottom: 2px;display:inline-block;} .ms-rtePasteFlyout-option:hover {background-color:rgb(223, 237, 250) !important;opacity:1 !important;} .ms-rtePasteFlyout-option {padding:8px 4px 8px 4px;outline:none;} .ms-cui-menusection {float:left; width:85px;height:24px;overflow:hidden}.wf {speak:none; font-weight:normal; font-variant:normal; text-transform:none; -webkit-font-smoothing:antialiased; vertical-align:middle; display:inline-block;}.wf-family-owa {font-family:'o365Icons'}@font-face {  font-family:'o365IconsIE8';  src:url('prem/15.0.913.23/resources/styles/office365icons.ie8.eot?#iefix') format('embedded-opentype'),         url('prem/15.0.913.23/resources/styles/office365icons.ie8.woff') format('woff'),         url('prem/15.0.913.23/resources/styles/office365icons.ie8.ttf') format('truetype');  font-weight:normal;  font-style:normal;}@font-face {  font-family:'o365IconsMouse';  src:url('prem/15.0.913.23/resources/styles/office365icons.mouse.eot?#iefix') format('embedded-opentype'),         url('prem/15.0.913.23/resources/styles/office365icons.mouse.woff') format('woff'),         url('prem/15.0.913.23/resources/styles/office365icons.mouse.ttf') format('truetype');  font-weight:normal;  font-style:normal;}.wf-family-owa {font-family:'o365IconsMouse'}.ie8 .wf-family-owa {font-family:'o365IconsIE8'}.ie8 .wf-owa-play-large:before {content:'\e254';}.notIE8 .wf-owa-play-large:before {content:'\e054';}.ie8 .wf-owa-play-large {color:#FFFFFF/*$WFWhiteColor*/;}.notIE8 .wf-owa-play-large {border-color:#FFFFFF/*$WFWhiteColor*/; width:1.4em; height:1.4em; border-width:.1em; border-style:solid; border-radius:.8em; text-align:center; box-sizing:border-box; -moz-box-sizing:border-box; padding:0.1em; color:#FFFFFF/*$WFWhiteColor*/;}.ie8 .wf-size-play-large {width:40px; height:40px; font-size:30px}.notIE8 .wf-size-play-large {width:40px; height:40px; font-size:30px}
<!--
@font-face
        {font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
.MsoChpDefault
        {font-family:"Calibri","sans-serif"}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
-->
--></style>
</head>
<body dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Here's a description.  We need to get this added to the docs.  <br>
</p>
<p><br>
</p>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;">Below is a full description of how you might utilize the Action-centric version of <span class="highlight" id="0.5718291904777288" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span>.
  The idea is that if you describe the effects that an action/API-call will have on the basic tables of nova/neutron/etc. (below called an Action Description policy) then you can ask Congress to <span class="highlight" id="0.03596030734479427" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> the
 execution of that action and answer a query in the resulting state.  The only downside to the action-centric application of simulate is writing the Action Policy for all of the actions you care about.</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"><br>
</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;">The other way to utilize <span class="highlight" id="0.06844586390070617" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> is to
 give it the changes in nova/neutron/etc. directly that you’d like to make.  That is, instead of an action, you’ll tell <span class="highlight" id="0.5350148577708751" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> what
 rows should be inserted and which ones should be deleted.  An insertion is denoted with a plus (+) and deletion is denoted with a minus (-).</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"><br>
</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;">For example, to compute all the errors after </span></font></div>
<ol style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; margin-top: 14pt; margin-bottom: 14pt; background-color: rgb(255, 255, 255);">
<li>inserting a row into the nova:servers table with ID uuid1, 2TB of disk, and 10GB of memory (this isn’t the actual schema BTW) and </li><li>deleting the row from neutron:security_groups with the ID “uuid2” and name “alice_default_group” (again not the real schema),  </li></ol>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;">you’d write something like the following.</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"><br>
</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Helvetica" size="1"><span style="font-size: 12px;">openstack congress policy <span class="highlight" id="0.14099471853114665" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'error(x)’ ‘nova:servers+(“uuid1”, “2TB”, “10
 GB”) neutron:security_groups-(“uuid2”, “alice_default_group”)' action</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"><br>
</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;">But I’d suggest reading the following to see some of the options.</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"><br>
</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"><font face="Helvetica" size="1"><span style="font-size: 12px;">
<div>=====================================</div>
<div>1. CREATE ACTION DESCRIPTION POLICY</div>
<div>=====================================</div>
<div><br>
</div>
<div>Suppose the table 'p' is a collection of key-value pairs:  p(key, value).</div>
<div><br>
</div>
<div>Suppose we have a single action 'set(key, newvalue)’ that changes the existing value of 'key' to 'newvalue' or sets the value of 'key' to 'newvalue' if 'key' was not already assigned.  We can describe the effects of ‘set’ using the following 3 Datalog
 rules.</div>
<div><br>
</div>
<div>p+(x,y) :- set(x,y)</div>
<div>p-(x,oldy) :- set(x,y), p(x,oldy)</div>
<div>action("set")</div>
<div><br>
</div>
<div>The first thing we do is add each of these 3 rules to the policy named 'action'.</div>
<div><br>
</div>
<div>$ openstack congress policy rule create action 'p+(x,y) :- set(x,y)'</div>
<div>$ openstack congress policy rule create action 'p-(x,oldy) :- set(x,y), p(x,oldy)'</div>
<div>$ openstack congress policy rule create action 'action("set")'</div>
<div><br>
</div>
<div><br>
</div>
<div>=========================================</div>
<div>2. ADD SOME KEY/VALUE PAIRS FOR TESTING</div>
<div>=========================================</div>
<div><br>
</div>
<div>Here’s we’ll populate the ‘classification’ policy with a few key/value pairs.</div>
<div><br>
</div>
<div>$ openstack congress policy rule create classification 'p(101, 0)'</div>
<div>$ openstack congress policy rule create classification 'p(202, "abc")'</div>
<div>$ openstack congress policy rule create classification 'p(302, 9)'</div>
<div><br>
</div>
<div><br>
</div>
<div>==================</div>
<div>3. DEFINE POLICY</div>
<div>==================</div>
<div><br>
</div>
<div>There's an error if a key's value is 9.</div>
<div><br>
</div>
<div>$ openstack congress policy rule create classification 'error(x) :- p(x, 9)'</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>===========================</div>
<div>4. RUN SIMULATION QUERIES</div>
<div>===========================</div>
<div><br>
</div>
<div>Each of the following is an example of a simulation query you might want to run.</div>
<div><br>
</div>
<div>a) <span class="highlight" id="0.4815767384134233" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span> changing the value of key 101 to 5 and query the contents of p.</div>
<div><br>
</div>
<div>$ openstack congress policy <span class="highlight" id="0.7201062496751547" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'p(x,y)' 'set(101, 5)' action</div>
<div>p(101, 5)</div>
<div>p(202, "abc")</div>
<div>p(302, 9)</div>
<div><br>
</div>
<div><br>
</div>
<div>b) <span class="highlight" id="0.38951995270326734" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span> changing the value of key 101 to 5 and query the error table</div>
<div><br>
</div>
<div>$ openstack congress policy <span class="highlight" id="0.7372662862762809" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'error(x)' 'set(101, 5)' action</div>
<div>error(302)</div>
<div><br>
</div>
<div><br>
</div>
<div>c) <span class="highlight" id="0.04069255664944649" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span> changing the value of key 101 to 9 and query the error table.</div>
<div><br>
</div>
<div>$ openstack congress policy <span class="highlight" id="0.5499595468863845" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'error(x)' 'set(101, 9)' action</div>
<div>error(302)</div>
<div>error(101)</div>
<div><br>
</div>
<div><br>
</div>
<div>d) <span class="highlight" id="0.3806434255093336" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span> changing the value of key 101 to 9 and query the *change* in the error table.</div>
<div><br>
</div>
<div>$ openstack congress policy <span class="highlight" id="0.4143459328915924" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'error(x)' 'set(101, 9)' action --delta</div>
<div>error+(101)</div>
<div><br>
</div>
<div><br>
</div>
<div>e) <span class="highlight" id="0.2890288799535483" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span> changing 101:9, 202:9, 302:1 and query the *change* in the error table.</div>
<div><br>
</div>
<div>$ openstack congress policy <span class="highlight" id="0.3181253499351442" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'error(x)' 'set(101, 9) set(202, 9) set(302, 1)' action --delta</div>
<div>error+(202)</div>
<div>error+(101)</div>
<div>error-(302)</div>
<div><br>
</div>
<div><br>
</div>
<div>f) <span class="highlight" id="0.00026599736884236336" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span> changing 101:9, 202:9, 302:1, and finally 101:15 (in that order).  Then query the *change* in the error table.</div>
<div><br>
</div>
<div>$ openstack congress policy <span class="highlight" id="0.8287185872904956" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'error(x)' 'set(101, 9) set(202, 9) set(302, 1) set(101, 15)' action
 --delta</div>
<div>error+(202)</div>
<div>error-(302)</div>
<div><br>
</div>
<div><br>
</div>
<div>g) <span class="highlight" id="0.9235040170606226" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span> changing 101:9 and query the *change* in the error table, while asking for a debug trace of the computation.</div>
<div><br>
</div>
<div>$ openstack congress policy <span class="highlight" id="0.2082621529698372" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">simulate</span> classification 'error(x)' 'set(101, 9)' action --delta --trace</div>
<div><br>
</div>
<div>error+(101)</div>
<div>RT    : ** <span class="highlight" id="0.645440922351554" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span>: Querying error(x)</div>
<div>Clas  : Call: error(x)</div>
<div>Clas  : | Call: p(x, 9)</div>
<div>Clas  : | Exit: p(302, 9)</div>
<div>Clas  : Exit: error(302)</div>
<div>Clas  : Redo: error(302)</div>
<div>Clas  : | Redo: p(302, 9)</div>
<div>Clas  : | Fail: p(x, 9)</div>
<div>Clas  : Fail: error(x)</div>
<div>Clas  : Found answer [error(302)]</div>
<div>RT    : Original result of error(x) is [error(302)]</div>
<div>RT    : ** <span class="highlight" id="0.02821197104640305" name="searchHitInReadingPane" style="background-color: rgb(255, 238, 148);">Simulate</span>: Applying sequence [set(101, 9)]</div>
<div>Action: Call: action(x)</div>
<div>...</div>
</div>
<div><br>
</div>
</span></font></span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;">Tim</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"><br>
</span></font></div>
<div style="color: rgb(40, 40, 40); font-family: 'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<font face="Calibri,sans-serif" size="2" color="black"><span style="font-size: 14px;"> </span></font></div>
<p><br>
</p>
<div style="color: rgb(40, 40, 40);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Tran, Steven <steven.tran2@hp.com><br>
<b>Sent:</b> Monday, December 22, 2014 10:38 PM<br>
<b>To:</b> openstack-dev@lists.openstack.org<br>
<b>Subject:</b> [openstack-dev] [Congress] simulate examples</font>
<div> </div>
</div>
<div>
<div class="WordSection1">
<p class="MsoNormal">Hi,</p>
<p class="MsoNormal">   Does anyone have an example on how to use ‘simulate’ according to the following command line usage?</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">usage: openstack congress policy simulate [-h] [--delta] [--trace]</p>
<p class="MsoNormal">                                          <policy> <query> <sequence></p>
<p class="MsoNormal">                                          <action_policy></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">  What are the query and sequence? The example under /opt/stack/congress/examples doesn’t mention about query and sequence.  It seems like all 4 parameters are required.</p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">-Steven</p>
</div>
</div>
</div>
</div>
</body>
</html>