...
Browse to the
SAMPLESRV
directory, and edit themetainfo.xml
file that describes the service. For example, adding a custom command to the SAMPLESRV_CLIENT:Code Block <component> <name>SAMPLESRV_CLIENT</name> <displayName>Sample Srv Client</displayName> <category>CLIENT</category> <cardinality>1+</cardinality> <commandScript> <script>scripts/sample_client.py</script> <scriptType>PYTHON</scriptType> <timeout>600</timeout> </commandScript> <customCommands> <customCommand> <name>SOMETHINGCUSTOM</name> <commandScript> <script>scripts/sample_client.py</script> <scriptType>PYTHON</scriptType> <timeout>600</timeout> </commandScript> </customCommand> </customCommands> </component> </components>
Next, let's create that command script by editing the package/scripts/sample_client.py file that we designated in the service metainfo.
Code Block import sys from resource_management import * class SampleClient(Script): def install(self, env): print 'Install the Sample Srv Client'; def configure(self, env): print 'Configure the Sample Srv Client'; def somethingcustom(self, env): print 'Something custom'; if __name__ == "__main__": SampleClient().execute()
...
In this example, we will add a configuration type "test-config" to our SAMPLESRV.
Modify the metainfo.xml
Code Block <component> <name>SAMPLESRV_CLIENT</name> <displayName>Sample Srv Client</displayName> <category>CLIENT</category> <cardinality>1+</cardinality> <commandScript> <script>scripts/sample_client.py</script> <scriptType>PYTHON</scriptType> <timeout>600</timeout> </commandScript> <configFiles> <configFile> <type>xml</type> <fileName>test-config.xml</fileName> <dictionaryName>test-config</dictionaryName> </configFile> </configFiles> </component>
Create a directory for the configuration dictionary file
SAMPLESRV
/
configuration
.Code Block mkdir -p configuration cd configuration
Create the
test-config.xml
file. For example:Code Block <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>some.test.property</name> <value>this.is.the.default.value</value> <description>This is a test description.</description> </property> </configuration>
...