<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2166/3/7/_/styles/combined.css?spaceKey=TOP&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><s>Creating New Plugins</s></h2>
     <h4>Page <b>removed</b> by             <a href="https://wiki.asterisk.org/wiki/display/~dsessions">Darren Sessions</a>
    </h4>
     <br/>
     <div class="notificationGreySide">
         <div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>WIP</td></tr></table></div>

<h1><a name="CreatingNewPlugins-Overview"></a>Overview</h1>

<h1><a name="CreatingNewPlugins-Structure"></a>Structure</h1>


<h1><a name="CreatingNewPlugins-BaseClasses"></a>Base Classes</h1>

<ul>
        <li>Test Case RPC</li>
        <li>Manual RPC</li>
</ul>


<h1><a name="CreatingNewPlugins-GlobalVariables"></a>Global Variables</h1>

<h1><a name="CreatingNewPlugins-Methods"></a>Methods</h1>
<h3><a name="CreatingNewPlugins-Overview"></a>Overview</h3>
<p>The method library used for plugins within the Server component is the exact same library that can be used within the Remote Agent when making RPC calls. </p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>wip</td></tr></table></div>

<br>
<h4><a name="CreatingNewPlugins-FileSystem"></a><em>File System</em></h4>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Name</th>
<th class='confluenceTh'>Description</th>
<th class='confluenceTh'>Args</th>
<th class='confluenceTh'>Returns</th>
</tr>
<tr>
<td class='confluenceTd'>writeFile</td>
<td class='confluenceTd'>Writes a file.</td>
<td class='confluenceTd'><em><b>filename</b></em> - Filename and path of the output file. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.<br><br/>
<em><b>data</b></em> - Data to be written.<br><br/>
<em><b>yamlBool</b></em> - Optional. Default = False. Process data to be written through the yaml.dump function in order to write yaml output.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
<tr>
<td class='confluenceTd'>readFile</td>
<td class='confluenceTd'>Reads a file.</td>
<td class='confluenceTd'><em><b>filename</b></em> - Filename of the output file. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.<br><br/>
<em><b>rpcBool</b></em> - Boolean. If rpcBool = True, the read data is sent through the xmlrpclib.Binary method in preparation for transfer across the wire.<br><br/>
<em><b>yamlBool</b></em> - Boolean. If yamlBool= True, the data data is sent through the yaml.load method and converted to a python dictionary.<br></td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.<br><br/>
<em><b>data</b></em> - If the file is read properly, this variable will contain the file data.</td>
</tr>
<tr>
<td class='confluenceTd'>removeFile</td>
<td class='confluenceTd'>Removes a file.</td>
<td class='confluenceTd'><em><b>filename</b></em> - Filename of the output file. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
<tr>
<td class='confluenceTd'>moveFile</td>
<td class='confluenceTd'>Moves a file from &lt;src&gt; to &lt;dst&gt;.</td>
<td class='confluenceTd'><em><b>src</b></em> - Source filename of the file to move. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.<br><br/>
<em><b>dst</b></em> - Destination file path. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
<tr>
<td class='confluenceTd'>changeDir</td>
<td class='confluenceTd'>Changes the current working directory.</td>
<td class='confluenceTd'><em><b>path</b></em> - Path to change directories to. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
<tr>
<td class='confluenceTd'>makeDir</td>
<td class='confluenceTd'>Makes a directory.</td>
<td class='confluenceTd'><em><b>path</b></em> - Path to including directory name to create. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
<tr>
<td class='confluenceTd'>removeDir</td>
<td class='confluenceTd'> Removes a directory. Due to limitations with shutil.rmtree on Windows, on a Windows remote, a simple 'rmdir' system call is made.</td>
<td class='confluenceTd'><em><b>path</b></em> - Path to remove. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
<tr>
<td class='confluenceTd'>tar</td>
<td class='confluenceTd'>Creates a gzip'd tarball of a file or directory, or directory structure and then checks the newly created tarball to make sure it's valid.</td>
<td class='confluenceTd'><em><b>tarFile</b></em> - The full path and name of the tarball to be created.<br><br/>
<em><b>whatToTar</b></em> - List. File(s) or directory path to be tar'd up.<br><br/>
<em><b>tarDirStruct</b></em> - Boolean. Default = False. If default = False, the function will change directories and tar directly from the path specified, thereby not saving the full directory path in the tar file. If default = True, the function does not change directories and will tar the complete path.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
<tr>
<td class='confluenceTd'>untar</td>
<td class='confluenceTd'>Unpacks a tarball.</td>
<td class='confluenceTd'><em><b>tarFile</b></em> - Filename and path of the tarfile. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.<br><br/>
<em><b>unPackPath</b></em> - Path where the tar file should be unpacked. Can include !!TMP!! for the tmp directory or !!CWD!! for the current working directory.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.</td>
</tr>
</tbody></table>
</div>

