The “History Command” of Chameleon
- Dec. 23, 2019 by
- Zhuo Zhen
The history
command available in Bash is a useful tool, and you probably use it frequently in your daily routine jobs to check the history of the commands executed by the user. In this blog, we will see how an equivalent tool in Chameleon can help you check the experiment setup events you performed on Chameleon.
Experiment Précis
Chameleon helps you record your experiment setup events performed on the testbed, such as creating leases, creating instances, and setting up networks. Like the history
command, you can request your experiment records from Chameleon using your Chameleon credentials and the cep client
tool. A report on those experiment records is known as the Experiment Précis. But there is more than that. Chameleon Experiment Précis also includes the detailed information of the hardware you use for your experiment, as well as the quality metrics collected from our monitoring service.
To Avoid the “Command Not Found” Error
You might never see “command not found” when running the history
command on Linux systems because most of the Linux distributions have bash
installed. To be able to retrieve your experiment setup history from Chameleon, you need to install the cep client
tool by running pip install cepclient
, and to set up the cep client
by sourcing the OpenStack RC file.
Print History
Simply running history
will print out the bash commands executed by the current user. To print out the experiment précis, you can use the following command:
To find the ep_id
and ep_name
, which are the ID and name of the experiment précis, run
Initially, Chameleon sets the name of an experiment précis the same as its ID. However, you can rename it for the convenience of future retrieving. To rename an experiment précis, run the following command:
A Lot More You Can Do
We know that there’s a lot more you can do with the history
command, such as filtering commands, excluding commands, setting the number of commands to print out, etc. With the cep client
, you can do the similar as well.
Pagination
The history
command allows you to print the most recent 3 commands by running history 3
. You can also tell history
how many commands to store and how many commands to print by setting “HISTFILESIZE” and “HISTSIZE” environment variables. The cep client
achieves the same goal with pagination parameters, including the page size and the page number. For example, if you’d like to show the first 3 events of your experiment, simply run the following command:
Filter
By piping history
with history | grep systemctl
, you can filter the commands that contains “systemctl”. You can also ignore commands by setting up the “HISTIGNORE” environment variable. The cep client
also provide filter parameters, so you can focus on the information you care about. For example, you can exclude quality metrics from your experiment précis by adding --exclude-metric
to the cep print
command. The cep client
also allows you to filter events by OpenStack services and time period.
And More To Come
With the history
command printout, you can quickly repeat any of the line by copying and pasting or by using a special syntax (!). Using the following as an example.
16 passwd
17 getenforce
18 history 3
Running !16
will repeat command passwd
. Running !-2
will repeat getenforce
. Running !!
means running the most recent command, in our case, history 3
.
With your experiment précis, you can create a complex appliance or a Jupyter Notebook, which allows you to easily repeat your experiment setup steps on Chameleon. In the near future, we will develop a Chameleon “!” tool to help you easily convert your experiment précis to a shareable artifact.
At the End
For any discipline, the abilities of keeping records of, sharing and repeating experiments are critical. To reduce the burden of the researchers when preparing experiments on Chameleon, we developed the Chameleon Experiment Précis framework to record testbed events, hardware information, and quality metrics for you and to allow you to retrieve the records via the cep client
tool. From there, you can create your experiment artifact, such as complex appliance or Jupyter Notebook, from your experiment précis and share it on the Chameleon Appliance Catalog or the Sharing Portal.
In this blog, we showed you how to generate an experiment précis and what you can do with it. If you are interested, please read our documentation for more details. You can leave a comment about this framework or submit a ticket to us if you have any questions.
No comments