mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-09 13:11:54 +00:00
lxc-start-ephemeral: startup time improvement
Re-organize the code to only call get_ips() when we actually need the IP address of the container. Also bump the timeout for get_ips() from 5s to 10s to accomodate slower machines. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
parent
6506255cfd
commit
abbe2ead95
@ -233,12 +233,17 @@ if not dest.start() or not dest.wait("RUNNING", timeout=5):
|
|||||||
dest.destroy()
|
dest.destroy()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Try to get the IP addresses
|
# Deal with the case where we just attach to the container's console
|
||||||
ips = dest.get_ips(timeout=5)
|
if not args.command and not args.daemon:
|
||||||
|
dest.console(tty=1)
|
||||||
|
dest.shutdown(timeout=5)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
# Deal with the case where we don't start a command in the container
|
# Try to get the IP addresses
|
||||||
if not args.command:
|
ips = dest.get_ips(timeout=10)
|
||||||
if args.daemon:
|
|
||||||
|
# Deal with the case where we just print info about the container
|
||||||
|
if args.daemon:
|
||||||
print(_("""The ephemeral container is now started.
|
print(_("""The ephemeral container is now started.
|
||||||
|
|
||||||
You can enter it from the command line with: lxc-console -n %s
|
You can enter it from the command line with: lxc-console -n %s
|
||||||
@ -249,10 +254,6 @@ The following IP addresses have be found in the container:
|
|||||||
or [" - %s" % _("No address could be found")])
|
or [" - %s" % _("No address could be found")])
|
||||||
))
|
))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
|
||||||
dest.console(tty=1)
|
|
||||||
dest.shutdown(timeout=5)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
# Now deal with the case where we want to run a command in the container
|
# Now deal with the case where we want to run a command in the container
|
||||||
if not ips:
|
if not ips:
|
||||||
|
Loading…
Reference in New Issue
Block a user