]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-start-ephemeral: Implement -n to match manpage
authorStéphane Graber <stgraber@ubuntu.com>
Wed, 27 Mar 2013 13:27:43 +0000 (09:27 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 27 Mar 2013 14:03:11 +0000 (10:03 -0400)
The -n/--name option of lxc-start-ephemeral was never implemented
even though it was documented in the manpage.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc-start-ephemeral.in

index 3e2a5d35bf9ab400effd6c0a6a6d5cc724a1c542..d1bb6be453e0de81dc80e9c1e217dd41c74135d6 100644 (file)
@@ -70,6 +70,9 @@ parser.add_argument("--lxcpath", "-P", dest="lxcpath", metavar="PATH",
 parser.add_argument("--orig", "-o", type=str, required=True,
                     help=_("name of the original container"))
 
+parser.add_argument("--name", "-n", type=str,
+                    help=_("name of the target container"))
+
 parser.add_argument("--bdir", "-b", type=str,
                     help=_("directory to bind mount into container"))
 
@@ -117,7 +120,13 @@ if not args.lxcpath:
 else:
     lxc_path = args.lxcpath
 
-dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir=lxc_path)
+if args.name:
+    if os.path.exists("%s/%s" % (lxc_path, args.name)):
+        parser.error(_("A container named '%s' already exists." % args.name))
+    dest_path = "%s/%s" % (lxc_path, args.name)
+    os.mkdir(dest_path)
+else:
+    dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir=lxc_path)
 os.mkdir(os.path.join(dest_path, "rootfs"))
 
 # Setup the new container's configuration