<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. https://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="https://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:openvz</id>
  <title>OpenVZ</title>
  <subtitle>OpenVZ</subtitle>
  <author>
    <name>OpenVZ</name>
  </author>
  <link rel="alternate" type="text/html" href="https://openvz.livejournal.com/"/>
  <link rel="self" type="text/xml" href="https://openvz.livejournal.com/data/atom"/>
  <updated>2009-05-22T12:23:09Z</updated>
  <lj:journal userid="9392309" username="openvz" type="community"/>
  <link rel="service.feed" type="application/x.atom+xml" href="https://openvz.livejournal.com/data/atom" title="OpenVZ"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:openvz:28393</id>
    <author>
      <name>Kir Kolyshkin</name>
    </author>
    <lj:poster user="k001" userid="990679"/>
    <link rel="alternate" type="text/html" href="https://openvz.livejournal.com/28393.html"/>
    <link rel="self" type="text/xml" href="https://openvz.livejournal.com/data/atom/?itemid=28393"/>
    <title>Completion in vzctl</title>
    <published>2009-05-22T12:11:43Z</published>
    <updated>2009-05-22T12:23:09Z</updated>
    <content type="html">There is a nice feature in vzctl (well, technically not in vzctl binary itself; it just comes in vzctl package) that many people don't know about -- completion. This basically makes it able to save a few keystrokes when typing.&lt;br /&gt;&lt;br /&gt;Say you want to create a container. You type &lt;tt&gt;vzct&lt;/tt&gt; and press &lt;tt&gt;&amp;lt;TAB&amp;gt;&lt;/tt&gt; -- it completes that to vzctl and a space after. This is usual feature of bash -- it looks all the binaries available in $PATH and tries to complete their names.&lt;br /&gt;&lt;br /&gt;Now let's see the vzctl completion:&lt;br /&gt;&lt;code&gt;# vzctl cr&amp;lt;TAB&amp;gt;&lt;/code&gt;&lt;br /&gt;completes to&lt;br /&gt;&lt;tt&gt;# vzctl create &lt;/tt&gt;&lt;br /&gt;and then after yet another &amp;lt;TAB&amp;gt; it suggests a CT ID which is the MAX+1 (i.e. if you have containers 101, 102 and 105 it will suggest 106):&lt;br /&gt;&lt;tt&gt;# vzctl create 106 &lt;/tt&gt;&lt;br /&gt;Now we want to specify an OS template:&lt;br /&gt;&lt;tt&gt;# vzctl create 106 --os&amp;lt;TAB&amp;gt;&lt;/tt&gt;&lt;br /&gt;will get you to&lt;br /&gt;&lt;tt&gt;# vzctl create 106 --ostemplate &lt;/tt&gt;&lt;br /&gt;and then you press &lt;tt&gt;&amp;lt;TAB&amp;gt;&lt;/tt&gt; again twice to see the list of available OS templates:&lt;br /&gt;&lt;tt&gt;# vzctl create 106 --ostemplate &amp;lt;TAB&amp;gt;&amp;lt;TAB&amp;gt;&lt;br /&gt;centos-5-x86        centos-5-x86-devel  fedora-9-x86        suse-11.1-x86&lt;/tt&gt;&lt;br /&gt;Now you type in the first few characters of the OS template you want to use:&lt;br /&gt;&lt;tt&gt;# vzctl create 106 --ostemplate f&amp;lt;TAB&amp;gt;&lt;/tt&gt;&lt;br /&gt;and it will complete that to&lt;br /&gt;&lt;tt&gt;# vzctl create 106 --ostemplate fedora-9-x86&lt;/tt&gt;&lt;br /&gt;Now, unless you want to specify &lt;tt&gt;--config&lt;/tt&gt; or some other parameters, just press Enter.&lt;br /&gt;&lt;br /&gt;This completion is smart -- say, if you want to start a container, type in&lt;br /&gt;&lt;tt&gt;# vzctl start &amp;lt;TAB&amp;gt;&amp;lt;TAB&amp;gt;&lt;/tt&gt;&lt;br /&gt;and it will give you the list of container IDs that can be started (i.e. all the stopped containers).&lt;br /&gt;&lt;br /&gt;And so on and so forth. Well, you say, it doesn't work! In that case you have to enable it, here's how.&lt;br /&gt;&lt;br /&gt;On a RHEL, CentOS or Fedora system run &lt;tt&gt;yum install bash-completion&lt;/tt&gt; and then relogin (i.e. log out and log in again). If your host system is Gentoo, run &lt;tt&gt;emerge bash-completion&lt;/tt&gt; and then &lt;tt&gt;eselect bashcomp enable vzctl&lt;/tt&gt;. I hope someone will comment on how to enable this for Debian/Ubuntu/SUSE or whatever your favorite distro is.</content>
  </entry>
</feed>