<br>
<h4><a name="CreatingNewPlugins-Misc"></a>Misc</h4>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Name</th>
<th class='confluenceTh'>Description</th>
<th class='confluenceTh'>Args</th>
<th class='confluenceTh'>Returns</th>
</tr>
<tr>
<td class='confluenceTd'>resultsHandler</td>
<td class='confluenceTd'>While this will not be called directly, it's certainly worth noting it's existence. This function is called by using either resSuccess() or resFailure() as they are both set to equal the resultsHanlder method object. Based on the fact that virtually the entire test-suite code is structured with checks and balances, instead of having to type out something like "return {'success':True, 'msg':'the message goes here', 'data':datavarhere}", this function knows how it's being called based on the resSuccess or resFailure calls, constructs the appropriate response based on the operating mode and function arguments, and returns a nicely formatted response. i.e. "return resSuccess('the message goes here', datavarhere)"</td>
<td class='confluenceTd'><em><b>msg</b></em> - A verbose message describing a failure. Typically not used with a successful return.<br><br/>
<em><b>addRes</b></em> - Dictionary. Adds additional user defined dictionary results when returning.</td>
<td class='confluenceTd'>Returns a dictionary defining the success boolean value, a message, and anything defined in the 'addRes' argument.</td>
</tr>
<tr>
<td class='confluenceTd'>dictMerge</td>
<td class='confluenceTd'>Merges dictionary A into dictionary B.</td>
<td class='confluenceTd'><em><b>fromDict</b></em> - The primary dictionary where dictionary B gets merged into.<br><br/>
<em><b>toDict</b></em> - The dictionary data to merge into dictionary A.</td>
<td class='confluenceTd'><em><b>mergedDict</b></em> - Dictionary. The merged data of B into A.</td>
</tr>
</tbody></table>
</div>

<br>
<h4><a name="CreatingNewPlugins-RPC"></a>RPC</h4>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Name</th>
<th class='confluenceTh'>Description</th>
<th class='confluenceTh'>Args</th>
<th class='confluenceTh'>Returns</th>
</tr>
<tr>
<td class='confluenceTd'>remote</td>
<td class='confluenceTd'> Establishes an RPC connection to a remote. </td>
<td class='confluenceTd'><em><b>remote hostname</em></b> - The fqdn of the remote host to connect to.</td>
<td class='confluenceTd'><em><b>success</b></em> - Boolean<br><br/>
<em><b>msg</b></em> - If success = False, the msg element is returned with a descriptive value on why there was a failure.<br><br/>
<em><b>rpc</b></em> - RPC remote method constructor<br><br/>
<em><b>ifaceInfo</b></em> - Provides 'rpc', 'public', and 'private' interface label (i.e. eth0) details (ipv4 addr, ipv6 addr, mac addr)<br><br/>
<em><b>hostInfo</b></em> - Provides a dictionary with a network interface list, platform, and architecture<br><br/>
<em><b>hostname</b></em> - Provides the hostname<br><br/>
<em><b>fqdn</b></em> - Provides the fully qualified domain name</td>
</tr>
</tbody></table>
</div>

<br>
     </div>
</div>
</div>
</div>
</div>
</body>
</html>