Commit 0e20afdd authored by Spiros Koulouzis's avatar Spiros Koulouzis

implement transformer component

parent 842f448b
...@@ -16,3 +16,7 @@ ...@@ -16,3 +16,7 @@
/argo_optimizer/nbproject/private/ /argo_optimizer/nbproject/private/
/drip_planner2/nbproject/private/ /drip_planner2/nbproject/private/
/drip-deployer/deployer_files/ /drip-deployer/deployer_files/
/drip_planner2 (copy)/nbproject/private/
/drip_util/nbproject/private/
/drip_transformer/nbproject/private/
/drip_parser/nbproject/private/
\ No newline at end of file
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
<tbody data-link="row" class="rowlink"> <tbody data-link="row" class="rowlink">
<tr class="clickable-row" data-href="drip-api-php.zip"> <tr class="clickable-row" data-href="drip-api-php.zip">
<td><span class="downloadfile-name">drip-api-php.zip</span></td> <td><span class="downloadfile-name">drip-api-php.zip</span></td>
<td><span class="downloadfile-size">5.95K</span></td> <td><span class="downloadfile-size">5.96K</span></td>
<td><span class="downloadfile-description">&nbsp;</span></td> <td><span class="downloadfile-description">&nbsp;</span></td>
</tr> </tr>
</tbody> </tbody>
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
<tbody data-link="row" class="rowlink"> <tbody data-link="row" class="rowlink">
<tr class="clickable-row" data-href="drip-api-php.zip"> <tr class="clickable-row" data-href="drip-api-php.zip">
<td><span class="downloadfile-name">drip-api-php.zip</span></td> <td><span class="downloadfile-name">drip-api-php.zip</span></td>
<td><span class="downloadfile-size">9.08K</span></td> <td><span class="downloadfile-size">9.07K</span></td>
<td><span class="downloadfile-description">&nbsp;</span></td> <td><span class="downloadfile-description">&nbsp;</span></td>
</tr> </tr>
</tbody> </tbody>
......
This diff is collapsed.
...@@ -331,12 +331,14 @@ used by the provisoner to run on the created VMs.</span> ...@@ -331,12 +331,14 @@ used by the provisoner to run on the created VMs.</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/transform/{id}</span>
</samp></li></ul></td> </samp></li></ul></td>
<td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span> <td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li></ul></td> </samp></li></ul></td>
<td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be <td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be
used by the planner.</span> used by the planner.</span>
......
...@@ -90,18 +90,18 @@ class</p> ...@@ -90,18 +90,18 @@ class</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">vmType</span> <td> <span class="property-name">start</span>
</td> </td>
<td> <span class="datatype-reference">string <td> <span class="datatype-reference">number
</span> </span>
</td> </td>
<td> <span class="property-description"></span> <td> <span class="property-description"></span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">end</span> <td> <span class="property-name">cloudDeploymentDomain</span>
</td> </td>
<td> <span class="datatype-reference">number <td> <span class="datatype-reference">string
</span> </span>
</td> </td>
<td> <span class="property-description"></span> <td> <span class="property-description"></span>
...@@ -117,18 +117,18 @@ class</p> ...@@ -117,18 +117,18 @@ class</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">cloudDeploymentDomain</span> <td> <span class="property-name">end</span>
</td> </td>
<td> <span class="datatype-reference">string <td> <span class="datatype-reference">number
</span> </span>
</td> </td>
<td> <span class="property-description"></span> <td> <span class="property-description"></span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">start</span> <td> <span class="property-name">vmType</span>
</td> </td>
<td> <span class="datatype-reference">number <td> <span class="datatype-reference">string
</span> </span>
</td> </td>
<td> <span class="property-description"></span> <td> <span class="property-description"></span>
...@@ -166,11 +166,11 @@ object is saved.</span></td> ...@@ -166,11 +166,11 @@ object is saved.</span></td>
<pre class="prettyprint language-js example">{ <pre class="prettyprint language-js example">{
&quot;host&quot; : &quot;147.228.242.58&quot;, &quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;vmType&quot; : &quot;...&quot;,
&quot;end&quot; : 12345,
&quot;delta&quot; : 12345,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;start&quot; : 12345, &quot;start&quot; : 12345,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;delta&quot; : 12345,
&quot;end&quot; : 12345,
&quot;vmType&quot; : &quot;...&quot;,
&quot;owner&quot; : &quot;user1&quot;, &quot;owner&quot; : &quot;user1&quot;,
&quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;, &quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;,
&quot;timestamp&quot; : 1499793079011 &quot;timestamp&quot; : 1499793079011
......
...@@ -823,18 +823,18 @@ class]]> ...@@ -823,18 +823,18 @@ class]]>
<xs:complexContent> <xs:complexContent>
<xs:extension base="ownedObject"> <xs:extension base="ownedObject">
<xs:sequence> <xs:sequence>
<xs:element name="start" type="xs:dateTime" minOccurs="0"> <xs:element name="cloudDeploymentDomain" type="xs:string" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="delta" type="xs:dateTime" minOccurs="0"> <xs:element name="delta" type="xs:dateTime" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="cloudDeploymentDomain" type="xs:string" minOccurs="0"> <xs:element name="start" type="xs:dateTime" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="end" type="xs:dateTime" minOccurs="0"> <xs:element name="end" type="xs:dateTime" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="host" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="vmType" type="xs:string" minOccurs="0"> <xs:element name="vmType" type="xs:string" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="host" type="xs:string" minOccurs="0">
</xs:element>
</xs:sequence> </xs:sequence>
</xs:extension> </xs:extension>
</xs:complexContent> </xs:complexContent>
......
...@@ -145,11 +145,11 @@ Content-Type: application/json ...@@ -145,11 +145,11 @@ Content-Type: application/json
<code class="prettyprint language-js"> <code class="prettyprint language-js">
[ { [ {
&quot;host&quot; : &quot;147.228.242.58&quot;, &quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;vmType&quot; : &quot;...&quot;,
&quot;end&quot; : 12345,
&quot;delta&quot; : 12345,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;start&quot; : 12345, &quot;start&quot; : 12345,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;delta&quot; : 12345,
&quot;end&quot; : 12345,
&quot;vmType&quot; : &quot;...&quot;,
&quot;owner&quot; : &quot;user1&quot;, &quot;owner&quot; : &quot;user1&quot;,
&quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;, &quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;,
&quot;timestamp&quot; : 1499793079011 &quot;timestamp&quot; : 1499793079011
...@@ -515,11 +515,11 @@ Content-Type: application/json ...@@ -515,11 +515,11 @@ Content-Type: application/json
<code class="prettyprint language-js"> <code class="prettyprint language-js">
{ {
&quot;host&quot; : &quot;147.228.242.58&quot;, &quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;vmType&quot; : &quot;...&quot;,
&quot;end&quot; : 12345,
&quot;delta&quot; : 12345,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;start&quot; : 12345, &quot;start&quot; : 12345,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;delta&quot; : 12345,
&quot;end&quot; : 12345,
&quot;vmType&quot; : &quot;...&quot;,
&quot;owner&quot; : &quot;user1&quot;, &quot;owner&quot; : &quot;user1&quot;,
&quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;, &quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;,
&quot;timestamp&quot; : 1499793079011 &quot;timestamp&quot; : 1499793079011
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
<li><a href="#resource_ToscaController_toscaUpload_POST">POST /user/v1.0/tosca/upload</a></li> <li><a href="#resource_ToscaController_toscaUpload_POST">POST /user/v1.0/tosca/upload</a></li>
<li><a href="#resource_ToscaController_delete_DELETE">DELETE /user/v1.0/tosca/{id}</a></li> <li><a href="#resource_ToscaController_delete_DELETE">DELETE /user/v1.0/tosca/{id}</a></li>
<li><a href="#resource_ToscaController_get_GET">GET /user/v1.0/tosca/{id}</a></li> <li><a href="#resource_ToscaController_get_GET">GET /user/v1.0/tosca/{id}</a></li>
<li><a href="#resource_ToscaController_transform_GET"><abbr title="GET /user/v1.0/tosca/transform/{id}">GET /user/v1.0/tosca/transform...</abbr></a></li>
<li class="divider"></li> <li class="divider"></li>
<li class="text-right"><a href="#top"><small>Back to Top</small></a></li> <li class="text-right"><a href="#top"><small>Back to Top</small></a></li>
</ul> </ul>
...@@ -77,7 +78,7 @@ used by the planner.</p> ...@@ -77,7 +78,7 @@ used by the planner.</p>
<div id="resource_ToscaController_deleteAll_DELETE"> <div id="resource_ToscaController_deleteAll_DELETE">
<h3><span class="label label-default resource-method">DELETE</span> <span class="resource-path">/user/v1.0/tosca/all <a href="../user/v1.0/tosca/all" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3> <h3><span class="label label-default resource-method">DELETE</span> <span class="resource-path">/user/v1.0/tosca/all <a href="../user/v1.0/tosca/all" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3>
<p>Gets the IDs of all the stored TOSCA descriptionss.</p> <p>Gets the IDs of all the stored TOSCA descriptions.</p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Security Roles Allowed</dt> <dt>Security Roles Allowed</dt>
...@@ -153,7 +154,7 @@ Content-Type: application/json ...@@ -153,7 +154,7 @@ Content-Type: application/json
<div id="resource_ToscaController_getIds_GET"> <div id="resource_ToscaController_getIds_GET">
<h3><span class="label label-default resource-method">GET</span> <span class="resource-path">/user/v1.0/tosca/ids <a href="../user/v1.0/tosca/ids" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3> <h3><span class="label label-default resource-method">GET</span> <span class="resource-path">/user/v1.0/tosca/ids <a href="../user/v1.0/tosca/ids" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3>
<p>Gets the IDs of all the stored TOSCA descriptionss.</p> <p>Gets the IDs of all the stored TOSCA descriptions.</p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Security Roles Allowed</dt> <dt>Security Roles Allowed</dt>
...@@ -609,6 +610,108 @@ Accept: application/json ...@@ -609,6 +610,108 @@ Accept: application/json
<h5>Response</h5> <h5>Response</h5>
<pre> <pre>
HTTP/1.1 200 Looks Good HTTP/1.1 200 Looks Good
Content-Type: application/json
<code class="prettyprint language-txt">
...
</code>
</pre>
</div>
</div>
</div>
</div>
<div id="resource_ToscaController_transform_GET">
<h3><span class="label label-default resource-method">GET</span> <span class="resource-path">/user/v1.0/tosca/transform/{id} <a href="../user/v1.0/tosca/transform/{id}" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3>
<p>Transforms the TOSCA description to docker compose</p>
<dl class="dl-horizontal">
<dt>Security Roles Allowed</dt>
<dd>ADMIN, USER</dd>
</dl>
<table class="table resource-parameters">
<caption>Request Parameters</caption>
<thead>
<tr>
<th>name</th>
<th>type</th>
<th>description</th>
<th>constraints</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parameter-name">id</span></td>
<td>path</td>
<td><span class="parameter-description">the ID TOSCA description.</span></td>
<td><span class="parameter-constraints">required</span></td>
</tr>
<tr>
<td><span class="parameter-name">type</span></td>
<td>query</td>
<td><span class="parameter-description">&nbsp;</span></td>
<td><span class="parameter-constraints">required</span></td>
</tr>
</tbody>
</table>
<table class="table resource-response-codes">
<caption>Response Codes</caption>
<thead>
<tr>
<th>code</th>
<th>condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="label label-warning response-code">401</span></td>
<td><span class="response-condition">Bad credentials</span></td>
</tr>
</tbody>
</table>
<table class="table resource-response-body">
<caption>Response Body</caption>
<thead>
<tr>
<th>media type</th>
<th>data type</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td><abbr data-toggle="tooltip" data-placement="top" title="Use the &quot;Accept: application/json&quot; HTTP header to request that this media type be provided by the server."><span class="response-type">application/json</span></abbr></td>
<td><span class="datatype-reference">string
(JSON)</span></td>
<td rowspan="2" class="multi-row-description"><span class="response-description">the docker-compose.</span></td>
</tr>
<tr>
<td><abbr data-toggle="tooltip" data-placement="top" title="Use the &quot;Accept: application/xml&quot; HTTP header to request that this media type be provided by the server."><span class="response-type">application/xml</span></abbr></td>
<td><span class="datatype-reference">string
(XML)</span></td>
</tr>
</tbody>
</table>
<h4>Example</h4>
<div class="container-fluid example panel">
<div class="row panel-body">
<div class="col-md-6">
<h5>Request</h5>
<pre>
GET /user/v1.0/tosca/transform/{id}
Accept: application/json
</pre>
</div>
<div class="col-md-6">
<h5>Response</h5>
<pre>
HTTP/1.1 200 Looks Good
Content-Type: application/json Content-Type: application/json
<code class="prettyprint language-txt"> <code class="prettyprint language-txt">
......
...@@ -323,12 +323,14 @@ used by the provisoner to run on the created VMs.</span> ...@@ -323,12 +323,14 @@ used by the provisoner to run on the created VMs.</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/transform/{id}</span>
</samp></li></ul></td> </samp></li></ul></td>
<td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span> <td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li></ul></td> </samp></li></ul></td>
<td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be <td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be
used by the planner.</span> used by the planner.</span>
......
...@@ -231,12 +231,12 @@ the DAO saves the object based on the principal how made the call</span></td> ...@@ -231,12 +231,12 @@ the DAO saves the object based on the principal how made the call</span></td>
<p class="lead">Example</p> <p class="lead">Example</p>
<pre class="prettyprint language-xml example">&lt;b-----&gt; <pre class="prettyprint language-xml example">&lt;b-----&gt;
&lt;start&gt;...&lt;/start&gt;
&lt;delta&gt;...&lt;/delta&gt;
&lt;cloudDeploymentDomain&gt;us-east-1&lt;/cloudDeploymentDomain&gt; &lt;cloudDeploymentDomain&gt;us-east-1&lt;/cloudDeploymentDomain&gt;
&lt;delta&gt;...&lt;/delta&gt;
&lt;start&gt;...&lt;/start&gt;
&lt;end&gt;...&lt;/end&gt; &lt;end&gt;...&lt;/end&gt;
&lt;host&gt;147.228.242.58&lt;/host&gt;
&lt;vmType&gt;...&lt;/vmType&gt; &lt;vmType&gt;...&lt;/vmType&gt;
&lt;host&gt;147.228.242.58&lt;/host&gt;
&lt;owner&gt;user1&lt;/owner&gt; &lt;owner&gt;user1&lt;/owner&gt;
&lt;timestamp&gt;1499793079011&lt;/timestamp&gt; &lt;timestamp&gt;1499793079011&lt;/timestamp&gt;
&lt;/b-----&gt; &lt;/b-----&gt;
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
<tbody data-link="row" class="rowlink"> <tbody data-link="row" class="rowlink">
<tr class="clickable-row" data-href="drip-api-php.zip"> <tr class="clickable-row" data-href="drip-api-php.zip">
<td><span class="downloadfile-name">drip-api-php.zip</span></td> <td><span class="downloadfile-name">drip-api-php.zip</span></td>
<td><span class="downloadfile-size">5.95K</span></td> <td><span class="downloadfile-size">5.96K</span></td>
<td><span class="downloadfile-description">&nbsp;</span></td> <td><span class="downloadfile-description">&nbsp;</span></td>
</tr> </tr>
</tbody> </tbody>
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
<tbody data-link="row" class="rowlink"> <tbody data-link="row" class="rowlink">
<tr class="clickable-row" data-href="drip-api-php.zip"> <tr class="clickable-row" data-href="drip-api-php.zip">
<td><span class="downloadfile-name">drip-api-php.zip</span></td> <td><span class="downloadfile-name">drip-api-php.zip</span></td>
<td><span class="downloadfile-size">9.08K</span></td> <td><span class="downloadfile-size">9.07K</span></td>
<td><span class="downloadfile-description">&nbsp;</span></td> <td><span class="downloadfile-description">&nbsp;</span></td>
</tr> </tr>
</tbody> </tbody>
......
This diff is collapsed.
...@@ -331,12 +331,14 @@ used by the provisoner to run on the created VMs.</span> ...@@ -331,12 +331,14 @@ used by the provisoner to run on the created VMs.</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/transform/{id}</span>
</samp></li></ul></td> </samp></li></ul></td>
<td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span> <td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li></ul></td> </samp></li></ul></td>
<td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be <td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be
used by the planner.</span> used by the planner.</span>
......
...@@ -90,7 +90,7 @@ class</p> ...@@ -90,7 +90,7 @@ class</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">host</span> <td> <span class="property-name">cloudDeploymentDomain</span>
</td> </td>
<td> <span class="datatype-reference">string <td> <span class="datatype-reference">string
</span> </span>
...@@ -99,7 +99,7 @@ class</p> ...@@ -99,7 +99,7 @@ class</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">cloudDeploymentDomain</span> <td> <span class="property-name">host</span>
</td> </td>
<td> <span class="datatype-reference">string <td> <span class="datatype-reference">string
</span> </span>
...@@ -108,7 +108,7 @@ class</p> ...@@ -108,7 +108,7 @@ class</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">end</span> <td> <span class="property-name">start</span>
</td> </td>
<td> <span class="datatype-reference">number <td> <span class="datatype-reference">number
</span> </span>
...@@ -117,7 +117,7 @@ class</p> ...@@ -117,7 +117,7 @@ class</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <span class="property-name">start</span> <td> <span class="property-name">end</span>
</td> </td>
<td> <span class="datatype-reference">number <td> <span class="datatype-reference">number
</span> </span>
...@@ -166,10 +166,10 @@ object is saved.</span></td> ...@@ -166,10 +166,10 @@ object is saved.</span></td>
<pre class="prettyprint language-js example">{ <pre class="prettyprint language-js example">{
&quot;delta&quot; : 12345, &quot;delta&quot; : 12345,
&quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;, &quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;end&quot; : 12345, &quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;start&quot; : 12345, &quot;start&quot; : 12345,
&quot;end&quot; : 12345,
&quot;vmType&quot; : &quot;...&quot;, &quot;vmType&quot; : &quot;...&quot;,
&quot;owner&quot; : &quot;user1&quot;, &quot;owner&quot; : &quot;user1&quot;,
&quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;, &quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;,
......
...@@ -69,7 +69,7 @@ class</p> ...@@ -69,7 +69,7 @@ class</p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Subtypes</dt> <dt>Subtypes</dt>
<dd><a href="json_KeyPair.html">KeyPair</a>, <a href="json_AnsibleOutput.html">AnsibleOutput</a>, <a href="json_ScaleRequest.html">ScaleRequest</a>, <a href="json_BenchmarkResult.html">BenchmarkResult</a>, <a href="json_CloudCredentials.html">CloudCredentials</a>, <a href="json_DeployResponse.html">DeployResponse</a>, <a href="json_ProvisionRequest.html">ProvisionRequest</a>, <a href="json_Script.html">Script</a>, <a href="json_KeyValueHolder.html">KeyValueHolder</a>, <a href="json_DeployRequest.html">DeployRequest</a>, <a href="json_ProvisionResponse.html">ProvisionResponse</a></dd> <dd><a href="json_KeyPair.html">KeyPair</a>, <a href="json_AnsibleOutput.html">AnsibleOutput</a>, <a href="json_ScaleRequest.html">ScaleRequest</a>, <a href="json_CloudCredentials.html">CloudCredentials</a>, <a href="json_BenchmarkResult.html">BenchmarkResult</a>, <a href="json_DeployResponse.html">DeployResponse</a>, <a href="json_ProvisionRequest.html">ProvisionRequest</a>, <a href="json_Script.html">Script</a>, <a href="json_KeyValueHolder.html">KeyValueHolder</a>, <a href="json_DeployRequest.html">DeployRequest</a>, <a href="json_ProvisionResponse.html">ProvisionResponse</a></dd>
</dl> </dl>
<table class="table datatype-properties"> <table class="table datatype-properties">
......
...@@ -823,18 +823,18 @@ class]]> ...@@ -823,18 +823,18 @@ class]]>
<xs:complexContent> <xs:complexContent>
<xs:extension base="ownedObject"> <xs:extension base="ownedObject">
<xs:sequence> <xs:sequence>
<xs:element name="delta" type="xs:dateTime" minOccurs="0"> <xs:element name="cloudDeploymentDomain" type="xs:string" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="end" type="xs:dateTime" minOccurs="0"> <xs:element name="host" type="xs:string" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="vmType" type="xs:string" minOccurs="0"> <xs:element name="vmType" type="xs:string" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="cloudDeploymentDomain" type="xs:string" minOccurs="0"> <xs:element name="delta" type="xs:dateTime" minOccurs="0">
</xs:element>
<xs:element name="host" type="xs:string" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="start" type="xs:dateTime" minOccurs="0"> <xs:element name="start" type="xs:dateTime" minOccurs="0">
</xs:element> </xs:element>
<xs:element name="end" type="xs:dateTime" minOccurs="0">
</xs:element>
</xs:sequence> </xs:sequence>
</xs:extension> </xs:extension>
</xs:complexContent> </xs:complexContent>
......
...@@ -145,10 +145,10 @@ Content-Type: application/json ...@@ -145,10 +145,10 @@ Content-Type: application/json
<code class="prettyprint language-js"> <code class="prettyprint language-js">
[ { [ {
&quot;delta&quot; : 12345, &quot;delta&quot; : 12345,
&quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;, &quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;end&quot; : 12345, &quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;start&quot; : 12345, &quot;start&quot; : 12345,
&quot;end&quot; : 12345,
&quot;vmType&quot; : &quot;...&quot;, &quot;vmType&quot; : &quot;...&quot;,
&quot;owner&quot; : &quot;user1&quot;, &quot;owner&quot; : &quot;user1&quot;,
&quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;, &quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;,
...@@ -515,10 +515,10 @@ Content-Type: application/json ...@@ -515,10 +515,10 @@ Content-Type: application/json
<code class="prettyprint language-js"> <code class="prettyprint language-js">
{ {
&quot;delta&quot; : 12345, &quot;delta&quot; : 12345,
&quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;, &quot;cloudDeploymentDomain&quot; : &quot;us-east-1&quot;,
&quot;end&quot; : 12345, &quot;host&quot; : &quot;147.228.242.58&quot;,
&quot;start&quot; : 12345, &quot;start&quot; : 12345,
&quot;end&quot; : 12345,
&quot;vmType&quot; : &quot;...&quot;, &quot;vmType&quot; : &quot;...&quot;,
&quot;owner&quot; : &quot;user1&quot;, &quot;owner&quot; : &quot;user1&quot;,
&quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;, &quot;id&quot; : &quot;58e3946e0fb4f562d84ba1ad&quot;,
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
<li><a href="#resource_ToscaController_toscaUpload_POST">POST /user/v1.0/tosca/upload</a></li> <li><a href="#resource_ToscaController_toscaUpload_POST">POST /user/v1.0/tosca/upload</a></li>
<li><a href="#resource_ToscaController_delete_DELETE">DELETE /user/v1.0/tosca/{id}</a></li> <li><a href="#resource_ToscaController_delete_DELETE">DELETE /user/v1.0/tosca/{id}</a></li>
<li><a href="#resource_ToscaController_get_GET">GET /user/v1.0/tosca/{id}</a></li> <li><a href="#resource_ToscaController_get_GET">GET /user/v1.0/tosca/{id}</a></li>
<li><a href="#resource_ToscaController_transform_GET"><abbr title="GET /user/v1.0/tosca/transform/{id}">GET /user/v1.0/tosca/transform...</abbr></a></li>
<li class="divider"></li> <li class="divider"></li>
<li class="text-right"><a href="#top"><small>Back to Top</small></a></li> <li class="text-right"><a href="#top"><small>Back to Top</small></a></li>
</ul> </ul>
...@@ -77,7 +78,7 @@ used by the planner.</p> ...@@ -77,7 +78,7 @@ used by the planner.</p>
<div id="resource_ToscaController_deleteAll_DELETE"> <div id="resource_ToscaController_deleteAll_DELETE">
<h3><span class="label label-default resource-method">DELETE</span> <span class="resource-path">/user/v1.0/tosca/all <a href="./user/v1.0/tosca/all" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3> <h3><span class="label label-default resource-method">DELETE</span> <span class="resource-path">/user/v1.0/tosca/all <a href="./user/v1.0/tosca/all" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3>
<p>Gets the IDs of all the stored TOSCA descriptionss.</p> <p>Gets the IDs of all the stored TOSCA descriptions.</p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Security Roles Allowed</dt> <dt>Security Roles Allowed</dt>
...@@ -153,7 +154,7 @@ Content-Type: application/json ...@@ -153,7 +154,7 @@ Content-Type: application/json
<div id="resource_ToscaController_getIds_GET"> <div id="resource_ToscaController_getIds_GET">
<h3><span class="label label-default resource-method">GET</span> <span class="resource-path">/user/v1.0/tosca/ids <a href="./user/v1.0/tosca/ids" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3> <h3><span class="label label-default resource-method">GET</span> <span class="resource-path">/user/v1.0/tosca/ids <a href="./user/v1.0/tosca/ids" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3>
<p>Gets the IDs of all the stored TOSCA descriptionss.</p> <p>Gets the IDs of all the stored TOSCA descriptions.</p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Security Roles Allowed</dt> <dt>Security Roles Allowed</dt>
...@@ -609,6 +610,108 @@ Accept: application/json ...@@ -609,6 +610,108 @@ Accept: application/json
<h5>Response</h5> <h5>Response</h5>
<pre> <pre>
HTTP/1.1 200 Looks Good HTTP/1.1 200 Looks Good
Content-Type: application/json
<code class="prettyprint language-txt">
...
</code>
</pre>
</div>
</div>
</div>
</div>
<div id="resource_ToscaController_transform_GET">
<h3><span class="label label-default resource-method">GET</span> <span class="resource-path">/user/v1.0/tosca/transform/{id} <a href="./user/v1.0/tosca/transform/{id}" class="glyphicon glyphicon-new-window" target="_blank"></a></span></h3>
<p>Transforms the TOSCA description to docker compose</p>
<dl class="dl-horizontal">
<dt>Security Roles Allowed</dt>
<dd>ADMIN, USER</dd>
</dl>
<table class="table resource-parameters">
<caption>Request Parameters</caption>
<thead>
<tr>
<th>name</th>
<th>type</th>
<th>description</th>
<th>constraints</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parameter-name">id</span></td>
<td>path</td>
<td><span class="parameter-description">the ID TOSCA description.</span></td>
<td><span class="parameter-constraints">required</span></td>
</tr>
<tr>
<td><span class="parameter-name">type</span></td>
<td>query</td>
<td><span class="parameter-description">&nbsp;</span></td>
<td><span class="parameter-constraints">required</span></td>
</tr>
</tbody>
</table>
<table class="table resource-response-codes">
<caption>Response Codes</caption>
<thead>
<tr>
<th>code</th>
<th>condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="label label-warning response-code">401</span></td>
<td><span class="response-condition">Bad credentials</span></td>
</tr>
</tbody>
</table>
<table class="table resource-response-body">
<caption>Response Body</caption>
<thead>
<tr>
<th>media type</th>
<th>data type</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td><abbr data-toggle="tooltip" data-placement="top" title="Use the &quot;Accept: application/json&quot; HTTP header to request that this media type be provided by the server."><span class="response-type">application/json</span></abbr></td>
<td><span class="datatype-reference">string
(JSON)</span></td>
<td rowspan="2" class="multi-row-description"><span class="response-description">the docker-compose.</span></td>
</tr>
<tr>
<td><abbr data-toggle="tooltip" data-placement="top" title="Use the &quot;Accept: application/xml&quot; HTTP header to request that this media type be provided by the server."><span class="response-type">application/xml</span></abbr></td>
<td><span class="datatype-reference">string
(XML)</span></td>
</tr>
</tbody>
</table>
<h4>Example</h4>
<div class="container-fluid example panel">
<div class="row panel-body">
<div class="col-md-6">
<h5>Request</h5>
<pre>
GET /user/v1.0/tosca/transform/{id}
Accept: application/json
</pre>
</div>
<div class="col-md-6">
<h5>Response</h5>
<pre>
HTTP/1.1 200 Looks Good
Content-Type: application/json Content-Type: application/json
<code class="prettyprint language-txt"> <code class="prettyprint language-txt">
......
...@@ -323,12 +323,14 @@ used by the provisoner to run on the created VMs.</span> ...@@ -323,12 +323,14 @@ used by the provisoner to run on the created VMs.</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/post</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/upload</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span> </samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/{id}</span>
</samp></li><li><samp> <span class="resource-path">/user/v1.0/tosca/transform/{id}</span>
</samp></li></ul></td> </samp></li></ul></td>
<td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span> <td class="text-nowrap"><ul class="list-unstyled"><li><samp> <span class="label label-default resource-method">DELETE</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">POST</span> </samp></li><li><samp> <span class="label label-default resource-method">POST</span>
</samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span> </samp></li><li><samp> <span class="label label-default resource-method">DELETE</span> <span class="label label-default resource-method">GET</span>
</samp></li><li><samp> <span class="label label-default resource-method">GET</span>
</samp></li></ul></td> </samp></li></ul></td>
<td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be <td> <span class="resource-description">This controller is responsible for storing TOSCA descriptions that can be
used by the planner.</span> used by the planner.</span>
......
...@@ -231,12 +231,12 @@ the DAO saves the object based on the principal how made the call</span></td> ...@@ -231,12 +231,12 @@ the DAO saves the object based on the principal how made the call</span></td>
<p class="lead">Example</p> <p class="lead">Example</p>
<pre class="prettyprint language-xml example">&lt;b-----&gt; <pre class="prettyprint language-xml example">&lt;b-----&gt;
&lt;delta&gt;...&lt;/delta&gt;
&lt;end&gt;...&lt;/end&gt;
&lt;vmType&gt;...&lt;/vmType&gt;
&lt;cloudDeploymentDomain&gt;us-east-1&lt;/cloudDeploymentDomain&gt; &lt;cloudDeploymentDomain&gt;us-east-1&lt;/cloudDeploymentDomain&gt;
&lt;host&gt;147.228.242.58&lt;/host&gt; &lt;host&gt;147.228.242.58&lt;/host&gt;
&lt;vmType&gt;...&lt;/vmType&gt;
&lt;delta&gt;...&lt;/delta&gt;
&lt;start&gt;...&lt;/start&gt; &lt;start&gt;...&lt;/start&gt;
&lt;end&gt;...&lt;/end&gt;
&lt;owner&gt;user1&lt;/owner&gt; &lt;owner&gt;user1&lt;/owner&gt;
&lt;timestamp&gt;1499793079011&lt;/timestamp&gt; &lt;timestamp&gt;1499793079011&lt;/timestamp&gt;
&lt;/b-----&gt; &lt;/b-----&gt;
......
This diff is collapsed.
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.api.rpc;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
/**
*
* @author S. Koulouzis
*/
public class TransformerCaller extends DRIPCaller {
private static final String REQUEST_QUEUE_NAME = "tosca_2_docker_compose_queue";
public TransformerCaller(String messageBrokerHost) throws IOException, TimeoutException {
super(messageBrokerHost, REQUEST_QUEUE_NAME);
}
}
...@@ -16,16 +16,24 @@ ...@@ -16,16 +16,24 @@
package nl.uva.sne.drip.api.service; package nl.uva.sne.drip.api.service;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeoutException;
import nl.uva.sne.drip.api.dao.ToscaDao; import nl.uva.sne.drip.api.dao.ToscaDao;
import nl.uva.sne.drip.api.exception.NotFoundException; import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.rpc.DRIPCaller;
import nl.uva.sne.drip.api.rpc.DeployerCaller;
import nl.uva.sne.drip.api.rpc.TransformerCaller;
import nl.uva.sne.drip.commons.utils.Constants; import nl.uva.sne.drip.commons.utils.Constants;
import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation; import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Converter; import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.drip.commons.data.internal.Message;
import nl.uva.sne.drip.drip.commons.data.internal.MessageParameter;
import nl.uva.sne.drip.drip.commons.data.v1.external.User; import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -44,6 +52,25 @@ public class ToscaService { ...@@ -44,6 +52,25 @@ public class ToscaService {
@Autowired @Autowired
private ToscaDao dao; private ToscaDao dao;
@Value("${message.broker.host}")
private String messageBrokerHost;
public String get(Map<String, Object> map, String fromat) throws JSONException {
if (fromat != null && fromat.equals("yml")) {
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
if (fromat != null && fromat.equals("json")) {
String jsonStr = Converter.map2JsonString(map);
jsonStr = jsonStr.replaceAll("\\uff0E", ".");
return jsonStr;
}
String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", ".");
return ymlStr;
}
public String get(String id, String fromat) throws JSONException { public String get(String id, String fromat) throws JSONException {
ToscaRepresentation tosca = findOne(id); ToscaRepresentation tosca = findOne(id);
if (tosca == null) { if (tosca == null) {
...@@ -51,7 +78,6 @@ public class ToscaService { ...@@ -51,7 +78,6 @@ public class ToscaService {
} }
Map<String, Object> map = tosca.getKeyValue(); Map<String, Object> map = tosca.getKeyValue();
if (fromat != null && fromat.equals("yml")) { if (fromat != null && fromat.equals("yml")) {
String ymlStr = Converter.map2YmlString(map); String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "."); ymlStr = ymlStr.replaceAll("\\uff0E", ".");
...@@ -119,9 +145,7 @@ public class ToscaService { ...@@ -119,9 +145,7 @@ public class ToscaService {
} }
public String saveStringContents(String toscaContents, String name) throws IOException { public String saveStringContents(String toscaContents, String name) throws IOException {
Map<String, Object> map = Converter.cleanStringContents(toscaContents, true);
Map<String, Object> map = Converter.cleanStringContents(toscaContents,true);
ToscaRepresentation t = new ToscaRepresentation(); ToscaRepresentation t = new ToscaRepresentation();
t.setName(name); t.setName(name);
t.setKvMap(map); t.setKvMap(map);
...@@ -129,4 +153,37 @@ public class ToscaService { ...@@ -129,4 +153,37 @@ public class ToscaService {
return t.getId(); return t.getId();
} }
public String transform(String id, String target) throws JSONException, IOException, TimeoutException, InterruptedException {
ToscaRepresentation toscaRep = findOne(id);
switch (target) {
case "docker_compose":
return getDockerCompose(toscaRep);
}
return null;
}
private String getDockerCompose(ToscaRepresentation toscaRep) throws IOException, TimeoutException, JSONException, InterruptedException {
try (DRIPCaller transformer = new TransformerCaller(messageBrokerHost);) {
Message transformerInvokationMessage = buildDockerComposeMessage(toscaRep);
Message response = (transformer.call(transformerInvokationMessage));
System.err.println(response.getParameters().get(0).getValue());
}
return null;
}
private Message buildDockerComposeMessage(ToscaRepresentation toscaRep) throws JSONException {
Message deployInvokationMessage = new Message();
List<MessageParameter> parameters = new ArrayList<>();
MessageParameter messageParam = new MessageParameter();
messageParam.setName(toscaRep.getName());
messageParam.setValue(get(toscaRep.getKeyValue(), "yml"));
parameters.add(messageParam);
deployInvokationMessage.setParameters(parameters);
deployInvokationMessage.setCreationDate(System.currentTimeMillis());
return deployInvokationMessage;
}
} }
...@@ -21,6 +21,7 @@ import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation; ...@@ -21,6 +21,7 @@ import nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
...@@ -61,7 +62,6 @@ public class ToscaController { ...@@ -61,7 +62,6 @@ public class ToscaController {
public @ResponseBody public @ResponseBody
String post(@RequestBody String toscaContents) { String post(@RequestBody String toscaContents) {
try { try {
return toscaService.saveStringContents(toscaContents, String.valueOf(System.currentTimeMillis())); return toscaService.saveStringContents(toscaContents, String.valueOf(System.currentTimeMillis()));
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(ToscaController.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(ToscaController.class.getName()).log(Level.SEVERE, null, ex);
...@@ -124,7 +124,7 @@ public class ToscaController { ...@@ -124,7 +124,7 @@ public class ToscaController {
} }
/** /**
* Gets the IDs of all the stored TOSCA descriptionss. * Gets the IDs of all the stored TOSCA descriptions.
* *
* @return a list of all the IDs * @return a list of all the IDs
*/ */
...@@ -141,7 +141,26 @@ public class ToscaController { ...@@ -141,7 +141,26 @@ public class ToscaController {
} }
/** /**
* Gets the IDs of all the stored TOSCA descriptionss. * Transforms the TOSCA description to docker compose
*
* @param id the ID TOSCA description.
* @param type. Transform it to a specific type e.g. "docker_compose"
* @return the docker-compose.
*/
@RequestMapping(value = "/transform/{id}", method = RequestMethod.GET, params = {"type"})
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String transform(@PathVariable("id") String id, @RequestParam(value = "type") String type) {
try {
return toscaService.transform(id, type);
} catch (JSONException | IOException | TimeoutException | InterruptedException ex) {
Logger.getLogger(ToscaController.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/**
* Gets the IDs of all the stored TOSCA descriptions.
* *
* @return a list of all the IDs * @return a list of all the IDs
*/ */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<type>org.netbeans.modules.python.project</type> <type>org.netbeans.modules.python.project</type>
<configuration> <configuration>
<data xmlns="http://nbpython.dev.java.net/ns/php-project/1"> <data xmlns="http://nbpython.dev.java.net/ns/php-project/1">
<name>drip_planner2</name> <name>drip_parser</name>
<sources> <sources>
<root id="src.dir"/> <root id="src.dir"/>
</sources> </sources>
......
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
import os
import os.path
import pika
import sys
import tempfile
import time
import json
from transformer.docker_compose_transformer import *
def init_chanel(args):
if len(args) > 1:
rabbitmq_host = args[1]
queue_name = args[2] #tosca_2_docker_compose_queue
else:
rabbitmq_host = '127.0.0.1'
connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host))
channel = connection.channel()
channel.queue_declare(queue=queue_name)
return channel
def start(channel):
channel.basic_qos(prefetch_count=1)
channel.basic_consume(on_request, queue=queue_name)
print(" [x] Awaiting RPC requests")
channel.start_consuming()
def on_request(ch, method, props, body):
response = handle_delivery(body)
ch.basic_publish(exchange='',
routing_key=props.reply_to,
properties=pika.BasicProperties(correlation_id=\
props.correlation_id),
body=str(response))
ch.basic_ack(delivery_tag=method.delivery_tag)
def handle_delivery(message):
parsed_json_message = json.loads(message)
params = parsed_json_message["parameters"]
param = params[0]
value = param["value"]
tosca_file_name = param["name"]
current_milli_time = lambda: int(round(time.time() * 1000))
try:
tosca_file_path = tempfile.gettempdir() + "/transformer_files/" + str(current_milli_time()) + "/"
except NameError:
import sys
tosca_file_path = os.path.dirname(os.path.abspath(sys.argv[0])) + "/transformer_files/" + str(current_milli_time()) + "/"
if not os.path.exists(tosca_file_path):
os.makedirs(tosca_file_path)
with open(tosca_file_path + "/" + tosca_file_name + ".yml", 'w') as outfile:
outfile.write(str(value))
if queue_name == "tosca_2_docker_compose_queue":
transformer = DockerComposeTransformer(tosca_file_path + "/" + tosca_file_name + ".yml");
transformer.getnerate_compose()
return "response"
if __name__ == "__main__":
print sys.argv
channel = init_chanel(sys.argv)
global queue_name
queue_name = sys.argv[2]
start(channel)
# try:
## for node in tosca.nodetemplates:
## print "Name %s Type: %s " %(node.name,node.type)
##
## for input in tosca.inputs:
## print input.name
#
## for node in tosca.nodetemplates:
## for relationship, trgt in node.relationships.items():
## rel_template = trgt.get_relationship_template()
## for rel in rel_template:
## print "source %s Relationship: %s target: %s" %(rel.source.type,rel.type,rel.target.type)
## print dir(rel)
# response = {}
# current_milli_time = lambda: int(round(time.time() * 1000))
# response["creationDate"] = current_milli_time()
# response["parameters"] = []
# vm_nodes = []
#
# for node in tosca.nodetemplates:
# if not node.relationships.items() and 'docker' in node.type.lower():
# print "1Adding: %s , %s" %(node.name,node.type)
# vm_nodes.append(node)
## else:
# for relationship, trgt in node.relationships.items():
# if relationship.type == EntityType.HOSTEDON:
# rel_template = trgt.get_relationship_template()
# for rel in rel_template:
# print "2Adding: %s , %s" %(rel.target.name,rel.target.type)
## print "Name: %s Type: %s " %(node.name, node.type)
# vm_nodes.append(rel.target)
#
#
## if not compute_nodes:
## for node in tosca.nodetemplates:
### print dir(node)
## print "Name: %s Type: %s props: %s"%(node.name,node.type,node.get_properties().keys())
#
# for vm in vm_nodes:
# result = {}
# parameter = {}
# result['name'] = vm.name
# result['size'] = 'Medium'
# if 'dockers' in vm.get_properties():
# result['docker'] = vm.get_properties()['dockers'].value
# elif 'artifacts' in vm.templates[next(iter(vm.templates))]:
# artifacts = vm.templates[next(iter(vm.templates))]['artifacts']
# result['docker'] = artifacts['docker_image']['file']
## print "1st Key: %s" %next(iter(vm.templates))
## print vm.templates[next(iter(vm.templates))]
#
## print dir(compute_node.get_properties()['dockers'] )
## print "dockers. Name: %s Type: %s Value: %s" % (compute_node.get_properties()['dockers'].name, compute_node.get_properties()['dockers'].type, compute_node.get_properties()['dockers'].value )
# parameter['value'] = str(json.dumps(result))
# parameter['attributes'] = 'null'
# parameter["url"] = "null"
# parameter["encoding"] = "UTF-8"
# response["parameters"].append(parameter)
## print "Name: %s Type: %s properties: %s" %(vm.name,vm.type,vm.get_properties().keys())
##
# print ("Output message: %s" % json.dumps(response))
#
# except AttributeError as e:
# z = e
# print z
from toscaparser import * from toscaparser import *
from toscaparser.tosca_template import ToscaTemplate from toscaparser.tosca_template import ToscaTemplate
import json import toscaparser.utils.yamlparser
import time
class DockerComposeTransformer:
def __init__(self, tosca_file_path):
yaml_dict_tpl = toscaparser.utils.yamlparser.load_yaml(tosca_file_path)
self.tt = ToscaTemplate(path=None, yaml_dict_tpl=yaml_dict_tpl)
self.DOCKER_TYPE = 'Switch.nodes.Application.Container.Docker'
class DumpPlanner: def getnerate_compose(self):
dockers = []
print dir(self.tt.topology_template)
print dir(self.tt.outputs)
print dir(self.tt.nested_tosca_tpls_with_topology)
print dir(self.tt.nested_tosca_templates_with_topology)
print dir(self.tt.inputs)
print dir(self.tt.input_path)
print dir(self.tt.graph)
for node in self.tt.nodetemplates:
if node.parent_type.type == self.DOCKER_TYPE:
dockers.append(node)
print "Name %s Type: %s Parent: %s" %(node.name,node.type,node.parent_type.type)
def __init__(self,tosca):
self.tosca = tosca
self.tt = ToscaTemplate()
def plan(self):
self.tt
# topology_template = parsed_json_value['topology_template'] # topology_template = parsed_json_value['topology_template']
# node_templates = topology_template["node_templates"] # node_templates = topology_template["node_templates"]
......
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
import pika
from planner.dump_planner import *
import sys
from toscaparser import *
from toscaparser.tosca_template import ToscaTemplate
from toscaparser.elements.entity_type import EntityType
def init_chanel(args):
if len(args) > 1:
rabbitmq_host = args[1]
else:
rabbitmq_host = '127.0.0.1'
connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host))
channel = connection.channel()
channel.queue_declare(queue='planner_queue')
return channel
def start(channel):
channel.basic_qos(prefetch_count=1)
channel.basic_consume(on_request, queue='planner_queue')
print(" [x] Awaiting RPC requests")
channel.start_consuming()
def on_request(ch, method, props, body):
response = handle_delivery(body)
ch.basic_publish(exchange='',
routing_key=props.reply_to,
properties=pika.BasicProperties(correlation_id=\
props.correlation_id),
body=str(response))
ch.basic_ack(delivery_tag=method.delivery_tag)
def handle_delivery(message):
parsed_json_message = json.loads(message)
params = parsed_json_message["parameters"]
param = params[0]
value = param["value"]
parsed_json_value = json.loads(value)
planner = DumpPlanner();
response = planner.plan(parsed_json_value);
return response
if __name__ == "__main__":
# print sys.argv
# channel = init_chanel(sys.argv)
# start(channel)
try:
# tosca = ToscaTemplate('/home/alogo/workspace/DRIP/docs/input_tosca_files/tosca_MOG_input.yaml')
tosca = ToscaTemplate('/home/alogo/workspace/DRIP/docs/input_tosca_files/input.yaml')
# for node in tosca.nodetemplates:
# print "Name %s Type: %s " %(node.name,node.type)
#
# for input in tosca.inputs:
# print input.name
# for node in tosca.nodetemplates:
# for relationship, trgt in node.relationships.items():
# rel_template = trgt.get_relationship_template()
# for rel in rel_template:
# print "source %s Relationship: %s target: %s" %(rel.source.type,rel.type,rel.target.type)
# print dir(rel)
response = {}
current_milli_time = lambda: int(round(time.time() * 1000))
response["creationDate"] = current_milli_time()
response["parameters"] = []
compute_nodes = []
for node in tosca.nodetemplates:
# print dir(node)
print "Name: %s Type: %s props: %s"%(node.name,node.type,node.get_properties().keys())
for relationship, trgt in node.relationships.items():
if relationship.type == EntityType.HOSTEDON:
rel_template = trgt.get_relationship_template()
for rel in rel_template:
compute_nodes.append(rel.target)
for compute_node in compute_nodes:
result = {}
parameter = {}
result['name'] = node.name
result['size'] = 'Medium'
result['docker'] = compute_node.get_properties()['dockers'].value
# print dir(compute_node.get_properties()['dockers'] )
# print "dockers. Name: %s Type: %s Value: %s" % (compute_node.get_properties()['dockers'].name, compute_node.get_properties()['dockers'].type, compute_node.get_properties()['dockers'].value )
parameter['value'] = str(json.dumps(result))
parameter['attributes'] = 'null'
parameter["url"] = "null"
parameter["encoding"] = "UTF-8"
response["parameters"].append(parameter)
# print "Name: %s Type: %s properties: %s" %(compute_node.name,compute_node.type,compute_node.get_properties().keys())
print ("Output message: %s" % json.dumps(response))
except AttributeError as e:
z = e
print z
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment