« Back to Technical Questions

RE: How to pass config parameters to app linux console

Combination View Flat View Tree View
How to pass config parameters to app linux console
hostname config parameters post-install.sh automate tsm
Answer
5/24/11 11:00 PM
Hi.
We have been able to install TSM client in our lab environment AXP modules and it´s working fine (great!! :-)). Now, we want to go ahead one more step. We are interested about the way to pass config parameters from AXP CLI mode to application linux console avoiding to log into linux console to modify tsm config files.
 
This is the problem. A TSM client installed in AXP module has one specific config parameter in dsm.sys TSM config file. This is the TSM remote nodename. Now, when we finish to install TSM client in AXP, we have to modify manually this file login into application linux console. We are looking for a way to automate TSM client setup in AXP without to modify manually config files. It would be a good idea to pass config parameters from AXP CLI mode to application linux console.
 
One example. We have noticed, when you configure hostname under app-service in AXP CLI mode:
app-service tsmc
hostname TSM-REMOTE1
.
.
An entry in /etc/hosts application linux console is created automatically with this hostname command under app-service. We could obtain this hostname from /etc/hosts file and configure it as nodename in dsm.sys TSM config file using script commands, and it would be great if these script commands could be executed in post-install.sh package script. The problem is we can configure hostname under app-service only when TSM application is already installed.
Is there anyway to do it? Can you help us to achieve it?

Hi Juan,

I think you can run script commands in post-install script did you get a chance of trying that out?, i will find out if there is another way.

Thanks,
Raghavendra

Hi Raghavendra.

Thanks for your response.

Yes, you can run script commands in post-install script, but when you have created application package, you can´t modify post-install script commands in order to add specific config parámeters for TSM config files. I thought to add hostname under app-service, because automatically it creates an entry in /etc/hosts file and I could use this entry to obtain TSM nodename. However, hostname under app-service is only available when tsm package is already installed.

B.R.

Hi Juan,

Postinstall script is executed after installation is complete but before the application has been started for the first time,so adding a config parameters for TSM config files after adding hostname under app-service option won't work i guess.
so you mean if hostname changes it automatically should change in TSM config file after application installed is that correct?

Thanks,
Raghavendra

Hi Juan,
 
Have you considered writing your own AXP CLI?  AXP provides a way for you to write a CLI in the app-service submode.  For example, you can write a CLI like the following:
 
axp# app-service my_app
axp(my_app-exec)# my new cli
 
This can execute whatever code you wish, so you do not have to go into a linux shell and modify files manually.
 
You can find examples and definitions in our AXP Developers Guide.  Take a look at the CLI Plug-in Applications section, beginning on p. 173 (of the 1.6.1 document.)  There is also an example of a simple applicaton CLI on p. 198.  This CLI prints the current time of the system, but can be modified to change the config files you want.
 
Hope this helps,
 
-Carl
 
Hi.
We have been able to install TSM client in our lab environment AXP modules and it´s working fine (great!! :-)). Now, we want to go ahead one more step. We are interested about the way to pass config parameters from AXP CLI mode to application linux console avoiding to log into linux console to modify tsm config files.
 
This is the problem. A TSM client installed in AXP module has one specific config parameter in dsm.sys TSM config file. This is the TSM remote nodename. Now, when we finish to install TSM client in AXP, we have to modify manually this file login into application linux console. We are looking for a way to automate TSM client setup in AXP without to modify manually config files. It would be a good idea to pass config parameters from AXP CLI mode to application linux console.
 
One example. We have noticed, when you configure hostname under app-service in AXP CLI mode:
app-service tsmc
hostname TSM-REMOTE1
.
.
An entry in /etc/hosts application linux console is created automatically with this hostname command under app-service. We could obtain this hostname from /etc/hosts file and configure it as nodename in dsm.sys TSM config file using script commands, and it would be great if these script commands could be executed in post-install.sh package script. The problem is we can configure hostname under app-service only when TSM application is already installed.
Is there anyway to do it? Can you help us to achieve it?

Hi Juan,

Postinstall script is executed after installation is complete but before the application has been started for the first time,so adding a config parameters for TSM config files after adding hostname under app-service option won't work i guess.
so you mean if hostname changes it automatically should change in TSM config file after application installed is that correct?

Thanks,
Raghavendra


Hi Again Raghavendra.
 
More or less.
 
I´m looking for a way to modify a specific field in dsm.sys TSM configuration file (nodename), avoiding to do it login into application linux console and modifying manually TSM configuration file. This nodename will be different in all remote TSM´s installed in AXP modules and TSM client has been packaged with a generic nodename.
 
I have been thinking about to configure hostname in app-service config mode, because it adds an entry in /etc/hosts file, and this hostname could be used as TSM nodename. However, when TSM package is installed, tsm services will be up before I had added hostname in app-service config mode. I´m looking for the way to modify dsm.sys file field before to start TSM client.
 
B.R.

Is there anyway to install one app in AXP module, maintaining it shutdown?. I have readed when one application is installed for the first time, the default status of app-service is "no shutdown". Perhaps it could be useful to me if default state for application was "shutdown"

B.R.

Hi Juan,

Regarding your question of setting the hostname so that your application can read it at start up without needing to do it via the linux console, I can think of two ways to accomplish this step.

1. If you want to be able to set parameters via a custom CLI command, you can utilize our CLI Plugin SDK for this process. Please check our white paper 'Implementing the AXP Cli Plug-in.pdf' located in http://developer.cisco.com/web/axp/docs for a step-by-step guide of how to implement this feature.

2. Alternatively, if using the current CLI to set the hostname works, but the timing is too late because it is after your application has already started, you do have the option of resetting the virtual machine and therefore your application after setting the hostname via the CLI so that the proper value can be read in. For example, you would install your package and your application would start without the proper hostname, you could then via the CLI as you pointed out set the hostname. The next step would be to issue the command on the CLI 'app-service <your app name>' and then enter 'reset'. The virtual machine would be restarted along with your application, and your application would then read in the proper hostname value.

Regarding your question of installing your application in a shutdown state, I think you want to do this so that your application does not start before the hostname has been set. Your application is starting up with the VM because you have a startup script being called at boot up. You might consider adding code to your application that if the hostname is not set, that it shuts down. Alternatively this code could be added to the startup script of the application located in the /etc/rc.d/init.d/<startup script name>.

Thanks,

Brett

Thanks Carl/Brett for your answers.

Sorry Brett, but I had to talk with development guys about your first point. I prefer your second point trying it on my own. I have thought the same as you. It doesn´t happen anything to reset app after to install packages. It would work fine for hostname/nodename, because AXP cli command is "transfered" to app linux cli.

I´m thinking too in file /etc/exports I want only one server ip address will be able to access AXP nfs shared resource. Again, this ip address won´t be the same in all AXP modules. In this case there is no command like hostname to pass server ip address to app linux cli. What is the best way to do it?

B.R.

Hi Juan,

As you know you can set the hostname via the CLI and the result will be that the HOSTNAME environment variable in the guest environment will contain the desired value. If you want to pass in other values after installation, as I mentioned earlier the best way to do it would be to use the CLI-Plugin because you can create custom CLI commands that then activate your custom written scripts or binaries to carry out the process. If you still don't want to follow this path you'll need come up with some gimmicky idea to pass in the values. While we don't recommend gimmicks, one I can think of is to also pass in your desired IP via the hostname as well. Your application will then parse the HOSTNAME environment variable to get the data it requires and then modify the /etc/exports file you mentioned. For example if you wanted to specify the hostname as AXPHost and also pass in the IP 192.168.1.60 you could do the following shown below on the service module. Notice that the HOSTNAME environment variable now has two values. Your application(s) would then need to parse these values from the HOSTNAME environment variable and use them as needed.

>#config t
>(config)#app-service helloworld
>(config-hello)#hostname AXPHost-192.168.1.60
>(config-hello)end
>#write memory
># app-service helloworld
>(exec-helloworld)# con con
console-3.2# echo $HOSTNAME
AXPHost-192.168.1.60

Thanks,

Brett

Hi Brett.
 
Thanks for your answer.
 
Hostname solution works fine for us. But you have convinced me, I want to go a step ahead. I will review to implement two CLI AXP commands to configure Risc IP address and tsm nodename using bash script on my own.
 
1. I want to implement sample CLI Plug-in Application. I¿ following your guide, but I¿ stuck in step 10. I¿ triying to verify if commands.xml is correctly formatted, but Im obtaining the following error:
 
[root@fedora1 custom_cli]# python cli_plugin.py
Traceback (most recent call last):
  File "cli_plugin.py", line 7, in <module>
    from xml.dom.ext.reader import Sax2
ImportError: No module named ext.reader
 
What am I doing wrong?
 
2. Commands I¿ thinking to implement will be something like:
 
risc-ip-address <ip address>
tsm-nodename <nodename>
 
Could I create only one commands.xml file for both commands? Could you send me your modified commands.xml with one of the command I want to implement. I dont know exactly pattern type I have to use for <ip address> or <nodename>
 
Thanks in advance.
 

Hi Juan,

Python version 2.3.4 or higher is needed, please Check version by typing: ¿python ¿V¿ in your development environment.

yes you can create only one commands.xml file for both commands.

Thanks,
Raghavendra

Hi Juan,

Yes this error message sounds like you've got the wrong python version. Please check it as suggested by Raghavendra. In addition, I've included below commands.xml data containing the commands/filters you requested. This xml functions properly on my system. You'll need to replace 'EMPTY' with your bash script.

Thanks,

Brett

 1
 2<?xml version='1.0' encoding='UTF-8' ?>
 3<!DOCTYPE cli_grammar SYSTEM "cli_grammar.dtd">
 4
 5<cli_grammar>
 6<mode>
 7<pattern type="id">exec</pattern>
 8<cmd>
 9    <pattern type="id">tsm</pattern>
10    <help>the tsm application</help>
11        <param>
12            <pattern type="id">nodename</pattern>
13            <help>the nodename</help>
14        </param>
15        <param>
16            <pattern type="regex">[0-9A-Za-z]*</pattern>
17            <pattern type="help">NAME</pattern>
18            <help>the name of the node</help>
19        </param>
20    <action>
21        <class>EMPTY</class>
22    </action>
23</cmd>
24
25<cmd>
26    <pattern type="id">risc</pattern>
27    <help>the risc</help>
28        <param>
29            <pattern type="id">ip</pattern>
30            <help>internet protocol</help>
31        </param>
32        <param>
33            <pattern type="id">address</pattern>
34            <help>the ip address</help>
35        </param>
36        <param>
37            <pattern type="regex">[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}</pattern>
38            <pattern type="help">IP</pattern>
39            <help>the IPv4 Address format</help>
40        </param>
41    <action>
42        <class>EMPTY</class>
43    </action>
44</cmd>
45</mode>
46</cli_grammar>

Thanks Raghavendra/Brett for your answers.
 
Taking a view to pdf manual, I need 2.3.4 python version or higher. My development linux installation has 2.7 python version. I think I have the right version.
 
K.R.

Hi Juan,

Thanks for pointing this out. Python requires xml packages for our script. You can create these packages in one of two ways. If the first process I provide below doesn't resolve your issue, please do the second which will work as I've tested it in my lab.

Process 1.
1. Access your Python 2.7.1 directory
2. Type 'python setup.py build'.
3. As root or sudo type 'python setup.py install'
4. Return to non-root user.
5. Access the custom_cli directory and type 'python cli_plugin.py' .
6. The files should now compile.

If Process 1 doesn't work.

Process 2
1. Download this python package: http://sourceforge.net/projects/pyxml/files/pyxml/0.8.4/PyXML-0.8.4.tar.gz/download
2. Untar the file via 'tar xvzf PyXML-0.8.4.tar.gz'.
3. Access the PyXML-0.8.4 directory .
4. Start from Step 2 of Process 1 and continue until complete.

Please let use know if you have other issues with the cli-plugin.

Thanks,

Brett